Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | static const QRectF boundingRect(const QPointF *points, int pointCount) | - |
14 | { | - |
15 | const QPointF *e = points; | - |
16 | const QPointF *last = points + pointCount; | - |
17 | qreal minx, maxx, miny, maxy; | - |
18 | minx = maxx = e->x(); | - |
19 | miny = maxy = e->y(); | - |
20 | while (++e < last) { evaluated: ++e < last yes Evaluation Count:1092545 | yes Evaluation Count:136931 |
| 136931-1092545 |
21 | if (e->x() < minx) evaluated: e->x() < minx yes Evaluation Count:147928 | yes Evaluation Count:944617 |
| 147928-944617 |
22 | minx = e->x(); executed: minx = e->x(); Execution Count:147928 | 147928 |
23 | else if (e->x() > maxx) evaluated: e->x() > maxx yes Evaluation Count:224539 | yes Evaluation Count:720078 |
| 224539-720078 |
24 | maxx = e->x(); executed: maxx = e->x(); Execution Count:224539 | 224539 |
25 | if (e->y() < miny) evaluated: e->y() < miny yes Evaluation Count:117340 | yes Evaluation Count:975205 |
| 117340-975205 |
26 | miny = e->y(); executed: miny = e->y(); Execution Count:117340 | 117340 |
27 | else if (e->y() > maxy) evaluated: e->y() > maxy yes Evaluation Count:210729 | yes Evaluation Count:764476 |
| 210729-764476 |
28 | maxy = e->y(); executed: maxy = e->y(); Execution Count:210729 | 210729 |
29 | } | - |
30 | return QRectF(QPointF(minx, miny), QPointF(maxx, maxy)); executed: return QRectF(QPointF(minx, miny), QPointF(maxx, maxy)); Execution Count:136931 | 136931 |
31 | } | - |
32 | | - |
33 | void QOutlineMapper::curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep) { | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | QBezier bezier = QBezier::fromPoints(m_elements.last(), cp1, cp2, ep); | - |
39 | bezier.addToPolygon(m_elements, m_curve_threshold); | - |
40 | m_element_types.reserve(m_elements.size()); | - |
41 | for (int i = m_elements.size() - m_element_types.size(); i; --i) evaluated: i yes Evaluation Count:232172 | yes Evaluation Count:11216 |
| 11216-232172 |
42 | m_element_types << QPainterPath::LineToElement; executed: m_element_types << QPainterPath::LineToElement; Execution Count:232172 | 232172 |
43 | qt_noop(); | - |
44 | } executed: } Execution Count:11216 | 11216 |
45 | | - |
46 | | - |
47 | QT_FT_Outline *QOutlineMapper::convertPath(const QPainterPath &path) | - |
48 | { | - |
49 | qt_noop(); | - |
50 | int elmCount = path.elementCount(); | - |
51 | | - |
52 | | - |
53 | | - |
54 | beginOutline(path.fillRule()); | - |
55 | | - |
56 | for (int index=0; index<elmCount; ++index) { evaluated: index<elmCount yes Evaluation Count:40 | yes Evaluation Count:8 |
| 8-40 |
57 | const QPainterPath::Element &elm = path.elementAt(index); | - |
58 | | - |
59 | switch (elm.type) { | - |
60 | | - |
61 | case QPainterPath::MoveToElement: | - |
62 | if (index == elmCount - 1) partially evaluated: index == elmCount - 1 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
63 | continue; never executed: continue; | 0 |
64 | moveTo(elm); | - |
65 | break; executed: break; Execution Count:8 | 8 |
66 | | - |
67 | case QPainterPath::LineToElement: | - |
68 | lineTo(elm); | - |
69 | break; executed: break; Execution Count:32 | 32 |
70 | | - |
71 | case QPainterPath::CurveToElement: | - |
72 | curveTo(elm, path.elementAt(index + 1), path.elementAt(index + 2)); | - |
73 | index += 2; | - |
74 | break; | 0 |
75 | | - |
76 | default: | - |
77 | break; | 0 |
78 | } | - |
79 | } executed: } Execution Count:40 | 40 |
80 | | - |
81 | endOutline(); | - |
82 | return outline(); executed: return outline(); Execution Count:8 | 8 |
83 | } | - |
84 | | - |
85 | QT_FT_Outline *QOutlineMapper::convertPath(const QVectorPath &path) | - |
86 | { | - |
87 | int count = path.elementCount(); | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | beginOutline(path.hasWindingFill() ? Qt::WindingFill : Qt::OddEvenFill); | - |
93 | | - |
94 | if (path.elements()) { evaluated: path.elements() yes Evaluation Count:135228 | yes Evaluation Count:858 |
| 858-135228 |
95 | | - |
96 | | - |
97 | const QPainterPath::ElementType *elements = path.elements(); | - |
98 | const QPointF *points = reinterpret_cast<const QPointF *>(path.points()); | - |
99 | | - |
100 | for (int index = 0; index < count; ++index) { evaluated: index < count yes Evaluation Count:899189 | yes Evaluation Count:135228 |
| 135228-899189 |
101 | switch (elements[index]) { | - |
102 | case QPainterPath::MoveToElement: | - |
103 | if (index == count - 1) partially evaluated: index == count - 1 no Evaluation Count:0 | yes Evaluation Count:219198 |
| 0-219198 |
104 | continue; never executed: continue; | 0 |
105 | moveTo(points[index]); | - |
106 | break; executed: break; Execution Count:219198 | 219198 |
107 | | - |
108 | case QPainterPath::LineToElement: | - |
109 | lineTo(points[index]); | - |
110 | break; executed: break; Execution Count:668775 | 668775 |
111 | | - |
112 | case QPainterPath::CurveToElement: | - |
113 | curveTo(points[index], points[index+1], points[index+2]); | - |
114 | index += 2; | - |
115 | break; executed: break; Execution Count:11216 | 11216 |
116 | | - |
117 | default: | - |
118 | break; | 0 |
119 | } | - |
120 | } executed: } Execution Count:899189 | 899189 |
121 | | - |
122 | } else { executed: } Execution Count:135228 | 135228 |
123 | | - |
124 | | - |
125 | m_elements.resize(count); | - |
126 | if (count) evaluated: count yes Evaluation Count:851 | yes Evaluation Count:7 |
| 7-851 |
127 | memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); executed: memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); Execution Count:851 | 851 |
128 | | - |
129 | m_element_types.resize(0); | - |
130 | } executed: } Execution Count:858 | 858 |
131 | | - |
132 | endOutline(); | - |
133 | return outline(); executed: return outline(); Execution Count:136086 | 136086 |
134 | } | - |
135 | | - |
136 | | - |
137 | void QOutlineMapper::endOutline() | - |
138 | { | - |
139 | closeSubpath(); | - |
140 | | - |
141 | if (m_elements.isEmpty()) { evaluated: m_elements.isEmpty() yes Evaluation Count:9 | yes Evaluation Count:136935 |
| 9-136935 |
142 | memset(&m_outline, 0, sizeof(m_outline)); | - |
143 | return; executed: return; Execution Count:9 | 9 |
144 | } | - |
145 | | - |
146 | QPointF *elements = m_elements.data(); | - |
147 | | - |
148 | | - |
149 | if (m_txop == QTransform::TxNone) { evaluated: m_txop == QTransform::TxNone yes Evaluation Count:100293 | yes Evaluation Count:36642 |
| 36642-100293 |
150 | | - |
151 | } else if (m_txop == QTransform::TxTranslate) { executed: } Execution Count:100293 evaluated: m_txop == QTransform::TxTranslate yes Evaluation Count:34630 | yes Evaluation Count:2012 |
| 2012-100293 |
152 | for (int i = 0; i < m_elements.size(); ++i) { evaluated: i < m_elements.size() yes Evaluation Count:503156 | yes Evaluation Count:34630 |
| 34630-503156 |
153 | QPointF &e = elements[i]; | - |
154 | e = QPointF(e.x() + m_dx, e.y() + m_dy); | - |
155 | } executed: } Execution Count:503156 | 503156 |
156 | } else if (m_txop == QTransform::TxScale) { executed: } Execution Count:34630 evaluated: m_txop == QTransform::TxScale yes Evaluation Count:29 | yes Evaluation Count:1983 |
| 29-34630 |
157 | for (int i = 0; i < m_elements.size(); ++i) { evaluated: i < m_elements.size() yes Evaluation Count:88091 | yes Evaluation Count:29 |
| 29-88091 |
158 | QPointF &e = elements[i]; | - |
159 | e = QPointF(m_m11 * e.x() + m_dx, m_m22 * e.y() + m_dy); | - |
160 | } executed: } Execution Count:88091 | 88091 |
161 | } else if (m_txop < QTransform::TxProject) { executed: } Execution Count:29 evaluated: m_txop < QTransform::TxProject yes Evaluation Count:1979 | yes Evaluation Count:4 |
| 4-1979 |
162 | for (int i = 0; i < m_elements.size(); ++i) { evaluated: i < m_elements.size() yes Evaluation Count:145581 | yes Evaluation Count:1979 |
| 1979-145581 |
163 | QPointF &e = elements[i]; | - |
164 | e = QPointF(m_m11 * e.x() + m_m21 * e.y() + m_dx, | - |
165 | m_m22 * e.y() + m_m12 * e.x() + m_dy); | - |
166 | } executed: } Execution Count:145581 | 145581 |
167 | } else { executed: } Execution Count:1979 | 1979 |
168 | const QVectorPath vp((qreal *)elements, m_elements.size(), | - |
169 | m_element_types.size() ? m_element_types.data() : 0); | - |
170 | QPainterPath path = vp.convertToPainterPath(); | - |
171 | path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path); | - |
172 | if (!(m_outline.flags & 0x2)) partially evaluated: !(m_outline.flags & 0x2) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
173 | path.setFillRule(Qt::WindingFill); never executed: path.setFillRule(Qt::WindingFill); | 0 |
174 | uint old_txop = m_txop; | - |
175 | m_txop = QTransform::TxNone; | - |
176 | if (path.isEmpty()) partially evaluated: path.isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
177 | m_valid = false; never executed: m_valid = false; | 0 |
178 | else | - |
179 | convertPath(path); executed: convertPath(path); Execution Count:4 | 4 |
180 | m_txop = old_txop; | - |
181 | return; executed: return; Execution Count:4 | 4 |
182 | } | - |
183 | | - |
184 | controlPointRect = boundingRect(elements, m_elements.size()); | - |
185 | const bool do_clip = !m_in_clip_elements && ((controlPointRect.left() < -QT_RASTER_COORD_LIMIT partially evaluated: !m_in_clip_elements yes Evaluation Count:136931 | no Evaluation Count:0 |
partially evaluated: controlPointRect.left() < -QT_RASTER_COORD_LIMIT no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
186 | || controlPointRect.right() > QT_RASTER_COORD_LIMIT partially evaluated: controlPointRect.right() > QT_RASTER_COORD_LIMIT no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
187 | || controlPointRect.top() < -QT_RASTER_COORD_LIMIT partially evaluated: controlPointRect.top() < -QT_RASTER_COORD_LIMIT no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
188 | || controlPointRect.bottom() > QT_RASTER_COORD_LIMIT partially evaluated: controlPointRect.bottom() > QT_RASTER_COORD_LIMIT no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
189 | || controlPointRect.width() > QT_RASTER_COORD_LIMIT partially evaluated: controlPointRect.width() > QT_RASTER_COORD_LIMIT no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
190 | || controlPointRect.height() > QT_RASTER_COORD_LIMIT)); partially evaluated: controlPointRect.height() > QT_RASTER_COORD_LIMIT no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
191 | | - |
192 | if (do_clip) { partially evaluated: do_clip no Evaluation Count:0 | yes Evaluation Count:136931 |
| 0-136931 |
193 | clipElements(elements, elementTypes(), m_elements.size()); | - |
194 | } else { | 0 |
195 | convertElements(elements, elementTypes(), m_elements.size()); | - |
196 | } executed: } Execution Count:136931 | 136931 |
197 | } | - |
198 | | - |
199 | void QOutlineMapper::convertElements(const QPointF *elements, | - |
200 | const QPainterPath::ElementType *types, | - |
201 | int element_count) | - |
202 | { | - |
203 | | - |
204 | if (types) { evaluated: types yes Evaluation Count:136080 | yes Evaluation Count:851 |
| 851-136080 |
205 | | - |
206 | const QPointF *e = elements; | - |
207 | for (int i=0; i<element_count; ++i) { evaluated: i<element_count yes Evaluation Count:1225147 | yes Evaluation Count:136080 |
| 136080-1225147 |
208 | switch (*types) { | - |
209 | case QPainterPath::MoveToElement: | - |
210 | { | - |
211 | QT_FT_Vector pt_fixed = { (int(e->x() * 64)), | - |
212 | (int(e->y() * 64)) }; | - |
213 | if (i != 0) evaluated: i != 0 yes Evaluation Count:83972 | yes Evaluation Count:136080 |
| 83972-136080 |
214 | m_contours << m_points.size() - 1; executed: m_contours << m_points.size() - 1; Execution Count:83972 | 83972 |
215 | m_points << pt_fixed; | - |
216 | m_tags << 1; | - |
217 | } | - |
218 | break; executed: break; Execution Count:220052 | 220052 |
219 | | - |
220 | case QPainterPath::LineToElement: | - |
221 | { | - |
222 | QT_FT_Vector pt_fixed = { (int(e->x() * 64)), | - |
223 | (int(e->y() * 64)) }; | - |
224 | m_points << pt_fixed; | - |
225 | m_tags << 1; | - |
226 | } | - |
227 | break; executed: break; Execution Count:1005095 | 1005095 |
228 | | - |
229 | case QPainterPath::CurveToElement: | - |
230 | { | - |
231 | QT_FT_Vector cp1_fixed = { (int(e->x() * 64)), | - |
232 | (int(e->y() * 64)) }; | - |
233 | ++e; | - |
234 | QT_FT_Vector cp2_fixed = { (int((e)->x() * 64)), | - |
235 | (int((e)->y() * 64)) }; | - |
236 | ++e; | - |
237 | QT_FT_Vector ep_fixed = { (int((e)->x() * 64)), | - |
238 | (int((e)->y() * 64)) }; | - |
239 | | - |
240 | m_points << cp1_fixed << cp2_fixed << ep_fixed; | - |
241 | m_tags << 2 | - |
242 | << 2 | - |
243 | << 1; | - |
244 | | - |
245 | types += 2; | - |
246 | i += 2; | - |
247 | } | - |
248 | break; | 0 |
249 | default: | - |
250 | break; | 0 |
251 | } | - |
252 | ++types; | - |
253 | ++e; | - |
254 | } executed: } Execution Count:1225147 | 1225147 |
255 | } else { executed: } Execution Count:136080 | 136080 |
256 | | - |
257 | const QPointF *last = elements + element_count; | - |
258 | const QPointF *e = elements; | - |
259 | while (e < last) { evaluated: e < last yes Evaluation Count:4329 | yes Evaluation Count:851 |
| 851-4329 |
260 | QT_FT_Vector pt_fixed = { (int(e->x() * 64)), | - |
261 | (int(e->y() * 64)) }; | - |
262 | m_points << pt_fixed; | - |
263 | m_tags << 1; | - |
264 | ++e; | - |
265 | } executed: } Execution Count:4329 | 4329 |
266 | } executed: } Execution Count:851 | 851 |
267 | | - |
268 | | - |
269 | m_contours << m_points.size() - 1; | - |
270 | | - |
271 | m_outline.n_contours = m_contours.size(); | - |
272 | m_outline.n_points = m_points.size(); | - |
273 | | - |
274 | m_outline.points = m_points.data(); | - |
275 | m_outline.tags = m_tags.data(); | - |
276 | m_outline.contours = m_contours.data(); | - |
277 | } executed: } Execution Count:136931 | 136931 |
278 | | - |
279 | void QOutlineMapper::clipElements(const QPointF *elements, | - |
280 | const QPainterPath::ElementType *types, | - |
281 | int element_count) | - |
282 | { | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | m_in_clip_elements = true; | - |
288 | | - |
289 | QPainterPath path; | - |
290 | | - |
291 | if (!(m_outline.flags & 0x2)) never evaluated: !(m_outline.flags & 0x2) | 0 |
292 | path.setFillRule(Qt::WindingFill); never executed: path.setFillRule(Qt::WindingFill); | 0 |
293 | | - |
294 | if (types) { | 0 |
295 | for (int i=0; i<element_count; ++i) { never evaluated: i<element_count | 0 |
296 | switch (types[i]) { | - |
297 | case QPainterPath::MoveToElement: | - |
298 | path.moveTo(elements[i]); | - |
299 | break; | 0 |
300 | | - |
301 | case QPainterPath::LineToElement: | - |
302 | path.lineTo(elements[i]); | - |
303 | break; | 0 |
304 | | - |
305 | case QPainterPath::CurveToElement: | - |
306 | path.cubicTo(elements[i], elements[i+1], elements[i+2]); | - |
307 | i += 2; | - |
308 | break; | 0 |
309 | default: | - |
310 | break; | 0 |
311 | } | - |
312 | } | 0 |
313 | } else { | 0 |
314 | path.moveTo(elements[0]); | - |
315 | for (int i=1; i<element_count; ++i) never evaluated: i<element_count | 0 |
316 | path.lineTo(elements[i]); never executed: path.lineTo(elements[i]); | 0 |
317 | } | 0 |
318 | | - |
319 | QPainterPath clipPath; | - |
320 | clipPath.addRect(m_clip_rect); | - |
321 | QPainterPath clippedPath = path.intersected(clipPath); | - |
322 | uint old_txop = m_txop; | - |
323 | m_txop = QTransform::TxNone; | - |
324 | if (clippedPath.isEmpty()) never evaluated: clippedPath.isEmpty() | 0 |
325 | m_valid = false; never executed: m_valid = false; | 0 |
326 | else | - |
327 | convertPath(clippedPath); never executed: convertPath(clippedPath); | 0 |
328 | m_txop = old_txop; | - |
329 | | - |
330 | m_in_clip_elements = false; | - |
331 | } | 0 |
332 | | - |
333 | | - |
334 | | - |
| | |