Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "private/qstroker_p.h" | - |
43 | #include "private/qbezier_p.h" | - |
44 | #include "private/qmath_p.h" | - |
45 | #include "qline.h" | - |
46 | #include "qtransform.h" | - |
47 | #include <qmath.h> | - |
48 | | - |
49 | QT_BEGIN_NAMESPACE | - |
50 | | - |
51 | // #define QPP_STROKE_DEBUG | - |
52 | | - |
53 | class QSubpathForwardIterator | - |
54 | { | - |
55 | public: | - |
56 | QSubpathForwardIterator(const QDataBuffer<QStrokerOps::Element> *path) | - |
57 | : m_path(path), m_pos(0) { } executed: } Execution Count:2833 | 2833 |
58 | inline int position() const { return m_pos; } never executed: return m_pos; | 0 |
59 | inline bool hasNext() const { return m_pos < m_path->size(); } executed: return m_pos < m_path->size(); Execution Count:9497 | 9497 |
60 | inline QStrokerOps::Element next() { Q_ASSERT(hasNext()); return m_path->at(m_pos++); } executed: return m_path->at(m_pos++); Execution Count:16793 | 16793 |
61 | | - |
62 | private: | - |
63 | const QDataBuffer<QStrokerOps::Element> *m_path; | - |
64 | int m_pos; | - |
65 | }; | - |
66 | | - |
67 | class QSubpathBackwardIterator | - |
68 | { | - |
69 | public: | - |
70 | QSubpathBackwardIterator(const QDataBuffer<QStrokerOps::Element> *path) | - |
71 | : m_path(path), m_pos(path->size() - 1) { } executed: } Execution Count:2833 | 2833 |
72 | | - |
73 | inline int position() const { return m_pos; } never executed: return m_pos; | 0 |
74 | | - |
75 | inline bool hasNext() const { return m_pos >= 0; } executed: return m_pos >= 0; Execution Count:9497 | 9497 |
76 | | - |
77 | inline QStrokerOps::Element next() | - |
78 | { | - |
79 | Q_ASSERT(hasNext()); executed (the execution status of this line is deduced): qt_noop(); | - |
80 | | - |
81 | QStrokerOps::Element ce = m_path->at(m_pos); // current element executed (the execution status of this line is deduced): QStrokerOps::Element ce = m_path->at(m_pos); | - |
82 | | - |
83 | if (m_pos == m_path->size() - 1) { evaluated: m_pos == m_path->size() - 1 yes Evaluation Count:2833 | yes Evaluation Count:13960 |
| 2833-13960 |
84 | --m_pos; executed (the execution status of this line is deduced): --m_pos; | - |
85 | ce.type = QPainterPath::MoveToElement; executed (the execution status of this line is deduced): ce.type = QPainterPath::MoveToElement; | - |
86 | return ce; executed: return ce; Execution Count:2833 | 2833 |
87 | } | - |
88 | | - |
89 | const QStrokerOps::Element &pe = m_path->at(m_pos + 1); // previous element executed (the execution status of this line is deduced): const QStrokerOps::Element &pe = m_path->at(m_pos + 1); | - |
90 | | - |
91 | switch (pe.type) { | - |
92 | case QPainterPath::LineToElement: | - |
93 | ce.type = QPainterPath::LineToElement; executed (the execution status of this line is deduced): ce.type = QPainterPath::LineToElement; | - |
94 | break; executed: break; Execution Count:3016 | 3016 |
95 | case QPainterPath::CurveToDataElement: | - |
96 | // First control point? | - |
97 | if (ce.type == QPainterPath::CurveToElement) { evaluated: ce.type == QPainterPath::CurveToElement yes Evaluation Count:3648 | yes Evaluation Count:3648 |
| 3648 |
98 | ce.type = QPainterPath::CurveToDataElement; executed (the execution status of this line is deduced): ce.type = QPainterPath::CurveToDataElement; | - |
99 | } else { // Second control point then executed: } Execution Count:3648 | 3648 |
100 | ce.type = QPainterPath::CurveToElement; executed (the execution status of this line is deduced): ce.type = QPainterPath::CurveToElement; | - |
101 | } executed: } Execution Count:3648 | 3648 |
102 | break; executed: break; Execution Count:7296 | 7296 |
103 | case QPainterPath::CurveToElement: | - |
104 | ce.type = QPainterPath::CurveToDataElement; executed (the execution status of this line is deduced): ce.type = QPainterPath::CurveToDataElement; | - |
105 | break; executed: break; Execution Count:3648 | 3648 |
106 | default: | - |
107 | qWarning("QSubpathReverseIterator::next: Case %d unhandled", ce.type); never executed (the execution status of this line is deduced): QMessageLogger("painting/qstroker.cpp", 107, __PRETTY_FUNCTION__).warning("QSubpathReverseIterator::next: Case %d unhandled", ce.type); | - |
108 | break; | 0 |
109 | } | - |
110 | --m_pos; executed (the execution status of this line is deduced): --m_pos; | - |
111 | | - |
112 | return ce; executed: return ce; Execution Count:13960 | 13960 |
113 | } | - |
114 | | - |
115 | private: | - |
116 | const QDataBuffer<QStrokerOps::Element> *m_path; | - |
117 | int m_pos; | - |
118 | }; | - |
119 | | - |
120 | class QSubpathFlatIterator | - |
121 | { | - |
122 | public: | - |
123 | QSubpathFlatIterator(const QDataBuffer<QStrokerOps::Element> *path, qreal threshold) | - |
124 | : m_path(path), m_pos(0), m_curve_index(-1), m_curve_threshold(threshold) { } executed: } Execution Count:1 | 1 |
125 | | - |
126 | inline bool hasNext() const { return m_curve_index >= 0 || m_pos < m_path->size(); } executed: return m_curve_index >= 0 || m_pos < m_path->size(); Execution Count:2 | 2 |
127 | | - |
128 | QStrokerOps::Element next() | - |
129 | { | - |
130 | Q_ASSERT(hasNext()); executed (the execution status of this line is deduced): qt_noop(); | - |
131 | | - |
132 | if (m_curve_index >= 0) { partially evaluated: m_curve_index >= 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
133 | QStrokerOps::Element e = { QPainterPath::LineToElement, never executed (the execution status of this line is deduced): QStrokerOps::Element e = { QPainterPath::LineToElement, | - |
134 | qt_real_to_fixed(m_curve.at(m_curve_index).x()), never executed (the execution status of this line is deduced): qfixed(m_curve.at(m_curve_index).x()), | - |
135 | qt_real_to_fixed(m_curve.at(m_curve_index).y()) never executed (the execution status of this line is deduced): qfixed(m_curve.at(m_curve_index).y()) | - |
136 | }; never executed (the execution status of this line is deduced): }; | - |
137 | ++m_curve_index; never executed (the execution status of this line is deduced): ++m_curve_index; | - |
138 | if (m_curve_index >= m_curve.size()) never evaluated: m_curve_index >= m_curve.size() | 0 |
139 | m_curve_index = -1; never executed: m_curve_index = -1; | 0 |
140 | return e; never executed: return e; | 0 |
141 | } | - |
142 | | - |
143 | QStrokerOps::Element e = m_path->at(m_pos); executed (the execution status of this line is deduced): QStrokerOps::Element e = m_path->at(m_pos); | - |
144 | if (e.isCurveTo()) { partially evaluated: e.isCurveTo() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
145 | Q_ASSERT(m_pos > 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
146 | Q_ASSERT(m_pos < m_path->size()); never executed (the execution status of this line is deduced): qt_noop(); | - |
147 | | - |
148 | m_curve = QBezier::fromPoints(QPointF(qt_fixed_to_real(m_path->at(m_pos-1).x), never executed (the execution status of this line is deduced): m_curve = QBezier::fromPoints(QPointF(m_path->at(m_pos-1).x, | - |
149 | qt_fixed_to_real(m_path->at(m_pos-1).y)), never executed (the execution status of this line is deduced): m_path->at(m_pos-1).y), | - |
150 | QPointF(qt_fixed_to_real(e.x), never executed (the execution status of this line is deduced): QPointF(e.x, | - |
151 | qt_fixed_to_real(e.y)), never executed (the execution status of this line is deduced): e.y), | - |
152 | QPointF(qt_fixed_to_real(m_path->at(m_pos+1).x), never executed (the execution status of this line is deduced): QPointF(m_path->at(m_pos+1).x, | - |
153 | qt_fixed_to_real(m_path->at(m_pos+1).y)), never executed (the execution status of this line is deduced): m_path->at(m_pos+1).y), | - |
154 | QPointF(qt_fixed_to_real(m_path->at(m_pos+2).x), never executed (the execution status of this line is deduced): QPointF(m_path->at(m_pos+2).x, | - |
155 | qt_fixed_to_real(m_path->at(m_pos+2).y))).toPolygon(m_curve_threshold); never executed (the execution status of this line is deduced): m_path->at(m_pos+2).y)).toPolygon(m_curve_threshold); | - |
156 | m_curve_index = 1; never executed (the execution status of this line is deduced): m_curve_index = 1; | - |
157 | e.type = QPainterPath::LineToElement; never executed (the execution status of this line is deduced): e.type = QPainterPath::LineToElement; | - |
158 | e.x = m_curve.at(0).x(); never executed (the execution status of this line is deduced): e.x = m_curve.at(0).x(); | - |
159 | e.y = m_curve.at(0).y(); never executed (the execution status of this line is deduced): e.y = m_curve.at(0).y(); | - |
160 | m_pos += 2; never executed (the execution status of this line is deduced): m_pos += 2; | - |
161 | } | 0 |
162 | Q_ASSERT(e.isLineTo() || e.isMoveTo()); executed (the execution status of this line is deduced): qt_noop(); | - |
163 | ++m_pos; executed (the execution status of this line is deduced): ++m_pos; | - |
164 | return e; executed: return e; Execution Count:2 | 2 |
165 | } | - |
166 | | - |
167 | private: | - |
168 | const QDataBuffer<QStrokerOps::Element> *m_path; | - |
169 | int m_pos; | - |
170 | QPolygonF m_curve; | - |
171 | int m_curve_index; | - |
172 | qreal m_curve_threshold; | - |
173 | }; | - |
174 | | - |
175 | template <class Iterator> bool qt_stroke_side(Iterator *it, QStroker *stroker, | - |
176 | bool capFirst, QLineF *startTangent); | - |
177 | | - |
178 | /******************************************************************************* | - |
179 | * QLineF::angle gives us the smalles angle between two lines. Here we | - |
180 | * want to identify the line's angle direction on the unit circle. | - |
181 | */ | - |
182 | static inline qreal adapted_angle_on_x(const QLineF &line) | - |
183 | { | - |
184 | qreal angle = line.angle(QLineF(0, 0, 1, 0)); never executed (the execution status of this line is deduced): qreal angle = line.angle(QLineF(0, 0, 1, 0)); | - |
185 | if (line.dy() > 0) never evaluated: line.dy() > 0 | 0 |
186 | angle = 360 - angle; never executed: angle = 360 - angle; | 0 |
187 | return angle; never executed: return angle; | 0 |
188 | } | - |
189 | | - |
190 | QStrokerOps::QStrokerOps() | - |
191 | : m_elements(0) | - |
192 | , m_curveThreshold(qt_real_to_fixed(0.25)) | - |
193 | , m_dashThreshold(qt_real_to_fixed(0.25)) | - |
194 | , m_customData(0) | - |
195 | , m_moveTo(0) | - |
196 | , m_lineTo(0) | - |
197 | , m_cubicTo(0) | - |
198 | { | - |
199 | } executed: } Execution Count:25103 | 25103 |
200 | | - |
201 | QStrokerOps::~QStrokerOps() | - |
202 | { | - |
203 | } | - |
204 | | - |
205 | /*! | - |
206 | Prepares the stroker. Call this function once before starting a | - |
207 | stroke by calling moveTo, lineTo or cubicTo. | - |
208 | | - |
209 | The \a customData is passed back through that callback functions | - |
210 | and can be used by the user to for instance maintain state | - |
211 | information. | - |
212 | */ | - |
213 | void QStrokerOps::begin(void *customData) | - |
214 | { | - |
215 | m_customData = customData; executed (the execution status of this line is deduced): m_customData = customData; | - |
216 | m_elements.reset(); executed (the execution status of this line is deduced): m_elements.reset(); | - |
217 | } executed: } Execution Count:2833 | 2833 |
218 | | - |
219 | | - |
220 | /*! | - |
221 | Finishes the stroke. Call this function once when an entire | - |
222 | primitive has been stroked. | - |
223 | */ | - |
224 | void QStrokerOps::end() | - |
225 | { | - |
226 | if (m_elements.size() > 1) partially evaluated: m_elements.size() > 1 yes Evaluation Count:2833 | no Evaluation Count:0 |
| 0-2833 |
227 | processCurrentSubpath(); executed: processCurrentSubpath(); Execution Count:2833 | 2833 |
228 | m_customData = 0; executed (the execution status of this line is deduced): m_customData = 0; | - |
229 | } executed: } Execution Count:2833 | 2833 |
230 | | - |
231 | /*! | - |
232 | Convenience function that decomposes \a path into begin(), | - |
233 | moveTo(), lineTo(), curevTo() and end() calls. | - |
234 | | - |
235 | The \a customData parameter is used in the callback functions | - |
236 | | - |
237 | The \a matrix is used to transform the points before input to the | - |
238 | stroker. | - |
239 | | - |
240 | \sa begin() | - |
241 | */ | - |
242 | void QStrokerOps::strokePath(const QPainterPath &path, void *customData, const QTransform &matrix) | - |
243 | { | - |
244 | if (path.isEmpty()) partially evaluated: path.isEmpty() no Evaluation Count:0 | yes Evaluation Count:1894 |
| 0-1894 |
245 | return; | 0 |
246 | | - |
247 | setCurveThresholdFromTransform(QTransform()); executed (the execution status of this line is deduced): setCurveThresholdFromTransform(QTransform()); | - |
248 | begin(customData); executed (the execution status of this line is deduced): begin(customData); | - |
249 | int count = path.elementCount(); executed (the execution status of this line is deduced): int count = path.elementCount(); | - |
250 | if (matrix.isIdentity()) { partially evaluated: matrix.isIdentity() yes Evaluation Count:1894 | no Evaluation Count:0 |
| 0-1894 |
251 | for (int i=0; i<count; ++i) { evaluated: i<count yes Evaluation Count:4349 | yes Evaluation Count:1894 |
| 1894-4349 |
252 | const QPainterPath::Element &e = path.elementAt(i); executed (the execution status of this line is deduced): const QPainterPath::Element &e = path.elementAt(i); | - |
253 | switch (e.type) { | - |
254 | case QPainterPath::MoveToElement: | - |
255 | moveTo(qt_real_to_fixed(e.x), qt_real_to_fixed(e.y)); executed (the execution status of this line is deduced): moveTo(qfixed(e.x), qfixed(e.y)); | - |
256 | break; executed: break; Execution Count:1894 | 1894 |
257 | case QPainterPath::LineToElement: | - |
258 | lineTo(qt_real_to_fixed(e.x), qt_real_to_fixed(e.y)); executed (the execution status of this line is deduced): lineTo(qfixed(e.x), qfixed(e.y)); | - |
259 | break; executed: break; Execution Count:2283 | 2283 |
260 | case QPainterPath::CurveToElement: | - |
261 | { | - |
262 | const QPainterPath::Element &cp2 = path.elementAt(++i); executed (the execution status of this line is deduced): const QPainterPath::Element &cp2 = path.elementAt(++i); | - |
263 | const QPainterPath::Element &ep = path.elementAt(++i); executed (the execution status of this line is deduced): const QPainterPath::Element &ep = path.elementAt(++i); | - |
264 | cubicTo(qt_real_to_fixed(e.x), qt_real_to_fixed(e.y), executed (the execution status of this line is deduced): cubicTo(qfixed(e.x), qfixed(e.y), | - |
265 | qt_real_to_fixed(cp2.x), qt_real_to_fixed(cp2.y), executed (the execution status of this line is deduced): qfixed(cp2.x), qfixed(cp2.y), | - |
266 | qt_real_to_fixed(ep.x), qt_real_to_fixed(ep.y)); executed (the execution status of this line is deduced): qfixed(ep.x), qfixed(ep.y)); | - |
267 | } | - |
268 | break; executed: break; Execution Count:172 | 172 |
269 | default: | - |
270 | break; | 0 |
271 | } | - |
272 | } executed: } Execution Count:4349 | 4349 |
273 | } else { executed: } Execution Count:1894 | 1894 |
274 | for (int i=0; i<count; ++i) { | 0 |
275 | const QPainterPath::Element &e = path.elementAt(i); never executed (the execution status of this line is deduced): const QPainterPath::Element &e = path.elementAt(i); | - |
276 | QPointF pt = QPointF(e.x, e.y) * matrix; never executed (the execution status of this line is deduced): QPointF pt = QPointF(e.x, e.y) * matrix; | - |
277 | switch (e.type) { | - |
278 | case QPainterPath::MoveToElement: | - |
279 | moveTo(qt_real_to_fixed(pt.x()), qt_real_to_fixed(pt.y())); never executed (the execution status of this line is deduced): moveTo(qfixed(pt.x()), qfixed(pt.y())); | - |
280 | break; | 0 |
281 | case QPainterPath::LineToElement: | - |
282 | lineTo(qt_real_to_fixed(pt.x()), qt_real_to_fixed(pt.y())); never executed (the execution status of this line is deduced): lineTo(qfixed(pt.x()), qfixed(pt.y())); | - |
283 | break; | 0 |
284 | case QPainterPath::CurveToElement: | - |
285 | { | - |
286 | QPointF cp2 = ((QPointF) path.elementAt(++i)) * matrix; never executed (the execution status of this line is deduced): QPointF cp2 = ((QPointF) path.elementAt(++i)) * matrix; | - |
287 | QPointF ep = ((QPointF) path.elementAt(++i)) * matrix; never executed (the execution status of this line is deduced): QPointF ep = ((QPointF) path.elementAt(++i)) * matrix; | - |
288 | cubicTo(qt_real_to_fixed(pt.x()), qt_real_to_fixed(pt.y()), never executed (the execution status of this line is deduced): cubicTo(qfixed(pt.x()), qfixed(pt.y()), | - |
289 | qt_real_to_fixed(cp2.x()), qt_real_to_fixed(cp2.y()), never executed (the execution status of this line is deduced): qfixed(cp2.x()), qfixed(cp2.y()), | - |
290 | qt_real_to_fixed(ep.x()), qt_real_to_fixed(ep.y())); never executed (the execution status of this line is deduced): qfixed(ep.x()), qfixed(ep.y())); | - |
291 | } | - |
292 | break; | 0 |
293 | default: | - |
294 | break; | 0 |
295 | } | - |
296 | } | 0 |
297 | } | 0 |
298 | end(); executed (the execution status of this line is deduced): end(); | - |
299 | } executed: } Execution Count:1894 | 1894 |
300 | | - |
301 | /*! | - |
302 | Convenience function for stroking a polygon of the \a pointCount | - |
303 | first points in \a points. If \a implicit_close is set to true a | - |
304 | line is implictly drawn between the first and last point in the | - |
305 | polygon. Typically true for polygons and false for polylines. | - |
306 | | - |
307 | The \a matrix is used to transform the points before they enter the | - |
308 | stroker. | - |
309 | | - |
310 | \sa begin() | - |
311 | */ | - |
312 | | - |
313 | void QStrokerOps::strokePolygon(const QPointF *points, int pointCount, bool implicit_close, | - |
314 | void *data, const QTransform &matrix) | - |
315 | { | - |
316 | if (!pointCount) never evaluated: !pointCount | 0 |
317 | return; | 0 |
318 | | - |
319 | setCurveThresholdFromTransform(QTransform()); never executed (the execution status of this line is deduced): setCurveThresholdFromTransform(QTransform()); | - |
320 | begin(data); never executed (the execution status of this line is deduced): begin(data); | - |
321 | if (matrix.isIdentity()) { never evaluated: matrix.isIdentity() | 0 |
322 | moveTo(qt_real_to_fixed(points[0].x()), qt_real_to_fixed(points[0].y())); never executed (the execution status of this line is deduced): moveTo(qfixed(points[0].x()), qfixed(points[0].y())); | - |
323 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
324 | lineTo(qt_real_to_fixed(points[i].x()), never executed: lineTo(qfixed(points[i].x()), qfixed(points[i].y())); | 0 |
325 | qt_real_to_fixed(points[i].y())); never executed: lineTo(qfixed(points[i].x()), qfixed(points[i].y())); | 0 |
326 | if (implicit_close) never evaluated: implicit_close | 0 |
327 | lineTo(qt_real_to_fixed(points[0].x()), qt_real_to_fixed(points[0].y())); never executed: lineTo(qfixed(points[0].x()), qfixed(points[0].y())); | 0 |
328 | } else { | 0 |
329 | QPointF start = points[0] * matrix; never executed (the execution status of this line is deduced): QPointF start = points[0] * matrix; | - |
330 | moveTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y())); never executed (the execution status of this line is deduced): moveTo(qfixed(start.x()), qfixed(start.y())); | - |
331 | for (int i=1; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
332 | QPointF pt = points[i] * matrix; never executed (the execution status of this line is deduced): QPointF pt = points[i] * matrix; | - |
333 | lineTo(qt_real_to_fixed(pt.x()), qt_real_to_fixed(pt.y())); never executed (the execution status of this line is deduced): lineTo(qfixed(pt.x()), qfixed(pt.y())); | - |
334 | } | 0 |
335 | if (implicit_close) never evaluated: implicit_close | 0 |
336 | lineTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y())); never executed: lineTo(qfixed(start.x()), qfixed(start.y())); | 0 |
337 | } | 0 |
338 | end(); never executed (the execution status of this line is deduced): end(); | - |
339 | } | 0 |
340 | | - |
341 | /*! | - |
342 | Convenience function for stroking an ellipse with bounding rect \a | - |
343 | rect. The \a matrix is used to transform the coordinates before | - |
344 | they enter the stroker. | - |
345 | */ | - |
346 | void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform &matrix) | - |
347 | { | - |
348 | int count = 0; never executed (the execution status of this line is deduced): int count = 0; | - |
349 | QPointF pts[12]; never executed (the execution status of this line is deduced): QPointF pts[12]; | - |
350 | QPointF start = qt_curves_for_arc(rect, 0, -360, pts, &count); never executed (the execution status of this line is deduced): QPointF start = qt_curves_for_arc(rect, 0, -360, pts, &count); | - |
351 | Q_ASSERT(count == 12); // a perfect circle.. never executed (the execution status of this line is deduced): qt_noop(); | - |
352 | | - |
353 | if (!matrix.isIdentity()) { never evaluated: !matrix.isIdentity() | 0 |
354 | start = start * matrix; never executed (the execution status of this line is deduced): start = start * matrix; | - |
355 | for (int i=0; i<12; ++i) { | 0 |
356 | pts[i] = pts[i] * matrix; never executed (the execution status of this line is deduced): pts[i] = pts[i] * matrix; | - |
357 | } | 0 |
358 | } | 0 |
359 | | - |
360 | setCurveThresholdFromTransform(QTransform()); never executed (the execution status of this line is deduced): setCurveThresholdFromTransform(QTransform()); | - |
361 | begin(data); never executed (the execution status of this line is deduced): begin(data); | - |
362 | moveTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y())); never executed (the execution status of this line is deduced): moveTo(qfixed(start.x()), qfixed(start.y())); | - |
363 | for (int i=0; i<12; i+=3) { | 0 |
364 | cubicTo(qt_real_to_fixed(pts[i].x()), qt_real_to_fixed(pts[i].y()), never executed (the execution status of this line is deduced): cubicTo(qfixed(pts[i].x()), qfixed(pts[i].y()), | - |
365 | qt_real_to_fixed(pts[i+1].x()), qt_real_to_fixed(pts[i+1].y()), never executed (the execution status of this line is deduced): qfixed(pts[i+1].x()), qfixed(pts[i+1].y()), | - |
366 | qt_real_to_fixed(pts[i+2].x()), qt_real_to_fixed(pts[i+2].y())); never executed (the execution status of this line is deduced): qfixed(pts[i+2].x()), qfixed(pts[i+2].y())); | - |
367 | } | 0 |
368 | end(); never executed (the execution status of this line is deduced): end(); | - |
369 | } | 0 |
370 | | - |
371 | | - |
372 | QStroker::QStroker() | - |
373 | : m_capStyle(SquareJoin), m_joinStyle(FlatJoin), | - |
374 | m_back1X(0), m_back1Y(0), | - |
375 | m_back2X(0), m_back2Y(0) | - |
376 | { | - |
377 | m_strokeWidth = qt_real_to_fixed(1); executed (the execution status of this line is deduced): m_strokeWidth = qfixed(1); | - |
378 | m_miterLimit = qt_real_to_fixed(2); executed (the execution status of this line is deduced): m_miterLimit = qfixed(2); | - |
379 | } executed: } Execution Count:16302 | 16302 |
380 | | - |
381 | QStroker::~QStroker() | - |
382 | { | - |
383 | } | - |
384 | | - |
385 | Qt::PenCapStyle QStroker::capForJoinMode(LineJoinMode mode) | - |
386 | { | - |
387 | if (mode == FlatJoin) return Qt::FlatCap; never executed: return Qt::FlatCap; partially evaluated: mode == FlatJoin no Evaluation Count:0 | yes Evaluation Count:938 |
| 0-938 |
388 | else if (mode == SquareJoin) return Qt::SquareCap; executed: return Qt::SquareCap; Execution Count:938 partially evaluated: mode == SquareJoin yes Evaluation Count:938 | no Evaluation Count:0 |
| 0-938 |
389 | else return Qt::RoundCap; never executed: return Qt::RoundCap; | 0 |
390 | } | - |
391 | | - |
392 | QStroker::LineJoinMode QStroker::joinModeForCap(Qt::PenCapStyle style) | - |
393 | { | - |
394 | if (style == Qt::FlatCap) return FlatJoin; executed: return FlatJoin; Execution Count:545 evaluated: style == Qt::FlatCap yes Evaluation Count:545 | yes Evaluation Count:97532 |
| 545-97532 |
395 | else if (style == Qt::SquareCap) return SquareJoin; executed: return SquareJoin; Execution Count:97528 evaluated: style == Qt::SquareCap yes Evaluation Count:97528 | yes Evaluation Count:4 |
| 4-97528 |
396 | else return RoundCap; executed: return RoundCap; Execution Count:4 | 4 |
397 | } | - |
398 | | - |
399 | Qt::PenJoinStyle QStroker::joinForJoinMode(LineJoinMode mode) | - |
400 | { | - |
401 | if (mode == FlatJoin) return Qt::BevelJoin; executed: return Qt::BevelJoin; Execution Count:938 partially evaluated: mode == FlatJoin yes Evaluation Count:938 | no Evaluation Count:0 |
| 0-938 |
402 | else if (mode == MiterJoin) return Qt::MiterJoin; never executed: return Qt::MiterJoin; never evaluated: mode == MiterJoin | 0 |
403 | else if (mode == SvgMiterJoin) return Qt::SvgMiterJoin; never executed: return Qt::SvgMiterJoin; never evaluated: mode == SvgMiterJoin | 0 |
404 | else return Qt::RoundJoin; never executed: return Qt::RoundJoin; | 0 |
405 | } | - |
406 | | - |
407 | QStroker::LineJoinMode QStroker::joinModeForJoin(Qt::PenJoinStyle joinStyle) | - |
408 | { | - |
409 | if (joinStyle == Qt::BevelJoin) return FlatJoin; executed: return FlatJoin; Execution Count:98073 evaluated: joinStyle == Qt::BevelJoin yes Evaluation Count:98073 | yes Evaluation Count:4 |
| 4-98073 |
410 | else if (joinStyle == Qt::MiterJoin) return MiterJoin; executed: return MiterJoin; Execution Count:4 partially evaluated: joinStyle == Qt::MiterJoin yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
411 | else if (joinStyle == Qt::SvgMiterJoin) return SvgMiterJoin; never executed: return SvgMiterJoin; never evaluated: joinStyle == Qt::SvgMiterJoin | 0 |
412 | else return RoundJoin; never executed: return RoundJoin; | 0 |
413 | } | - |
414 | | - |
415 | | - |
416 | /*! | - |
417 | This function is called to stroke the currently built up | - |
418 | subpath. The subpath is cleared when the function completes. | - |
419 | */ | - |
420 | void QStroker::processCurrentSubpath() | - |
421 | { | - |
422 | Q_ASSERT(!m_elements.isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
423 | Q_ASSERT(m_elements.first().type == QPainterPath::MoveToElement); executed (the execution status of this line is deduced): qt_noop(); | - |
424 | Q_ASSERT(m_elements.size() > 1); executed (the execution status of this line is deduced): qt_noop(); | - |
425 | | - |
426 | QSubpathForwardIterator fwit(&m_elements); executed (the execution status of this line is deduced): QSubpathForwardIterator fwit(&m_elements); | - |
427 | QSubpathBackwardIterator bwit(&m_elements); executed (the execution status of this line is deduced): QSubpathBackwardIterator bwit(&m_elements); | - |
428 | | - |
429 | QLineF fwStartTangent, bwStartTangent; executed (the execution status of this line is deduced): QLineF fwStartTangent, bwStartTangent; | - |
430 | | - |
431 | bool fwclosed = qt_stroke_side(&fwit, this, false, &fwStartTangent); executed (the execution status of this line is deduced): bool fwclosed = qt_stroke_side(&fwit, this, false, &fwStartTangent); | - |
432 | bool bwclosed = qt_stroke_side(&bwit, this, !fwclosed, &bwStartTangent); executed (the execution status of this line is deduced): bool bwclosed = qt_stroke_side(&bwit, this, !fwclosed, &bwStartTangent); | - |
433 | | - |
434 | if (!bwclosed) evaluated: !bwclosed yes Evaluation Count:1708 | yes Evaluation Count:1125 |
| 1125-1708 |
435 | joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle); executed: joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle); Execution Count:1708 | 1708 |
436 | } executed: } Execution Count:2833 | 2833 |
437 | | - |
438 | | - |
439 | /*! | - |
440 | \internal | - |
441 | */ | - |
442 | void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine, LineJoinMode join) | - |
443 | { | - |
444 | #ifdef QPP_STROKE_DEBUG | - |
445 | printf(" -----> joinPoints: around=(%.0f, %.0f), next_p1=(%.0f, %.f) next_p2=(%.0f, %.f)\n", | - |
446 | qt_fixed_to_real(focal_x), | - |
447 | qt_fixed_to_real(focal_y), | - |
448 | nextLine.x1(), nextLine.y1(), nextLine.x2(), nextLine.y2()); | - |
449 | #endif | - |
450 | // points connected already, don't join | - |
451 | | - |
452 | #if !defined (QFIXED_26_6) && !defined (Q_FIXED_32_32) | - |
453 | if (qFuzzyCompare(m_back1X, nextLine.x1()) && qFuzzyCompare(m_back1Y, nextLine.y1())) evaluated: qFuzzyCompare(m_back1X, nextLine.x1()) yes Evaluation Count:9168 | yes Evaluation Count:4112 |
evaluated: qFuzzyCompare(m_back1Y, nextLine.y1()) yes Evaluation Count:7448 | yes Evaluation Count:1720 |
| 1720-9168 |
454 | return; executed: return; Execution Count:7448 | 7448 |
455 | #else | - |
456 | if (m_back1X == qt_real_to_fixed(nextLine.x1()) | - |
457 | && m_back1Y == qt_real_to_fixed(nextLine.y1())) { | - |
458 | return; | - |
459 | } | - |
460 | #endif | - |
461 | | - |
462 | if (join == FlatJoin) { evaluated: join == FlatJoin yes Evaluation Count:2410 | yes Evaluation Count:3422 |
| 2410-3422 |
463 | QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y), executed (the execution status of this line is deduced): QLineF prevLine(m_back2X, m_back2Y, | - |
464 | qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y)); executed (the execution status of this line is deduced): m_back1X, m_back1Y); | - |
465 | QPointF isect; executed (the execution status of this line is deduced): QPointF isect; | - |
466 | QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); executed (the execution status of this line is deduced): QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); | - |
467 | QLineF shortCut(prevLine.p2(), nextLine.p1()); executed (the execution status of this line is deduced): QLineF shortCut(prevLine.p2(), nextLine.p1()); | - |
468 | qreal angle = shortCut.angleTo(prevLine); executed (the execution status of this line is deduced): qreal angle = shortCut.angleTo(prevLine); | - |
469 | if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { evaluated: type == QLineF::BoundedIntersection yes Evaluation Count:1192 | yes Evaluation Count:1218 |
evaluated: angle > 90 yes Evaluation Count:4 | yes Evaluation Count:1214 |
partially evaluated: !qFuzzyCompare(angle, (qreal)90) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-1218 |
470 | emitLineTo(focal_x, focal_y); executed (the execution status of this line is deduced): emitLineTo(focal_x, focal_y); | - |
471 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
472 | return; executed: return; Execution Count:1196 | 1196 |
473 | } | - |
474 | emitLineTo(qt_real_to_fixed(nextLine.x1()), executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), | - |
475 | qt_real_to_fixed(nextLine.y1())); executed (the execution status of this line is deduced): qfixed(nextLine.y1())); | - |
476 | | - |
477 | } else { executed: } Execution Count:1214 | 1214 |
478 | QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y), executed (the execution status of this line is deduced): QLineF prevLine(m_back2X, m_back2Y, | - |
479 | qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y)); executed (the execution status of this line is deduced): m_back1X, m_back1Y); | - |
480 | | - |
481 | QPointF isect; executed (the execution status of this line is deduced): QPointF isect; | - |
482 | QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); executed (the execution status of this line is deduced): QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); | - |
483 | | - |
484 | if (join == MiterJoin) { evaluated: join == MiterJoin yes Evaluation Count:8 | yes Evaluation Count:3414 |
| 8-3414 |
485 | qreal appliedMiterLimit = qt_fixed_to_real(m_strokeWidth * m_miterLimit); executed (the execution status of this line is deduced): qreal appliedMiterLimit = m_strokeWidth * m_miterLimit; | - |
486 | | - |
487 | // If we are on the inside, do the short cut... | - |
488 | QLineF shortCut(prevLine.p2(), nextLine.p1()); executed (the execution status of this line is deduced): QLineF shortCut(prevLine.p2(), nextLine.p1()); | - |
489 | qreal angle = shortCut.angleTo(prevLine); executed (the execution status of this line is deduced): qreal angle = shortCut.angleTo(prevLine); | - |
490 | if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { evaluated: type == QLineF::BoundedIntersection yes Evaluation Count:4 | yes Evaluation Count:4 |
partially evaluated: angle > 90 no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: !qFuzzyCompare(angle, (qreal)90) | 0-4 |
491 | emitLineTo(focal_x, focal_y); executed (the execution status of this line is deduced): emitLineTo(focal_x, focal_y); | - |
492 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
493 | return; executed: return; Execution Count:4 | 4 |
494 | } | - |
495 | QLineF miterLine(QPointF(qt_fixed_to_real(m_back1X), executed (the execution status of this line is deduced): QLineF miterLine(QPointF(m_back1X, | - |
496 | qt_fixed_to_real(m_back1Y)), isect); executed (the execution status of this line is deduced): m_back1Y), isect); | - |
497 | if (type == QLineF::NoIntersection || miterLine.length() > appliedMiterLimit) { partially evaluated: type == QLineF::NoIntersection no Evaluation Count:0 | yes Evaluation Count:4 |
partially evaluated: miterLine.length() > appliedMiterLimit no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
498 | QLineF l1(prevLine); never executed (the execution status of this line is deduced): QLineF l1(prevLine); | - |
499 | l1.setLength(appliedMiterLimit); never executed (the execution status of this line is deduced): l1.setLength(appliedMiterLimit); | - |
500 | l1.translate(prevLine.dx(), prevLine.dy()); never executed (the execution status of this line is deduced): l1.translate(prevLine.dx(), prevLine.dy()); | - |
501 | | - |
502 | QLineF l2(nextLine); never executed (the execution status of this line is deduced): QLineF l2(nextLine); | - |
503 | l2.setLength(appliedMiterLimit); never executed (the execution status of this line is deduced): l2.setLength(appliedMiterLimit); | - |
504 | l2.translate(-l2.dx(), -l2.dy()); never executed (the execution status of this line is deduced): l2.translate(-l2.dx(), -l2.dy()); | - |
505 | | - |
506 | emitLineTo(qt_real_to_fixed(l1.x2()), qt_real_to_fixed(l1.y2())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(l1.x2()), qfixed(l1.y2())); | - |
507 | emitLineTo(qt_real_to_fixed(l2.x1()), qt_real_to_fixed(l2.y1())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(l2.x1()), qfixed(l2.y1())); | - |
508 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
509 | } else { | 0 |
510 | emitLineTo(qt_real_to_fixed(isect.x()), qt_real_to_fixed(isect.y())); executed (the execution status of this line is deduced): emitLineTo(qfixed(isect.x()), qfixed(isect.y())); | - |
511 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
512 | } executed: } Execution Count:4 | 4 |
513 | | - |
514 | } else if (join == SquareJoin) { partially evaluated: join == SquareJoin yes Evaluation Count:3414 | no Evaluation Count:0 |
| 0-3414 |
515 | qfixed offset = m_strokeWidth / 2; executed (the execution status of this line is deduced): qfixed offset = m_strokeWidth / 2; | - |
516 | | - |
517 | QLineF l1(prevLine); executed (the execution status of this line is deduced): QLineF l1(prevLine); | - |
518 | l1.translate(l1.dx(), l1.dy()); executed (the execution status of this line is deduced): l1.translate(l1.dx(), l1.dy()); | - |
519 | l1.setLength(qt_fixed_to_real(offset)); executed (the execution status of this line is deduced): l1.setLength(offset); | - |
520 | QLineF l2(nextLine.p2(), nextLine.p1()); executed (the execution status of this line is deduced): QLineF l2(nextLine.p2(), nextLine.p1()); | - |
521 | l2.translate(l2.dx(), l2.dy()); executed (the execution status of this line is deduced): l2.translate(l2.dx(), l2.dy()); | - |
522 | l2.setLength(qt_fixed_to_real(offset)); executed (the execution status of this line is deduced): l2.setLength(offset); | - |
523 | emitLineTo(qt_real_to_fixed(l1.x2()), qt_real_to_fixed(l1.y2())); executed (the execution status of this line is deduced): emitLineTo(qfixed(l1.x2()), qfixed(l1.y2())); | - |
524 | emitLineTo(qt_real_to_fixed(l2.x2()), qt_real_to_fixed(l2.y2())); executed (the execution status of this line is deduced): emitLineTo(qfixed(l2.x2()), qfixed(l2.y2())); | - |
525 | emitLineTo(qt_real_to_fixed(l2.x1()), qt_real_to_fixed(l2.y1())); executed (the execution status of this line is deduced): emitLineTo(qfixed(l2.x1()), qfixed(l2.y1())); | - |
526 | | - |
527 | } else if (join == RoundJoin) { executed: } Execution Count:3414 never evaluated: join == RoundJoin | 0-3414 |
528 | qfixed offset = m_strokeWidth / 2; never executed (the execution status of this line is deduced): qfixed offset = m_strokeWidth / 2; | - |
529 | | - |
530 | QLineF shortCut(prevLine.p2(), nextLine.p1()); never executed (the execution status of this line is deduced): QLineF shortCut(prevLine.p2(), nextLine.p1()); | - |
531 | qreal angle = shortCut.angleTo(prevLine); never executed (the execution status of this line is deduced): qreal angle = shortCut.angleTo(prevLine); | - |
532 | if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { never evaluated: type == QLineF::BoundedIntersection never evaluated: angle > 90 never evaluated: !qFuzzyCompare(angle, (qreal)90) | 0 |
533 | emitLineTo(focal_x, focal_y); never executed (the execution status of this line is deduced): emitLineTo(focal_x, focal_y); | - |
534 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
535 | return; | 0 |
536 | } | - |
537 | qreal l1_on_x = adapted_angle_on_x(prevLine); never executed (the execution status of this line is deduced): qreal l1_on_x = adapted_angle_on_x(prevLine); | - |
538 | qreal l2_on_x = adapted_angle_on_x(nextLine); never executed (the execution status of this line is deduced): qreal l2_on_x = adapted_angle_on_x(nextLine); | - |
539 | | - |
540 | qreal sweepLength = qAbs(l2_on_x - l1_on_x); never executed (the execution status of this line is deduced): qreal sweepLength = qAbs(l2_on_x - l1_on_x); | - |
541 | | - |
542 | int point_count; never executed (the execution status of this line is deduced): int point_count; | - |
543 | QPointF curves[15]; never executed (the execution status of this line is deduced): QPointF curves[15]; | - |
544 | | - |
545 | QPointF curve_start = never executed (the execution status of this line is deduced): QPointF curve_start = | - |
546 | qt_curves_for_arc(QRectF(qt_fixed_to_real(focal_x - offset), never executed (the execution status of this line is deduced): qt_curves_for_arc(QRectF(focal_x - offset, | - |
547 | qt_fixed_to_real(focal_y - offset), never executed (the execution status of this line is deduced): focal_y - offset, | - |
548 | qt_fixed_to_real(offset * 2), never executed (the execution status of this line is deduced): offset * 2, | - |
549 | qt_fixed_to_real(offset * 2)), never executed (the execution status of this line is deduced): offset * 2), | - |
550 | l1_on_x + 90, -sweepLength, never executed (the execution status of this line is deduced): l1_on_x + 90, -sweepLength, | - |
551 | curves, &point_count); never executed (the execution status of this line is deduced): curves, &point_count); | - |
552 | | - |
553 | // // line to the beginning of the arc segment, (should not be needed). | - |
554 | // emitLineTo(qt_real_to_fixed(curve_start.x()), qt_real_to_fixed(curve_start.y())); | - |
555 | Q_UNUSED(curve_start); never executed (the execution status of this line is deduced): (void)curve_start;; | - |
556 | | - |
557 | for (int i=0; i<point_count; i+=3) { never evaluated: i<point_count | 0 |
558 | emitCubicTo(qt_real_to_fixed(curves[i].x()), never executed (the execution status of this line is deduced): emitCubicTo(qfixed(curves[i].x()), | - |
559 | qt_real_to_fixed(curves[i].y()), never executed (the execution status of this line is deduced): qfixed(curves[i].y()), | - |
560 | qt_real_to_fixed(curves[i+1].x()), never executed (the execution status of this line is deduced): qfixed(curves[i+1].x()), | - |
561 | qt_real_to_fixed(curves[i+1].y()), never executed (the execution status of this line is deduced): qfixed(curves[i+1].y()), | - |
562 | qt_real_to_fixed(curves[i+2].x()), never executed (the execution status of this line is deduced): qfixed(curves[i+2].x()), | - |
563 | qt_real_to_fixed(curves[i+2].y())); never executed (the execution status of this line is deduced): qfixed(curves[i+2].y())); | - |
564 | } | 0 |
565 | | - |
566 | // line to the end of the arc segment, (should also not be needed). | - |
567 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
568 | | - |
569 | // Same as round join except we know its 180 degrees. Can also optimize this | - |
570 | // later based on the addEllipse logic | - |
571 | } else if (join == RoundCap) { never executed: } never evaluated: join == RoundCap | 0 |
572 | qfixed offset = m_strokeWidth / 2; never executed (the execution status of this line is deduced): qfixed offset = m_strokeWidth / 2; | - |
573 | | - |
574 | // first control line | - |
575 | QLineF l1 = prevLine; never executed (the execution status of this line is deduced): QLineF l1 = prevLine; | - |
576 | l1.translate(l1.dx(), l1.dy()); never executed (the execution status of this line is deduced): l1.translate(l1.dx(), l1.dy()); | - |
577 | l1.setLength(QT_PATH_KAPPA * offset); never executed (the execution status of this line is deduced): l1.setLength(0.5522847498 * offset); | - |
578 | | - |
579 | // second control line, find through normal between prevLine and focal. | - |
580 | QLineF l2(qt_fixed_to_real(focal_x), qt_fixed_to_real(focal_y), never executed (the execution status of this line is deduced): QLineF l2(focal_x, focal_y, | - |
581 | prevLine.x2(), prevLine.y2()); never executed (the execution status of this line is deduced): prevLine.x2(), prevLine.y2()); | - |
582 | l2.translate(-l2.dy(), l2.dx()); never executed (the execution status of this line is deduced): l2.translate(-l2.dy(), l2.dx()); | - |
583 | l2.setLength(QT_PATH_KAPPA * offset); never executed (the execution status of this line is deduced): l2.setLength(0.5522847498 * offset); | - |
584 | | - |
585 | emitCubicTo(qt_real_to_fixed(l1.x2()), never executed (the execution status of this line is deduced): emitCubicTo(qfixed(l1.x2()), | - |
586 | qt_real_to_fixed(l1.y2()), never executed (the execution status of this line is deduced): qfixed(l1.y2()), | - |
587 | qt_real_to_fixed(l2.x2()), never executed (the execution status of this line is deduced): qfixed(l2.x2()), | - |
588 | qt_real_to_fixed(l2.y2()), never executed (the execution status of this line is deduced): qfixed(l2.y2()), | - |
589 | qt_real_to_fixed(l2.x1()), never executed (the execution status of this line is deduced): qfixed(l2.x1()), | - |
590 | qt_real_to_fixed(l2.y1())); never executed (the execution status of this line is deduced): qfixed(l2.y1())); | - |
591 | | - |
592 | // move so that it matches | - |
593 | l2 = QLineF(l2.x1(), l2.y1(), l2.x1()-l2.dx(), l2.y1()-l2.dy()); never executed (the execution status of this line is deduced): l2 = QLineF(l2.x1(), l2.y1(), l2.x1()-l2.dx(), l2.y1()-l2.dy()); | - |
594 | | - |
595 | // last line is parallel to l1 so just shift it down. | - |
596 | l1.translate(nextLine.x1() - l1.x1(), nextLine.y1() - l1.y1()); never executed (the execution status of this line is deduced): l1.translate(nextLine.x1() - l1.x1(), nextLine.y1() - l1.y1()); | - |
597 | | - |
598 | emitCubicTo(qt_real_to_fixed(l2.x2()), never executed (the execution status of this line is deduced): emitCubicTo(qfixed(l2.x2()), | - |
599 | qt_real_to_fixed(l2.y2()), never executed (the execution status of this line is deduced): qfixed(l2.y2()), | - |
600 | qt_real_to_fixed(l1.x2()), never executed (the execution status of this line is deduced): qfixed(l1.x2()), | - |
601 | qt_real_to_fixed(l1.y2()), never executed (the execution status of this line is deduced): qfixed(l1.y2()), | - |
602 | qt_real_to_fixed(l1.x1()), never executed (the execution status of this line is deduced): qfixed(l1.x1()), | - |
603 | qt_real_to_fixed(l1.y1())); never executed (the execution status of this line is deduced): qfixed(l1.y1())); | - |
604 | } else if (join == SvgMiterJoin) { never executed: } never evaluated: join == SvgMiterJoin | 0 |
605 | QLineF shortCut(prevLine.p2(), nextLine.p1()); never executed (the execution status of this line is deduced): QLineF shortCut(prevLine.p2(), nextLine.p1()); | - |
606 | qreal angle = shortCut.angleTo(prevLine); never executed (the execution status of this line is deduced): qreal angle = shortCut.angleTo(prevLine); | - |
607 | if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { never evaluated: type == QLineF::BoundedIntersection never evaluated: angle > 90 never evaluated: !qFuzzyCompare(angle, (qreal)90) | 0 |
608 | emitLineTo(focal_x, focal_y); never executed (the execution status of this line is deduced): emitLineTo(focal_x, focal_y); | - |
609 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
610 | return; | 0 |
611 | } | - |
612 | QLineF miterLine(QPointF(qt_fixed_to_real(focal_x), never executed (the execution status of this line is deduced): QLineF miterLine(QPointF(focal_x, | - |
613 | qt_fixed_to_real(focal_y)), isect); never executed (the execution status of this line is deduced): focal_y), isect); | - |
614 | if (type == QLineF::NoIntersection || miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) { never evaluated: type == QLineF::NoIntersection never evaluated: miterLine.length() > m_strokeWidth * m_miterLimit / 2 | 0 |
615 | emitLineTo(qt_real_to_fixed(nextLine.x1()), never executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), | - |
616 | qt_real_to_fixed(nextLine.y1())); never executed (the execution status of this line is deduced): qfixed(nextLine.y1())); | - |
617 | } else { | 0 |
618 | emitLineTo(qt_real_to_fixed(isect.x()), qt_real_to_fixed(isect.y())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(isect.x()), qfixed(isect.y())); | - |
619 | emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); never executed (the execution status of this line is deduced): emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - |
620 | } | 0 |
621 | } else { | - |
622 | Q_ASSERT(!"QStroker::joinPoints(), bad join style..."); never executed (the execution status of this line is deduced): qt_noop(); | - |
623 | } | 0 |
624 | } | - |
625 | } | - |
626 | | - |
627 | | - |
628 | /* | - |
629 | Strokes a subpath side using the \a it as source. Results are put into | - |
630 | \a stroke. The function returns true if the subpath side was closed. | - |
631 | If \a capFirst is true, we will use capPoints instead of joinPoints to | - |
632 | connect the first segment, other segments will be joined using joinPoints. | - |
633 | This is to put capping in order... | - |
634 | */ | - |
635 | template <class Iterator> bool qt_stroke_side(Iterator *it, | - |
636 | QStroker *stroker, | - |
637 | bool capFirst, | - |
638 | QLineF *startTangent) | - |
639 | { | - |
640 | // Used in CurveToElement section below. | - |
641 | const int MAX_OFFSET = 16; executed (the execution status of this line is deduced): const int MAX_OFFSET = 16; | - |
642 | QBezier offsetCurves[MAX_OFFSET]; executed (the execution status of this line is deduced): QBezier offsetCurves[MAX_OFFSET]; | - |
643 | | - |
644 | Q_ASSERT(it->hasNext()); // The initaial move to executed (the execution status of this line is deduced): qt_noop(); | - |
645 | QStrokerOps::Element first_element = it->next(); executed (the execution status of this line is deduced): QStrokerOps::Element first_element = it->next(); | - |
646 | Q_ASSERT(first_element.isMoveTo()); executed (the execution status of this line is deduced): qt_noop(); | - |
647 | | - |
648 | qfixed2d start = first_element; executed (the execution status of this line is deduced): qfixed2d start = first_element; | - |
649 | | - |
650 | #ifdef QPP_STROKE_DEBUG | - |
651 | qDebug(" -> (side) [%.2f, %.2f], startPos=%d", | - |
652 | qt_fixed_to_real(start.x), | - |
653 | qt_fixed_to_real(start.y)); | - |
654 | #endif | - |
655 | | - |
656 | qfixed2d prev = start; executed (the execution status of this line is deduced): qfixed2d prev = start; | - |
657 | | - |
658 | bool first = true; executed (the execution status of this line is deduced): bool first = true; | - |
659 | | - |
660 | qfixed offset = stroker->strokeWidth() / 2; executed (the execution status of this line is deduced): qfixed offset = stroker->strokeWidth() / 2; | - |
661 | | - |
662 | while (it->hasNext()) { evaluated: it->hasNext() yes Evaluation Count:13328 | yes Evaluation Count:5666 |
| 5666-13328 |
663 | QStrokerOps::Element e = it->next(); executed (the execution status of this line is deduced): QStrokerOps::Element e = it->next(); | - |
664 | | - |
665 | // LineToElement | - |
666 | if (e.isLineTo()) { evaluated: e.isLineTo() yes Evaluation Count:6032 | yes Evaluation Count:7296 |
| 6032-7296 |
667 | #ifdef QPP_STROKE_DEBUG | - |
668 | qDebug("\n ---> (side) lineto [%.2f, %.2f]", e.x, e.y); | - |
669 | #endif | - |
670 | QLineF line(qt_fixed_to_real(prev.x), qt_fixed_to_real(prev.y), executed (the execution status of this line is deduced): QLineF line(prev.x, prev.y, | - |
671 | qt_fixed_to_real(e.x), qt_fixed_to_real(e.y)); executed (the execution status of this line is deduced): e.x, e.y); | - |
672 | if (line.p1() != line.p2()) { evaluated: line.p1() != line.p2() yes Evaluation Count:5984 | yes Evaluation Count:48 |
| 48-5984 |
673 | QLineF normal = line.normalVector(); executed (the execution status of this line is deduced): QLineF normal = line.normalVector(); | - |
674 | normal.setLength(offset); executed (the execution status of this line is deduced): normal.setLength(offset); | - |
675 | line.translate(normal.dx(), normal.dy()); executed (the execution status of this line is deduced): line.translate(normal.dx(), normal.dy()); | - |
676 | | - |
677 | // If we are starting a new subpath, move to correct starting point. | - |
678 | if (first) { evaluated: first yes Evaluation Count:3844 | yes Evaluation Count:2140 |
| 2140-3844 |
679 | if (capFirst) evaluated: capFirst yes Evaluation Count:1708 | yes Evaluation Count:2136 |
| 1708-2136 |
680 | stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode()); executed: stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode()); Execution Count:1708 | 1708 |
681 | else | - |
682 | stroker->emitMoveTo(qt_real_to_fixed(line.x1()), qt_real_to_fixed(line.y1())); executed: stroker->emitMoveTo(qfixed(line.x1()), qfixed(line.y1())); Execution Count:2136 | 2136 |
683 | *startTangent = line; executed (the execution status of this line is deduced): *startTangent = line; | - |
684 | first = false; executed (the execution status of this line is deduced): first = false; | - |
685 | } else { executed: } Execution Count:3844 | 3844 |
686 | stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode()); executed (the execution status of this line is deduced): stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode()); | - |
687 | } executed: } Execution Count:2140 | 2140 |
688 | | - |
689 | // Add the stroke for this line. | - |
690 | stroker->emitLineTo(qt_real_to_fixed(line.x2()), executed (the execution status of this line is deduced): stroker->emitLineTo(qfixed(line.x2()), | - |
691 | qt_real_to_fixed(line.y2())); executed (the execution status of this line is deduced): qfixed(line.y2())); | - |
692 | prev = e; executed (the execution status of this line is deduced): prev = e; | - |
693 | } executed: } Execution Count:5984 | 5984 |
694 | | - |
695 | // CurveToElement | - |
696 | } else if (e.isCurveTo()) { executed: } Execution Count:6032 partially evaluated: e.isCurveTo() yes Evaluation Count:7296 | no Evaluation Count:0 |
| 0-7296 |
697 | QStrokerOps::Element cp2 = it->next(); // control point 2 executed (the execution status of this line is deduced): QStrokerOps::Element cp2 = it->next(); | - |
698 | QStrokerOps::Element ep = it->next(); // end point executed (the execution status of this line is deduced): QStrokerOps::Element ep = it->next(); | - |
699 | | - |
700 | #ifdef QPP_STROKE_DEBUG | - |
701 | qDebug("\n ---> (side) cubicTo [%.2f, %.2f]", | - |
702 | qt_fixed_to_real(ep.x), | - |
703 | qt_fixed_to_real(ep.y)); | - |
704 | #endif | - |
705 | | - |
706 | QBezier bezier = executed (the execution status of this line is deduced): QBezier bezier = | - |
707 | QBezier::fromPoints(QPointF(qt_fixed_to_real(prev.x), qt_fixed_to_real(prev.y)), executed (the execution status of this line is deduced): QBezier::fromPoints(QPointF(prev.x, prev.y), | - |
708 | QPointF(qt_fixed_to_real(e.x), qt_fixed_to_real(e.y)), executed (the execution status of this line is deduced): QPointF(e.x, e.y), | - |
709 | QPointF(qt_fixed_to_real(cp2.x), qt_fixed_to_real(cp2.y)), executed (the execution status of this line is deduced): QPointF(cp2.x, cp2.y), | - |
710 | QPointF(qt_fixed_to_real(ep.x), qt_fixed_to_real(ep.y))); executed (the execution status of this line is deduced): QPointF(ep.x, ep.y)); | - |
711 | | - |
712 | int count = bezier.shifted(offsetCurves, executed (the execution status of this line is deduced): int count = bezier.shifted(offsetCurves, | - |
713 | MAX_OFFSET, executed (the execution status of this line is deduced): MAX_OFFSET, | - |
714 | offset, executed (the execution status of this line is deduced): offset, | - |
715 | stroker->curveThreshold()); executed (the execution status of this line is deduced): stroker->curveThreshold()); | - |
716 | | - |
717 | if (count) { partially evaluated: count yes Evaluation Count:7296 | no Evaluation Count:0 |
| 0-7296 |
718 | // If we are starting a new subpath, move to correct starting point | - |
719 | QLineF tangent = bezier.startTangent(); executed (the execution status of this line is deduced): QLineF tangent = bezier.startTangent(); | - |
720 | tangent.translate(offsetCurves[0].pt1() - bezier.pt1()); executed (the execution status of this line is deduced): tangent.translate(offsetCurves[0].pt1() - bezier.pt1()); | - |
721 | if (first) { evaluated: first yes Evaluation Count:1822 | yes Evaluation Count:5474 |
| 1822-5474 |
722 | QPointF pt = offsetCurves[0].pt1(); executed (the execution status of this line is deduced): QPointF pt = offsetCurves[0].pt1(); | - |
723 | if (capFirst) { partially evaluated: capFirst no Evaluation Count:0 | yes Evaluation Count:1822 |
| 0-1822 |
724 | stroker->joinPoints(prev.x, prev.y, never executed (the execution status of this line is deduced): stroker->joinPoints(prev.x, prev.y, | - |
725 | tangent, never executed (the execution status of this line is deduced): tangent, | - |
726 | stroker->capStyleMode()); never executed (the execution status of this line is deduced): stroker->capStyleMode()); | - |
727 | } else { | 0 |
728 | stroker->emitMoveTo(qt_real_to_fixed(pt.x()), executed (the execution status of this line is deduced): stroker->emitMoveTo(qfixed(pt.x()), | - |
729 | qt_real_to_fixed(pt.y())); executed (the execution status of this line is deduced): qfixed(pt.y())); | - |
730 | } executed: } Execution Count:1822 | 1822 |
731 | *startTangent = tangent; executed (the execution status of this line is deduced): *startTangent = tangent; | - |
732 | first = false; executed (the execution status of this line is deduced): first = false; | - |
733 | } else { executed: } Execution Count:1822 | 1822 |
734 | stroker->joinPoints(prev.x, prev.y, executed (the execution status of this line is deduced): stroker->joinPoints(prev.x, prev.y, | - |
735 | tangent, executed (the execution status of this line is deduced): tangent, | - |
736 | stroker->joinStyleMode()); executed (the execution status of this line is deduced): stroker->joinStyleMode()); | - |
737 | } executed: } Execution Count:5474 | 5474 |
738 | | - |
739 | // Add these beziers | - |
740 | for (int i=0; i<count; ++i) { evaluated: i<count yes Evaluation Count:7504 | yes Evaluation Count:7296 |
| 7296-7504 |
741 | QPointF cp1 = offsetCurves[i].pt2(); executed (the execution status of this line is deduced): QPointF cp1 = offsetCurves[i].pt2(); | - |
742 | QPointF cp2 = offsetCurves[i].pt3(); executed (the execution status of this line is deduced): QPointF cp2 = offsetCurves[i].pt3(); | - |
743 | QPointF ep = offsetCurves[i].pt4(); executed (the execution status of this line is deduced): QPointF ep = offsetCurves[i].pt4(); | - |
744 | stroker->emitCubicTo(qt_real_to_fixed(cp1.x()), qt_real_to_fixed(cp1.y()), executed (the execution status of this line is deduced): stroker->emitCubicTo(qfixed(cp1.x()), qfixed(cp1.y()), | - |
745 | qt_real_to_fixed(cp2.x()), qt_real_to_fixed(cp2.y()), executed (the execution status of this line is deduced): qfixed(cp2.x()), qfixed(cp2.y()), | - |
746 | qt_real_to_fixed(ep.x()), qt_real_to_fixed(ep.y())); executed (the execution status of this line is deduced): qfixed(ep.x()), qfixed(ep.y())); | - |
747 | } executed: } Execution Count:7504 | 7504 |
748 | } executed: } Execution Count:7296 | 7296 |
749 | | - |
750 | prev = ep; executed (the execution status of this line is deduced): prev = ep; | - |
751 | } executed: } Execution Count:7296 | 7296 |
752 | } | - |
753 | | - |
754 | if (start == prev) { evaluated: start == prev yes Evaluation Count:2250 | yes Evaluation Count:3416 |
| 2250-3416 |
755 | // closed subpath, join first and last point | - |
756 | #ifdef QPP_STROKE_DEBUG | - |
757 | qDebug("\n ---> (side) closed subpath"); | - |
758 | #endif | - |
759 | // don't join empty subpaths | - |
760 | if (!first) partially evaluated: !first yes Evaluation Count:2250 | no Evaluation Count:0 |
| 0-2250 |
761 | stroker->joinPoints(prev.x, prev.y, *startTangent, stroker->joinStyleMode()); executed: stroker->joinPoints(prev.x, prev.y, *startTangent, stroker->joinStyleMode()); Execution Count:2250 | 2250 |
762 | return true; executed: return true; Execution Count:2250 | 2250 |
763 | } else { | - |
764 | #ifdef QPP_STROKE_DEBUG | - |
765 | qDebug("\n ---> (side) open subpath"); | - |
766 | #endif | - |
767 | return false; executed: return false; Execution Count:3416 | 3416 |
768 | } | - |
769 | } | - |
770 | | - |
771 | /*! | - |
772 | \internal | - |
773 | | - |
774 | For a given angle in the range [0 .. 90], finds the corresponding parameter t | - |
775 | of the prototype cubic bezier arc segment | - |
776 | b = fromPoints(QPointF(1, 0), QPointF(1, KAPPA), QPointF(KAPPA, 1), QPointF(0, 1)); | - |
777 | | - |
778 | From the bezier equation: | - |
779 | b.pointAt(t).x() = (1-t)^3 + t*(1-t)^2 + t^2*(1-t)*KAPPA | - |
780 | b.pointAt(t).y() = t*(1-t)^2 * KAPPA + t^2*(1-t) + t^3 | - |
781 | | - |
782 | Third degree coefficients: | - |
783 | b.pointAt(t).x() = at^3 + bt^2 + ct + d | - |
784 | where a = 2-3*KAPPA, b = 3*(KAPPA-1), c = 0, d = 1 | - |
785 | | - |
786 | b.pointAt(t).y() = at^3 + bt^2 + ct + d | - |
787 | where a = 3*KAPPA-2, b = 6*KAPPA+3, c = 3*KAPPA, d = 0 | - |
788 | | - |
789 | Newton's method to find the zero of a function: | - |
790 | given a function f(x) and initial guess x_0 | - |
791 | x_1 = f(x_0) / f'(x_0) | - |
792 | x_2 = f(x_1) / f'(x_1) | - |
793 | etc... | - |
794 | */ | - |
795 | | - |
796 | qreal qt_t_for_arc_angle(qreal angle) | - |
797 | { | - |
798 | if (qFuzzyIsNull(angle)) evaluated: qFuzzyIsNull(angle) yes Evaluation Count:312 | yes Evaluation Count:25890 |
| 312-25890 |
799 | return 0; executed: return 0; Execution Count:312 | 312 |
800 | | - |
801 | if (qFuzzyCompare(angle, qreal(90))) evaluated: qFuzzyCompare(angle, qreal(90)) yes Evaluation Count:88 | yes Evaluation Count:25802 |
| 88-25802 |
802 | return 1; executed: return 1; Execution Count:88 | 88 |
803 | | - |
804 | qreal radians = Q_PI * angle / 180; executed (the execution status of this line is deduced): qreal radians = Q_PI * angle / 180; | - |
805 | qreal cosAngle = qCos(radians); executed (the execution status of this line is deduced): qreal cosAngle = qCos(radians); | - |
806 | qreal sinAngle = qSin(radians); executed (the execution status of this line is deduced): qreal sinAngle = qSin(radians); | - |
807 | | - |
808 | // initial guess | - |
809 | qreal tc = angle / 90; executed (the execution status of this line is deduced): qreal tc = angle / 90; | - |
810 | // do some iterations of newton's method to approximate cosAngle | - |
811 | // finds the zero of the function b.pointAt(tc).x() - cosAngle | - |
812 | tc -= ((((2-3*QT_PATH_KAPPA) * tc + 3*(QT_PATH_KAPPA-1)) * tc) * tc + 1 - cosAngle) // value executed (the execution status of this line is deduced): tc -= ((((2-3*0.5522847498) * tc + 3*(0.5522847498 -1)) * tc) * tc + 1 - cosAngle) | - |
813 | / (((6-9*QT_PATH_KAPPA) * tc + 6*(QT_PATH_KAPPA-1)) * tc); // derivative executed (the execution status of this line is deduced): / (((6-9*0.5522847498) * tc + 6*(0.5522847498 -1)) * tc); | - |
814 | tc -= ((((2-3*QT_PATH_KAPPA) * tc + 3*(QT_PATH_KAPPA-1)) * tc) * tc + 1 - cosAngle) // value executed (the execution status of this line is deduced): tc -= ((((2-3*0.5522847498) * tc + 3*(0.5522847498 -1)) * tc) * tc + 1 - cosAngle) | - |
815 | / (((6-9*QT_PATH_KAPPA) * tc + 6*(QT_PATH_KAPPA-1)) * tc); // derivative executed (the execution status of this line is deduced): / (((6-9*0.5522847498) * tc + 6*(0.5522847498 -1)) * tc); | - |
816 | | - |
817 | // initial guess | - |
818 | qreal ts = tc; executed (the execution status of this line is deduced): qreal ts = tc; | - |
819 | // do some iterations of newton's method to approximate sinAngle | - |
820 | // finds the zero of the function b.pointAt(tc).y() - sinAngle | - |
821 | ts -= ((((3*QT_PATH_KAPPA-2) * ts - 6*QT_PATH_KAPPA + 3) * ts + 3*QT_PATH_KAPPA) * ts - sinAngle) executed (the execution status of this line is deduced): ts -= ((((3*0.5522847498 -2) * ts - 6*0.5522847498 + 3) * ts + 3*0.5522847498) * ts - sinAngle) | - |
822 | / (((9*QT_PATH_KAPPA-6) * ts + 12*QT_PATH_KAPPA - 6) * ts + 3*QT_PATH_KAPPA); executed (the execution status of this line is deduced): / (((9*0.5522847498 -6) * ts + 12*0.5522847498 - 6) * ts + 3*0.5522847498); | - |
823 | ts -= ((((3*QT_PATH_KAPPA-2) * ts - 6*QT_PATH_KAPPA + 3) * ts + 3*QT_PATH_KAPPA) * ts - sinAngle) executed (the execution status of this line is deduced): ts -= ((((3*0.5522847498 -2) * ts - 6*0.5522847498 + 3) * ts + 3*0.5522847498) * ts - sinAngle) | - |
824 | / (((9*QT_PATH_KAPPA-6) * ts + 12*QT_PATH_KAPPA - 6) * ts + 3*QT_PATH_KAPPA); executed (the execution status of this line is deduced): / (((9*0.5522847498 -6) * ts + 12*0.5522847498 - 6) * ts + 3*0.5522847498); | - |
825 | | - |
826 | // use the average of the t that best approximates cosAngle | - |
827 | // and the t that best approximates sinAngle | - |
828 | qreal t = 0.5 * (tc + ts); executed (the execution status of this line is deduced): qreal t = 0.5 * (tc + ts); | - |
829 | | - |
830 | #if 0 | - |
831 | printf("angle: %f, t: %f\n", angle, t); | - |
832 | qreal a, b, c, d; | - |
833 | bezierCoefficients(t, a, b, c, d); | - |
834 | printf("cosAngle: %.10f, value: %.10f\n", cosAngle, a + b + c * QT_PATH_KAPPA); | - |
835 | printf("sinAngle: %.10f, value: %.10f\n", sinAngle, b * QT_PATH_KAPPA + c + d); | - |
836 | #endif | - |
837 | | - |
838 | return t; executed: return t; Execution Count:25802 | 25802 |
839 | } | - |
840 | | - |
841 | Q_GUI_EXPORT void qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length, | - |
842 | QPointF* startPoint, QPointF *endPoint); | - |
843 | | - |
844 | /*! | - |
845 | \internal | - |
846 | | - |
847 | Creates a number of curves for a given arc definition. The arc is | - |
848 | defined an arc along the ellipses that fits into \a rect starting | - |
849 | at \a startAngle and an arc length of \a sweepLength. | - |
850 | | - |
851 | The function has three out parameters. The return value is the | - |
852 | starting point of the arc. The \a curves array represents the list | - |
853 | of cubicTo elements up to a maximum of \a point_count. There are of course | - |
854 | 3 points pr curve. | - |
855 | */ | - |
856 | QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, | - |
857 | QPointF *curves, int *point_count) | - |
858 | { | - |
859 | Q_ASSERT(point_count); executed (the execution status of this line is deduced): qt_noop(); | - |
860 | Q_ASSERT(curves); executed (the execution status of this line is deduced): qt_noop(); | - |
861 | | - |
862 | *point_count = 0; executed (the execution status of this line is deduced): *point_count = 0; | - |
863 | if (qt_is_nan(rect.x()) || qt_is_nan(rect.y()) || qt_is_nan(rect.width()) || qt_is_nan(rect.height()) partially evaluated: qt_is_nan(rect.x()) no Evaluation Count:0 | yes Evaluation Count:6804 |
partially evaluated: qt_is_nan(rect.y()) no Evaluation Count:0 | yes Evaluation Count:6804 |
partially evaluated: qt_is_nan(rect.width()) no Evaluation Count:0 | yes Evaluation Count:6804 |
partially evaluated: qt_is_nan(rect.height()) no Evaluation Count:0 | yes Evaluation Count:6804 |
| 0-6804 |
864 | || qt_is_nan(startAngle) || qt_is_nan(sweepLength)) { partially evaluated: qt_is_nan(startAngle) no Evaluation Count:0 | yes Evaluation Count:6804 |
partially evaluated: qt_is_nan(sweepLength) no Evaluation Count:0 | yes Evaluation Count:6804 |
| 0-6804 |
865 | qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qstroker.cpp", 865, __PRETTY_FUNCTION__).warning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined"); | - |
866 | return QPointF(); never executed: return QPointF(); | 0 |
867 | } | - |
868 | | - |
869 | if (rect.isNull()) { partially evaluated: rect.isNull() no Evaluation Count:0 | yes Evaluation Count:6804 |
| 0-6804 |
870 | return QPointF(); never executed: return QPointF(); | 0 |
871 | } | - |
872 | | - |
873 | qreal x = rect.x(); executed (the execution status of this line is deduced): qreal x = rect.x(); | - |
874 | qreal y = rect.y(); executed (the execution status of this line is deduced): qreal y = rect.y(); | - |
875 | | - |
876 | qreal w = rect.width(); executed (the execution status of this line is deduced): qreal w = rect.width(); | - |
877 | qreal w2 = rect.width() / 2; executed (the execution status of this line is deduced): qreal w2 = rect.width() / 2; | - |
878 | qreal w2k = w2 * QT_PATH_KAPPA; executed (the execution status of this line is deduced): qreal w2k = w2 * 0.5522847498; | - |
879 | | - |
880 | qreal h = rect.height(); executed (the execution status of this line is deduced): qreal h = rect.height(); | - |
881 | qreal h2 = rect.height() / 2; executed (the execution status of this line is deduced): qreal h2 = rect.height() / 2; | - |
882 | qreal h2k = h2 * QT_PATH_KAPPA; executed (the execution status of this line is deduced): qreal h2k = h2 * 0.5522847498; | - |
883 | | - |
884 | QPointF points[16] = executed (the execution status of this line is deduced): QPointF points[16] = | - |
885 | { executed (the execution status of this line is deduced): { | - |
886 | // start point executed (the execution status of this line is deduced):
| - |
887 | QPointF(x + w, y + h2), executed (the execution status of this line is deduced): QPointF(x + w, y + h2), | - |
888 | executed (the execution status of this line is deduced):
| - |
889 | // 0 -> 270 degrees executed (the execution status of this line is deduced):
| - |
890 | QPointF(x + w, y + h2 + h2k), executed (the execution status of this line is deduced): QPointF(x + w, y + h2 + h2k), | - |
891 | QPointF(x + w2 + w2k, y + h), executed (the execution status of this line is deduced): QPointF(x + w2 + w2k, y + h), | - |
892 | QPointF(x + w2, y + h), executed (the execution status of this line is deduced): QPointF(x + w2, y + h), | - |
893 | executed (the execution status of this line is deduced):
| - |
894 | // 270 -> 180 degrees executed (the execution status of this line is deduced):
| - |
895 | QPointF(x + w2 - w2k, y + h), executed (the execution status of this line is deduced): QPointF(x + w2 - w2k, y + h), | - |
896 | QPointF(x, y + h2 + h2k), executed (the execution status of this line is deduced): QPointF(x, y + h2 + h2k), | - |
897 | QPointF(x, y + h2), executed (the execution status of this line is deduced): QPointF(x, y + h2), | - |
898 | executed (the execution status of this line is deduced):
| - |
899 | // 180 -> 90 degrees executed (the execution status of this line is deduced):
| - |
900 | QPointF(x, y + h2 - h2k), executed (the execution status of this line is deduced): QPointF(x, y + h2 - h2k), | - |
901 | QPointF(x + w2 - w2k, y), executed (the execution status of this line is deduced): QPointF(x + w2 - w2k, y), | - |
902 | QPointF(x + w2, y), executed (the execution status of this line is deduced): QPointF(x + w2, y), | - |
903 | executed (the execution status of this line is deduced):
| - |
904 | // 90 -> 0 degrees executed (the execution status of this line is deduced):
| - |
905 | QPointF(x + w2 + w2k, y), executed (the execution status of this line is deduced): QPointF(x + w2 + w2k, y), | - |
906 | QPointF(x + w, y + h2 - h2k), executed (the execution status of this line is deduced): QPointF(x + w, y + h2 - h2k), | - |
907 | QPointF(x + w, y + h2) executed (the execution status of this line is deduced): QPointF(x + w, y + h2) | - |
908 | }; executed (the execution status of this line is deduced): }; | - |
909 | | - |
910 | if (sweepLength > 360) sweepLength = 360; never executed: sweepLength = 360; partially evaluated: sweepLength > 360 no Evaluation Count:0 | yes Evaluation Count:6804 |
| 0-6804 |
911 | else if (sweepLength < -360) sweepLength = -360; never executed: sweepLength = -360; partially evaluated: sweepLength < -360 no Evaluation Count:0 | yes Evaluation Count:6804 |
| 0-6804 |
912 | | - |
913 | // Special case fast paths | - |
914 | if (startAngle == 0.0) { evaluated: startAngle == 0.0 yes Evaluation Count:995 | yes Evaluation Count:5809 |
| 995-5809 |
915 | if (sweepLength == 360.0) { evaluated: sweepLength == 360.0 yes Evaluation Count:1 | yes Evaluation Count:994 |
| 1-994 |
916 | for (int i = 11; i >= 0; --i) evaluated: i >= 0 yes Evaluation Count:12 | yes Evaluation Count:1 |
| 1-12 |
917 | curves[(*point_count)++] = points[i]; executed: curves[(*point_count)++] = points[i]; Execution Count:12 | 12 |
918 | return points[12]; executed: return points[12]; Execution Count:1 | 1 |
919 | } else if (sweepLength == -360.0) { evaluated: sweepLength == -360.0 yes Evaluation Count:980 | yes Evaluation Count:14 |
| 14-980 |
920 | for (int i = 1; i <= 12; ++i) evaluated: i <= 12 yes Evaluation Count:11760 | yes Evaluation Count:980 |
| 980-11760 |
921 | curves[(*point_count)++] = points[i]; executed: curves[(*point_count)++] = points[i]; Execution Count:11760 | 11760 |
922 | return points[0]; executed: return points[0]; Execution Count:980 | 980 |
923 | } | - |
924 | } | - |
925 | | - |
926 | int startSegment = int(qFloor(startAngle / 90)); executed (the execution status of this line is deduced): int startSegment = int(qFloor(startAngle / 90)); | - |
927 | int endSegment = int(qFloor((startAngle + sweepLength) / 90)); executed (the execution status of this line is deduced): int endSegment = int(qFloor((startAngle + sweepLength) / 90)); | - |
928 | | - |
929 | qreal startT = (startAngle - startSegment * 90) / 90; executed (the execution status of this line is deduced): qreal startT = (startAngle - startSegment * 90) / 90; | - |
930 | qreal endT = (startAngle + sweepLength - endSegment * 90) / 90; executed (the execution status of this line is deduced): qreal endT = (startAngle + sweepLength - endSegment * 90) / 90; | - |
931 | | - |
932 | int delta = sweepLength > 0 ? 1 : -1; evaluated: sweepLength > 0 yes Evaluation Count:5798 | yes Evaluation Count:25 |
| 25-5798 |
933 | if (delta < 0) { evaluated: delta < 0 yes Evaluation Count:25 | yes Evaluation Count:5798 |
| 25-5798 |
934 | startT = 1 - startT; executed (the execution status of this line is deduced): startT = 1 - startT; | - |
935 | endT = 1 - endT; executed (the execution status of this line is deduced): endT = 1 - endT; | - |
936 | } executed: } Execution Count:25 | 25 |
937 | | - |
938 | // avoid empty start segment | - |
939 | if (qFuzzyIsNull(startT - qreal(1))) { evaluated: qFuzzyIsNull(startT - qreal(1)) yes Evaluation Count:24 | yes Evaluation Count:5799 |
| 24-5799 |
940 | startT = 0; executed (the execution status of this line is deduced): startT = 0; | - |
941 | startSegment += delta; executed (the execution status of this line is deduced): startSegment += delta; | - |
942 | } executed: } Execution Count:24 | 24 |
943 | | - |
944 | // avoid empty end segment | - |
945 | if (qFuzzyIsNull(endT)) { evaluated: qFuzzyIsNull(endT) yes Evaluation Count:64 | yes Evaluation Count:5759 |
| 64-5759 |
946 | endT = 1; executed (the execution status of this line is deduced): endT = 1; | - |
947 | endSegment -= delta; executed (the execution status of this line is deduced): endSegment -= delta; | - |
948 | } executed: } Execution Count:64 | 64 |
949 | | - |
950 | startT = qt_t_for_arc_angle(startT * 90); executed (the execution status of this line is deduced): startT = qt_t_for_arc_angle(startT * 90); | - |
951 | endT = qt_t_for_arc_angle(endT * 90); executed (the execution status of this line is deduced): endT = qt_t_for_arc_angle(endT * 90); | - |
952 | | - |
953 | const bool splitAtStart = !qFuzzyIsNull(startT); executed (the execution status of this line is deduced): const bool splitAtStart = !qFuzzyIsNull(startT); | - |
954 | const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1)); executed (the execution status of this line is deduced): const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1)); | - |
955 | | - |
956 | const int end = endSegment + delta; executed (the execution status of this line is deduced): const int end = endSegment + delta; | - |
957 | | - |
958 | // empty arc? | - |
959 | if (startSegment == end) { partially evaluated: startSegment == end no Evaluation Count:0 | yes Evaluation Count:5823 |
| 0-5823 |
960 | const int quadrant = 3 - ((startSegment % 4) + 4) % 4; never executed (the execution status of this line is deduced): const int quadrant = 3 - ((startSegment % 4) + 4) % 4; | - |
961 | const int j = 3 * quadrant; never executed (the execution status of this line is deduced): const int j = 3 * quadrant; | - |
962 | return delta > 0 ? points[j + 3] : points[j]; never executed: return delta > 0 ? points[j + 3] : points[j]; | 0 |
963 | } | - |
964 | | - |
965 | QPointF startPoint, endPoint; executed (the execution status of this line is deduced): QPointF startPoint, endPoint; | - |
966 | qt_find_ellipse_coords(rect, startAngle, sweepLength, &startPoint, &endPoint); executed (the execution status of this line is deduced): qt_find_ellipse_coords(rect, startAngle, sweepLength, &startPoint, &endPoint); | - |
967 | | - |
968 | for (int i = startSegment; i != end; i += delta) { evaluated: i != end yes Evaluation Count:7715 | yes Evaluation Count:5823 |
| 5823-7715 |
969 | const int quadrant = 3 - ((i % 4) + 4) % 4; executed (the execution status of this line is deduced): const int quadrant = 3 - ((i % 4) + 4) % 4; | - |
970 | const int j = 3 * quadrant; executed (the execution status of this line is deduced): const int j = 3 * quadrant; | - |
971 | | - |
972 | QBezier b; executed (the execution status of this line is deduced): QBezier b; | - |
973 | if (delta > 0) evaluated: delta > 0 yes Evaluation Count:7686 | yes Evaluation Count:29 |
| 29-7686 |
974 | b = QBezier::fromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]); executed: b = QBezier::fromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]); Execution Count:7686 | 7686 |
975 | else | - |
976 | b = QBezier::fromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]); executed: b = QBezier::fromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]); Execution Count:29 | 29 |
977 | | - |
978 | // empty arc? | - |
979 | if (startSegment == endSegment && qFuzzyCompare(startT, endT)) evaluated: startSegment == endSegment yes Evaluation Count:3949 | yes Evaluation Count:3766 |
partially evaluated: qFuzzyCompare(startT, endT) no Evaluation Count:0 | yes Evaluation Count:3949 |
| 0-3949 |
980 | return startPoint; never executed: return startPoint; | 0 |
981 | | - |
982 | if (i == startSegment) { evaluated: i == startSegment yes Evaluation Count:5823 | yes Evaluation Count:1892 |
| 1892-5823 |
983 | if (i == endSegment && splitAtEnd) evaluated: i == endSegment yes Evaluation Count:3949 | yes Evaluation Count:1874 |
evaluated: splitAtEnd yes Evaluation Count:3861 | yes Evaluation Count:88 |
| 88-3949 |
984 | b = b.bezierOnInterval(startT, endT); executed: b = b.bezierOnInterval(startT, endT); Execution Count:3861 | 3861 |
985 | else if (splitAtStart) evaluated: splitAtStart yes Evaluation Count:1938 | yes Evaluation Count:24 |
| 24-1938 |
986 | b = b.bezierOnInterval(startT, 1); executed: b = b.bezierOnInterval(startT, 1); Execution Count:1938 | 1938 |
987 | } else if (i == endSegment && splitAtEnd) { evaluated: i == endSegment yes Evaluation Count:1874 | yes Evaluation Count:18 |
partially evaluated: splitAtEnd yes Evaluation Count:1874 | no Evaluation Count:0 |
| 0-1874 |
988 | b = b.bezierOnInterval(0, endT); executed (the execution status of this line is deduced): b = b.bezierOnInterval(0, endT); | - |
989 | } executed: } Execution Count:1874 | 1874 |
990 | | - |
991 | // push control points | - |
992 | curves[(*point_count)++] = b.pt2(); executed (the execution status of this line is deduced): curves[(*point_count)++] = b.pt2(); | - |
993 | curves[(*point_count)++] = b.pt3(); executed (the execution status of this line is deduced): curves[(*point_count)++] = b.pt3(); | - |
994 | curves[(*point_count)++] = b.pt4(); executed (the execution status of this line is deduced): curves[(*point_count)++] = b.pt4(); | - |
995 | } executed: } Execution Count:7715 | 7715 |
996 | | - |
997 | Q_ASSERT(*point_count > 0); executed (the execution status of this line is deduced): qt_noop(); | - |
998 | curves[*(point_count)-1] = endPoint; executed (the execution status of this line is deduced): curves[*(point_count)-1] = endPoint; | - |
999 | | - |
1000 | return startPoint; executed: return startPoint; Execution Count:5823 | 5823 |
1001 | } | - |
1002 | | - |
1003 | | - |
1004 | static inline void qdashstroker_moveTo(qfixed x, qfixed y, void *data) { | - |
1005 | ((QStroker *) data)->moveTo(x, y); executed (the execution status of this line is deduced): ((QStroker *) data)->moveTo(x, y); | - |
1006 | } executed: } Execution Count:2 | 2 |
1007 | | - |
1008 | static inline void qdashstroker_lineTo(qfixed x, qfixed y, void *data) { | - |
1009 | ((QStroker *) data)->lineTo(x, y); executed (the execution status of this line is deduced): ((QStroker *) data)->lineTo(x, y); | - |
1010 | } executed: } Execution Count:2 | 2 |
1011 | | - |
1012 | static inline void qdashstroker_cubicTo(qfixed, qfixed, qfixed, qfixed, qfixed, qfixed, void *) { | - |
1013 | Q_ASSERT(0); never executed (the execution status of this line is deduced): qt_noop(); | - |
1014 | // ((QStroker *) data)->cubicTo(c1x, c1y, c2x, c2y, ex, ey); | - |
1015 | } | 0 |
1016 | | - |
1017 | | - |
1018 | /******************************************************************************* | - |
1019 | * QDashStroker members | - |
1020 | */ | - |
1021 | QDashStroker::QDashStroker(QStroker *stroker) | - |
1022 | : m_stroker(stroker), m_dashOffset(0), m_stroke_width(1), m_miter_limit(1) | - |
1023 | { | - |
1024 | if (m_stroker) { partially evaluated: m_stroker yes Evaluation Count:8801 | no Evaluation Count:0 |
| 0-8801 |
1025 | setMoveToHook(qdashstroker_moveTo); executed (the execution status of this line is deduced): setMoveToHook(qdashstroker_moveTo); | - |
1026 | setLineToHook(qdashstroker_lineTo); executed (the execution status of this line is deduced): setLineToHook(qdashstroker_lineTo); | - |
1027 | setCubicToHook(qdashstroker_cubicTo); executed (the execution status of this line is deduced): setCubicToHook(qdashstroker_cubicTo); | - |
1028 | } executed: } Execution Count:8801 | 8801 |
1029 | } executed: } Execution Count:8801 | 8801 |
1030 | | - |
1031 | QDashStroker::~QDashStroker() | - |
1032 | { | - |
1033 | } | - |
1034 | | - |
1035 | QVector<qfixed> QDashStroker::patternForStyle(Qt::PenStyle style) | - |
1036 | { | - |
1037 | const qfixed space = 2; executed (the execution status of this line is deduced): const qfixed space = 2; | - |
1038 | const qfixed dot = 1; executed (the execution status of this line is deduced): const qfixed dot = 1; | - |
1039 | const qfixed dash = 4; executed (the execution status of this line is deduced): const qfixed dash = 4; | - |
1040 | | - |
1041 | QVector<qfixed> pattern; executed (the execution status of this line is deduced): QVector<qfixed> pattern; | - |
1042 | | - |
1043 | switch (style) { | - |
1044 | case Qt::DashLine: | - |
1045 | pattern << dash << space; never executed (the execution status of this line is deduced): pattern << dash << space; | - |
1046 | break; | 0 |
1047 | case Qt::DotLine: | - |
1048 | pattern << dot << space; executed (the execution status of this line is deduced): pattern << dot << space; | - |
1049 | break; executed: break; Execution Count:1 | 1 |
1050 | case Qt::DashDotLine: | - |
1051 | pattern << dash << space << dot << space; never executed (the execution status of this line is deduced): pattern << dash << space << dot << space; | - |
1052 | break; | 0 |
1053 | case Qt::DashDotDotLine: | - |
1054 | pattern << dash << space << dot << space << dot << space; never executed (the execution status of this line is deduced): pattern << dash << space << dot << space << dot << space; | - |
1055 | break; | 0 |
1056 | default: | - |
1057 | break; executed: break; Execution Count:3 | 3 |
1058 | } | - |
1059 | | - |
1060 | return pattern; executed: return pattern; Execution Count:4 | 4 |
1061 | } | - |
1062 | | - |
1063 | static inline bool lineRectIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) | - |
1064 | { | - |
1065 | return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) never executed: return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); | 0 |
1066 | && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); never executed: return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); | 0 |
1067 | } | - |
1068 | | - |
1069 | // If the line intersects the rectangle, this function will return true. | - |
1070 | static bool lineIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) | - |
1071 | { | - |
1072 | if (!lineRectIntersectsRect(p1, p2, tl, br)) never evaluated: !lineRectIntersectsRect(p1, p2, tl, br) | 0 |
1073 | return false; never executed: return false; | 0 |
1074 | if (p1.x == p2.x || p1.y == p2.y) never evaluated: p1.x == p2.x never evaluated: p1.y == p2.y | 0 |
1075 | return true; never executed: return true; | 0 |
1076 | | - |
1077 | if (p1.y > p2.y) never evaluated: p1.y > p2.y | 0 |
1078 | qSwap(p1, p2); // make p1 above p2 never executed: qSwap(p1, p2); | 0 |
1079 | qfixed2d u; never executed (the execution status of this line is deduced): qfixed2d u; | - |
1080 | qfixed2d v; never executed (the execution status of this line is deduced): qfixed2d v; | - |
1081 | qfixed2d w = {p2.x - p1.x, p2.y - p1.y}; never executed (the execution status of this line is deduced): qfixed2d w = {p2.x - p1.x, p2.y - p1.y}; | - |
1082 | if (p1.x < p2.x) { never evaluated: p1.x < p2.x | 0 |
1083 | // backslash | - |
1084 | u.x = tl.x - p1.x; u.y = br.y - p1.y; never executed (the execution status of this line is deduced): u.x = tl.x - p1.x; u.y = br.y - p1.y; | - |
1085 | v.x = br.x - p1.x; v.y = tl.y - p1.y; never executed (the execution status of this line is deduced): v.x = br.x - p1.x; v.y = tl.y - p1.y; | - |
1086 | } else { | 0 |
1087 | // slash | - |
1088 | u.x = tl.x - p1.x; u.y = tl.y - p1.y; never executed (the execution status of this line is deduced): u.x = tl.x - p1.x; u.y = tl.y - p1.y; | - |
1089 | v.x = br.x - p1.x; v.y = br.y - p1.y; never executed (the execution status of this line is deduced): v.x = br.x - p1.x; v.y = br.y - p1.y; | - |
1090 | } | 0 |
1091 | #if defined(QFIXED_IS_26_6) || defined(QFIXED_IS_16_16) | - |
1092 | qint64 val1 = qint64(u.x) * qint64(w.y) - qint64(u.y) * qint64(w.x); | - |
1093 | qint64 val2 = qint64(v.x) * qint64(w.y) - qint64(v.y) * qint64(w.x); | - |
1094 | return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0); | - |
1095 | #elif defined(QFIXED_IS_32_32) | - |
1096 | // Cannot do proper test because it may overflow. | - |
1097 | return true; | - |
1098 | #else | - |
1099 | qreal val1 = u.x * w.y - u.y * w.x; never executed (the execution status of this line is deduced): qreal val1 = u.x * w.y - u.y * w.x; | - |
1100 | qreal val2 = v.x * w.y - v.y * w.x; never executed (the execution status of this line is deduced): qreal val2 = v.x * w.y - v.y * w.x; | - |
1101 | return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0); never executed: return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0); | 0 |
1102 | #endif | - |
1103 | } | - |
1104 | | - |
1105 | void QDashStroker::processCurrentSubpath() | - |
1106 | { | - |
1107 | int dashCount = qMin(m_dashPattern.size(), 32); executed (the execution status of this line is deduced): int dashCount = qMin(m_dashPattern.size(), 32); | - |
1108 | qfixed dashes[32]; executed (the execution status of this line is deduced): qfixed dashes[32]; | - |
1109 | | - |
1110 | if (m_stroker) { partially evaluated: m_stroker yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1111 | m_customData = m_stroker; executed (the execution status of this line is deduced): m_customData = m_stroker; | - |
1112 | m_stroke_width = m_stroker->strokeWidth(); executed (the execution status of this line is deduced): m_stroke_width = m_stroker->strokeWidth(); | - |
1113 | m_miter_limit = m_stroker->miterLimit(); executed (the execution status of this line is deduced): m_miter_limit = m_stroker->miterLimit(); | - |
1114 | } executed: } Execution Count:1 | 1 |
1115 | | - |
1116 | qreal longestLength = 0; executed (the execution status of this line is deduced): qreal longestLength = 0; | - |
1117 | qreal sumLength = 0; executed (the execution status of this line is deduced): qreal sumLength = 0; | - |
1118 | for (int i=0; i<dashCount; ++i) { evaluated: i<dashCount yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
1119 | dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke_width; executed (the execution status of this line is deduced): dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke_width; | - |
1120 | sumLength += dashes[i]; executed (the execution status of this line is deduced): sumLength += dashes[i]; | - |
1121 | if (dashes[i] > longestLength) partially evaluated: dashes[i] > longestLength yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1122 | longestLength = dashes[i]; executed: longestLength = dashes[i]; Execution Count:2 | 2 |
1123 | } executed: } Execution Count:2 | 2 |
1124 | | - |
1125 | if (qFuzzyIsNull(sumLength)) partially evaluated: qFuzzyIsNull(sumLength) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1126 | return; | 0 |
1127 | | - |
1128 | qreal invSumLength = qreal(1) / sumLength; executed (the execution status of this line is deduced): qreal invSumLength = qreal(1) / sumLength; | - |
1129 | | - |
1130 | Q_ASSERT(dashCount > 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1131 | | - |
1132 | dashCount = dashCount & -2; // Round down to even number executed (the execution status of this line is deduced): dashCount = dashCount & -2; | - |
1133 | | - |
1134 | int idash = 0; // Index to current dash executed (the execution status of this line is deduced): int idash = 0; | - |
1135 | qreal pos = 0; // The position on the curve, 0 <= pos <= path.length executed (the execution status of this line is deduced): qreal pos = 0; | - |
1136 | qreal elen = 0; // element length executed (the execution status of this line is deduced): qreal elen = 0; | - |
1137 | qreal doffset = m_dashOffset * m_stroke_width; executed (the execution status of this line is deduced): qreal doffset = m_dashOffset * m_stroke_width; | - |
1138 | | - |
1139 | // make sure doffset is in range [0..sumLength) | - |
1140 | doffset -= qFloor(doffset * invSumLength) * sumLength; executed (the execution status of this line is deduced): doffset -= qFloor(doffset * invSumLength) * sumLength; | - |
1141 | | - |
1142 | while (doffset >= dashes[idash]) { partially evaluated: doffset >= dashes[idash] no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1143 | doffset -= dashes[idash]; never executed (the execution status of this line is deduced): doffset -= dashes[idash]; | - |
1144 | if (++idash >= dashCount) never evaluated: ++idash >= dashCount | 0 |
1145 | idash = 0; never executed: idash = 0; | 0 |
1146 | } | 0 |
1147 | | - |
1148 | qreal estart = 0; // The elements starting position executed (the execution status of this line is deduced): qreal estart = 0; | - |
1149 | qreal estop = 0; // The element stop position executed (the execution status of this line is deduced): qreal estop = 0; | - |
1150 | | - |
1151 | QLineF cline; executed (the execution status of this line is deduced): QLineF cline; | - |
1152 | | - |
1153 | QPainterPath dashPath; executed (the execution status of this line is deduced): QPainterPath dashPath; | - |
1154 | | - |
1155 | QSubpathFlatIterator it(&m_elements, m_dashThreshold); executed (the execution status of this line is deduced): QSubpathFlatIterator it(&m_elements, m_dashThreshold); | - |
1156 | qfixed2d prev = it.next(); executed (the execution status of this line is deduced): qfixed2d prev = it.next(); | - |
1157 | | - |
1158 | bool clipping = !m_clip_rect.isEmpty(); executed (the execution status of this line is deduced): bool clipping = !m_clip_rect.isEmpty(); | - |
1159 | qfixed2d move_to_pos = prev; executed (the execution status of this line is deduced): qfixed2d move_to_pos = prev; | - |
1160 | qfixed2d line_to_pos; executed (the execution status of this line is deduced): qfixed2d line_to_pos; | - |
1161 | | - |
1162 | // Pad to avoid clipping the borders of thick pens. | - |
1163 | qfixed padding = qt_real_to_fixed(qMax(m_stroke_width, m_miter_limit) * longestLength); executed (the execution status of this line is deduced): qfixed padding = qfixed(qMax(m_stroke_width, m_miter_limit) * longestLength); | - |
1164 | qfixed2d clip_tl = { qt_real_to_fixed(m_clip_rect.left()) - padding, executed (the execution status of this line is deduced): qfixed2d clip_tl = { qfixed(m_clip_rect.left()) - padding, | - |
1165 | qt_real_to_fixed(m_clip_rect.top()) - padding }; executed (the execution status of this line is deduced): qfixed(m_clip_rect.top()) - padding }; | - |
1166 | qfixed2d clip_br = { qt_real_to_fixed(m_clip_rect.right()) + padding , executed (the execution status of this line is deduced): qfixed2d clip_br = { qfixed(m_clip_rect.right()) + padding , | - |
1167 | qt_real_to_fixed(m_clip_rect.bottom()) + padding }; executed (the execution status of this line is deduced): qfixed(m_clip_rect.bottom()) + padding }; | - |
1168 | | - |
1169 | bool hasMoveTo = false; executed (the execution status of this line is deduced): bool hasMoveTo = false; | - |
1170 | while (it.hasNext()) { evaluated: it.hasNext() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1171 | QStrokerOps::Element e = it.next(); executed (the execution status of this line is deduced): QStrokerOps::Element e = it.next(); | - |
1172 | | - |
1173 | Q_ASSERT(e.isLineTo()); executed (the execution status of this line is deduced): qt_noop(); | - |
1174 | cline = QLineF(qt_fixed_to_real(prev.x), executed (the execution status of this line is deduced): cline = QLineF(prev.x, | - |
1175 | qt_fixed_to_real(prev.y), executed (the execution status of this line is deduced): prev.y, | - |
1176 | qt_fixed_to_real(e.x), executed (the execution status of this line is deduced): e.x, | - |
1177 | qt_fixed_to_real(e.y)); executed (the execution status of this line is deduced): e.y); | - |
1178 | elen = cline.length(); executed (the execution status of this line is deduced): elen = cline.length(); | - |
1179 | | - |
1180 | estop = estart + elen; executed (the execution status of this line is deduced): estop = estart + elen; | - |
1181 | | - |
1182 | bool done = pos >= estop; executed (the execution status of this line is deduced): bool done = pos >= estop; | - |
1183 | | - |
1184 | if (clipping) { partially evaluated: clipping no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1185 | // Check if the entire line can be clipped away. | - |
1186 | if (!lineIntersectsRect(prev, e, clip_tl, clip_br)) { never evaluated: !lineIntersectsRect(prev, e, clip_tl, clip_br) | 0 |
1187 | // Cut away full dash sequences. | - |
1188 | elen -= qFloor(elen * invSumLength) * sumLength; never executed (the execution status of this line is deduced): elen -= qFloor(elen * invSumLength) * sumLength; | - |
1189 | // Update dash offset. | - |
1190 | while (!done) { | 0 |
1191 | qreal dpos = pos + dashes[idash] - doffset - estart; never executed (the execution status of this line is deduced): qreal dpos = pos + dashes[idash] - doffset - estart; | - |
1192 | | - |
1193 | Q_ASSERT(dpos >= 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
1194 | | - |
1195 | if (dpos > elen) { // dash extends this line never evaluated: dpos > elen | 0 |
1196 | doffset = dashes[idash] - (dpos - elen); // subtract the part already used never executed (the execution status of this line is deduced): doffset = dashes[idash] - (dpos - elen); | - |
1197 | pos = estop; // move pos to next path element never executed (the execution status of this line is deduced): pos = estop; | - |
1198 | done = true; never executed (the execution status of this line is deduced): done = true; | - |
1199 | } else { // Dash is on this line | 0 |
1200 | pos = dpos + estart; never executed (the execution status of this line is deduced): pos = dpos + estart; | - |
1201 | done = pos >= estop; never executed (the execution status of this line is deduced): done = pos >= estop; | - |
1202 | if (++idash >= dashCount) never evaluated: ++idash >= dashCount | 0 |
1203 | idash = 0; never executed: idash = 0; | 0 |
1204 | doffset = 0; // full segment so no offset on next. never executed (the execution status of this line is deduced): doffset = 0; | - |
1205 | } | 0 |
1206 | } | - |
1207 | hasMoveTo = false; never executed (the execution status of this line is deduced): hasMoveTo = false; | - |
1208 | move_to_pos = e; never executed (the execution status of this line is deduced): move_to_pos = e; | - |
1209 | } | 0 |
1210 | } | 0 |
1211 | | - |
1212 | // Dash away... | - |
1213 | while (!done) { evaluated: !done yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
1214 | QPointF p2; executed (the execution status of this line is deduced): QPointF p2; | - |
1215 | | - |
1216 | bool has_offset = doffset > 0; executed (the execution status of this line is deduced): bool has_offset = doffset > 0; | - |
1217 | bool evenDash = (idash & 1) == 0; executed (the execution status of this line is deduced): bool evenDash = (idash & 1) == 0; | - |
1218 | qreal dpos = pos + dashes[idash] - doffset - estart; executed (the execution status of this line is deduced): qreal dpos = pos + dashes[idash] - doffset - estart; | - |
1219 | | - |
1220 | Q_ASSERT(dpos >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1221 | | - |
1222 | if (dpos > elen) { // dash extends this line evaluated: dpos > elen yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
1223 | doffset = dashes[idash] - (dpos - elen); // subtract the part already used executed (the execution status of this line is deduced): doffset = dashes[idash] - (dpos - elen); | - |
1224 | pos = estop; // move pos to next path element executed (the execution status of this line is deduced): pos = estop; | - |
1225 | done = true; executed (the execution status of this line is deduced): done = true; | - |
1226 | p2 = cline.p2(); executed (the execution status of this line is deduced): p2 = cline.p2(); | - |
1227 | } else { // Dash is on this line executed: } Execution Count:1 | 1 |
1228 | p2 = cline.pointAt(dpos/elen); executed (the execution status of this line is deduced): p2 = cline.pointAt(dpos/elen); | - |
1229 | pos = dpos + estart; executed (the execution status of this line is deduced): pos = dpos + estart; | - |
1230 | done = pos >= estop; executed (the execution status of this line is deduced): done = pos >= estop; | - |
1231 | if (++idash >= dashCount) evaluated: ++idash >= dashCount yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
1232 | idash = 0; executed: idash = 0; Execution Count:1 | 1 |
1233 | doffset = 0; // full segment so no offset on next. executed (the execution status of this line is deduced): doffset = 0; | - |
1234 | } executed: } Execution Count:3 | 3 |
1235 | | - |
1236 | if (evenDash) { evaluated: evenDash yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1237 | line_to_pos.x = qt_real_to_fixed(p2.x()); executed (the execution status of this line is deduced): line_to_pos.x = qfixed(p2.x()); | - |
1238 | line_to_pos.y = qt_real_to_fixed(p2.y()); executed (the execution status of this line is deduced): line_to_pos.y = qfixed(p2.y()); | - |
1239 | | - |
1240 | if (!clipping partially evaluated: !clipping yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1241 | || lineRectIntersectsRect(move_to_pos, line_to_pos, clip_tl, clip_br)) never evaluated: lineRectIntersectsRect(move_to_pos, line_to_pos, clip_tl, clip_br) | 0 |
1242 | { | - |
1243 | // If we have an offset, we're continuing a dash | - |
1244 | // from a previous element and should only | - |
1245 | // continue the current dash, without starting a | - |
1246 | // new subpath. | - |
1247 | if (!has_offset || !hasMoveTo) { partially evaluated: !has_offset yes Evaluation Count:2 | no Evaluation Count:0 |
never evaluated: !hasMoveTo | 0-2 |
1248 | emitMoveTo(move_to_pos.x, move_to_pos.y); executed (the execution status of this line is deduced): emitMoveTo(move_to_pos.x, move_to_pos.y); | - |
1249 | hasMoveTo = true; executed (the execution status of this line is deduced): hasMoveTo = true; | - |
1250 | } executed: } Execution Count:2 | 2 |
1251 | | - |
1252 | emitLineTo(line_to_pos.x, line_to_pos.y); executed (the execution status of this line is deduced): emitLineTo(line_to_pos.x, line_to_pos.y); | - |
1253 | } else { executed: } Execution Count:2 | 2 |
1254 | hasMoveTo = false; never executed (the execution status of this line is deduced): hasMoveTo = false; | - |
1255 | } | 0 |
1256 | move_to_pos = line_to_pos; executed (the execution status of this line is deduced): move_to_pos = line_to_pos; | - |
1257 | } else { executed: } Execution Count:2 | 2 |
1258 | move_to_pos.x = qt_real_to_fixed(p2.x()); executed (the execution status of this line is deduced): move_to_pos.x = qfixed(p2.x()); | - |
1259 | move_to_pos.y = qt_real_to_fixed(p2.y()); executed (the execution status of this line is deduced): move_to_pos.y = qfixed(p2.y()); | - |
1260 | } executed: } Execution Count:2 | 2 |
1261 | } | - |
1262 | | - |
1263 | // Shuffle to the next cycle... | - |
1264 | estart = estop; executed (the execution status of this line is deduced): estart = estop; | - |
1265 | prev = e; executed (the execution status of this line is deduced): prev = e; | - |
1266 | } executed: } Execution Count:1 | 1 |
1267 | | - |
1268 | } executed: } Execution Count:1 | 1 |
1269 | | - |
1270 | QT_END_NAMESPACE | - |
1271 | | - |
| | |