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