53 const QPointF*
const points =
reinterpret_cast<
const QPointF*>(path.points());
54 const QPainterPath::ElementType*
const elements = path.elements();
56 if (boundingRectDirty) {
57 minX = maxX = points[0].x();
58 minY = maxY = points[0].y();
59 boundingRectDirty =
false;
62 if (!outline && !path.isConvex())
65 int lastMoveTo = vertexArray.size();
66 vertexArray.add(points[0]);
73 for (
int i=1; i<path.elementCount(); ++i)
74 lineToArray(points[i].x(), points[i].y());
80 for (
int i=1; i<path.elementCount(); ++i) {
81 switch (elements[i]) {
82 case QPainterPath::MoveToElement:
84 addClosingLine(lastMoveTo);
86 vertexArrayStops.add(vertexArray.size());
88 if (!path.isConvex()) addCentroid(path, i);
89 lastMoveTo = vertexArray.size();
91 lineToArray(points[i].x(), points[i].y());
93 case QPainterPath::LineToElement:
95 lineToArray(points[i].x(), points[i].y());
97 case QPainterPath::CurveToElement: {
98 QBezier b = QBezier::fromPoints(*(((
const QPointF *) points) + i - 1),
102 QRectF bounds = b.bounds();
104 int threshold = qMin<
float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6));
105 if (threshold < 3) threshold = 3;
106 qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1);
107 for (
int t=0; t<threshold; ++t) {
108 QPointF pt = b.pointAt(t * one_over_threshold_minus_1);
109 lineToArray(pt.x(), pt.y());
120 addClosingLine(lastMoveTo);
121 vertexArrayStops.add(vertexArray.size());