painting/qstroker.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6class QSubpathForwardIterator -
7{ -
8public: -
9 QSubpathForwardIterator(const QDataBuffer<QStrokerOps::Element> *path) -
10 : m_path(path), m_pos(0) { }
executed: }
Execution Count:2833
2833
11 inline int position() const { return m_pos; }
never executed: return m_pos;
0
12 inline bool hasNext() const { return m_pos < m_path->size(); }
executed: return m_pos < m_path->size();
Execution Count:9497
9497
13 inline QStrokerOps::Element next() { qt_noop(); return m_path->at(m_pos++); }
executed: return m_path->at(m_pos++);
Execution Count:16793
16793
14 -
15private: -
16 const QDataBuffer<QStrokerOps::Element> *m_path; -
17 int m_pos; -
18}; -
19 -
20class QSubpathBackwardIterator -
21{ -
22public: -
23 QSubpathBackwardIterator(const QDataBuffer<QStrokerOps::Element> *path) -
24 : m_path(path), m_pos(path->size() - 1) { }
executed: }
Execution Count:2833
2833
25 -
26 inline int position() const { return m_pos; }
never executed: return m_pos;
0
27 -
28 inline bool hasNext() const { return m_pos >= 0; }
executed: return m_pos >= 0;
Execution Count:9497
9497
29 -
30 inline QStrokerOps::Element next() -
31 { -
32 qt_noop(); -
33 -
34 QStrokerOps::Element ce = m_path->at(m_pos); -
35 -
36 if (m_pos == m_path->size() - 1) {
evaluated: m_pos == m_path->size() - 1
TRUEFALSE
yes
Evaluation Count:2833
yes
Evaluation Count:13960
2833-13960
37 --m_pos; -
38 ce.type = QPainterPath::MoveToElement; -
39 return ce;
executed: return ce;
Execution Count:2833
2833
40 } -
41 -
42 const QStrokerOps::Element &pe = m_path->at(m_pos + 1); -
43 -
44 switch (pe.type) { -
45 case QPainterPath::LineToElement: -
46 ce.type = QPainterPath::LineToElement; -
47 break;
executed: break;
Execution Count:3016
3016
48 case QPainterPath::CurveToDataElement: -
49 -
50 if (ce.type == QPainterPath::CurveToElement) {
evaluated: ce.type == QPainterPath::CurveToElement
TRUEFALSE
yes
Evaluation Count:3648
yes
Evaluation Count:3648
3648
51 ce.type = QPainterPath::CurveToDataElement; -
52 } else {
executed: }
Execution Count:3648
3648
53 ce.type = QPainterPath::CurveToElement; -
54 }
executed: }
Execution Count:3648
3648
55 break;
executed: break;
Execution Count:7296
7296
56 case QPainterPath::CurveToElement: -
57 ce.type = QPainterPath::CurveToDataElement; -
58 break;
executed: break;
Execution Count:3648
3648
59 default: -
60 QMessageLogger("painting/qstroker.cpp", 107, __PRETTY_FUNCTION__).warning("QSubpathReverseIterator::next: Case %d unhandled", ce.type); -
61 break;
never executed: break;
0
62 } -
63 --m_pos; -
64 -
65 return ce;
executed: return ce;
Execution Count:13960
13960
66 } -
67 -
68private: -
69 const QDataBuffer<QStrokerOps::Element> *m_path; -
70 int m_pos; -
71}; -
72 -
73class QSubpathFlatIterator -
74{ -
75public: -
76 QSubpathFlatIterator(const QDataBuffer<QStrokerOps::Element> *path, qreal threshold) -
77 : m_path(path), m_pos(0), m_curve_index(-1), m_curve_threshold(threshold) { }
executed: }
Execution Count:1
1
78 -
79 inline bool hasNext() const { return m_curve_index >= 0 || m_pos < m_path->size(); }
executed: return m_curve_index >= 0 || m_pos < m_path->size();
Execution Count:2
2
80 -
81 QStrokerOps::Element next() -
82 { -
83 qt_noop(); -
84 -
85 if (m_curve_index >= 0) {
partially evaluated: m_curve_index >= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
86 QStrokerOps::Element e = { QPainterPath::LineToElement, -
87 qfixed(m_curve.at(m_curve_index).x()), -
88 qfixed(m_curve.at(m_curve_index).y()) -
89 }; -
90 ++m_curve_index; -
91 if (m_curve_index >= m_curve.size())
never evaluated: m_curve_index >= m_curve.size()
0
92 m_curve_index = -1;
never executed: m_curve_index = -1;
0
93 return e;
never executed: return e;
0
94 } -
95 -
96 QStrokerOps::Element e = m_path->at(m_pos); -
97 if (e.isCurveTo()) {
partially evaluated: e.isCurveTo()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
98 qt_noop(); -
99 qt_noop(); -
100 -
101 m_curve = QBezier::fromPoints(QPointF(m_path->at(m_pos-1).x, -
102 m_path->at(m_pos-1).y), -
103 QPointF(e.x, -
104 e.y), -
105 QPointF(m_path->at(m_pos+1).x, -
106 m_path->at(m_pos+1).y), -
107 QPointF(m_path->at(m_pos+2).x, -
108 m_path->at(m_pos+2).y)).toPolygon(m_curve_threshold); -
109 m_curve_index = 1; -
110 e.type = QPainterPath::LineToElement; -
111 e.x = m_curve.at(0).x(); -
112 e.y = m_curve.at(0).y(); -
113 m_pos += 2; -
114 }
never executed: }
0
115 qt_noop(); -
116 ++m_pos; -
117 return e;
executed: return e;
Execution Count:2
2
118 } -
119 -
120private: -
121 const QDataBuffer<QStrokerOps::Element> *m_path; -
122 int m_pos; -
123 QPolygonF m_curve; -
124 int m_curve_index; -
125 qreal m_curve_threshold; -
126}; -
127 -
128template <class Iterator> bool qt_stroke_side(Iterator *it, QStroker *stroker, -
129 bool capFirst, QLineF *startTangent); -
130 -
131 -
132 -
133 -
134 -
135static inline qreal adapted_angle_on_x(const QLineF &line) -
136{ -
137 qreal angle = line.angle(QLineF(0, 0, 1, 0)); -
138 if (line.dy() > 0)
never evaluated: line.dy() > 0
0
139 angle = 360 - angle;
never executed: angle = 360 - angle;
0
140 return angle;
never executed: return angle;
0
141} -
142 -
143QStrokerOps::QStrokerOps() -
144 : m_elements(0) -
145 , m_curveThreshold(qfixed(0.25)) -
146 , m_dashThreshold(qfixed(0.25)) -
147 , m_customData(0) -
148 , m_moveTo(0) -
149 , m_lineTo(0) -
150 , m_cubicTo(0) -
151{ -
152}
executed: }
Execution Count:25103
25103
153 -
154QStrokerOps::~QStrokerOps() -
155{ -
156} -
157void QStrokerOps::begin(void *customData) -
158{ -
159 m_customData = customData; -
160 m_elements.reset(); -
161}
executed: }
Execution Count:2833
2833
162 -
163 -
164 -
165 -
166 -
167 -
168void QStrokerOps::end() -
169{ -
170 if (m_elements.size() > 1)
partially evaluated: m_elements.size() > 1
TRUEFALSE
yes
Evaluation Count:2833
no
Evaluation Count:0
0-2833
171 processCurrentSubpath();
executed: processCurrentSubpath();
Execution Count:2833
2833
172 m_customData = 0; -
173}
executed: }
Execution Count:2833
2833
174void QStrokerOps::strokePath(const QPainterPath &path, void *customData, const QTransform &matrix) -
175{ -
176 if (path.isEmpty())
partially evaluated: path.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1894
0-1894
177 return;
never executed: return;
0
178 -
179 setCurveThresholdFromTransform(QTransform()); -
180 begin(customData); -
181 int count = path.elementCount(); -
182 if (matrix.isIdentity()) {
partially evaluated: matrix.isIdentity()
TRUEFALSE
yes
Evaluation Count:1894
no
Evaluation Count:0
0-1894
183 for (int i=0; i<count; ++i) {
evaluated: i<count
TRUEFALSE
yes
Evaluation Count:4349
yes
Evaluation Count:1894
1894-4349
184 const QPainterPath::Element &e = path.elementAt(i); -
185 switch (e.type) { -
186 case QPainterPath::MoveToElement: -
187 moveTo(qfixed(e.x), qfixed(e.y)); -
188 break;
executed: break;
Execution Count:1894
1894
189 case QPainterPath::LineToElement: -
190 lineTo(qfixed(e.x), qfixed(e.y)); -
191 break;
executed: break;
Execution Count:2283
2283
192 case QPainterPath::CurveToElement: -
193 { -
194 const QPainterPath::Element &cp2 = path.elementAt(++i); -
195 const QPainterPath::Element &ep = path.elementAt(++i); -
196 cubicTo(qfixed(e.x), qfixed(e.y), -
197 qfixed(cp2.x), qfixed(cp2.y), -
198 qfixed(ep.x), qfixed(ep.y)); -
199 } -
200 break;
executed: break;
Execution Count:172
172
201 default: -
202 break;
never executed: break;
0
203 } -
204 }
executed: }
Execution Count:4349
4349
205 } else {
executed: }
Execution Count:1894
1894
206 for (int i=0; i<count; ++i) {
never evaluated: i<count
0
207 const QPainterPath::Element &e = path.elementAt(i); -
208 QPointF pt = QPointF(e.x, e.y) * matrix; -
209 switch (e.type) { -
210 case QPainterPath::MoveToElement: -
211 moveTo(qfixed(pt.x()), qfixed(pt.y())); -
212 break;
never executed: break;
0
213 case QPainterPath::LineToElement: -
214 lineTo(qfixed(pt.x()), qfixed(pt.y())); -
215 break;
never executed: break;
0
216 case QPainterPath::CurveToElement: -
217 { -
218 QPointF cp2 = ((QPointF) path.elementAt(++i)) * matrix; -
219 QPointF ep = ((QPointF) path.elementAt(++i)) * matrix; -
220 cubicTo(qfixed(pt.x()), qfixed(pt.y()), -
221 qfixed(cp2.x()), qfixed(cp2.y()), -
222 qfixed(ep.x()), qfixed(ep.y())); -
223 } -
224 break;
never executed: break;
0
225 default: -
226 break;
never executed: break;
0
227 } -
228 }
never executed: }
0
229 }
never executed: }
0
230 end(); -
231}
executed: }
Execution Count:1894
1894
232void QStrokerOps::strokePolygon(const QPointF *points, int pointCount, bool implicit_close, -
233 void *data, const QTransform &matrix) -
234{ -
235 if (!pointCount)
never evaluated: !pointCount
0
236 return;
never executed: return;
0
237 -
238 setCurveThresholdFromTransform(QTransform()); -
239 begin(data); -
240 if (matrix.isIdentity()) {
never evaluated: matrix.isIdentity()
0
241 moveTo(qfixed(points[0].x()), qfixed(points[0].y())); -
242 for (int i=1; i<pointCount; ++i)
never evaluated: i<pointCount
0
243 lineTo(qfixed(points[i].x()), 0
244 qfixed(points[i].y()));
never executed: lineTo(qfixed(points[i].x()), qfixed(points[i].y()));
0
245 if (implicit_close)
never evaluated: implicit_close
0
246 lineTo(qfixed(points[0].x()), qfixed(points[0].y()));
never executed: lineTo(qfixed(points[0].x()), qfixed(points[0].y()));
0
247 } else {
never executed: }
0
248 QPointF start = points[0] * matrix; -
249 moveTo(qfixed(start.x()), qfixed(start.y())); -
250 for (int i=1; i<pointCount; ++i) {
never evaluated: i<pointCount
0
251 QPointF pt = points[i] * matrix; -
252 lineTo(qfixed(pt.x()), qfixed(pt.y())); -
253 }
never executed: }
0
254 if (implicit_close)
never evaluated: implicit_close
0
255 lineTo(qfixed(start.x()), qfixed(start.y()));
never executed: lineTo(qfixed(start.x()), qfixed(start.y()));
0
256 }
never executed: }
0
257 end(); -
258}
never executed: }
0
259 -
260 -
261 -
262 -
263 -
264 -
265void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform &matrix) -
266{ -
267 int count = 0; -
268 QPointF pts[12]; -
269 QPointF start = qt_curves_for_arc(rect, 0, -360, pts, &count); -
270 qt_noop(); -
271 -
272 if (!matrix.isIdentity()) {
never evaluated: !matrix.isIdentity()
0
273 start = start * matrix; -
274 for (int i=0; i<12; ++i) {
never evaluated: i<12
0
275 pts[i] = pts[i] * matrix; -
276 }
never executed: }
0
277 }
never executed: }
0
278 -
279 setCurveThresholdFromTransform(QTransform()); -
280 begin(data); -
281 moveTo(qfixed(start.x()), qfixed(start.y())); -
282 for (int i=0; i<12; i+=3) {
never evaluated: i<12
0
283 cubicTo(qfixed(pts[i].x()), qfixed(pts[i].y()), -
284 qfixed(pts[i+1].x()), qfixed(pts[i+1].y()), -
285 qfixed(pts[i+2].x()), qfixed(pts[i+2].y())); -
286 }
never executed: }
0
287 end(); -
288}
never executed: }
0
289 -
290 -
291QStroker::QStroker() -
292 : m_capStyle(SquareJoin), m_joinStyle(FlatJoin), -
293 m_back1X(0), m_back1Y(0), -
294 m_back2X(0), m_back2Y(0) -
295{ -
296 m_strokeWidth = qfixed(1); -
297 m_miterLimit = qfixed(2); -
298}
executed: }
Execution Count:16302
16302
299 -
300QStroker::~QStroker() -
301{ -
302} -
303 -
304Qt::PenCapStyle QStroker::capForJoinMode(LineJoinMode mode) -
305{ -
306 if (mode == FlatJoin) return Qt::FlatCap;
partially evaluated: mode == FlatJoin
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:938
never executed: return Qt::FlatCap;
0-938
307 else if (mode == SquareJoin) return Qt::SquareCap;
partially evaluated: mode == SquareJoin
TRUEFALSE
yes
Evaluation Count:938
no
Evaluation Count:0
executed: return Qt::SquareCap;
Execution Count:938
0-938
308 else return Qt::RoundCap;
never executed: return Qt::RoundCap;
0
309} -
310 -
311QStroker::LineJoinMode QStroker::joinModeForCap(Qt::PenCapStyle style) -
312{ -
313 if (style == Qt::FlatCap) return FlatJoin;
evaluated: style == Qt::FlatCap
TRUEFALSE
yes
Evaluation Count:545
yes
Evaluation Count:97532
executed: return FlatJoin;
Execution Count:545
545-97532
314 else if (style == Qt::SquareCap) return SquareJoin;
evaluated: style == Qt::SquareCap
TRUEFALSE
yes
Evaluation Count:97528
yes
Evaluation Count:4
executed: return SquareJoin;
Execution Count:97528
4-97528
315 else return RoundCap;
executed: return RoundCap;
Execution Count:4
4
316} -
317 -
318Qt::PenJoinStyle QStroker::joinForJoinMode(LineJoinMode mode) -
319{ -
320 if (mode == FlatJoin) return Qt::BevelJoin;
partially evaluated: mode == FlatJoin
TRUEFALSE
yes
Evaluation Count:938
no
Evaluation Count:0
executed: return Qt::BevelJoin;
Execution Count:938
0-938
321 else if (mode == MiterJoin) return Qt::MiterJoin;
never evaluated: mode == MiterJoin
never executed: return Qt::MiterJoin;
0
322 else if (mode == SvgMiterJoin) return Qt::SvgMiterJoin;
never evaluated: mode == SvgMiterJoin
never executed: return Qt::SvgMiterJoin;
0
323 else return Qt::RoundJoin;
never executed: return Qt::RoundJoin;
0
324} -
325 -
326QStroker::LineJoinMode QStroker::joinModeForJoin(Qt::PenJoinStyle joinStyle) -
327{ -
328 if (joinStyle == Qt::BevelJoin) return FlatJoin;
evaluated: joinStyle == Qt::BevelJoin
TRUEFALSE
yes
Evaluation Count:98073
yes
Evaluation Count:4
executed: return FlatJoin;
Execution Count:98073
4-98073
329 else if (joinStyle == Qt::MiterJoin) return MiterJoin;
partially evaluated: joinStyle == Qt::MiterJoin
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
executed: return MiterJoin;
Execution Count:4
0-4
330 else if (joinStyle == Qt::SvgMiterJoin) return SvgMiterJoin;
never evaluated: joinStyle == Qt::SvgMiterJoin
never executed: return SvgMiterJoin;
0
331 else return RoundJoin;
never executed: return RoundJoin;
0
332} -
333 -
334 -
335 -
336 -
337 -
338 -
339void QStroker::processCurrentSubpath() -
340{ -
341 qt_noop(); -
342 qt_noop(); -
343 qt_noop(); -
344 -
345 QSubpathForwardIterator fwit(&m_elements); -
346 QSubpathBackwardIterator bwit(&m_elements); -
347 -
348 QLineF fwStartTangent, bwStartTangent; -
349 -
350 bool fwclosed = qt_stroke_side(&fwit, this, false, &fwStartTangent); -
351 bool bwclosed = qt_stroke_side(&bwit, this, !fwclosed, &bwStartTangent); -
352 -
353 if (!bwclosed)
evaluated: !bwclosed
TRUEFALSE
yes
Evaluation Count:1708
yes
Evaluation Count:1125
1125-1708
354 joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle);
executed: joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle);
Execution Count:1708
1708
355}
executed: }
Execution Count:2833
2833
356 -
357 -
358 -
359 -
360 -
361void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine, LineJoinMode join) -
362{ -
363 if (qFuzzyCompare(m_back1X, nextLine.x1()) && qFuzzyCompare(m_back1Y, nextLine.y1()))
evaluated: qFuzzyCompare(m_back1X, nextLine.x1())
TRUEFALSE
yes
Evaluation Count:9168
yes
Evaluation Count:4112
evaluated: qFuzzyCompare(m_back1Y, nextLine.y1())
TRUEFALSE
yes
Evaluation Count:7448
yes
Evaluation Count:1720
1720-9168
364 return;
executed: return;
Execution Count:7448
7448
365 -
366 -
367 -
368 -
369 -
370 -
371 -
372 if (join == FlatJoin) {
evaluated: join == FlatJoin
TRUEFALSE
yes
Evaluation Count:2410
yes
Evaluation Count:3422
2410-3422
373 QLineF prevLine(m_back2X, m_back2Y, -
374 m_back1X, m_back1Y); -
375 QPointF isect; -
376 QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); -
377 QLineF shortCut(prevLine.p2(), nextLine.p1()); -
378 qreal angle = shortCut.angleTo(prevLine); -
379 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
evaluated: type == QLineF::BoundedIntersection
TRUEFALSE
yes
Evaluation Count:1192
yes
Evaluation Count:1218
evaluated: angle > 90
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1214
partially evaluated: !qFuzzyCompare(angle, (qreal)90)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-1218
380 emitLineTo(focal_x, focal_y); -
381 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
382 return;
executed: return;
Execution Count:1196
1196
383 } -
384 emitLineTo(qfixed(nextLine.x1()), -
385 qfixed(nextLine.y1())); -
386 -
387 } else {
executed: }
Execution Count:1214
1214
388 QLineF prevLine(m_back2X, m_back2Y, -
389 m_back1X, m_back1Y); -
390 -
391 QPointF isect; -
392 QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); -
393 -
394 if (join == MiterJoin) {
evaluated: join == MiterJoin
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:3414
8-3414
395 qreal appliedMiterLimit = m_strokeWidth * m_miterLimit; -
396 -
397 -
398 QLineF shortCut(prevLine.p2(), nextLine.p1()); -
399 qreal angle = shortCut.angleTo(prevLine); -
400 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
evaluated: type == QLineF::BoundedIntersection
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
partially evaluated: angle > 90
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: !qFuzzyCompare(angle, (qreal)90)
0-4
401 emitLineTo(focal_x, focal_y); -
402 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
403 return;
executed: return;
Execution Count:4
4
404 } -
405 QLineF miterLine(QPointF(m_back1X, -
406 m_back1Y), isect); -
407 if (type == QLineF::NoIntersection || miterLine.length() > appliedMiterLimit) {
partially evaluated: type == QLineF::NoIntersection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
partially evaluated: miterLine.length() > appliedMiterLimit
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
408 QLineF l1(prevLine); -
409 l1.setLength(appliedMiterLimit); -
410 l1.translate(prevLine.dx(), prevLine.dy()); -
411 -
412 QLineF l2(nextLine); -
413 l2.setLength(appliedMiterLimit); -
414 l2.translate(-l2.dx(), -l2.dy()); -
415 -
416 emitLineTo(qfixed(l1.x2()), qfixed(l1.y2())); -
417 emitLineTo(qfixed(l2.x1()), qfixed(l2.y1())); -
418 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
419 } else {
never executed: }
0
420 emitLineTo(qfixed(isect.x()), qfixed(isect.y())); -
421 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
422 }
executed: }
Execution Count:4
4
423 -
424 } else if (join == SquareJoin) {
partially evaluated: join == SquareJoin
TRUEFALSE
yes
Evaluation Count:3414
no
Evaluation Count:0
0-3414
425 qfixed offset = m_strokeWidth / 2; -
426 -
427 QLineF l1(prevLine); -
428 l1.translate(l1.dx(), l1.dy()); -
429 l1.setLength(offset); -
430 QLineF l2(nextLine.p2(), nextLine.p1()); -
431 l2.translate(l2.dx(), l2.dy()); -
432 l2.setLength(offset); -
433 emitLineTo(qfixed(l1.x2()), qfixed(l1.y2())); -
434 emitLineTo(qfixed(l2.x2()), qfixed(l2.y2())); -
435 emitLineTo(qfixed(l2.x1()), qfixed(l2.y1())); -
436 -
437 } else if (join == RoundJoin) {
never evaluated: join == RoundJoin
executed: }
Execution Count:3414
0-3414
438 qfixed offset = m_strokeWidth / 2; -
439 -
440 QLineF shortCut(prevLine.p2(), nextLine.p1()); -
441 qreal angle = shortCut.angleTo(prevLine); -
442 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
never evaluated: type == QLineF::BoundedIntersection
never evaluated: angle > 90
never evaluated: !qFuzzyCompare(angle, (qreal)90)
0
443 emitLineTo(focal_x, focal_y); -
444 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
445 return;
never executed: return;
0
446 } -
447 qreal l1_on_x = adapted_angle_on_x(prevLine); -
448 qreal l2_on_x = adapted_angle_on_x(nextLine); -
449 -
450 qreal sweepLength = qAbs(l2_on_x - l1_on_x); -
451 -
452 int point_count; -
453 QPointF curves[15]; -
454 -
455 QPointF curve_start = -
456 qt_curves_for_arc(QRectF(focal_x - offset, -
457 focal_y - offset, -
458 offset * 2, -
459 offset * 2), -
460 l1_on_x + 90, -sweepLength, -
461 curves, &point_count); -
462 -
463 -
464 -
465 (void)curve_start;; -
466 -
467 for (int i=0; i<point_count; i+=3) {
never evaluated: i<point_count
0
468 emitCubicTo(qfixed(curves[i].x()), -
469 qfixed(curves[i].y()), -
470 qfixed(curves[i+1].x()), -
471 qfixed(curves[i+1].y()), -
472 qfixed(curves[i+2].x()), -
473 qfixed(curves[i+2].y())); -
474 }
never executed: }
0
475 -
476 -
477 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
478 -
479 -
480 -
481 } else if (join == RoundCap) {
never evaluated: join == RoundCap
never executed: }
0
482 qfixed offset = m_strokeWidth / 2; -
483 -
484 -
485 QLineF l1 = prevLine; -
486 l1.translate(l1.dx(), l1.dy()); -
487 l1.setLength(0.5522847498 * offset); -
488 -
489 -
490 QLineF l2(focal_x, focal_y, -
491 prevLine.x2(), prevLine.y2()); -
492 l2.translate(-l2.dy(), l2.dx()); -
493 l2.setLength(0.5522847498 * offset); -
494 -
495 emitCubicTo(qfixed(l1.x2()), -
496 qfixed(l1.y2()), -
497 qfixed(l2.x2()), -
498 qfixed(l2.y2()), -
499 qfixed(l2.x1()), -
500 qfixed(l2.y1())); -
501 -
502 -
503 l2 = QLineF(l2.x1(), l2.y1(), l2.x1()-l2.dx(), l2.y1()-l2.dy()); -
504 -
505 -
506 l1.translate(nextLine.x1() - l1.x1(), nextLine.y1() - l1.y1()); -
507 -
508 emitCubicTo(qfixed(l2.x2()), -
509 qfixed(l2.y2()), -
510 qfixed(l1.x2()), -
511 qfixed(l1.y2()), -
512 qfixed(l1.x1()), -
513 qfixed(l1.y1())); -
514 } else if (join == SvgMiterJoin) {
never evaluated: join == SvgMiterJoin
never executed: }
0
515 QLineF shortCut(prevLine.p2(), nextLine.p1()); -
516 qreal angle = shortCut.angleTo(prevLine); -
517 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
never evaluated: type == QLineF::BoundedIntersection
never evaluated: angle > 90
never evaluated: !qFuzzyCompare(angle, (qreal)90)
0
518 emitLineTo(focal_x, focal_y); -
519 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
520 return;
never executed: return;
0
521 } -
522 QLineF miterLine(QPointF(focal_x, -
523 focal_y), isect); -
524 if (type == QLineF::NoIntersection || miterLine.length() > m_strokeWidth * m_miterLimit / 2) {
never evaluated: type == QLineF::NoIntersection
never evaluated: miterLine.length() > m_strokeWidth * m_miterLimit / 2
0
525 emitLineTo(qfixed(nextLine.x1()), -
526 qfixed(nextLine.y1())); -
527 } else {
never executed: }
0
528 emitLineTo(qfixed(isect.x()), qfixed(isect.y())); -
529 emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); -
530 }
never executed: }
0
531 } else { -
532 qt_noop(); -
533 }
never executed: }
0
534 } -
535} -
536template <class Iterator> bool qt_stroke_side(Iterator *it, -
537 QStroker *stroker, -
538 bool capFirst, -
539 QLineF *startTangent) -
540{ -
541 -
542 const int MAX_OFFSET = 16; -
543 QBezier offsetCurves[MAX_OFFSET]; -
544 -
545 qt_noop(); -
546 QStrokerOps::Element first_element = it->next(); -
547 qt_noop(); -
548 -
549 qfixed2d start = first_element; -
550 -
551 -
552 -
553 -
554 -
555 -
556 -
557 qfixed2d prev = start; -
558 -
559 bool first = true; -
560 -
561 qfixed offset = stroker->strokeWidth() / 2; -
562 -
563 while (it->hasNext()) {
evaluated: it->hasNext()
TRUEFALSE
yes
Evaluation Count:13328
yes
Evaluation Count:5666
5666-13328
564 QStrokerOps::Element e = it->next(); -
565 -
566 -
567 if (e.isLineTo()) {
evaluated: e.isLineTo()
TRUEFALSE
yes
Evaluation Count:6032
yes
Evaluation Count:7296
6032-7296
568 -
569 -
570 -
571 QLineF line(prev.x, prev.y, -
572 e.x, e.y); -
573 if (line.p1() != line.p2()) {
evaluated: line.p1() != line.p2()
TRUEFALSE
yes
Evaluation Count:5984
yes
Evaluation Count:48
48-5984
574 QLineF normal = line.normalVector(); -
575 normal.setLength(offset); -
576 line.translate(normal.dx(), normal.dy()); -
577 -
578 -
579 if (first) {
evaluated: first
TRUEFALSE
yes
Evaluation Count:3844
yes
Evaluation Count:2140
2140-3844
580 if (capFirst)
evaluated: capFirst
TRUEFALSE
yes
Evaluation Count:1708
yes
Evaluation Count:2136
1708-2136
581 stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode());
executed: stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode());
Execution Count:1708
1708
582 else -
583 stroker->emitMoveTo(qfixed(line.x1()), qfixed(line.y1()));
executed: stroker->emitMoveTo(qfixed(line.x1()), qfixed(line.y1()));
Execution Count:2136
2136
584 *startTangent = line; -
585 first = false; -
586 } else {
executed: }
Execution Count:3844
3844
587 stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode()); -
588 }
executed: }
Execution Count:2140
2140
589 -
590 -
591 stroker->emitLineTo(qfixed(line.x2()), -
592 qfixed(line.y2())); -
593 prev = e; -
594 }
executed: }
Execution Count:5984
5984
595 -
596 -
597 } else if (e.isCurveTo()) {
partially evaluated: e.isCurveTo()
TRUEFALSE
yes
Evaluation Count:7296
no
Evaluation Count:0
executed: }
Execution Count:6032
0-7296
598 QStrokerOps::Element cp2 = it->next(); -
599 QStrokerOps::Element ep = it->next(); -
600 -
601 -
602 -
603 -
604 -
605 -
606 -
607 QBezier bezier = -
608 QBezier::fromPoints(QPointF(prev.x, prev.y), -
609 QPointF(e.x, e.y), -
610 QPointF(cp2.x, cp2.y), -
611 QPointF(ep.x, ep.y)); -
612 -
613 int count = bezier.shifted(offsetCurves, -
614 MAX_OFFSET, -
615 offset, -
616 stroker->curveThreshold()); -
617 -
618 if (count) {
partially evaluated: count
TRUEFALSE
yes
Evaluation Count:7296
no
Evaluation Count:0
0-7296
619 -
620 QLineF tangent = bezier.startTangent(); -
621 tangent.translate(offsetCurves[0].pt1() - bezier.pt1()); -
622 if (first) {
evaluated: first
TRUEFALSE
yes
Evaluation Count:1822
yes
Evaluation Count:5474
1822-5474
623 QPointF pt = offsetCurves[0].pt1(); -
624 if (capFirst) {
partially evaluated: capFirst
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1822
0-1822
625 stroker->joinPoints(prev.x, prev.y, -
626 tangent, -
627 stroker->capStyleMode()); -
628 } else {
never executed: }
0
629 stroker->emitMoveTo(qfixed(pt.x()), -
630 qfixed(pt.y())); -
631 }
executed: }
Execution Count:1822
1822
632 *startTangent = tangent; -
633 first = false; -
634 } else {
executed: }
Execution Count:1822
1822
635 stroker->joinPoints(prev.x, prev.y, -
636 tangent, -
637 stroker->joinStyleMode()); -
638 }
executed: }
Execution Count:5474
5474
639 -
640 -
641 for (int i=0; i<count; ++i) {
evaluated: i<count
TRUEFALSE
yes
Evaluation Count:7504
yes
Evaluation Count:7296
7296-7504
642 QPointF cp1 = offsetCurves[i].pt2(); -
643 QPointF cp2 = offsetCurves[i].pt3(); -
644 QPointF ep = offsetCurves[i].pt4(); -
645 stroker->emitCubicTo(qfixed(cp1.x()), qfixed(cp1.y()), -
646 qfixed(cp2.x()), qfixed(cp2.y()), -
647 qfixed(ep.x()), qfixed(ep.y())); -
648 }
executed: }
Execution Count:7504
7504
649 }
executed: }
Execution Count:7296
7296
650 -
651 prev = ep; -
652 }
executed: }
Execution Count:7296
7296
653 } -
654 -
655 if (start == prev) {
evaluated: start == prev
TRUEFALSE
yes
Evaluation Count:2250
yes
Evaluation Count:3416
2250-3416
656 -
657 -
658 -
659 -
660 -
661 if (!first)
partially evaluated: !first
TRUEFALSE
yes
Evaluation Count:2250
no
Evaluation Count:0
0-2250
662 stroker->joinPoints(prev.x, prev.y, *startTangent, stroker->joinStyleMode());
executed: stroker->joinPoints(prev.x, prev.y, *startTangent, stroker->joinStyleMode());
Execution Count:2250
2250
663 return true;
executed: return true;
Execution Count:2250
2250
664 } else { -
665 -
666 -
667 -
668 return false;
executed: return false;
Execution Count:3416
3416
669 } -
670} -
671qreal qt_t_for_arc_angle(qreal angle) -
672{ -
673 if (qFuzzyIsNull(angle))
evaluated: qFuzzyIsNull(angle)
TRUEFALSE
yes
Evaluation Count:312
yes
Evaluation Count:25890
312-25890
674 return 0;
executed: return 0;
Execution Count:312
312
675 -
676 if (qFuzzyCompare(angle, qreal(90)))
evaluated: qFuzzyCompare(angle, qreal(90))
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:25802
88-25802
677 return 1;
executed: return 1;
Execution Count:88
88
678 -
679 qreal radians = Q_PI * angle / 180; -
680 qreal cosAngle = qCos(radians); -
681 qreal sinAngle = qSin(radians); -
682 -
683 -
684 qreal tc = angle / 90; -
685 -
686 -
687 tc -= ((((2-3*0.5522847498) * tc + 3*(0.5522847498 -1)) * tc) * tc + 1 - cosAngle) -
688 / (((6-9*0.5522847498) * tc + 6*(0.5522847498 -1)) * tc); -
689 tc -= ((((2-3*0.5522847498) * tc + 3*(0.5522847498 -1)) * tc) * tc + 1 - cosAngle) -
690 / (((6-9*0.5522847498) * tc + 6*(0.5522847498 -1)) * tc); -
691 -
692 -
693 qreal ts = tc; -
694 -
695 -
696 ts -= ((((3*0.5522847498 -2) * ts - 6*0.5522847498 + 3) * ts + 3*0.5522847498) * ts - sinAngle) -
697 / (((9*0.5522847498 -6) * ts + 12*0.5522847498 - 6) * ts + 3*0.5522847498); -
698 ts -= ((((3*0.5522847498 -2) * ts - 6*0.5522847498 + 3) * ts + 3*0.5522847498) * ts - sinAngle) -
699 / (((9*0.5522847498 -6) * ts + 12*0.5522847498 - 6) * ts + 3*0.5522847498); -
700 -
701 -
702 -
703 qreal t = 0.5 * (tc + ts); -
704 return t;
executed: return t;
Execution Count:25802
25802
705} -
706 -
707__attribute__((visibility("default"))) void qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length, -
708 QPointF* startPoint, QPointF *endPoint); -
709QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, -
710 QPointF *curves, int *point_count) -
711{ -
712 qt_noop(); -
713 qt_noop(); -
714 -
715 *point_count = 0; -
716 if (qt_is_nan(rect.x()) || qt_is_nan(rect.y()) || qt_is_nan(rect.width()) || qt_is_nan(rect.height())
partially evaluated: qt_is_nan(rect.x())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
partially evaluated: qt_is_nan(rect.y())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
partially evaluated: qt_is_nan(rect.width())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
partially evaluated: qt_is_nan(rect.height())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
0-6804
717 || qt_is_nan(startAngle) || qt_is_nan(sweepLength)) {
partially evaluated: qt_is_nan(startAngle)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
partially evaluated: qt_is_nan(sweepLength)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
0-6804
718 QMessageLogger("painting/qstroker.cpp", 865, __PRETTY_FUNCTION__).warning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined"); -
719 return QPointF();
never executed: return QPointF();
0
720 } -
721 -
722 if (rect.isNull()) {
partially evaluated: rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
0-6804
723 return QPointF();
never executed: return QPointF();
0
724 } -
725 -
726 qreal x = rect.x(); -
727 qreal y = rect.y(); -
728 -
729 qreal w = rect.width(); -
730 qreal w2 = rect.width() / 2; -
731 qreal w2k = w2 * 0.5522847498; -
732 -
733 qreal h = rect.height(); -
734 qreal h2 = rect.height() / 2; -
735 qreal h2k = h2 * 0.5522847498; -
736 -
737 QPointF points[16] = -
738 { -
739 -
740 QPointF(x + w, y + h2), -
741 -
742 -
743 QPointF(x + w, y + h2 + h2k), -
744 QPointF(x + w2 + w2k, y + h), -
745 QPointF(x + w2, y + h), -
746 -
747 -
748 QPointF(x + w2 - w2k, y + h), -
749 QPointF(x, y + h2 + h2k), -
750 QPointF(x, y + h2), -
751 -
752 -
753 QPointF(x, y + h2 - h2k), -
754 QPointF(x + w2 - w2k, y), -
755 QPointF(x + w2, y), -
756 -
757 -
758 QPointF(x + w2 + w2k, y), -
759 QPointF(x + w, y + h2 - h2k), -
760 QPointF(x + w, y + h2) -
761 }; -
762 -
763 if (sweepLength > 360) sweepLength = 360;
never executed: sweepLength = 360;
partially evaluated: sweepLength > 360
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
0-6804
764 else if (sweepLength < -360) sweepLength = -360;
never executed: sweepLength = -360;
partially evaluated: sweepLength < -360
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6804
0-6804
765 -
766 -
767 if (startAngle == 0.0) {
evaluated: startAngle == 0.0
TRUEFALSE
yes
Evaluation Count:995
yes
Evaluation Count:5809
995-5809
768 if (sweepLength == 360.0) {
evaluated: sweepLength == 360.0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:994
1-994
769 for (int i = 11; i >= 0; --i)
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
770 curves[(*point_count)++] = points[i];
executed: curves[(*point_count)++] = points[i];
Execution Count:12
12
771 return points[12];
executed: return points[12];
Execution Count:1
1
772 } else if (sweepLength == -360.0) {
evaluated: sweepLength == -360.0
TRUEFALSE
yes
Evaluation Count:980
yes
Evaluation Count:14
14-980
773 for (int i = 1; i <= 12; ++i)
evaluated: i <= 12
TRUEFALSE
yes
Evaluation Count:11760
yes
Evaluation Count:980
980-11760
774 curves[(*point_count)++] = points[i];
executed: curves[(*point_count)++] = points[i];
Execution Count:11760
11760
775 return points[0];
executed: return points[0];
Execution Count:980
980
776 } -
777 } -
778 -
779 int startSegment = int(qFloor(startAngle / 90)); -
780 int endSegment = int(qFloor((startAngle + sweepLength) / 90)); -
781 -
782 qreal startT = (startAngle - startSegment * 90) / 90; -
783 qreal endT = (startAngle + sweepLength - endSegment * 90) / 90; -
784 -
785 int delta = sweepLength > 0 ? 1 : -1;
evaluated: sweepLength > 0
TRUEFALSE
yes
Evaluation Count:5798
yes
Evaluation Count:25
25-5798
786 if (delta < 0) {
evaluated: delta < 0
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:5798
25-5798
787 startT = 1 - startT; -
788 endT = 1 - endT; -
789 }
executed: }
Execution Count:25
25
790 -
791 -
792 if (qFuzzyIsNull(startT - qreal(1))) {
evaluated: qFuzzyIsNull(startT - qreal(1))
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:5799
24-5799
793 startT = 0; -
794 startSegment += delta; -
795 }
executed: }
Execution Count:24
24
796 -
797 -
798 if (qFuzzyIsNull(endT)) {
evaluated: qFuzzyIsNull(endT)
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:5759
64-5759
799 endT = 1; -
800 endSegment -= delta; -
801 }
executed: }
Execution Count:64
64
802 -
803 startT = qt_t_for_arc_angle(startT * 90); -
804 endT = qt_t_for_arc_angle(endT * 90); -
805 -
806 const bool splitAtStart = !qFuzzyIsNull(startT); -
807 const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1)); -
808 -
809 const int end = endSegment + delta; -
810 -
811 -
812 if (startSegment == end) {
partially evaluated: startSegment == end
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5823
0-5823
813 const int quadrant = 3 - ((startSegment % 4) + 4) % 4; -
814 const int j = 3 * quadrant; -
815 return delta > 0 ? points[j + 3] : points[j];
never executed: return delta > 0 ? points[j + 3] : points[j];
0
816 } -
817 -
818 QPointF startPoint, endPoint; -
819 qt_find_ellipse_coords(rect, startAngle, sweepLength, &startPoint, &endPoint); -
820 -
821 for (int i = startSegment; i != end; i += delta) {
evaluated: i != end
TRUEFALSE
yes
Evaluation Count:7715
yes
Evaluation Count:5823
5823-7715
822 const int quadrant = 3 - ((i % 4) + 4) % 4; -
823 const int j = 3 * quadrant; -
824 -
825 QBezier b; -
826 if (delta > 0)
evaluated: delta > 0
TRUEFALSE
yes
Evaluation Count:7686
yes
Evaluation Count:29
29-7686
827 b = QBezier::fromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]);
executed: b = QBezier::fromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]);
Execution Count:7686
7686
828 else -
829 b = QBezier::fromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]);
executed: b = QBezier::fromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]);
Execution Count:29
29
830 -
831 -
832 if (startSegment == endSegment && qFuzzyCompare(startT, endT))
evaluated: startSegment == endSegment
TRUEFALSE
yes
Evaluation Count:3949
yes
Evaluation Count:3766
partially evaluated: qFuzzyCompare(startT, endT)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3949
0-3949
833 return startPoint;
never executed: return startPoint;
0
834 -
835 if (i == startSegment) {
evaluated: i == startSegment
TRUEFALSE
yes
Evaluation Count:5823
yes
Evaluation Count:1892
1892-5823
836 if (i == endSegment && splitAtEnd)
evaluated: i == endSegment
TRUEFALSE
yes
Evaluation Count:3949
yes
Evaluation Count:1874
evaluated: splitAtEnd
TRUEFALSE
yes
Evaluation Count:3861
yes
Evaluation Count:88
88-3949
837 b = b.bezierOnInterval(startT, endT);
executed: b = b.bezierOnInterval(startT, endT);
Execution Count:3861
3861
838 else if (splitAtStart)
evaluated: splitAtStart
TRUEFALSE
yes
Evaluation Count:1938
yes
Evaluation Count:24
24-1938
839 b = b.bezierOnInterval(startT, 1);
executed: b = b.bezierOnInterval(startT, 1);
Execution Count:1938
1938
840 } else if (i == endSegment && splitAtEnd) {
evaluated: i == endSegment
TRUEFALSE
yes
Evaluation Count:1874
yes
Evaluation Count:18
partially evaluated: splitAtEnd
TRUEFALSE
yes
Evaluation Count:1874
no
Evaluation Count:0
0-1874
841 b = b.bezierOnInterval(0, endT); -
842 }
executed: }
Execution Count:1874
1874
843 -
844 -
845 curves[(*point_count)++] = b.pt2(); -
846 curves[(*point_count)++] = b.pt3(); -
847 curves[(*point_count)++] = b.pt4(); -
848 }
executed: }
Execution Count:7715
7715
849 -
850 qt_noop(); -
851 curves[*(point_count)-1] = endPoint; -
852 -
853 return startPoint;
executed: return startPoint;
Execution Count:5823
5823
854} -
855 -
856 -
857static inline void qdashstroker_moveTo(qfixed x, qfixed y, void *data) { -
858 ((QStroker *) data)->moveTo(x, y); -
859}
executed: }
Execution Count:2
2
860 -
861static inline void qdashstroker_lineTo(qfixed x, qfixed y, void *data) { -
862 ((QStroker *) data)->lineTo(x, y); -
863}
executed: }
Execution Count:2
2
864 -
865static inline void qdashstroker_cubicTo(qfixed, qfixed, qfixed, qfixed, qfixed, qfixed, void *) { -
866 qt_noop(); -
867 -
868}
never executed: }
0
869 -
870 -
871 -
872 -
873 -
874QDashStroker::QDashStroker(QStroker *stroker) -
875 : m_stroker(stroker), m_dashOffset(0), m_stroke_width(1), m_miter_limit(1) -
876{ -
877 if (m_stroker) {
partially evaluated: m_stroker
TRUEFALSE
yes
Evaluation Count:8801
no
Evaluation Count:0
0-8801
878 setMoveToHook(qdashstroker_moveTo); -
879 setLineToHook(qdashstroker_lineTo); -
880 setCubicToHook(qdashstroker_cubicTo); -
881 }
executed: }
Execution Count:8801
8801
882}
executed: }
Execution Count:8801
8801
883 -
884QDashStroker::~QDashStroker() -
885{ -
886} -
887 -
888QVector<qfixed> QDashStroker::patternForStyle(Qt::PenStyle style) -
889{ -
890 const qfixed space = 2; -
891 const qfixed dot = 1; -
892 const qfixed dash = 4; -
893 -
894 QVector<qfixed> pattern; -
895 -
896 switch (style) { -
897 case Qt::DashLine: -
898 pattern << dash << space; -
899 break;
never executed: break;
0
900 case Qt::DotLine: -
901 pattern << dot << space; -
902 break;
executed: break;
Execution Count:1
1
903 case Qt::DashDotLine: -
904 pattern << dash << space << dot << space; -
905 break;
never executed: break;
0
906 case Qt::DashDotDotLine: -
907 pattern << dash << space << dot << space << dot << space; -
908 break;
never executed: break;
0
909 default: -
910 break;
executed: break;
Execution Count:3
3
911 } -
912 -
913 return pattern;
executed: return pattern;
Execution Count:4
4
914} -
915 -
916static inline bool lineRectIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) -
917{ -
918 return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) 0
919 && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y));
never executed: return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y));
0
920} -
921 -
922 -
923static bool lineIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) -
924{ -
925 if (!lineRectIntersectsRect(p1, p2, tl, br))
never evaluated: !lineRectIntersectsRect(p1, p2, tl, br)
0
926 return false;
never executed: return false;
0
927 if (p1.x == p2.x || p1.y == p2.y)
never evaluated: p1.x == p2.x
never evaluated: p1.y == p2.y
0
928 return true;
never executed: return true;
0
929 -
930 if (p1.y > p2.y)
never evaluated: p1.y > p2.y
0
931 qSwap(p1, p2);
never executed: qSwap(p1, p2);
0
932 qfixed2d u; -
933 qfixed2d v; -
934 qfixed2d w = {p2.x - p1.x, p2.y - p1.y}; -
935 if (p1.x < p2.x) {
never evaluated: p1.x < p2.x
0
936 -
937 u.x = tl.x - p1.x; u.y = br.y - p1.y; -
938 v.x = br.x - p1.x; v.y = tl.y - p1.y; -
939 } else {
never executed: }
0
940 -
941 u.x = tl.x - p1.x; u.y = tl.y - p1.y; -
942 v.x = br.x - p1.x; v.y = br.y - p1.y; -
943 }
never executed: }
0
944 qreal val1 = u.x * w.y - u.y * w.x; -
945 qreal val2 = v.x * w.y - v.y * w.x; -
946 return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0);
never executed: return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0);
0
947 -
948} -
949 -
950void QDashStroker::processCurrentSubpath() -
951{ -
952 int dashCount = qMin(m_dashPattern.size(), 32); -
953 qfixed dashes[32]; -
954 -
955 if (m_stroker) {
partially evaluated: m_stroker
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
956 m_customData = m_stroker; -
957 m_stroke_width = m_stroker->strokeWidth(); -
958 m_miter_limit = m_stroker->miterLimit(); -
959 }
executed: }
Execution Count:1
1
960 -
961 qreal longestLength = 0; -
962 qreal sumLength = 0; -
963 for (int i=0; i<dashCount; ++i) {
evaluated: i<dashCount
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
964 dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke_width; -
965 sumLength += dashes[i]; -
966 if (dashes[i] > longestLength)
partially evaluated: dashes[i] > longestLength
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
967 longestLength = dashes[i];
executed: longestLength = dashes[i];
Execution Count:2
2
968 }
executed: }
Execution Count:2
2
969 -
970 if (qFuzzyIsNull(sumLength))
partially evaluated: qFuzzyIsNull(sumLength)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
971 return;
never executed: return;
0
972 -
973 qreal invSumLength = qreal(1) / sumLength; -
974 -
975 qt_noop(); -
976 -
977 dashCount = dashCount & -2; -
978 -
979 int idash = 0; -
980 qreal pos = 0; -
981 qreal elen = 0; -
982 qreal doffset = m_dashOffset * m_stroke_width; -
983 -
984 -
985 doffset -= qFloor(doffset * invSumLength) * sumLength; -
986 -
987 while (doffset >= dashes[idash]) {
partially evaluated: doffset >= dashes[idash]
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
988 doffset -= dashes[idash]; -
989 if (++idash >= dashCount)
never evaluated: ++idash >= dashCount
0
990 idash = 0;
never executed: idash = 0;
0
991 }
never executed: }
0
992 -
993 qreal estart = 0; -
994 qreal estop = 0; -
995 -
996 QLineF cline; -
997 -
998 QPainterPath dashPath; -
999 -
1000 QSubpathFlatIterator it(&m_elements, m_dashThreshold); -
1001 qfixed2d prev = it.next(); -
1002 -
1003 bool clipping = !m_clip_rect.isEmpty(); -
1004 qfixed2d move_to_pos = prev; -
1005 qfixed2d line_to_pos; -
1006 -
1007 -
1008 qfixed padding = qfixed(qMax(m_stroke_width, m_miter_limit) * longestLength); -
1009 qfixed2d clip_tl = { qfixed(m_clip_rect.left()) - padding, -
1010 qfixed(m_clip_rect.top()) - padding }; -
1011 qfixed2d clip_br = { qfixed(m_clip_rect.right()) + padding , -
1012 qfixed(m_clip_rect.bottom()) + padding }; -
1013 -
1014 bool hasMoveTo = false; -
1015 while (it.hasNext()) {
evaluated: it.hasNext()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1016 QStrokerOps::Element e = it.next(); -
1017 -
1018 qt_noop(); -
1019 cline = QLineF(prev.x, -
1020 prev.y, -
1021 e.x, -
1022 e.y); -
1023 elen = cline.length(); -
1024 -
1025 estop = estart + elen; -
1026 -
1027 bool done = pos >= estop; -
1028 -
1029 if (clipping) {
partially evaluated: clipping
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1030 -
1031 if (!lineIntersectsRect(prev, e, clip_tl, clip_br)) {
never evaluated: !lineIntersectsRect(prev, e, clip_tl, clip_br)
0
1032 -
1033 elen -= qFloor(elen * invSumLength) * sumLength; -
1034 -
1035 while (!done) {
never evaluated: !done
0
1036 qreal dpos = pos + dashes[idash] - doffset - estart; -
1037 -
1038 qt_noop(); -
1039 -
1040 if (dpos > elen) {
never evaluated: dpos > elen
0
1041 doffset = dashes[idash] - (dpos - elen); -
1042 pos = estop; -
1043 done = true; -
1044 } else {
never executed: }
0
1045 pos = dpos + estart; -
1046 done = pos >= estop; -
1047 if (++idash >= dashCount)
never evaluated: ++idash >= dashCount
0
1048 idash = 0;
never executed: idash = 0;
0
1049 doffset = 0; -
1050 }
never executed: }
0
1051 } -
1052 hasMoveTo = false; -
1053 move_to_pos = e; -
1054 }
never executed: }
0
1055 }
never executed: }
0
1056 -
1057 -
1058 while (!done) {
evaluated: !done
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1059 QPointF p2; -
1060 -
1061 bool has_offset = doffset > 0; -
1062 bool evenDash = (idash & 1) == 0; -
1063 qreal dpos = pos + dashes[idash] - doffset - estart; -
1064 -
1065 qt_noop(); -
1066 -
1067 if (dpos > elen) {
evaluated: dpos > elen
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
1068 doffset = dashes[idash] - (dpos - elen); -
1069 pos = estop; -
1070 done = true; -
1071 p2 = cline.p2(); -
1072 } else {
executed: }
Execution Count:1
1
1073 p2 = cline.pointAt(dpos/elen); -
1074 pos = dpos + estart; -
1075 done = pos >= estop; -
1076 if (++idash >= dashCount)
evaluated: ++idash >= dashCount
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1077 idash = 0;
executed: idash = 0;
Execution Count:1
1
1078 doffset = 0; -
1079 }
executed: }
Execution Count:3
3
1080 -
1081 if (evenDash) {
evaluated: evenDash
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1082 line_to_pos.x = qfixed(p2.x()); -
1083 line_to_pos.y = qfixed(p2.y()); -
1084 -
1085 if (!clipping
partially evaluated: !clipping
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1086 || lineRectIntersectsRect(move_to_pos, line_to_pos, clip_tl, clip_br))
never evaluated: lineRectIntersectsRect(move_to_pos, line_to_pos, clip_tl, clip_br)
0
1087 { -
1088 -
1089 -
1090 -
1091 -
1092 if (!has_offset || !hasMoveTo) {
partially evaluated: !has_offset
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
never evaluated: !hasMoveTo
0-2
1093 emitMoveTo(move_to_pos.x, move_to_pos.y); -
1094 hasMoveTo = true; -
1095 }
executed: }
Execution Count:2
2
1096 -
1097 emitLineTo(line_to_pos.x, line_to_pos.y); -
1098 } else {
executed: }
Execution Count:2
2
1099 hasMoveTo = false; -
1100 }
never executed: }
0
1101 move_to_pos = line_to_pos; -
1102 } else {
executed: }
Execution Count:2
2
1103 move_to_pos.x = qfixed(p2.x()); -
1104 move_to_pos.y = qfixed(p2.y()); -
1105 }
executed: }
Execution Count:2
2
1106 } -
1107 -
1108 -
1109 estart = estop; -
1110 prev = e; -
1111 }
executed: }
Execution Count:1
1
1112 -
1113}
executed: }
Execution Count:1
1
1114 -
1115 -
1116 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial