qoutlinemapper.cpp

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

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