src/gui/painting/qpainterpath.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   686     d->maybeMoveTo();
   686     d->maybeMoveTo();
   687     if (p == QPointF(d->elements.last()))
   687     if (p == QPointF(d->elements.last()))
   688         return;
   688         return;
   689     Element elm = { p.x(), p.y(), LineToElement };
   689     Element elm = { p.x(), p.y(), LineToElement };
   690     d->elements.append(elm);
   690     d->elements.append(elm);
       
   691 
       
   692     d->convex = d->elements.size() == 3 || (d->elements.size() == 4 && d->isClosed());
   691 }
   693 }
   692 
   694 
   693 /*!
   695 /*!
   694     \fn void QPainterPath::cubicTo(qreal c1X, qreal c1Y, qreal c2X,
   696     \fn void QPainterPath::cubicTo(qreal c1X, qreal c1Y, qreal c2X,
   695     qreal c2Y, qreal endPointX, qreal endPointY);
   697     qreal c2Y, qreal endPointX, qreal endPointY);
   958         return;
   960         return;
   959 
   961 
   960     ensureData();
   962     ensureData();
   961     detach();
   963     detach();
   962 
   964 
       
   965     bool first = d_func()->elements.size() < 2;
       
   966 
   963     d_func()->elements.reserve(d_func()->elements.size() + 5);
   967     d_func()->elements.reserve(d_func()->elements.size() + 5);
   964     moveTo(r.x(), r.y());
   968     moveTo(r.x(), r.y());
   965 
   969 
   966     Element l1 = { r.x() + r.width(), r.y(), LineToElement };
   970     Element l1 = { r.x() + r.width(), r.y(), LineToElement };
   967     Element l2 = { r.x() + r.width(), r.y() + r.height(), LineToElement };
   971     Element l2 = { r.x() + r.width(), r.y() + r.height(), LineToElement };
   968     Element l3 = { r.x(), r.y() + r.height(), LineToElement };
   972     Element l3 = { r.x(), r.y() + r.height(), LineToElement };
   969     Element l4 = { r.x(), r.y(), LineToElement };
   973     Element l4 = { r.x(), r.y(), LineToElement };
   970 
   974 
   971     d_func()->elements << l1 << l2 << l3 << l4;
   975     d_func()->elements << l1 << l2 << l3 << l4;
   972     d_func()->require_moveTo = true;
   976     d_func()->require_moveTo = true;
       
   977     d_func()->convex = first;
   973 }
   978 }
   974 
   979 
   975 /*!
   980 /*!
   976     Adds the given \a polygon to the path as an (unclosed) subpath.
   981     Adds the given \a polygon to the path as an (unclosed) subpath.
   977 
   982 
  1037 
  1042 
  1038     ensureData();
  1043     ensureData();
  1039     detach();
  1044     detach();
  1040 
  1045 
  1041     Q_D(QPainterPath);
  1046     Q_D(QPainterPath);
       
  1047     bool first = d_func()->elements.size() < 2;
  1042     d->elements.reserve(d->elements.size() + 13);
  1048     d->elements.reserve(d->elements.size() + 13);
  1043 
  1049 
  1044     QPointF pts[12];
  1050     QPointF pts[12];
  1045     int point_count;
  1051     int point_count;
  1046     QPointF start = qt_curves_for_arc(boundingRect, 0, -360, pts, &point_count);
  1052     QPointF start = qt_curves_for_arc(boundingRect, 0, -360, pts, &point_count);
  1049     cubicTo(pts[0], pts[1], pts[2]);           // 0 -> 270
  1055     cubicTo(pts[0], pts[1], pts[2]);           // 0 -> 270
  1050     cubicTo(pts[3], pts[4], pts[5]);           // 270 -> 180
  1056     cubicTo(pts[3], pts[4], pts[5]);           // 270 -> 180
  1051     cubicTo(pts[6], pts[7], pts[8]);           // 180 -> 90
  1057     cubicTo(pts[6], pts[7], pts[8]);           // 180 -> 90
  1052     cubicTo(pts[9], pts[10], pts[11]);         // 90 - >0
  1058     cubicTo(pts[9], pts[10], pts[11]);         // 90 - >0
  1053     d_func()->require_moveTo = true;
  1059     d_func()->require_moveTo = true;
       
  1060 
       
  1061     d_func()->convex = first;
  1054 }
  1062 }
  1055 
  1063 
  1056 /*!
  1064 /*!
  1057     \fn void QPainterPath::addText(const QPointF &point, const QFont &font, const QString &text)
  1065     \fn void QPainterPath::addText(const QPointF &point, const QFont &font, const QString &text)
  1058 
  1066 
  3025     qreal ryy2 = h*yRadius/100;
  3033     qreal ryy2 = h*yRadius/100;
  3026 
  3034 
  3027     ensureData();
  3035     ensureData();
  3028     detach();
  3036     detach();
  3029 
  3037 
  3030     arcMoveTo(x, y, rxx2, ryy2, 90);
  3038     bool first = d_func()->elements.size() < 2;
  3031     arcTo(x, y, rxx2, ryy2, 90, 90);
  3039 
  3032     arcTo(x, y+h-ryy2, rxx2, ryy2, 2*90, 90);
  3040     arcMoveTo(x, y, rxx2, ryy2, 180);
  3033     arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 3*90, 90);
  3041     arcTo(x, y, rxx2, ryy2, 180, -90);
  3034     arcTo(x+w-rxx2, y, rxx2, ryy2, 0, 90);
  3042     arcTo(x+w-rxx2, y, rxx2, ryy2, 90, -90);
       
  3043     arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 0, -90);
       
  3044     arcTo(x, y+h-ryy2, rxx2, ryy2, 270, -90);
  3035     closeSubpath();
  3045     closeSubpath();
  3036 
  3046 
  3037     d_func()->require_moveTo = true;
  3047     d_func()->require_moveTo = true;
       
  3048     d_func()->convex = first;
  3038 }
  3049 }
  3039 
  3050 
  3040 /*!
  3051 /*!
  3041   \fn void QPainterPath::addRoundedRect(qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize);
  3052   \fn void QPainterPath::addRoundedRect(qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize);
  3042   \since 4.4
  3053   \since 4.4
  3079     qreal ryy2 = h*yRnd/100;
  3090     qreal ryy2 = h*yRnd/100;
  3080 
  3091 
  3081     ensureData();
  3092     ensureData();
  3082     detach();
  3093     detach();
  3083 
  3094 
  3084     arcMoveTo(x, y, rxx2, ryy2, 90);
  3095     bool first = d_func()->elements.size() < 2;
  3085     arcTo(x, y, rxx2, ryy2, 90, 90);
  3096 
  3086     arcTo(x, y+h-ryy2, rxx2, ryy2, 2*90, 90);
  3097     arcMoveTo(x, y, rxx2, ryy2, 180);
  3087     arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 3*90, 90);
  3098     arcTo(x, y, rxx2, ryy2, 180, -90);
  3088     arcTo(x+w-rxx2, y, rxx2, ryy2, 0, 90);
  3099     arcTo(x+w-rxx2, y, rxx2, ryy2, 90, -90);
       
  3100     arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 0, -90);
       
  3101     arcTo(x, y+h-ryy2, rxx2, ryy2, 270, -90);
  3089     closeSubpath();
  3102     closeSubpath();
  3090 
  3103 
  3091     d_func()->require_moveTo = true;
  3104     d_func()->require_moveTo = true;
       
  3105     d_func()->convex = first;
  3092 }
  3106 }
  3093 
  3107 
  3094 /*!
  3108 /*!
  3095   \obsolete
  3109   \obsolete
  3096 
  3110 
  3267 {
  3281 {
  3268     d_func()->dirtyBounds        = dirty;
  3282     d_func()->dirtyBounds        = dirty;
  3269     d_func()->dirtyControlBounds = dirty;
  3283     d_func()->dirtyControlBounds = dirty;
  3270     delete d_func()->pathConverter;
  3284     delete d_func()->pathConverter;
  3271     d_func()->pathConverter = 0;
  3285     d_func()->pathConverter = 0;
       
  3286     d_func()->convex = false;
  3272 }
  3287 }
  3273 
  3288 
  3274 void QPainterPath::computeBoundingRect() const
  3289 void QPainterPath::computeBoundingRect() const
  3275 {
  3290 {
  3276     QPainterPathData *d = d_func();
  3291     QPainterPathData *d = d_func();