qpainterpath.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qpainterpath.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6struct QPainterPathPrivateDeleter-
7{-
8 static inline void cleanup(QPainterPathPrivate *d)-
9 {-
10-
11-
12 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
13 delete static_cast<QPainterPathData *>(d);
never executed: delete static_cast<QPainterPathData *>(d);
0
14 }
never executed: end of block
0
15};-
16QPainterPath qt_stroke_dash(const QPainterPath &path, qreal *dashes, int dashCount);-
17-
18void qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length,-
19 QPointF* startPoint, QPointF *endPoint)-
20{-
21 if (r.isNull()
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
22 if (startPoint
startPointDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
23 *
never executed: *startPoint = QPointF();
startPoint = QPointF();
never executed: *startPoint = QPointF();
0
24 if (endPoint
endPointDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
25 *
never executed: *endPoint = QPointF();
endPoint = QPointF();
never executed: *endPoint = QPointF();
0
26 return;
never executed: return;
0
27 }-
28-
29 qreal w2 = r.width() / 2;-
30 qreal h2 = r.height() / 2;-
31-
32 qreal angles[2] = { angle, angle + length };-
33 QPointF *points[2] = { startPoint, endPoint };-
34-
35 for (int i = 0; i < 2
i < 2Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
36 if (!points[i]
!points[i]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
37 continue;
never executed: continue;
0
38-
39 qreal theta = angles[i] - 360 * qFloor(angles[i] / 360);-
40 qreal t = theta / 90;-
41-
42 int quadrant = int(t);-
43 t -= quadrant;-
44-
45 t = qt_t_for_arc_angle(90 * t);-
46-
47-
48 if (quadrant & 1
quadrant & 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
49 t = 1 - t;
never executed: t = 1 - t;
0
50-
51 qreal a, b, c, d;-
52 QBezier::coefficients(t, a, b, c, d);-
53 QPointF p(a + b + c*0.5522847498, d + c + b*0.5522847498);-
54-
55-
56 if (quadrant == 1
quadrant == 1Description
TRUEnever evaluated
FALSEnever evaluated
|| quadrant == 2
quadrant == 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
57 p.rx() = -p.x();
never executed: p.rx() = -p.x();
0
58-
59-
60 if (quadrant == 0
quadrant == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| quadrant == 1
quadrant == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
61 p.ry() = -p.y();
never executed: p.ry() = -p.y();
0
62-
63 *points[i] = r.center() + QPointF(w2 * p.x(), h2 * p.y());-
64 }
never executed: end of block
0
65}
never executed: end of block
0
66int QPainterPath::elementCount() const-
67{-
68 return
never executed: return d_ptr ? d_ptr->elements.size() : 0;
d_ptr ? d_ptr->elements.size() : 0;
never executed: return d_ptr ? d_ptr->elements.size() : 0;
0
69}-
70QPainterPath::Element QPainterPath::elementAt(int i) const-
71{-
72 ((!(d_ptr)) ? qt_assert("d_ptr",__FILE__,496) : qt_noop());-
73 ((!(i >= 0 && i < elementCount())) ? qt_assert("i >= 0 && i < elementCount()",__FILE__,497) : qt_noop());-
74 return
never executed: return d_ptr->elements.at(i);
d_ptr->elements.at(i);
never executed: return d_ptr->elements.at(i);
0
75}-
76void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)-
77{-
78 ((!(d_ptr)) ? qt_assert("d_ptr",__FILE__,511) : qt_noop());-
79 ((!(i >= 0 && i < elementCount())) ? qt_assert("i >= 0 && i < elementCount()",__FILE__,512) : qt_noop());-
80 detach();-
81 QPainterPath::Element &e = d_ptr->elements[i];-
82 e.x = x;-
83 e.y = y;-
84}
never executed: end of block
0
85QPainterPath::QPainterPath() noexcept-
86 : d_ptr(0)-
87{-
88}
never executed: end of block
0
89QPainterPath::QPainterPath(const QPainterPath &other)-
90 : d_ptr(other.d_ptr.data())-
91{-
92 if (d_ptr
d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
93 d_ptr->ref.ref();
never executed: d_ptr->ref.ref();
0
94}
never executed: end of block
0
95-
96-
97-
98-
99-
100-
101QPainterPath::QPainterPath(const QPointF &startPoint)-
102 : d_ptr(new QPainterPathData)-
103{-
104 Element e = { startPoint.x(), startPoint.y(), MoveToElement };-
105 d_func()->elements << e;-
106}
never executed: end of block
0
107-
108void QPainterPath::detach()-
109{-
110 if (d_ptr->ref.load() != 1
d_ptr->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
111 detach_helper();
never executed: detach_helper();
0
112 setDirty(true);-
113}
never executed: end of block
0
114-
115-
116-
117-
118void QPainterPath::detach_helper()-
119{-
120 QPainterPathPrivate *data = new QPainterPathData(*d_func());-
121 d_ptr.reset(data);-
122}
never executed: end of block
0
123-
124-
125-
126-
127void QPainterPath::ensureData_helper()-
128{-
129 QPainterPathPrivate *data = new QPainterPathData;-
130 data->elements.reserve(16);-
131 QPainterPath::Element e = { 0, 0, QPainterPath::MoveToElement };-
132 data->elements << e;-
133 d_ptr.reset(data);-
134 ((!(d_ptr != 0)) ? qt_assert("d_ptr != 0",__FILE__,587) : qt_noop());-
135}
never executed: end of block
0
136QPainterPath &QPainterPath::operator=(const QPainterPath &other)-
137{-
138 if (other.d_func() != d_func()
other.d_func() != d_func()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
139 QPainterPathPrivate *data = other.d_func();-
140 if (data
dataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
141 data->ref.ref();
never executed: data->ref.ref();
0
142 d_ptr.reset(data);-
143 }
never executed: end of block
0
144 return
never executed: return *this;
*this;
never executed: return *this;
0
145}-
146QPainterPath::~QPainterPath()-
147{-
148}-
149void QPainterPath::closeSubpath()-
150{-
151-
152-
153-
154 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
155 return;
never executed: return;
0
156 detach();-
157-
158 d_func()->close();-
159}
never executed: end of block
0
160void QPainterPath::moveTo(const QPointF &p)-
161{-
162-
163-
164-
165-
166 if (!qt_is_finite(p.x())
!qt_is_finite(p.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(p.y())
!qt_is_finite(p.y())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
167-
168 QMessageLogger(__FILE__, 680, __PRETTY_FUNCTION__).warning("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");-
169-
170 return;
never executed: return;
0
171 }-
172-
173 ensureData();-
174 detach();-
175-
176 QPainterPathData *d = d_func();-
177 ((!(!d->elements.isEmpty())) ? qt_assert("!d->elements.isEmpty()",__FILE__,689) : qt_noop());-
178-
179 d->require_moveTo = false;-
180-
181 if (d->elements.constLast().type == MoveToElement
d->elements.co... MoveToElementDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
182 d->elements.last().x = p.x();-
183 d->elements.last().y = p.y();-
184 }
never executed: end of block
else {
0
185 Element elm = { p.x(), p.y(), MoveToElement };-
186 d->elements.append(elm);-
187 }
never executed: end of block
0
188 d->cStart = d->elements.size() - 1;-
189}
never executed: end of block
0
190void QPainterPath::lineTo(const QPointF &p)-
191{-
192-
193-
194-
195-
196 if (!qt_is_finite(p.x())
!qt_is_finite(p.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(p.y())
!qt_is_finite(p.y())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
197-
198 QMessageLogger(__FILE__, 730, __PRETTY_FUNCTION__).warning("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");-
199-
200 return;
never executed: return;
0
201 }-
202-
203 ensureData();-
204 detach();-
205-
206 QPainterPathData *d = d_func();-
207 ((!(!d->elements.isEmpty())) ? qt_assert("!d->elements.isEmpty()",__FILE__,739) : qt_noop());-
208 d->maybeMoveTo();-
209 if (p == QPointF(d->elements.constLast())
p == QPointF(d...s.constLast())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
210 return;
never executed: return;
0
211 Element elm = { p.x(), p.y(), LineToElement };-
212 d->elements.append(elm);-
213-
214 d->convex = d->elements.size() == 3
d->elements.size() == 3Description
TRUEnever evaluated
FALSEnever evaluated
|| (d->elements.size() == 4
d->elements.size() == 4Description
TRUEnever evaluated
FALSEnever evaluated
&& d->isClosed()
d->isClosed()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
215}
never executed: end of block
0
216void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &e)-
217{-
218-
219-
220-
221-
222-
223 if (!qt_is_finite(c1.x())
!qt_is_finite(c1.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(c1.y())
!qt_is_finite(c1.y())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(c2.x())
!qt_is_finite(c2.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(c2.y())
!qt_is_finite(c2.y())Description
TRUEnever evaluated
FALSEnever evaluated
0
224 || !qt_is_finite(e.x())
!qt_is_finite(e.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(e.y())
!qt_is_finite(e.y())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
225-
226 QMessageLogger(__FILE__, 790, __PRETTY_FUNCTION__).warning("QPainterPath::cubicTo: Adding point where x or y is NaN or Inf, ignoring call");-
227-
228 return;
never executed: return;
0
229 }-
230-
231 ensureData();-
232 detach();-
233-
234 QPainterPathData *d = d_func();-
235 ((!(!d->elements.isEmpty())) ? qt_assert("!d->elements.isEmpty()",__FILE__,799) : qt_noop());-
236-
237-
238-
239-
240 if (d->elements.constLast() == c1
d->elements.constLast() == c1Description
TRUEnever evaluated
FALSEnever evaluated
&& c1 == c2
c1 == c2Description
TRUEnever evaluated
FALSEnever evaluated
&& c2 == e
c2 == eDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
241 return;
never executed: return;
0
242-
243 d->maybeMoveTo();-
244-
245 Element ce1 = { c1.x(), c1.y(), CurveToElement };-
246 Element ce2 = { c2.x(), c2.y(), CurveToDataElement };-
247 Element ee = { e.x(), e.y(), CurveToDataElement };-
248 d->elements << ce1 << ce2 << ee;-
249}
never executed: end of block
0
250void QPainterPath::quadTo(const QPointF &c, const QPointF &e)-
251{-
252-
253-
254-
255-
256-
257 if (!qt_is_finite(c.x())
!qt_is_finite(c.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(c.y())
!qt_is_finite(c.y())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(e.x())
!qt_is_finite(e.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(e.y())
!qt_is_finite(e.y())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
258-
259 QMessageLogger(__FILE__, 846, __PRETTY_FUNCTION__).warning("QPainterPath::quadTo: Adding point where x or y is NaN or Inf, ignoring call");-
260-
261 return;
never executed: return;
0
262 }-
263-
264 ensureData();-
265 detach();-
266-
267 QPainterPathPrivate * const d = d_func();-
268 ((!(!d->elements.isEmpty())) ? qt_assert("!d->elements.isEmpty()",__FILE__,855) : qt_noop());-
269 const QPainterPath::Element &elm = d->elements.at(elementCount()-1);-
270 QPointF prev(elm.x, elm.y);-
271-
272-
273-
274 if (prev == c
prev == cDescription
TRUEnever evaluated
FALSEnever evaluated
&& c == e
c == eDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
275 return;
never executed: return;
0
276-
277 QPointF c1((prev.x() + 2*c.x()) / 3, (prev.y() + 2*c.y()) / 3);-
278 QPointF c2((e.x() + 2*c.x()) / 3, (e.y() + 2*c.y()) / 3);-
279 cubicTo(c1, c2, e);-
280}
never executed: end of block
0
281void QPainterPath::arcTo(const QRectF &rect, qreal startAngle, qreal sweepLength)-
282{-
283-
284-
285-
286-
287-
288 if ((!qt_is_finite(rect.x())
!qt_is_finite(rect.x())Description
TRUEnever evaluated
FALSEnever evaluated
&& !qt_is_finite(rect.y())
!qt_is_finite(rect.y())Description
TRUEnever evaluated
FALSEnever evaluated
) || !qt_is_finite(rect.width())
!qt_is_finite(rect.width())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(rect.height())
!qt_is_finite(rect.height())Description
TRUEnever evaluated
FALSEnever evaluated
0
289 || !qt_is_finite(startAngle)
!qt_is_finite(startAngle)Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(sweepLength)
!qt_is_finite(sweepLength)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
290-
291 QMessageLogger(__FILE__, 918, __PRETTY_FUNCTION__).warning("QPainterPath::arcTo: Adding arc where a parameter is NaN or Inf, ignoring call");-
292-
293 return;
never executed: return;
0
294 }-
295-
296 if (rect.isNull()
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
297 return;
never executed: return;
0
298-
299 ensureData();-
300 detach();-
301-
302 int point_count;-
303 QPointF pts[15];-
304 QPointF curve_start = qt_curves_for_arc(rect, startAngle, sweepLength, pts, &point_count);-
305-
306 lineTo(curve_start);-
307 for (int i=0; i<point_count
i<point_countDescription
TRUEnever evaluated
FALSEnever evaluated
; i+=3) {
0
308 cubicTo(pts[i].x(), pts[i].y(),-
309 pts[i+1].x(), pts[i+1].y(),-
310 pts[i+2].x(), pts[i+2].y());-
311 }
never executed: end of block
0
312-
313}
never executed: end of block
0
314void QPainterPath::arcMoveTo(const QRectF &rect, qreal angle)-
315{-
316 if (rect.isNull()
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
317 return;
never executed: return;
0
318-
319 QPointF pt;-
320 qt_find_ellipse_coords(rect, angle, 0, &pt, 0);-
321 moveTo(pt);-
322}
never executed: end of block
0
323QPointF QPainterPath::currentPosition() const-
324{-
325 return
never executed: return !d_ptr || d_func()->elements.isEmpty() ? QPointF() : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y);
!d_ptr || d_func()->elements.isEmpty()
never executed: return !d_ptr || d_func()->elements.isEmpty() ? QPointF() : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y);
0
326 ? QPointF()
never executed: return !d_ptr || d_func()->elements.isEmpty() ? QPointF() : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y);
0
327 : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y);
never executed: return !d_ptr || d_func()->elements.isEmpty() ? QPointF() : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y);
0
328}-
329void QPainterPath::addRect(const QRectF &r)-
330{-
331 if (!qt_is_finite(r.x())
!qt_is_finite(r.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(r.y())
!qt_is_finite(r.y())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(r.width())
!qt_is_finite(r.width())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(r.height())
!qt_is_finite(r.height())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
332-
333 QMessageLogger(__FILE__, 1023, __PRETTY_FUNCTION__).warning("QPainterPath::addRect: Adding rect where a parameter is NaN or Inf, ignoring call");-
334-
335 return;
never executed: return;
0
336 }-
337-
338 if (r.isNull()
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
339 return;
never executed: return;
0
340-
341 ensureData();-
342 detach();-
343-
344 bool first = d_func()->elements.size() < 2;-
345-
346 d_func()->elements.reserve(d_func()->elements.size() + 5);-
347 moveTo(r.x(), r.y());-
348-
349 Element l1 = { r.x() + r.width(), r.y(), LineToElement };-
350 Element l2 = { r.x() + r.width(), r.y() + r.height(), LineToElement };-
351 Element l3 = { r.x(), r.y() + r.height(), LineToElement };-
352 Element l4 = { r.x(), r.y(), LineToElement };-
353-
354 d_func()->elements << l1 << l2 << l3 << l4;-
355 d_func()->require_moveTo = true;-
356 d_func()->convex = first;-
357}
never executed: end of block
0
358void QPainterPath::addPolygon(const QPolygonF &polygon)-
359{-
360 if (polygon.isEmpty()
polygon.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
361 return;
never executed: return;
0
362-
363 ensureData();-
364 detach();-
365-
366 d_func()->elements.reserve(d_func()->elements.size() + polygon.size());-
367-
368 moveTo(polygon.constFirst());-
369 for (int i=1; i<polygon.size()
i<polygon.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
370 Element elm = { polygon.at(i).x(), polygon.at(i).y(), LineToElement };-
371 d_func()->elements << elm;-
372 }
never executed: end of block
0
373}
never executed: end of block
0
374void QPainterPath::addEllipse(const QRectF &boundingRect)-
375{-
376 if (!qt_is_finite(boundingRect.x())
!qt_is_finite(...ndingRect.x())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(boundingRect.y())
!qt_is_finite(...ndingRect.y())Description
TRUEnever evaluated
FALSEnever evaluated
0
377 || !qt_is_finite(boundingRect.width())
!qt_is_finite(...gRect.width())Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(boundingRect.height())
!qt_is_finite(...Rect.height())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
378-
379 QMessageLogger(__FILE__, 1107, __PRETTY_FUNCTION__).warning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN or Inf, ignoring call");-
380-
381 return;
never executed: return;
0
382 }-
383-
384 if (boundingRect.isNull()
boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
385 return;
never executed: return;
0
386-
387 ensureData();-
388 detach();-
389-
390 QPainterPathPrivate * const d = d_func();-
391 bool first = d_func()->elements.size() < 2;-
392 d->elements.reserve(d->elements.size() + 13);-
393-
394 QPointF pts[12];-
395 int point_count;-
396 QPointF start = qt_curves_for_arc(boundingRect, 0, -360, pts, &point_count);-
397-
398 moveTo(start);-
399 cubicTo(pts[0], pts[1], pts[2]);-
400 cubicTo(pts[3], pts[4], pts[5]);-
401 cubicTo(pts[6], pts[7], pts[8]);-
402 cubicTo(pts[9], pts[10], pts[11]);-
403 d_func()->require_moveTo = true;-
404-
405 d_func()->convex = first;-
406}
never executed: end of block
0
407void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &text)-
408{-
409 if (text.isEmpty()
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
410 return;
never executed: return;
0
411-
412 ensureData();-
413 detach();-
414-
415 QTextLayout layout(text, f);-
416 layout.setCacheEnabled(true);-
417 QTextEngine *eng = layout.engine();-
418 layout.beginLayout();-
419 QTextLine line = layout.createLine();-
420 (void)line;;-
421 layout.endLayout();-
422 const QScriptLine &sl = eng->lines[0];-
423 if (!sl.length
!sl.lengthDescription
TRUEnever evaluated
FALSEnever evaluated
|| !eng->layoutData
!eng->layoutDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
424 return;
never executed: return;
0
425-
426 int nItems = eng->layoutData->items.size();-
427-
428 qreal x(point.x());-
429 qreal y(point.y());-
430-
431 QVarLengthArray<int> visualOrder(nItems);-
432 QVarLengthArray<uchar> levels(nItems);-
433 for (int i = 0; i < nItems
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
434 levels[i] = eng->layoutData->items.at(i).analysis.bidiLevel;
never executed: levels[i] = eng->layoutData->items.at(i).analysis.bidiLevel;
0
435 QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());-
436-
437 for (int i = 0; i < nItems
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
438 int item = visualOrder[i];-
439 const QScriptItem &si = eng->layoutData->items.at(item);-
440-
441 if (si.analysis.flags < QScriptAnalysis::TabOrObject
si.analysis.fl...s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
442 QGlyphLayout glyphs = eng->shapedGlyphs(&si);-
443 QFontEngine *fe = f.d->engineForScript(si.analysis.script);-
444 ((!(fe)) ? qt_assert("fe",__FILE__,1191) : qt_noop());-
445 fe->addOutlineToPath(x, y, glyphs, this,-
446 si.analysis.bidiLevel % 2-
447 ? QTextItem::RenderFlags(QTextItem::RightToLeft)-
448 : QTextItem::RenderFlags(0));-
449-
450 const qreal lw = fe->lineThickness().toReal();-
451 if (f.d->underline
f.d->underlineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
452 qreal pos = fe->underlinePosition().toReal();-
453 addRect(x, y + pos, si.width.toReal(), lw);-
454 }
never executed: end of block
0
455 if (f.d->overline
f.d->overlineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
456 qreal pos = fe->ascent().toReal() + 1;-
457 addRect(x, y - pos, si.width.toReal(), lw);-
458 }
never executed: end of block
0
459 if (f.d->strikeOut
f.d->strikeOutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
460 qreal pos = fe->ascent().toReal() / 3;-
461 addRect(x, y - pos, si.width.toReal(), lw);-
462 }
never executed: end of block
0
463 }
never executed: end of block
0
464 x += si.width.toReal();-
465 }
never executed: end of block
0
466}
never executed: end of block
0
467void QPainterPath::addPath(const QPainterPath &other)-
468{-
469 if (other.isEmpty()
other.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
470 return;
never executed: return;
0
471-
472 ensureData();-
473 detach();-
474-
475 QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());-
476-
477 if (d->elements.constLast().type == MoveToElement
d->elements.co... MoveToElementDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
478 d->elements.remove(d->elements.size()-1);
never executed: d->elements.remove(d->elements.size()-1);
0
479-
480-
481 int cStart = d->elements.size() + other.d_func()->cStart;-
482 d->elements += other.d_func()->elements;-
483 d->cStart = cStart;-
484-
485 d->require_moveTo = other.d_func()->isClosed();-
486}
never executed: end of block
0
487void QPainterPath::connectPath(const QPainterPath &other)-
488{-
489 if (other.isEmpty()
other.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
490 return;
never executed: return;
0
491-
492 ensureData();-
493 detach();-
494-
495 QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());-
496-
497 if (d->elements.constLast().type == MoveToElement
d->elements.co... MoveToElementDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
498 d->elements.remove(d->elements.size()-1);
never executed: d->elements.remove(d->elements.size()-1);
0
499-
500-
501 int cStart = d->elements.size() + other.d_func()->cStart;-
502 int first = d->elements.size();-
503 d->elements += other.d_func()->elements;-
504-
505 if (first != 0
first != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
506 d->elements[first].type = LineToElement;
never executed: d->elements[first].type = LineToElement;
0
507-
508-
509 if (first > 0
first > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& QPointF(d->elements.at(first)) == QPointF(d->elements.at(first - 1))
QPointF(d->ele...at(first - 1))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
510 d->elements.remove(first--);-
511 --cStart;-
512 }
never executed: end of block
0
513-
514 if (cStart != first
cStart != firstDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
515 d->cStart = cStart;
never executed: d->cStart = cStart;
0
516}
never executed: end of block
0
517void QPainterPath::addRegion(const QRegion &region)-
518{-
519 ensureData();-
520 detach();-
521-
522 QVector<QRect> rects = region.rects();-
523 d_func()->elements.reserve(rects.size() * 5);-
524 for (int i=0; i<rects.size()
i<rects.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
525 addRect(rects.at(i));
never executed: addRect(rects.at(i));
0
526}
never executed: end of block
0
527-
528-
529-
530-
531-
532-
533-
534Qt::FillRule QPainterPath::fillRule() const-
535{-
536 return
never executed: return isEmpty() ? Qt::OddEvenFill : d_func()->fillRule;
isEmpty() ? Qt::OddEvenFill : d_func()->fillRule;
never executed: return isEmpty() ? Qt::OddEvenFill : d_func()->fillRule;
0
537}-
538void QPainterPath::setFillRule(Qt::FillRule fillRule)-
539{-
540 ensureData();-
541 if (d_func()->fillRule == fillRule
d_func()->fillRule == fillRuleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
542 return;
never executed: return;
0
543 detach();-
544-
545 d_func()->fillRule = fillRule;-
546}
never executed: end of block
0
547static QRectF qt_painterpath_bezier_extrema(const QBezier &b)-
548{-
549 qreal minx, miny, maxx, maxy;-
550-
551-
552 if (b.x1 < b.x4
b.x1 < b.x4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
553 minx = b.x1;-
554 maxx = b.x4;-
555 }
never executed: end of block
else {
0
556 minx = b.x4;-
557 maxx = b.x1;-
558 }
never executed: end of block
0
559 if (b.y1 < b.y4
b.y1 < b.y4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
560 miny = b.y1;-
561 maxy = b.y4;-
562 }
never executed: end of block
else {
0
563 miny = b.y4;-
564 maxy = b.y1;-
565 }
never executed: end of block
0
566-
567-
568 {-
569 qreal ax = 3 * (-b.x1 + 3*b.x2 - 3*b.x3 +b.x4);-
570 qreal bx = 6 * (b.x1 - 2*b.x2 + b.x3);-
571 qreal cx = 3 * (- b.x1 + b.x2);-
572-
573 if (qFuzzyIsNull(ax)
qFuzzyIsNull(ax)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
574-
575-
576 if (!qFuzzyIsNull(bx)
!qFuzzyIsNull(bx)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
577 qreal t = -cx / bx;-
578 if (t >= 0
t >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& t <= 1
t <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) { QPointF p(b.pointAt(t)); if (p.x() < minx
p.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = p.x();
never executed: minx = p.x();
else if (p.x() > maxx
p.x() > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = p.x();
never executed: maxx = p.x();
if (p.y() < miny
p.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = p.y();
never executed: miny = p.y();
else if (p.y() > maxy
p.y() > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = p.y();
never executed: maxy = p.y();
}
never executed: end of block
;
0
579 }
never executed: end of block
0
580-
581 }
never executed: end of block
else {
0
582 const qreal tx = bx * bx - 4 * ax * cx;-
583-
584 if (tx >= 0
tx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
585 qreal temp = qSqrt(tx);-
586 qreal rcp = 1 / (2 * ax);-
587 qreal t1 = (-bx + temp) * rcp;-
588 if (t1 >= 0
t1 >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& t1 <= 1
t1 <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) { QPointF p(b.pointAt(t1)); if (p.x() < minx
p.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = p.x();
never executed: minx = p.x();
else if (p.x() > maxx
p.x() > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = p.x();
never executed: maxx = p.x();
if (p.y() < miny
p.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = p.y();
never executed: miny = p.y();
else if (p.y() > maxy
p.y() > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = p.y();
never executed: maxy = p.y();
}
never executed: end of block
;
0
589-
590 qreal t2 = (-bx - temp) * rcp;-
591 if (t2 >= 0
t2 >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& t2 <= 1
t2 <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) { QPointF p(b.pointAt(t2)); if (p.x() < minx
p.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = p.x();
never executed: minx = p.x();
else if (p.x() > maxx
p.x() > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = p.x();
never executed: maxx = p.x();
if (p.y() < miny
p.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = p.y();
never executed: miny = p.y();
else if (p.y() > maxy
p.y() > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = p.y();
never executed: maxy = p.y();
}
never executed: end of block
;
0
592 }
never executed: end of block
0
593 }
never executed: end of block
0
594 }-
595-
596-
597 {-
598 qreal ay = 3 * (-b.y1 + 3*b.y2 - 3*b.y3 +b.y4);-
599 qreal by = 6 * (b.y1 - 2*b.y2 + b.y3);-
600 qreal cy = 3 * (- b.y1 + b.y2);-
601-
602-
603 if (qFuzzyIsNull(ay)
qFuzzyIsNull(ay)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
604-
605-
606 if (!qFuzzyIsNull(by)
!qFuzzyIsNull(by)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
607 qreal t = -cy / by;-
608 if (t >= 0
t >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& t <= 1
t <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) { QPointF p(b.pointAt(t)); if (p.x() < minx
p.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = p.x();
never executed: minx = p.x();
else if (p.x() > maxx
p.x() > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = p.x();
never executed: maxx = p.x();
if (p.y() < miny
p.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = p.y();
never executed: miny = p.y();
else if (p.y() > maxy
p.y() > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = p.y();
never executed: maxy = p.y();
}
never executed: end of block
;
0
609 }
never executed: end of block
0
610-
611 }
never executed: end of block
else {
0
612 const qreal ty = by * by - 4 * ay * cy;-
613-
614 if (ty > 0
ty > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
615 qreal temp = qSqrt(ty);-
616 qreal rcp = 1 / (2 * ay);-
617 qreal t1 = (-by + temp) * rcp;-
618 if (t1 >= 0
t1 >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& t1 <= 1
t1 <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) { QPointF p(b.pointAt(t1)); if (p.x() < minx
p.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = p.x();
never executed: minx = p.x();
else if (p.x() > maxx
p.x() > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = p.x();
never executed: maxx = p.x();
if (p.y() < miny
p.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = p.y();
never executed: miny = p.y();
else if (p.y() > maxy
p.y() > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = p.y();
never executed: maxy = p.y();
}
never executed: end of block
;
0
619-
620 qreal t2 = (-by - temp) * rcp;-
621 if (t2 >= 0
t2 >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& t2 <= 1
t2 <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) { QPointF p(b.pointAt(t2)); if (p.x() < minx
p.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = p.x();
never executed: minx = p.x();
else if (p.x() > maxx
p.x() > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = p.x();
never executed: maxx = p.x();
if (p.y() < miny
p.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = p.y();
never executed: miny = p.y();
else if (p.y() > maxy
p.y() > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = p.y();
never executed: maxy = p.y();
}
never executed: end of block
;
0
622 }
never executed: end of block
0
623 }
never executed: end of block
0
624 }-
625 return
never executed: return QRectF(minx, miny, maxx - minx, maxy - miny);
QRectF(minx, miny, maxx - minx, maxy - miny);
never executed: return QRectF(minx, miny, maxx - minx, maxy - miny);
0
626}-
627-
628-
629-
630-
631-
632-
633-
634QRectF QPainterPath::boundingRect() const-
635{-
636 if (!d_ptr
!d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
637 return
never executed: return QRectF();
QRectF();
never executed: return QRectF();
0
638 QPainterPathData *d = d_func();-
639-
640 if (d->dirtyBounds
d->dirtyBoundsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
641 computeBoundingRect();
never executed: computeBoundingRect();
0
642 return
never executed: return d->bounds;
d->bounds;
never executed: return d->bounds;
0
643}-
644QRectF QPainterPath::controlPointRect() const-
645{-
646 if (!d_ptr
!d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
647 return
never executed: return QRectF();
QRectF();
never executed: return QRectF();
0
648 QPainterPathData *d = d_func();-
649-
650 if (d->dirtyControlBounds
d->dirtyControlBoundsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
651 computeControlPointRect();
never executed: computeControlPointRect();
0
652 return
never executed: return d->controlBounds;
d->controlBounds;
never executed: return d->controlBounds;
0
653}-
654bool QPainterPath::isEmpty() const-
655{-
656 return
never executed: return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
!d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
never executed: return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
0
657}-
658QPainterPath QPainterPath::toReversed() const-
659{-
660 const QPainterPathPrivate * const d = d_func();-
661 QPainterPath rev;-
662-
663 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
664 rev = *this;-
665 return
never executed: return rev;
rev;
never executed: return rev;
0
666 }-
667-
668 rev.moveTo(d->elements.at(d->elements.size()-1).x, d->elements.at(d->elements.size()-1).y);-
669-
670 for (int i=d->elements.size()-1; i>=1
i>=1Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
671 const QPainterPath::Element &elm = d->elements.at(i);-
672 const QPainterPath::Element &prev = d->elements.at(i-1);-
673 switch (elm.type) {-
674 case
never executed: case LineToElement:
LineToElement:
never executed: case LineToElement:
0
675 rev.lineTo(prev.x, prev.y);-
676 break;
never executed: break;
0
677 case
never executed: case MoveToElement:
MoveToElement:
never executed: case MoveToElement:
0
678 rev.moveTo(prev.x, prev.y);-
679 break;
never executed: break;
0
680 case
never executed: case CurveToDataElement:
CurveToDataElement:
never executed: case CurveToDataElement:
0
681 {-
682 ((!(i>=3)) ? qt_assert("i>=3",__FILE__,1529) : qt_noop());-
683 const QPainterPath::Element &cp1 = d->elements.at(i-2);-
684 const QPainterPath::Element &sp = d->elements.at(i-3);-
685 ((!(prev.type == CurveToDataElement)) ? qt_assert("prev.type == CurveToDataElement",__FILE__,1532) : qt_noop());-
686 ((!(cp1.type == CurveToElement)) ? qt_assert("cp1.type == CurveToElement",__FILE__,1533) : qt_noop());-
687 rev.cubicTo(prev.x, prev.y, cp1.x, cp1.y, sp.x, sp.y);-
688 i -= 2;-
689 break;
never executed: break;
0
690 }-
691 default
never executed: default:
:
never executed: default:
0
692 ((!(!"qt_reversed_path")) ? qt_assert("!\"qt_reversed_path\"",__FILE__,1539) : qt_noop());-
693 break;
never executed: break;
0
694 }-
695 }-
696-
697 return
never executed: return rev;
rev;
never executed: return rev;
0
698}-
699QList<QPolygonF> QPainterPath::toSubpathPolygons(const QTransform &matrix) const-
700{-
701-
702 const QPainterPathPrivate * const d = d_func();-
703 QList<QPolygonF> flatCurves;-
704 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
705 return
never executed: return flatCurves;
flatCurves;
never executed: return flatCurves;
0
706-
707 QPolygonF current;-
708 for (int i=0; i<elementCount()
i<elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
709 const QPainterPath::Element &e = d->elements.at(i);-
710 switch (e.type) {-
711 case
never executed: case QPainterPath::MoveToElement:
QPainterPath::MoveToElement:
never executed: case QPainterPath::MoveToElement:
0
712 if (current.size() > 1
current.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
713 flatCurves += current;
never executed: flatCurves += current;
0
714 current.clear();-
715 current.reserve(16);-
716 current += QPointF(e.x, e.y) * matrix;-
717 break;
never executed: break;
0
718 case
never executed: case QPainterPath::LineToElement:
QPainterPath::LineToElement:
never executed: case QPainterPath::LineToElement:
0
719 current += QPointF(e.x, e.y) * matrix;-
720 break;
never executed: break;
0
721 case
never executed: case QPainterPath::CurveToElement:
QPainterPath::CurveToElement:
never executed: case QPainterPath::CurveToElement:
{
0
722 ((!(d->elements.at(i+1).type == QPainterPath::CurveToDataElement)) ? qt_assert("d->elements.at(i+1).type == QPainterPath::CurveToDataElement",__FILE__,1582) : qt_noop());-
723 ((!(d->elements.at(i+2).type == QPainterPath::CurveToDataElement)) ? qt_assert("d->elements.at(i+2).type == QPainterPath::CurveToDataElement",__FILE__,1583) : qt_noop());-
724 QBezier bezier = QBezier::fromPoints(QPointF(d->elements.at(i-1).x, d->elements.at(i-1).y) * matrix,-
725 QPointF(e.x, e.y) * matrix,-
726 QPointF(d->elements.at(i+1).x, d->elements.at(i+1).y) * matrix,-
727 QPointF(d->elements.at(i+2).x, d->elements.at(i+2).y) * matrix);-
728 bezier.addToPolygon(&current);-
729 i+=2;-
730 break;
never executed: break;
0
731 }-
732 case
never executed: case QPainterPath::CurveToDataElement:
QPainterPath::CurveToDataElement:
never executed: case QPainterPath::CurveToDataElement:
0
733 ((!(!"QPainterPath::toSubpathPolygons(), bad element type")) ? qt_assert("!\"QPainterPath::toSubpathPolygons(), bad element type\"",__FILE__,1593) : qt_noop());-
734 break;
never executed: break;
0
735 }-
736 }
never executed: end of block
0
737-
738 if (current.size()>1
current.size()>1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
739 flatCurves += current;
never executed: flatCurves += current;
0
740-
741 return
never executed: return flatCurves;
flatCurves;
never executed: return flatCurves;
0
742}-
743-
744-
745-
746-
747QList<QPolygonF> QPainterPath::toSubpathPolygons(const QMatrix &matrix) const-
748{-
749 return
never executed: return toSubpathPolygons(QTransform(matrix));
toSubpathPolygons(QTransform(matrix));
never executed: return toSubpathPolygons(QTransform(matrix));
0
750}-
751QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const-
752{-
753-
754 QList<QPolygonF> polys;-
755-
756 QList<QPolygonF> subpaths = toSubpathPolygons(matrix);-
757 int count = subpaths.size();-
758-
759 if (count == 0
count == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
760 return
never executed: return polys;
polys;
never executed: return polys;
0
761-
762 QVector<QRectF> bounds;-
763 bounds.reserve(count);-
764 for (int i=0; i<count
i<countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
765 bounds += subpaths.at(i).boundingRect();
never executed: bounds += subpaths.at(i).boundingRect();
0
766-
767-
768-
769-
770-
771-
772-
773 QVector< QVector<int> > isects;-
774 isects.resize(count);-
775-
776-
777 for (int j=0; j<count
j<countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
778 if (subpaths.at(j).size() <= 2
subpaths.at(j).size() <= 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
779 continue;
never executed: continue;
0
780 QRectF cbounds = bounds.at(j);-
781 for (int i=0; i<count
i<countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
782 if (cbounds.intersects(bounds.at(i))
cbounds.inters...(bounds.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
783 isects[j] << i;-
784 }
never executed: end of block
0
785 }
never executed: end of block
0
786 }
never executed: end of block
0
787 for (int i=0; i<count
i<countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
788 const QVector<int> &current_isects = isects.at(i);-
789 for (int j=0; j<current_isects.size()
j<current_isects.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
790 int isect_j = current_isects.at(j);-
791 if (isect_j == i
isect_j == iDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
792 continue;
never executed: continue;
0
793 const QVector<int> &isects_j = isects.at(isect_j);-
794 for (int k = 0, size = isects_j.size(); k < size
k < sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++k) {
0
795 int isect_k = isects_j.at(k);-
796 if (isect_k != i
isect_k != iDescription
TRUEnever evaluated
FALSEnever evaluated
&& !isects.at(i).contains(isect_k)
!isects.at(i)....tains(isect_k)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
797 isects[i] += isect_k;-
798 }
never executed: end of block
0
799 }
never executed: end of block
0
800 isects[isect_j].clear();-
801 }
never executed: end of block
0
802 }
never executed: end of block
0
803 for (int i=0; i<count
i<countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
804 const QVector<int> &subpath_list = isects.at(i);-
805 if (!subpath_list.isEmpty()
!subpath_list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
806 QPolygonF buildUp;-
807 for (int j=0; j<subpath_list.size()
j<subpath_list.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
808 const QPolygonF &subpath = subpaths.at(subpath_list.at(j));-
809 buildUp += subpath;-
810 if (!subpath.isClosed()
!subpath.isClosed()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
811 buildUp += subpath.first();
never executed: buildUp += subpath.first();
0
812 if (!buildUp.isClosed()
!buildUp.isClosed()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
813 buildUp += buildUp.constFirst();
never executed: buildUp += buildUp.constFirst();
0
814 }
never executed: end of block
0
815 polys += buildUp;-
816 }
never executed: end of block
0
817 }
never executed: end of block
0
818-
819 return
never executed: return polys;
polys;
never executed: return polys;
0
820}-
821-
822-
823-
824-
825QList<QPolygonF> QPainterPath::toFillPolygons(const QMatrix &matrix) const-
826{-
827 return
never executed: return toFillPolygons(QTransform(matrix));
toFillPolygons(QTransform(matrix));
never executed: return toFillPolygons(QTransform(matrix));
0
828}-
829-
830-
831static void qt_painterpath_isect_line(const QPointF &p1,-
832 const QPointF &p2,-
833 const QPointF &pos,-
834 int *winding)-
835{-
836 qreal x1 = p1.x();-
837 qreal y1 = p1.y();-
838 qreal x2 = p2.x();-
839 qreal y2 = p2.y();-
840 qreal y = pos.y();-
841-
842 int dir = 1;-
843-
844 if (qFuzzyCompare(y1, y2)
qFuzzyCompare(y1, y2)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
845-
846 return;
never executed: return;
0
847 } else if (y2 < y1
y2 < y1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
848 qreal x_tmp = x2; x2 = x1; x1 = x_tmp;-
849 qreal y_tmp = y2; y2 = y1; y1 = y_tmp;-
850 dir = -1;-
851 }
never executed: end of block
0
852-
853 if (y >= y1
y >= y1Description
TRUEnever evaluated
FALSEnever evaluated
&& y < y2
y < y2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
854 qreal x = x1 + ((x2 - x1) / (y2 - y1)) * (y - y1);-
855-
856-
857 if (x<=pos.x()
x<=pos.x()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
858 (*winding) += dir;-
859 }
never executed: end of block
0
860 }
never executed: end of block
0
861}
never executed: end of block
0
862-
863static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,-
864 int *winding, int depth = 0)-
865{-
866 qreal y = pt.y();-
867 qreal x = pt.x();-
868 QRectF bounds = bezier.bounds();-
869-
870-
871-
872-
873-
874 if (y >= bounds.y()
y >= bounds.y()Description
TRUEnever evaluated
FALSEnever evaluated
&& y < bounds.y() + bounds.height()
y < bounds.y()...ounds.height()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
875-
876-
877-
878 const qreal lower_bound = qreal(.001);-
879 if (depth == 32
depth == 32Description
TRUEnever evaluated
FALSEnever evaluated
|| (bounds.width() < lower_bound
bounds.width() < lower_boundDescription
TRUEnever evaluated
FALSEnever evaluated
&& bounds.height() < lower_bound
bounds.height() < lower_boundDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
880-
881-
882-
883 if (bezier.pt1().x() <= x
bezier.pt1().x() <= xDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
884 (*winding) += (bezier.pt4().y() > bezier.pt1().y()
bezier.pt4().y...zier.pt1().y()Description
TRUEnever evaluated
FALSEnever evaluated
? 1 : -1);
0
885 }
never executed: end of block
0
886 return;
never executed: return;
0
887 }-
888-
889-
890 QBezier first_half, second_half;-
891 bezier.split(&first_half, &second_half);-
892 qt_painterpath_isect_curve(first_half, pt, winding, depth + 1);-
893 qt_painterpath_isect_curve(second_half, pt, winding, depth + 1);-
894 }
never executed: end of block
0
895}
never executed: end of block
0
896bool QPainterPath::contains(const QPointF &pt) const-
897{-
898 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| !controlPointRect().contains(pt)
!controlPointR...).contains(pt)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
899 return
never executed: return false;
false;
never executed: return false;
0
900-
901 QPainterPathData *d = d_func();-
902-
903 int winding_number = 0;-
904-
905 QPointF last_pt;-
906 QPointF last_start;-
907 for (int i=0; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
908 const Element &e = d->elements.at(i);-
909-
910 switch (e.type) {-
911-
912 case
never executed: case MoveToElement:
MoveToElement:
never executed: case MoveToElement:
0
913 if (i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
914 qt_painterpath_isect_line(last_pt, last_start, pt, &winding_number);
never executed: qt_painterpath_isect_line(last_pt, last_start, pt, &winding_number);
0
915 last_start = last_pt = e;-
916 break;
never executed: break;
0
917-
918 case
never executed: case LineToElement:
LineToElement:
never executed: case LineToElement:
0
919 qt_painterpath_isect_line(last_pt, e, pt, &winding_number);-
920 last_pt = e;-
921 break;
never executed: break;
0
922-
923 case
never executed: case CurveToElement:
CurveToElement:
never executed: case CurveToElement:
0
924 {-
925 const QPainterPath::Element &cp2 = d->elements.at(++i);-
926 const QPainterPath::Element &ep = d->elements.at(++i);-
927 qt_painterpath_isect_curve(QBezier::fromPoints(last_pt, e, cp2, ep),-
928 pt, &winding_number);-
929 last_pt = ep;-
930-
931 }-
932 break;
never executed: break;
0
933-
934 default
never executed: default:
:
never executed: default:
0
935 break;
never executed: break;
0
936 }-
937 }-
938-
939-
940 if (last_pt != last_start
last_pt != last_startDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
941 qt_painterpath_isect_line(last_pt, last_start, pt, &winding_number);
never executed: qt_painterpath_isect_line(last_pt, last_start, pt, &winding_number);
0
942-
943 return
never executed: return (d->fillRule == Qt::WindingFill ? (winding_number != 0) : ((winding_number % 2) != 0));
(d->fillRule == Qt::WindingFill
never executed: return (d->fillRule == Qt::WindingFill ? (winding_number != 0) : ((winding_number % 2) != 0));
0
944 ? (winding_number != 0)
never executed: return (d->fillRule == Qt::WindingFill ? (winding_number != 0) : ((winding_number % 2) != 0));
0
945 : ((winding_number % 2) != 0));
never executed: return (d->fillRule == Qt::WindingFill ? (winding_number != 0) : ((winding_number % 2) != 0));
0
946}-
947-
948enum PainterDirections { Left, Right, Top, Bottom };-
949-
950static bool qt_painterpath_isect_line_rect(qreal x1, qreal y1, qreal x2, qreal y2,-
951 const QRectF &rect)-
952{-
953 qreal left = rect.left();-
954 qreal right = rect.right();-
955 qreal top = rect.top();-
956 qreal bottom = rect.bottom();-
957-
958-
959 int p1 = ((x1 < left) << Left)-
960 | ((x1 > right) << Right)-
961 | ((y1 < top) << Top)-
962 | ((y1 > bottom) << Bottom);-
963 int p2 = ((x2 < left) << Left)-
964 | ((x2 > right) << Right)-
965 | ((y2 < top) << Top)-
966 | ((y2 > bottom) << Bottom);-
967-
968 if (p1 & p2
p1 & p2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
969-
970 return
never executed: return false;
false;
never executed: return false;
0
971-
972 if (p1 | p2
p1 | p2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
973 qreal dx = x2 - x1;-
974 qreal dy = y2 - y1;-
975-
976-
977 if (x1 < left
x1 < leftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
978 y1 += dy/dx * (left - x1);-
979 x1 = left;-
980 }
never executed: end of block
else if (x1 > right
x1 > rightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
981 y1 -= dy/dx * (x1 - right);-
982 x1 = right;-
983 }
never executed: end of block
0
984 if (x2 < left
x2 < leftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
985 y2 += dy/dx * (left - x2);-
986 x2 = left;-
987 }
never executed: end of block
else if (x2 > right
x2 > rightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
988 y2 -= dy/dx * (x2 - right);-
989 x2 = right;-
990 }
never executed: end of block
0
991-
992 p1 = ((y1 < top) << Top)-
993 | ((y1 > bottom) << Bottom);-
994 p2 = ((y2 < top) << Top)-
995 | ((y2 > bottom) << Bottom);-
996-
997 if (p1 & p2
p1 & p2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
998 return
never executed: return false;
false;
never executed: return false;
0
999-
1000-
1001 if (y1 < top
y1 < topDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1002 x1 += dx/dy * (top - y1);-
1003 y1 = top;-
1004 }
never executed: end of block
else if (y1 > bottom
y1 > bottomDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1005 x1 -= dx/dy * (y1 - bottom);-
1006 y1 = bottom;-
1007 }
never executed: end of block
0
1008 if (y2 < top
y2 < topDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1009 x2 += dx/dy * (top - y2);-
1010 y2 = top;-
1011 }
never executed: end of block
else if (y2 > bottom
y2 > bottomDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1012 x2 -= dx/dy * (y2 - bottom);-
1013 y2 = bottom;-
1014 }
never executed: end of block
0
1015-
1016 p1 = ((x1 < left) << Left)-
1017 | ((x1 > right) << Right);-
1018 p2 = ((x2 < left) << Left)-
1019 | ((x2 > right) << Right);-
1020-
1021 if (p1 & p2
p1 & p2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1022 return
never executed: return false;
false;
never executed: return false;
0
1023-
1024 return
never executed: return true;
true;
never executed: return true;
0
1025 }-
1026 return
never executed: return false;
false;
never executed: return false;
0
1027}-
1028-
1029static bool qt_isect_curve_horizontal(const QBezier &bezier, qreal y, qreal x1, qreal x2, int depth = 0)-
1030{-
1031 QRectF bounds = bezier.bounds();-
1032-
1033 if (y >= bounds.top()
y >= bounds.top()Description
TRUEnever evaluated
FALSEnever evaluated
&& y < bounds.bottom()
y < bounds.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
1034 && bounds.right() >= x1
bounds.right() >= x1Description
TRUEnever evaluated
FALSEnever evaluated
&& bounds.left() < x2
bounds.left() < x2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1035 const qreal lower_bound = qreal(.01);-
1036 if (depth == 32
depth == 32Description
TRUEnever evaluated
FALSEnever evaluated
|| (bounds.width() < lower_bound
bounds.width() < lower_boundDescription
TRUEnever evaluated
FALSEnever evaluated
&& bounds.height() < lower_bound
bounds.height() < lower_boundDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
1037 return
never executed: return true;
true;
never executed: return true;
0
1038-
1039 QBezier first_half, second_half;-
1040 bezier.split(&first_half, &second_half);-
1041 if (qt_isect_curve_horizontal(first_half, y, x1, x2, depth + 1)
qt_isect_curve...x2, depth + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1042 || qt_isect_curve_horizontal(second_half, y, x1, x2, depth + 1)
qt_isect_curve...x2, depth + 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1043 return
never executed: return true;
true;
never executed: return true;
0
1044 }
never executed: end of block
0
1045 return
never executed: return false;
false;
never executed: return false;
0
1046}-
1047-
1048static bool qt_isect_curve_vertical(const QBezier &bezier, qreal x, qreal y1, qreal y2, int depth = 0)-
1049{-
1050 QRectF bounds = bezier.bounds();-
1051-
1052 if (x >= bounds.left()
x >= bounds.left()Description
TRUEnever evaluated
FALSEnever evaluated
&& x < bounds.right()
x < bounds.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
1053 && bounds.bottom() >= y1
bounds.bottom() >= y1Description
TRUEnever evaluated
FALSEnever evaluated
&& bounds.top() < y2
bounds.top() < y2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1054 const qreal lower_bound = qreal(.01);-
1055 if (depth == 32
depth == 32Description
TRUEnever evaluated
FALSEnever evaluated
|| (bounds.width() < lower_bound
bounds.width() < lower_boundDescription
TRUEnever evaluated
FALSEnever evaluated
&& bounds.height() < lower_bound
bounds.height() < lower_boundDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
1056 return
never executed: return true;
true;
never executed: return true;
0
1057-
1058 QBezier first_half, second_half;-
1059 bezier.split(&first_half, &second_half);-
1060 if (qt_isect_curve_vertical(first_half, x, y1, y2, depth + 1)
qt_isect_curve...y2, depth + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1061 || qt_isect_curve_vertical(second_half, x, y1, y2, depth + 1)
qt_isect_curve...y2, depth + 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1062 return
never executed: return true;
true;
never executed: return true;
0
1063 }
never executed: end of block
0
1064 return
never executed: return false;
false;
never executed: return false;
0
1065}-
1066-
1067-
1068-
1069-
1070static bool qt_painterpath_check_crossing(const QPainterPath *path, const QRectF &rect)-
1071{-
1072 QPointF last_pt;-
1073 QPointF last_start;-
1074 for (int i=0; i<path->elementCount()
i<path->elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1075 const QPainterPath::Element &e = path->elementAt(i);-
1076-
1077 switch (e.type) {-
1078-
1079 case
never executed: case QPainterPath::MoveToElement:
QPainterPath::MoveToElement:
never executed: case QPainterPath::MoveToElement:
0
1080 if (i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1081 && qFuzzyCompare(last_pt.x(), last_start.x())
qFuzzyCompare(...ast_start.x())Description
TRUEnever evaluated
FALSEnever evaluated
0
1082 && qFuzzyCompare(last_pt.y(), last_start.y())
qFuzzyCompare(...ast_start.y())Description
TRUEnever evaluated
FALSEnever evaluated
0
1083 && qt_painterpath_isect_line_rect(last_pt.x(), last_pt.y(),
qt_painterpath...art.y(), rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1084 last_start.x(), last_start.y(), rect)
qt_painterpath...art.y(), rect)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1085 return
never executed: return true;
true;
never executed: return true;
0
1086 last_start = last_pt = e;-
1087 break;
never executed: break;
0
1088-
1089 case
never executed: case QPainterPath::LineToElement:
QPainterPath::LineToElement:
never executed: case QPainterPath::LineToElement:
0
1090 if (qt_painterpath_isect_line_rect(last_pt.x(), last_pt.y(), e.x, e.y, rect)
qt_painterpath....x, e.y, rect)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1091 return
never executed: return true;
true;
never executed: return true;
0
1092 last_pt = e;-
1093 break;
never executed: break;
0
1094-
1095 case
never executed: case QPainterPath::CurveToElement:
QPainterPath::CurveToElement:
never executed: case QPainterPath::CurveToElement:
0
1096 {-
1097 QPointF cp2 = path->elementAt(++i);-
1098 QPointF ep = path->elementAt(++i);-
1099 QBezier bezier = QBezier::fromPoints(last_pt, e, cp2, ep);-
1100 if (qt_isect_curve_horizontal(bezier, rect.top(), rect.left(), rect.right())
qt_isect_curve... rect.right())Description
TRUEnever evaluated
FALSEnever evaluated
0
1101 || qt_isect_curve_horizontal(bezier, rect.bottom(), rect.left(), rect.right())
qt_isect_curve... rect.right())Description
TRUEnever evaluated
FALSEnever evaluated
0
1102 || qt_isect_curve_vertical(bezier, rect.left(), rect.top(), rect.bottom())
qt_isect_curve...rect.bottom())Description
TRUEnever evaluated
FALSEnever evaluated
0
1103 || qt_isect_curve_vertical(bezier, rect.right(), rect.top(), rect.bottom())
qt_isect_curve...rect.bottom())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1104 return
never executed: return true;
true;
never executed: return true;
0
1105 last_pt = ep;-
1106 }-
1107 break;
never executed: break;
0
1108-
1109 default
never executed: default:
:
never executed: default:
0
1110 break;
never executed: break;
0
1111 }-
1112 }-
1113-
1114-
1115 if (last_pt != last_start
last_pt != last_startDescription
TRUEnever evaluated
FALSEnever evaluated
0
1116 && qt_painterpath_isect_line_rect(last_pt.x(), last_pt.y(),
qt_painterpath...art.y(), rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1117 last_start.x(), last_start.y(), rect)
qt_painterpath...art.y(), rect)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1118 return
never executed: return true;
true;
never executed: return true;
0
1119-
1120 return
never executed: return false;
false;
never executed: return false;
0
1121}-
1122bool QPainterPath::intersects(const QRectF &rect) const-
1123{-
1124 if (elementCount() == 1
elementCount() == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& rect.contains(elementAt(0))
rect.contains(elementAt(0))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1125 return
never executed: return true;
true;
never executed: return true;
0
1126-
1127 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1128 return
never executed: return false;
false;
never executed: return false;
0
1129-
1130 QRectF cp = controlPointRect();-
1131 QRectF rn = rect.normalized();-
1132-
1133-
1134-
1135-
1136 if (qMax(rn.left(), cp.left()) > qMin(rn.right(), cp.right())
qMax(rn.left()...), cp.right())Description
TRUEnever evaluated
FALSEnever evaluated
0
1137 || qMax(rn.top(), cp.top()) > qMin(rn.bottom(), cp.bottom())
qMax(rn.top(),..., cp.bottom())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1138 return
never executed: return false;
false;
never executed: return false;
0
1139-
1140-
1141 if (qt_painterpath_check_crossing(this, rect)
qt_painterpath...ng(this, rect)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1142 return
never executed: return true;
true;
never executed: return true;
0
1143-
1144 if (contains(rect.center())
contains(rect.center())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1145 return
never executed: return true;
true;
never executed: return true;
0
1146-
1147 QPainterPathPrivate * const d = d_func();-
1148-
1149-
1150 for (int i=0; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1151 const Element &e = d->elements.at(i);-
1152 if (e.type == QPainterPath::MoveToElement
e.type == QPai...:MoveToElementDescription
TRUEnever evaluated
FALSEnever evaluated
&& rect.contains(e)
rect.contains(e)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1153 return
never executed: return true;
true;
never executed: return true;
0
1154 }
never executed: end of block
0
1155-
1156 return
never executed: return false;
false;
never executed: return false;
0
1157}-
1158-
1159-
1160-
1161-
1162-
1163-
1164-
1165void QPainterPath::translate(qreal dx, qreal dy)-
1166{-
1167 if (!d_ptr
!d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
|| (dx == 0
dx == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& dy == 0
dy == 0Description
TRUEnever evaluated
FALSEnever evaluated
))
0
1168 return;
never executed: return;
0
1169-
1170 int elementsLeft = d_ptr->elements.size();-
1171 if (elementsLeft <= 0
elementsLeft <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1172 return;
never executed: return;
0
1173-
1174 detach();-
1175 QPainterPath::Element *element = d_func()->elements.data();-
1176 ((!(element)) ? qt_assert("element",__FILE__,2109) : qt_noop());-
1177 while (elementsLeft--
elementsLeft--Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1178 element->x += dx;-
1179 element->y += dy;-
1180 ++element;-
1181 }
never executed: end of block
0
1182}
never executed: end of block
0
1183QPainterPath QPainterPath::translated(qreal dx, qreal dy) const-
1184{-
1185 QPainterPath copy(*this);-
1186 copy.translate(dx, dy);-
1187 return
never executed: return copy;
copy;
never executed: return copy;
0
1188}-
1189bool QPainterPath::contains(const QRectF &rect) const-
1190{-
1191 QPainterPathPrivate * const d = d_func();-
1192-
1193-
1194-
1195 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| !controlPointRect().contains(rect)
!controlPointR...contains(rect)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1196 return
never executed: return false;
false;
never executed: return false;
0
1197-
1198-
1199-
1200-
1201 if (qt_painterpath_check_crossing(this, rect)
qt_painterpath...ng(this, rect)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1202 if (fillRule() == Qt::OddEvenFill
fillRule() == Qt::OddEvenFillDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1203 return
never executed: return false;
false;
never executed: return false;
0
1204 } else {-
1205-
1206-
1207 if (!contains(rect.topLeft())
!contains(rect.topLeft())Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1208 !contains(rect.topRight())
!contains(rect.topRight())Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1209 !contains(rect.bottomRight())
!contains(rect.bottomRight())Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1210 !contains(rect.bottomLeft())
!contains(rect.bottomLeft())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1211 return
never executed: return false;
false;
never executed: return false;
0
1212 }
never executed: end of block
0
1213 }-
1214-
1215-
1216-
1217-
1218-
1219 if (!contains(rect.center())
!contains(rect.center())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1220 return
never executed: return false;
false;
never executed: return false;
0
1221-
1222-
1223-
1224-
1225-
1226-
1227-
1228 for (int i=0; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1229 const Element &e = d->elements.at(i);-
1230 if (e.type == QPainterPath::MoveToElement
e.type == QPai...:MoveToElementDescription
TRUEnever evaluated
FALSEnever evaluated
&& rect.contains(e)
rect.contains(e)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1231 if (fillRule() == Qt::OddEvenFill
fillRule() == Qt::OddEvenFillDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1232 return
never executed: return false;
false;
never executed: return false;
0
1233-
1234 bool stop = false;-
1235 for (; !stop
!stopDescription
TRUEnever evaluated
FALSEnever evaluated
&& i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1236 const Element &el = d->elements.at(i);-
1237 switch (el.type) {-
1238 case
never executed: case MoveToElement:
MoveToElement:
never executed: case MoveToElement:
0
1239 stop = true;-
1240 break;
never executed: break;
0
1241 case
never executed: case LineToElement:
LineToElement:
never executed: case LineToElement:
0
1242 if (!contains(el)
!contains(el)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1243 return
never executed: return false;
false;
never executed: return false;
0
1244 break;
never executed: break;
0
1245 case
never executed: case CurveToElement:
CurveToElement:
never executed: case CurveToElement:
0
1246 if (!contains(d->elements.at(i+2))
!contains(d->elements.at(i+2))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1247 return
never executed: return false;
false;
never executed: return false;
0
1248 i += 2;-
1249 break;
never executed: break;
0
1250 default
never executed: default:
:
never executed: default:
0
1251 break;
never executed: break;
0
1252 }-
1253 }-
1254-
1255-
1256 --i;-
1257 }
never executed: end of block
0
1258 }
never executed: end of block
0
1259-
1260 return
never executed: return true;
true;
never executed: return true;
0
1261}-
1262-
1263static inline bool epsilonCompare(const QPointF &a, const QPointF &b, const QSizeF &epsilon)-
1264{-
1265 return
never executed: return qAbs(a.x() - b.x()) <= epsilon.width() && qAbs(a.y() - b.y()) <= epsilon.height();
qAbs(a.x() - b.x()) <= epsilon.width()
never executed: return qAbs(a.x() - b.x()) <= epsilon.width() && qAbs(a.y() - b.y()) <= epsilon.height();
0
1266 && qAbs(a.y() - b.y()) <= epsilon.height();
never executed: return qAbs(a.x() - b.x()) <= epsilon.width() && qAbs(a.y() - b.y()) <= epsilon.height();
0
1267}-
1268bool QPainterPath::operator==(const QPainterPath &path) const-
1269{-
1270 QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());-
1271 if (path.d_func() == d
path.d_func() == dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1272 return
never executed: return true;
true;
never executed: return true;
0
1273 else if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
|| !path.d_func()
!path.d_func()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1274 return
never executed: return false;
false;
never executed: return false;
0
1275 else if (d->fillRule != path.d_func()->fillRule
d->fillRule !=...nc()->fillRuleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1276 return
never executed: return false;
false;
never executed: return false;
0
1277 else if (d->elements.size() != path.d_func()->elements.size()
d->elements.si...lements.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1278 return
never executed: return false;
false;
never executed: return false;
0
1279-
1280 const qreal qt_epsilon = sizeof(qreal) == sizeof(double)
sizeof(qreal) ...sizeof(double)Description
TRUEnever evaluated
FALSEnever evaluated
? 1e-12 : qreal(1e-5);
0
1281-
1282 QSizeF epsilon = boundingRect().size();-
1283 epsilon.rwidth() *= qt_epsilon;-
1284 epsilon.rheight() *= qt_epsilon;-
1285-
1286 for (int i = 0; i < d->elements.size()
i < d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1287 if (d->elements.at(i).type != path.d_func()->elements.at(i).type
d->elements.at...nts.at(i).typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1288 || !epsilonCompare(d->elements.at(i), path.d_func()->elements.at(i), epsilon)
!epsilonCompar...t(i), epsilon)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1289 return
never executed: return false;
false;
never executed: return false;
0
1290-
1291 return
never executed: return true;
true;
never executed: return true;
0
1292}-
1293bool QPainterPath::operator!=(const QPainterPath &path) const-
1294{-
1295 return
never executed: return !(*this==path);
!(*this==path);
never executed: return !(*this==path);
0
1296}-
1297QPainterPath QPainterPath::operator&(const QPainterPath &other) const-
1298{-
1299 return
never executed: return intersected(other);
intersected(other);
never executed: return intersected(other);
0
1300}-
1301QPainterPath QPainterPath::operator|(const QPainterPath &other) const-
1302{-
1303 return
never executed: return united(other);
united(other);
never executed: return united(other);
0
1304}-
1305QPainterPath QPainterPath::operator+(const QPainterPath &other) const-
1306{-
1307 return
never executed: return united(other);
united(other);
never executed: return united(other);
0
1308}-
1309QPainterPath QPainterPath::operator-(const QPainterPath &other) const-
1310{-
1311 return
never executed: return subtracted(other);
subtracted(other);
never executed: return subtracted(other);
0
1312}-
1313QPainterPath &QPainterPath::operator&=(const QPainterPath &other)-
1314{-
1315 return
never executed: return *this = (*this & other);
*this = (*this & other);
never executed: return *this = (*this & other);
0
1316}-
1317QPainterPath &QPainterPath::operator|=(const QPainterPath &other)-
1318{-
1319 return
never executed: return *this = (*this | other);
*this = (*this | other);
never executed: return *this = (*this | other);
0
1320}-
1321QPainterPath &QPainterPath::operator+=(const QPainterPath &other)-
1322{-
1323 return
never executed: return *this = (*this + other);
*this = (*this + other);
never executed: return *this = (*this + other);
0
1324}-
1325QPainterPath &QPainterPath::operator-=(const QPainterPath &other)-
1326{-
1327 return
never executed: return *this = (*this - other);
*this = (*this - other);
never executed: return *this = (*this - other);
0
1328}-
1329QDataStream &operator<<(QDataStream &s, const QPainterPath &p)-
1330{-
1331 if (p.isEmpty()
p.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1332 s << 0;-
1333 return
never executed: return s;
s;
never executed: return s;
0
1334 }-
1335-
1336 s << p.elementCount();-
1337 for (int i=0; i < p.d_func()->elements.size()
i < p.d_func()...lements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1338 const QPainterPath::Element &e = p.d_func()->elements.at(i);-
1339 s << int(e.type);-
1340 s << double(e.x) << double(e.y);-
1341 }
never executed: end of block
0
1342 s << p.d_func()->cStart;-
1343 s << int(p.d_func()->fillRule);-
1344 return
never executed: return s;
s;
never executed: return s;
0
1345}-
1346QDataStream &operator>>(QDataStream &s, QPainterPath &p)-
1347{-
1348 int size;-
1349 s >> size;-
1350-
1351 if (size == 0
size == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1352 return
never executed: return s;
s;
never executed: return s;
0
1353-
1354 p.ensureData();-
1355 if (p.d_func()->elements.size() == 1
p.d_func()->el...ts.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1356 ((!(p.d_func()->elements.at(0).type == QPainterPath::MoveToElement)) ? qt_assert("p.d_func()->elements.at(0).type == QPainterPath::MoveToElement",__FILE__,2431) : qt_noop());-
1357 p.d_func()->elements.clear();-
1358 }
never executed: end of block
0
1359 p.d_func()->elements.reserve(p.d_func()->elements.size() + size);-
1360 for (int i=0; i<size
i<sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1361 int type;-
1362 double x, y;-
1363 s >> type;-
1364 s >> x;-
1365 s >> y;-
1366 ((!(type >= 0 && type <= 3)) ? qt_assert("type >= 0 && type <= 3",__FILE__,2441) : qt_noop());-
1367 if (!qt_is_finite(x)
!qt_is_finite(x)Description
TRUEnever evaluated
FALSEnever evaluated
|| !qt_is_finite(y)
!qt_is_finite(y)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1368-
1369 QMessageLogger(__FILE__, 2444, __PRETTY_FUNCTION__).warning("QDataStream::operator>>: NaN or Inf element found in path, skipping it");-
1370-
1371 continue;
never executed: continue;
0
1372 }-
1373 QPainterPath::Element elm = { qreal(x), qreal(y), QPainterPath::ElementType(type) };-
1374 p.d_func()->elements.append(elm);-
1375 }
never executed: end of block
0
1376 s >> p.d_func()->cStart;-
1377 int fillRule;-
1378 s >> fillRule;-
1379 ((!(fillRule == Qt::OddEvenFill || Qt::WindingFill)) ? qt_assert("fillRule == Qt::OddEvenFill || Qt::WindingFill",__FILE__,2454) : qt_noop());-
1380 p.d_func()->fillRule = Qt::FillRule(fillRule);-
1381 p.d_func()->dirtyBounds = true;-
1382 p.d_func()->dirtyControlBounds = true;-
1383 return
never executed: return s;
s;
never executed: return s;
0
1384}-
1385-
1386-
1387-
1388-
1389-
1390-
1391-
1392void qt_path_stroke_move_to(qfixed x, qfixed y, void *data)-
1393{-
1394 ((QPainterPath *) data)->moveTo(x, y);-
1395}
never executed: end of block
0
1396-
1397void qt_path_stroke_line_to(qfixed x, qfixed y, void *data)-
1398{-
1399 ((QPainterPath *) data)->lineTo(x, y);-
1400}
never executed: end of block
0
1401-
1402void qt_path_stroke_cubic_to(qfixed c1x, qfixed c1y,-
1403 qfixed c2x, qfixed c2y,-
1404 qfixed ex, qfixed ey,-
1405 void *data)-
1406{-
1407 ((QPainterPath *) data)->cubicTo(c1x, c1y,-
1408 c2x, c2y,-
1409 ex, ey);-
1410}
never executed: end of block
0
1411QPainterPathStrokerPrivate::QPainterPathStrokerPrivate()-
1412 : dashOffset(0)-
1413{-
1414 stroker.setMoveToHook(qt_path_stroke_move_to);-
1415 stroker.setLineToHook(qt_path_stroke_line_to);-
1416 stroker.setCubicToHook(qt_path_stroke_cubic_to);-
1417}
never executed: end of block
0
1418-
1419-
1420-
1421-
1422QPainterPathStroker::QPainterPathStroker()-
1423 : d_ptr(new QPainterPathStrokerPrivate)-
1424{-
1425}
never executed: end of block
0
1426-
1427-
1428-
1429-
1430-
1431-
1432QPainterPathStroker::QPainterPathStroker(const QPen &pen)-
1433 : d_ptr(new QPainterPathStrokerPrivate)-
1434{-
1435 setWidth(pen.widthF());-
1436 setCapStyle(pen.capStyle());-
1437 setJoinStyle(pen.joinStyle());-
1438 setMiterLimit(pen.miterLimit());-
1439 setDashOffset(pen.dashOffset());-
1440-
1441 if (pen.style() == Qt::CustomDashLine
pen.style() ==...CustomDashLineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1442 setDashPattern(pen.dashPattern());
never executed: setDashPattern(pen.dashPattern());
0
1443 else-
1444 setDashPattern(pen.style());
never executed: setDashPattern(pen.style());
0
1445}-
1446-
1447-
1448-
1449-
1450QPainterPathStroker::~QPainterPathStroker()-
1451{-
1452}-
1453QPainterPath QPainterPathStroker::createStroke(const QPainterPath &path) const-
1454{-
1455 QPainterPathStrokerPrivate *d = const_cast<QPainterPathStrokerPrivate *>(d_func());-
1456 QPainterPath stroke;-
1457 if (path.isEmpty()
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1458 return
never executed: return path;
path;
never executed: return path;
0
1459 if (d->dashPattern.isEmpty()
d->dashPattern.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1460 d->stroker.strokePath(path, &stroke, QTransform());-
1461 }
never executed: end of block
else {
0
1462 QDashStroker dashStroker(&d->stroker);-
1463 dashStroker.setDashPattern(d->dashPattern);-
1464 dashStroker.setDashOffset(d->dashOffset);-
1465 dashStroker.setClipRect(d->stroker.clipRect());-
1466 dashStroker.strokePath(path, &stroke, QTransform());-
1467 }
never executed: end of block
0
1468 stroke.setFillRule(Qt::WindingFill);-
1469 return
never executed: return stroke;
stroke;
never executed: return stroke;
0
1470}-
1471-
1472-
1473-
1474-
1475-
1476-
1477-
1478void QPainterPathStroker::setWidth(qreal width)-
1479{-
1480 QPainterPathStrokerPrivate * const d = d_func();-
1481 if (width <= 0
width <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1482 width = 1;
never executed: width = 1;
0
1483 d->stroker.setStrokeWidth(qfixed(width));-
1484}
never executed: end of block
0
1485-
1486-
1487-
1488-
1489qreal QPainterPathStroker::width() const-
1490{-
1491 return
never executed: return d_func()->stroker.strokeWidth();
d_func()->stroker.strokeWidth();
never executed: return d_func()->stroker.strokeWidth();
0
1492}-
1493-
1494-
1495-
1496-
1497-
1498-
1499-
1500void QPainterPathStroker::setCapStyle(Qt::PenCapStyle style)-
1501{-
1502 d_func()->stroker.setCapStyle(style);-
1503}
never executed: end of block
0
1504-
1505-
1506-
1507-
1508-
1509Qt::PenCapStyle QPainterPathStroker::capStyle() const-
1510{-
1511 return
never executed: return d_func()->stroker.capStyle();
d_func()->stroker.capStyle();
never executed: return d_func()->stroker.capStyle();
0
1512}-
1513-
1514-
1515-
1516-
1517void QPainterPathStroker::setJoinStyle(Qt::PenJoinStyle style)-
1518{-
1519 d_func()->stroker.setJoinStyle(style);-
1520}
never executed: end of block
0
1521-
1522-
1523-
1524-
1525Qt::PenJoinStyle QPainterPathStroker::joinStyle() const-
1526{-
1527 return
never executed: return d_func()->stroker.joinStyle();
d_func()->stroker.joinStyle();
never executed: return d_func()->stroker.joinStyle();
0
1528}-
1529void QPainterPathStroker::setMiterLimit(qreal limit)-
1530{-
1531 d_func()->stroker.setMiterLimit(qfixed(limit));-
1532}
never executed: end of block
0
1533-
1534-
1535-
1536-
1537qreal QPainterPathStroker::miterLimit() const-
1538{-
1539 return
never executed: return d_func()->stroker.miterLimit();
d_func()->stroker.miterLimit();
never executed: return d_func()->stroker.miterLimit();
0
1540}-
1541void QPainterPathStroker::setCurveThreshold(qreal threshold)-
1542{-
1543 d_func()->stroker.setCurveThreshold(qfixed(threshold));-
1544}
never executed: end of block
0
1545-
1546-
1547-
1548-
1549-
1550qreal QPainterPathStroker::curveThreshold() const-
1551{-
1552 return
never executed: return d_func()->stroker.curveThreshold();
d_func()->stroker.curveThreshold();
never executed: return d_func()->stroker.curveThreshold();
0
1553}-
1554-
1555-
1556-
1557-
1558void QPainterPathStroker::setDashPattern(Qt::PenStyle style)-
1559{-
1560 d_func()->dashPattern = QDashStroker::patternForStyle(style);-
1561}
never executed: end of block
0
1562void QPainterPathStroker::setDashPattern(const QVector<qreal> &dashPattern)-
1563{-
1564 d_func()->dashPattern.clear();-
1565 for (int i=0; i<dashPattern.size()
i<dashPattern.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1566 d_func()->dashPattern << qfixed(dashPattern.at(i));
never executed: d_func()->dashPattern << qfixed(dashPattern.at(i));
0
1567}
never executed: end of block
0
1568-
1569-
1570-
1571-
1572QVector<qreal> QPainterPathStroker::dashPattern() const-
1573{-
1574 return
never executed: return d_func()->dashPattern;
d_func()->dashPattern;
never executed: return d_func()->dashPattern;
0
1575}-
1576-
1577-
1578-
1579-
1580qreal QPainterPathStroker::dashOffset() const-
1581{-
1582 return
never executed: return d_func()->dashOffset;
d_func()->dashOffset;
never executed: return d_func()->dashOffset;
0
1583}-
1584-
1585-
1586-
1587-
1588-
1589-
1590-
1591void QPainterPathStroker::setDashOffset(qreal offset)-
1592{-
1593 d_func()->dashOffset = offset;-
1594}
never executed: end of block
0
1595QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix) const-
1596{-
1597-
1598 const QList<QPolygonF> flats = toSubpathPolygons(matrix);-
1599 QPolygonF polygon;-
1600 if (flats.isEmpty()
flats.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1601 return
never executed: return polygon;
polygon;
never executed: return polygon;
0
1602 QPointF first = flats.first().first();-
1603 for (int i=0; i<flats.size()
i<flats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1604 polygon += flats.at(i);-
1605 if (!flats.at(i).isClosed()
!flats.at(i).isClosed()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1606 polygon += flats.at(i).first();
never executed: polygon += flats.at(i).first();
0
1607 if (i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1608 polygon += first;
never executed: polygon += first;
0
1609 }
never executed: end of block
0
1610 return
never executed: return polygon;
polygon;
never executed: return polygon;
0
1611}-
1612-
1613-
1614-
1615-
1616QPolygonF QPainterPath::toFillPolygon(const QMatrix &matrix) const-
1617{-
1618 return
never executed: return toFillPolygon(QTransform(matrix));
toFillPolygon(QTransform(matrix));
never executed: return toFillPolygon(QTransform(matrix));
0
1619}-
1620-
1621-
1622-
1623static inline qreal slopeAt(qreal t, qreal a, qreal b, qreal c, qreal d)-
1624{-
1625 return
never executed: return 3*t*t*(d - 3*c + 3*b - a) + 6*t*(c - 2*b + a) + 3*(b - a);
3*t*t*(d - 3*c + 3*b - a) + 6*t*(c - 2*b + a) + 3*(b - a);
never executed: return 3*t*t*(d - 3*c + 3*b - a) + 6*t*(c - 2*b + a) + 3*(b - a);
0
1626}-
1627-
1628-
1629-
1630-
1631qreal QPainterPath::length() const-
1632{-
1633 QPainterPathPrivate * const d = d_func();-
1634 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1635 return
never executed: return 0;
0;
never executed: return 0;
0
1636-
1637 qreal len = 0;-
1638 for (int i=1; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1639 const Element &e = d->elements.at(i);-
1640-
1641 switch (e.type) {-
1642 case
never executed: case MoveToElement:
MoveToElement:
never executed: case MoveToElement:
0
1643 break;
never executed: break;
0
1644 case
never executed: case LineToElement:
LineToElement:
never executed: case LineToElement:
0
1645 {-
1646 len += QLineF(d->elements.at(i-1), e).length();-
1647 break;
never executed: break;
0
1648 }-
1649 case
never executed: case CurveToElement:
CurveToElement:
never executed: case CurveToElement:
0
1650 {-
1651 QBezier b = QBezier::fromPoints(d->elements.at(i-1),-
1652 e,-
1653 d->elements.at(i+1),-
1654 d->elements.at(i+2));-
1655 len += b.length();-
1656 i += 2;-
1657 break;
never executed: break;
0
1658 }-
1659 default
never executed: default:
:
never executed: default:
0
1660 break;
never executed: break;
0
1661 }-
1662 }-
1663 return
never executed: return len;
len;
never executed: return len;
0
1664}-
1665qreal QPainterPath::percentAtLength(qreal len) const-
1666{-
1667 QPainterPathPrivate * const d = d_func();-
1668 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| len <= 0
len <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1669 return
never executed: return 0;
0;
never executed: return 0;
0
1670-
1671 qreal totalLength = length();-
1672 if (len > totalLength
len > totalLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1673 return
never executed: return 1;
1;
never executed: return 1;
0
1674-
1675 qreal curLen = 0;-
1676 for (int i=1; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1677 const Element &e = d->elements.at(i);-
1678-
1679 switch (e.type) {-
1680 case
never executed: case MoveToElement:
MoveToElement:
never executed: case MoveToElement:
0
1681 break;
never executed: break;
0
1682 case
never executed: case LineToElement:
LineToElement:
never executed: case LineToElement:
0
1683 {-
1684 QLineF line(d->elements.at(i-1), e);-
1685 qreal llen = line.length();-
1686 curLen += llen;-
1687 if (curLen >= len
curLen >= lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1688 return
never executed: return len/totalLength ;
len/totalLength ;
never executed: return len/totalLength ;
0
1689 }-
1690-
1691 break;
never executed: break;
0
1692 }-
1693 case
never executed: case CurveToElement:
CurveToElement:
never executed: case CurveToElement:
0
1694 {-
1695 QBezier b = QBezier::fromPoints(d->elements.at(i-1),-
1696 e,-
1697 d->elements.at(i+1),-
1698 d->elements.at(i+2));-
1699 qreal blen = b.length();-
1700 qreal prevLen = curLen;-
1701 curLen += blen;-
1702-
1703 if (curLen >= len
curLen >= lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1704 qreal res = b.tAtLength(len - prevLen);-
1705 return
never executed: return (res * blen + prevLen)/totalLength;
(res * blen + prevLen)/totalLength;
never executed: return (res * blen + prevLen)/totalLength;
0
1706 }-
1707-
1708 i += 2;-
1709 break;
never executed: break;
0
1710 }-
1711 default
never executed: default:
:
never executed: default:
0
1712 break;
never executed: break;
0
1713 }-
1714 }-
1715-
1716 return
never executed: return 0;
0;
never executed: return 0;
0
1717}-
1718-
1719static inline QBezier bezierAtT(const QPainterPath &path, qreal t, qreal *startingLength, qreal *bezierLength)-
1720{-
1721 *startingLength = 0;-
1722 if (t > 1
t > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1723 return
never executed: return QBezier();
QBezier();
never executed: return QBezier();
0
1724-
1725 qreal curLen = 0;-
1726 qreal totalLength = path.length();-
1727-
1728 const int lastElement = path.elementCount() - 1;-
1729 for (int i=0; i <= lastElement
i <= lastElementDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1730 const QPainterPath::Element &e = path.elementAt(i);-
1731-
1732 switch (e.type) {-
1733 case
never executed: case QPainterPath::MoveToElement:
QPainterPath::MoveToElement:
never executed: case QPainterPath::MoveToElement:
0
1734 break;
never executed: break;
0
1735 case
never executed: case QPainterPath::LineToElement:
QPainterPath::LineToElement:
never executed: case QPainterPath::LineToElement:
0
1736 {-
1737 QLineF line(path.elementAt(i-1), e);-
1738 qreal llen = line.length();-
1739 curLen += llen;-
1740 if (i == lastElement
i == lastElementDescription
TRUEnever evaluated
FALSEnever evaluated
|| curLen/totalLength >= t
curLen/totalLength >= tDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1741 *bezierLength = llen;-
1742 QPointF a = path.elementAt(i-1);-
1743 QPointF delta = e - a;-
1744 return
never executed: return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
never executed: return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
0
1745 }-
1746 break;
never executed: break;
0
1747 }-
1748 case
never executed: case QPainterPath::CurveToElement:
QPainterPath::CurveToElement:
never executed: case QPainterPath::CurveToElement:
0
1749 {-
1750 QBezier b = QBezier::fromPoints(path.elementAt(i-1),-
1751 e,-
1752 path.elementAt(i+1),-
1753 path.elementAt(i+2));-
1754 qreal blen = b.length();-
1755 curLen += blen;-
1756-
1757 if (i + 2 == lastElement
i + 2 == lastElementDescription
TRUEnever evaluated
FALSEnever evaluated
|| curLen/totalLength >= t
curLen/totalLength >= tDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1758 *bezierLength = blen;-
1759 return
never executed: return b;
b;
never executed: return b;
0
1760 }-
1761-
1762 i += 2;-
1763 break;
never executed: break;
0
1764 }-
1765 default
never executed: default:
:
never executed: default:
0
1766 break;
never executed: break;
0
1767 }-
1768 *startingLength = curLen;-
1769 }
never executed: end of block
0
1770 return
never executed: return QBezier();
QBezier();
never executed: return QBezier();
0
1771}-
1772QPointF QPainterPath::pointAtPercent(qreal t) const-
1773{-
1774 if (t < 0
t < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| t > 1
t > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1775 QMessageLogger(__FILE__, 2990, __PRETTY_FUNCTION__).warning("QPainterPath::pointAtPercent accepts only values between 0 and 1");-
1776 return
never executed: return QPointF();
QPointF();
never executed: return QPointF();
0
1777 }-
1778-
1779 if (!d_ptr
!d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
|| d_ptr->elements.size() == 0
d_ptr->elements.size() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1780 return
never executed: return QPointF();
QPointF();
never executed: return QPointF();
0
1781-
1782 if (d_ptr->elements.size() == 1
d_ptr->elements.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1783 return
never executed: return d_ptr->elements.at(0);
d_ptr->elements.at(0);
never executed: return d_ptr->elements.at(0);
0
1784-
1785 qreal totalLength = length();-
1786 qreal curLen = 0;-
1787 qreal bezierLen = 0;-
1788 QBezier b = bezierAtT(*this, t, &curLen, &bezierLen);-
1789 qreal realT = (totalLength * t - curLen) / bezierLen;-
1790-
1791 return
never executed: return b.pointAt(qBound(qreal(0), realT, qreal(1)));
b.pointAt(qBound(qreal(0), realT, qreal(1)));
never executed: return b.pointAt(qBound(qreal(0), realT, qreal(1)));
0
1792}-
1793qreal QPainterPath::angleAtPercent(qreal t) const-
1794{-
1795 if (t < 0
t < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| t > 1
t > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1796 QMessageLogger(__FILE__, 3024, __PRETTY_FUNCTION__).warning("QPainterPath::angleAtPercent accepts only values between 0 and 1");-
1797 return
never executed: return 0;
0;
never executed: return 0;
0
1798 }-
1799-
1800 qreal totalLength = length();-
1801 qreal curLen = 0;-
1802 qreal bezierLen = 0;-
1803 QBezier bez = bezierAtT(*this, t, &curLen, &bezierLen);-
1804 qreal realT = (totalLength * t - curLen) / bezierLen;-
1805-
1806 qreal m1 = slopeAt(realT, bez.x1, bez.x2, bez.x3, bez.x4);-
1807 qreal m2 = slopeAt(realT, bez.y1, bez.y2, bez.y3, bez.y4);-
1808-
1809 return
never executed: return QLineF(0, 0, m1, m2).angle();
QLineF(0, 0, m1, m2).angle();
never executed: return QLineF(0, 0, m1, m2).angle();
0
1810}-
1811qreal QPainterPath::slopeAtPercent(qreal t) const-
1812{-
1813 if (t < 0
t < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| t > 1
t > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1814 QMessageLogger(__FILE__, 3053, __PRETTY_FUNCTION__).warning("QPainterPath::slopeAtPercent accepts only values between 0 and 1");-
1815 return
never executed: return 0;
0;
never executed: return 0;
0
1816 }-
1817-
1818 qreal totalLength = length();-
1819 qreal curLen = 0;-
1820 qreal bezierLen = 0;-
1821 QBezier bez = bezierAtT(*this, t, &curLen, &bezierLen);-
1822 qreal realT = (totalLength * t - curLen) / bezierLen;-
1823-
1824 qreal m1 = slopeAt(realT, bez.x1, bez.x2, bez.x3, bez.x4);-
1825 qreal m2 = slopeAt(realT, bez.y1, bez.y2, bez.y3, bez.y4);-
1826-
1827 qreal slope = 0;-
1828-
1829 if (m1
m1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1830 slope = m2/m1;
never executed: slope = m2/m1;
0
1831 else {-
1832 if (std::numeric_limits<qreal>::has_infinity
std::numeric_l...::has_infinityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1833 slope = (
(m2 < 0)Description
TRUEnever evaluated
FALSEnever evaluated
m2 < 0)
(m2 < 0)Description
TRUEnever evaluated
FALSEnever evaluated
? -std::numeric_limits<qreal>::infinity()
0
1834 : std::numeric_limits<qreal>::infinity();-
1835 }
never executed: end of block
else {
0
1836 if (sizeof(qreal) == sizeof(double)
sizeof(qreal) ...sizeof(double)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1837 return
never executed: return 1.79769313486231570e+308;
1.79769313486231570e+308;
never executed: return 1.79769313486231570e+308;
0
1838 } else {-
1839 return
never executed: return ((qreal)3.40282346638528860e+38);
((qreal)3.40282346638528860e+38);
never executed: return ((qreal)3.40282346638528860e+38);
0
1840 }-
1841 }-
1842 }-
1843-
1844 return
never executed: return slope;
slope;
never executed: return slope;
0
1845}-
1846void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,-
1847 Qt::SizeMode mode)-
1848{-
1849 QRectF r = rect.normalized();-
1850-
1851 if (r.isNull()
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1852 return;
never executed: return;
0
1853-
1854 if (mode == Qt::AbsoluteSize
mode == Qt::AbsoluteSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1855 qreal w = r.width() / 2;-
1856 qreal h = r.height() / 2;-
1857-
1858 if (w == 0
w == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1859 xRadius = 0;-
1860 }
never executed: end of block
else {
0
1861 xRadius = 100 * qMin(xRadius, w) / w;-
1862 }
never executed: end of block
0
1863 if (h == 0
h == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1864 yRadius = 0;-
1865 }
never executed: end of block
else {
0
1866 yRadius = 100 * qMin(yRadius, h) / h;-
1867 }
never executed: end of block
0
1868 } else {-
1869 if (xRadius > 100
xRadius > 100Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1870 xRadius = 100;
never executed: xRadius = 100;
0
1871-
1872 if (yRadius > 100
yRadius > 100Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1873 yRadius = 100;
never executed: yRadius = 100;
0
1874 }
never executed: end of block
0
1875-
1876 if (xRadius <= 0
xRadius <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| yRadius <= 0
yRadius <= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1877 addRect(r);-
1878 return;
never executed: return;
0
1879 }-
1880-
1881 qreal x = r.x();-
1882 qreal y = r.y();-
1883 qreal w = r.width();-
1884 qreal h = r.height();-
1885 qreal rxx2 = w*xRadius/100;-
1886 qreal ryy2 = h*yRadius/100;-
1887-
1888 ensureData();-
1889 detach();-
1890-
1891 bool first = d_func()->elements.size() < 2;-
1892-
1893 arcMoveTo(x, y, rxx2, ryy2, 180);-
1894 arcTo(x, y, rxx2, ryy2, 180, -90);-
1895 arcTo(x+w-rxx2, y, rxx2, ryy2, 90, -90);-
1896 arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 0, -90);-
1897 arcTo(x, y+h-ryy2, rxx2, ryy2, 270, -90);-
1898 closeSubpath();-
1899-
1900 d_func()->require_moveTo = true;-
1901 d_func()->convex = first;-
1902}
never executed: end of block
0
1903void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd)-
1904{-
1905 if(xRnd >= 100
xRnd >= 100Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1906 xRnd = 99;
never executed: xRnd = 99;
0
1907 if(yRnd >= 100
yRnd >= 100Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1908 yRnd = 99;
never executed: yRnd = 99;
0
1909 if(xRnd <= 0
xRnd <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| yRnd <= 0
yRnd <= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1910 addRect(r);-
1911 return;
never executed: return;
0
1912 }-
1913-
1914 QRectF rect = r.normalized();-
1915-
1916 if (rect.isNull()
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1917 return;
never executed: return;
0
1918-
1919 qreal x = rect.x();-
1920 qreal y = rect.y();-
1921 qreal w = rect.width();-
1922 qreal h = rect.height();-
1923 qreal rxx2 = w*xRnd/100;-
1924 qreal ryy2 = h*yRnd/100;-
1925-
1926 ensureData();-
1927 detach();-
1928-
1929 bool first = d_func()->elements.size() < 2;-
1930-
1931 arcMoveTo(x, y, rxx2, ryy2, 180);-
1932 arcTo(x, y, rxx2, ryy2, 180, -90);-
1933 arcTo(x+w-rxx2, y, rxx2, ryy2, 90, -90);-
1934 arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 0, -90);-
1935 arcTo(x, y+h-ryy2, rxx2, ryy2, 270, -90);-
1936 closeSubpath();-
1937-
1938 d_func()->require_moveTo = true;-
1939 d_func()->convex = first;-
1940}
never executed: end of block
0
1941QPainterPath QPainterPath::united(const QPainterPath &p) const-
1942{-
1943 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| p.isEmpty()
p.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1944 return
never executed: return isEmpty() ? p : *this;
isEmpty() ? p : *this;
never executed: return isEmpty() ? p : *this;
0
1945 QPathClipper clipper(*this, p);-
1946 return
never executed: return clipper.clip(QPathClipper::BoolOr);
clipper.clip(QPathClipper::BoolOr);
never executed: return clipper.clip(QPathClipper::BoolOr);
0
1947}-
1948QPainterPath QPainterPath::intersected(const QPainterPath &p) const-
1949{-
1950 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| p.isEmpty()
p.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1951 return
never executed: return QPainterPath();
QPainterPath();
never executed: return QPainterPath();
0
1952 QPathClipper clipper(*this, p);-
1953 return
never executed: return clipper.clip(QPathClipper::BoolAnd);
clipper.clip(QPathClipper::BoolAnd);
never executed: return clipper.clip(QPathClipper::BoolAnd);
0
1954}-
1955QPainterPath QPainterPath::subtracted(const QPainterPath &p) const-
1956{-
1957 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| p.isEmpty()
p.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1958 return
never executed: return *this;
*this;
never executed: return *this;
0
1959 QPathClipper clipper(*this, p);-
1960 return
never executed: return clipper.clip(QPathClipper::BoolSub);
clipper.clip(QPathClipper::BoolSub);
never executed: return clipper.clip(QPathClipper::BoolSub);
0
1961}-
1962QPainterPath QPainterPath::subtractedInverted(const QPainterPath &p) const-
1963{-
1964 return
never executed: return p.subtracted(*this);
p.subtracted(*this);
never executed: return p.subtracted(*this);
0
1965}-
1966QPainterPath QPainterPath::simplified() const-
1967{-
1968 if(isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1969 return
never executed: return *this;
*this;
never executed: return *this;
0
1970 QPathClipper clipper(*this, QPainterPath());-
1971 return
never executed: return clipper.clip(QPathClipper::Simplify);
clipper.clip(QPathClipper::Simplify);
never executed: return clipper.clip(QPathClipper::Simplify);
0
1972}-
1973bool QPainterPath::intersects(const QPainterPath &p) const-
1974{-
1975 if (p.elementCount() == 1
p.elementCount() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1976 return
never executed: return contains(p.elementAt(0));
contains(p.elementAt(0));
never executed: return contains(p.elementAt(0));
0
1977 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| p.isEmpty()
p.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1978 return
never executed: return false;
false;
never executed: return false;
0
1979 QPathClipper clipper(*this, p);-
1980 return
never executed: return clipper.intersect();
clipper.intersect();
never executed: return clipper.intersect();
0
1981}-
1982bool QPainterPath::contains(const QPainterPath &p) const-
1983{-
1984 if (p.elementCount() == 1
p.elementCount() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1985 return
never executed: return contains(p.elementAt(0));
contains(p.elementAt(0));
never executed: return contains(p.elementAt(0));
0
1986 if (isEmpty()
isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| p.isEmpty()
p.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1987 return
never executed: return false;
false;
never executed: return false;
0
1988 QPathClipper clipper(*this, p);-
1989 return
never executed: return clipper.contains();
clipper.contains();
never executed: return clipper.contains();
0
1990}-
1991-
1992void QPainterPath::setDirty(bool dirty)-
1993{-
1994 d_func()->dirtyBounds = dirty;-
1995 d_func()->dirtyControlBounds = dirty;-
1996 delete d_func()->pathConverter;-
1997 d_func()->pathConverter = 0;-
1998 d_func()->convex = false;-
1999}
never executed: end of block
0
2000-
2001void QPainterPath::computeBoundingRect() const-
2002{-
2003 QPainterPathData *d = d_func();-
2004 d->dirtyBounds = false;-
2005 if (!d_ptr
!d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2006 d->bounds = QRect();-
2007 return;
never executed: return;
0
2008 }-
2009-
2010 qreal minx, maxx, miny, maxy;-
2011 minx = maxx = d->elements.at(0).x;-
2012 miny = maxy = d->elements.at(0).y;-
2013 for (int i=1; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2014 const Element &e = d->elements.at(i);-
2015-
2016 switch (e.type) {-
2017 case
never executed: case MoveToElement:
MoveToElement:
never executed: case MoveToElement:
0
2018 case
never executed: case LineToElement:
LineToElement:
never executed: case LineToElement:
0
2019 if (e.x > maxx
e.x > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = e.x;
never executed: maxx = e.x;
0
2020 else if (e.x < minx
e.x < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = e.x;
never executed: minx = e.x;
0
2021 if (e.y > maxy
e.y > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = e.y;
never executed: maxy = e.y;
0
2022 else if (e.y < miny
e.y < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = e.y;
never executed: miny = e.y;
0
2023 break;
never executed: break;
0
2024 case
never executed: case CurveToElement:
CurveToElement:
never executed: case CurveToElement:
0
2025 {-
2026 QBezier b = QBezier::fromPoints(d->elements.at(i-1),-
2027 e,-
2028 d->elements.at(i+1),-
2029 d->elements.at(i+2));-
2030 QRectF r = qt_painterpath_bezier_extrema(b);-
2031 qreal right = r.right();-
2032 qreal bottom = r.bottom();-
2033 if (r.x() < minx
r.x() < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = r.x();
never executed: minx = r.x();
0
2034 if (right > maxx
right > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = right;
never executed: maxx = right;
0
2035 if (r.y() < miny
r.y() < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = r.y();
never executed: miny = r.y();
0
2036 if (bottom > maxy
bottom > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = bottom;
never executed: maxy = bottom;
0
2037 i += 2;-
2038 }-
2039 break;
never executed: break;
0
2040 default
never executed: default:
:
never executed: default:
0
2041 break;
never executed: break;
0
2042 }-
2043 }-
2044 d->bounds = QRectF(minx, miny, maxx - minx, maxy - miny);-
2045}
never executed: end of block
0
2046-
2047-
2048void QPainterPath::computeControlPointRect() const-
2049{-
2050 QPainterPathData *d = d_func();-
2051 d->dirtyControlBounds = false;-
2052 if (!d_ptr
!d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2053 d->controlBounds = QRect();-
2054 return;
never executed: return;
0
2055 }-
2056-
2057 qreal minx, maxx, miny, maxy;-
2058 minx = maxx = d->elements.at(0).x;-
2059 miny = maxy = d->elements.at(0).y;-
2060 for (int i=1; i<d->elements.size()
i<d->elements.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2061 const Element &e = d->elements.at(i);-
2062 if (e.x > maxx
e.x > maxxDescription
TRUEnever evaluated
FALSEnever evaluated
) maxx = e.x;
never executed: maxx = e.x;
0
2063 else if (e.x < minx
e.x < minxDescription
TRUEnever evaluated
FALSEnever evaluated
) minx = e.x;
never executed: minx = e.x;
0
2064 if (e.y > maxy
e.y > maxyDescription
TRUEnever evaluated
FALSEnever evaluated
) maxy = e.y;
never executed: maxy = e.y;
0
2065 else if (e.y < miny
e.y < minyDescription
TRUEnever evaluated
FALSEnever evaluated
) miny = e.y;
never executed: miny = e.y;
0
2066 }
never executed: end of block
0
2067 d->controlBounds = QRectF(minx, miny, maxx - minx, maxy - miny);-
2068}
never executed: end of block
0
2069-
2070-
2071QDebug operator<<(QDebug s, const QPainterPath &p)-
2072{-
2073 s.nospace() << "QPainterPath: Element count=" << p.elementCount() << endl;-
2074 const char *types[] = {"MoveTo", "LineTo", "CurveTo", "CurveToData"};-
2075 for (int i=0; i<p.elementCount()
i<p.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2076 s.nospace() << " -> " << types[p.elementAt(i).type] << "(x=" << p.elementAt(i).x << ", y=" << p.elementAt(i).y << ')' << endl;-
2077-
2078 }
never executed: end of block
0
2079 return
never executed: return s;
s;
never executed: return s;
0
2080}-
2081-
2082-
2083-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9