Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | void QGL2PEXVertexArray::clear() | - |
6 | { | - |
7 | vertexArray.reset(); | - |
8 | vertexArrayStops.reset(); | - |
9 | boundingRectDirty = true; | - |
10 | } | 0 |
11 | | - |
12 | | - |
13 | QGLRect QGL2PEXVertexArray::boundingRect() const | - |
14 | { | - |
15 | if (boundingRectDirty) never evaluated: boundingRectDirty | 0 |
16 | return QGLRect(0.0, 0.0, 0.0, 0.0); never executed: return QGLRect(0.0, 0.0, 0.0, 0.0); | 0 |
17 | else | - |
18 | return QGLRect(minX, minY, maxX, maxY); never executed: return QGLRect(minX, minY, maxX, maxY); | 0 |
19 | } | - |
20 | | - |
21 | void QGL2PEXVertexArray::addClosingLine(int index) | - |
22 | { | - |
23 | QPointF point(vertexArray.at(index)); | - |
24 | if (point != QPointF(vertexArray.last())) never evaluated: point != QPointF(vertexArray.last()) | 0 |
25 | vertexArray.add(point); never executed: vertexArray.add(point); | 0 |
26 | } | 0 |
27 | | - |
28 | void QGL2PEXVertexArray::addCentroid(const QVectorPath &path, int subPathIndex) | - |
29 | { | - |
30 | const QPointF *const points = reinterpret_cast<const QPointF *>(path.points()); | - |
31 | const QPainterPath::ElementType *const elements = path.elements(); | - |
32 | | - |
33 | QPointF sum = points[subPathIndex]; | - |
34 | int count = 1; | - |
35 | | - |
36 | for (int i = subPathIndex + 1; i < path.elementCount() && (!elements || elements[i] != QPainterPath::MoveToElement); ++i) { never evaluated: i < path.elementCount() never evaluated: !elements never evaluated: elements[i] != QPainterPath::MoveToElement | 0 |
37 | sum += points[i]; | - |
38 | ++count; | - |
39 | } | 0 |
40 | | - |
41 | const QPointF centroid = sum / qreal(count); | - |
42 | vertexArray.add(centroid); | - |
43 | } | 0 |
44 | | - |
45 | void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline) | - |
46 | { | - |
47 | const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); | - |
48 | const QPainterPath::ElementType* const elements = path.elements(); | - |
49 | | - |
50 | if (boundingRectDirty) { never evaluated: boundingRectDirty | 0 |
51 | minX = maxX = points[0].x(); | - |
52 | minY = maxY = points[0].y(); | - |
53 | boundingRectDirty = false; | - |
54 | } | 0 |
55 | | - |
56 | if (!outline && !path.isConvex()) never evaluated: !outline never evaluated: !path.isConvex() | 0 |
57 | addCentroid(path, 0); never executed: addCentroid(path, 0); | 0 |
58 | | - |
59 | int lastMoveTo = vertexArray.size(); | - |
60 | vertexArray.add(points[0]); | - |
61 | | - |
62 | do { | - |
63 | if (!elements) { never evaluated: !elements | 0 |
64 | | - |
65 | | - |
66 | | - |
67 | for (int i=1; i<path.elementCount(); ++i) never evaluated: i<path.elementCount() | 0 |
68 | lineToArray(points[i].x(), points[i].y()); never executed: lineToArray(points[i].x(), points[i].y()); | 0 |
69 | | - |
70 | break; | 0 |
71 | } | - |
72 | | - |
73 | | - |
74 | for (int i=1; i<path.elementCount(); ++i) { never evaluated: i<path.elementCount() | 0 |
75 | switch (elements[i]) { | - |
76 | case QPainterPath::MoveToElement: | - |
77 | if (!outline) never evaluated: !outline | 0 |
78 | addClosingLine(lastMoveTo); never executed: addClosingLine(lastMoveTo); | 0 |
79 | | - |
80 | vertexArrayStops.add(vertexArray.size()); | - |
81 | if (!outline) { never evaluated: !outline | 0 |
82 | if (!path.isConvex()) addCentroid(path, i); never executed: addCentroid(path, i); never evaluated: !path.isConvex() | 0 |
83 | lastMoveTo = vertexArray.size(); | - |
84 | } | 0 |
85 | lineToArray(points[i].x(), points[i].y()); | - |
86 | break; | 0 |
87 | case QPainterPath::LineToElement: | - |
88 | | - |
89 | lineToArray(points[i].x(), points[i].y()); | - |
90 | break; | 0 |
91 | case QPainterPath::CurveToElement: { | - |
92 | QBezier b = QBezier::fromPoints(*(((const QPointF *) points) + i - 1), | - |
93 | points[i], | - |
94 | points[i+1], | - |
95 | points[i+2]); | - |
96 | QRectF bounds = b.bounds(); | - |
97 | | - |
98 | int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6)); | - |
99 | if (threshold < 3) threshold = 3; never executed: threshold = 3; never evaluated: threshold < 3 | 0 |
100 | qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1); | - |
101 | for (int t=0; t<threshold; ++t) { never evaluated: t<threshold | 0 |
102 | QPointF pt = b.pointAt(t * one_over_threshold_minus_1); | - |
103 | lineToArray(pt.x(), pt.y()); | - |
104 | } | 0 |
105 | i += 2; | - |
106 | break; } | 0 |
107 | default: | - |
108 | break; | 0 |
109 | } | - |
110 | } | 0 |
111 | } while (0); | 0 |
112 | | - |
113 | if (!outline) never evaluated: !outline | 0 |
114 | addClosingLine(lastMoveTo); never executed: addClosingLine(lastMoveTo); | 0 |
115 | vertexArrayStops.add(vertexArray.size()); | - |
116 | } | 0 |
117 | | - |
118 | void QGL2PEXVertexArray::lineToArray(const GLfloat x, const GLfloat y) | - |
119 | { | - |
120 | vertexArray.add(QGLPoint(x, y)); | - |
121 | | - |
122 | if (x > maxX) never evaluated: x > maxX | 0 |
123 | maxX = x; never executed: maxX = x; | 0 |
124 | else if (x < minX) never evaluated: x < minX | 0 |
125 | minX = x; never executed: minX = x; | 0 |
126 | if (y > maxY) never evaluated: y > maxY | 0 |
127 | maxY = y; never executed: maxY = y; | 0 |
128 | else if (y < minY) never evaluated: y < minY | 0 |
129 | minY = y; never executed: minY = y; | 0 |
130 | } | - |
131 | | - |
132 | | - |
133 | | - |
| | |