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 "qregion.h" | - |
43 | #include "qpainterpath.h" | - |
44 | #include "qpolygon.h" | - |
45 | #include "qbuffer.h" | - |
46 | #include "qdatastream.h" | - |
47 | #include "qvariant.h" | - |
48 | #include "qvarlengtharray.h" | - |
49 | #include "qimage.h" | - |
50 | #include "qbitmap.h" | - |
51 | | - |
52 | #include <qdebug.h> | - |
53 | | - |
54 | QT_BEGIN_NAMESPACE | - |
55 | | - |
56 | /*! | - |
57 | \class QRegion | - |
58 | \brief The QRegion class specifies a clip region for a painter. | - |
59 | | - |
60 | \inmodule QtGui | - |
61 | \ingroup painting | - |
62 | \ingroup shared | - |
63 | | - |
64 | QRegion is used with QPainter::setClipRegion() to limit the paint | - |
65 | area to what needs to be painted. There is also a QWidget::repaint() | - |
66 | function that takes a QRegion parameter. QRegion is the best tool for | - |
67 | minimizing the amount of screen area to be updated by a repaint. | - |
68 | | - |
69 | This class is not suitable for constructing shapes for rendering, especially | - |
70 | as outlines. Use QPainterPath to create paths and shapes for use with | - |
71 | QPainter. | - |
72 | | - |
73 | QRegion is an \l{implicitly shared} class. | - |
74 | | - |
75 | \section1 Creating and Using Regions | - |
76 | | - |
77 | A region can be created from a rectangle, an ellipse, a polygon or | - |
78 | a bitmap. Complex regions may be created by combining simple | - |
79 | regions using united(), intersected(), subtracted(), or xored() (exclusive | - |
80 | or). You can move a region using translate(). | - |
81 | | - |
82 | You can test whether a region isEmpty() or if it | - |
83 | contains() a QPoint or QRect. The bounding rectangle can be found | - |
84 | with boundingRect(). | - |
85 | | - |
86 | The function rects() gives a decomposition of the region into | - |
87 | rectangles. | - |
88 | | - |
89 | Example of using complex regions: | - |
90 | \snippet code/src_gui_painting_qregion.cpp 0 | - |
91 | | - |
92 | \section1 Additional License Information | - |
93 | | - |
94 | On Embedded Linux, Windows CE and X11 platforms, parts of this class rely on | - |
95 | code obtained under the following licenses: | - |
96 | | - |
97 | \legalese | - |
98 | Copyright (c) 1987 X Consortium | - |
99 | | - |
100 | Permission is hereby granted, free of charge, to any person obtaining a copy | - |
101 | of this software and associated documentation files (the "Software"), to deal | - |
102 | in the Software without restriction, including without limitation the rights | - |
103 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | - |
104 | copies of the Software, and to permit persons to whom the Software is | - |
105 | furnished to do so, subject to the following conditions: | - |
106 | | - |
107 | The above copyright notice and this permission notice shall be included in | - |
108 | all copies or substantial portions of the Software. | - |
109 | | - |
110 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | - |
111 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | - |
112 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | - |
113 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | - |
114 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | - |
115 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | - |
116 | | - |
117 | Except as contained in this notice, the name of the X Consortium shall not be | - |
118 | used in advertising or otherwise to promote the sale, use or other dealings | - |
119 | in this Software without prior written authorization from the X Consortium. | - |
120 | \endlegalese | - |
121 | | - |
122 | \br | - |
123 | | - |
124 | \legalese | - |
125 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. | - |
126 | | - |
127 | All Rights Reserved | - |
128 | | - |
129 | Permission to use, copy, modify, and distribute this software and its | - |
130 | documentation for any purpose and without fee is hereby granted, | - |
131 | provided that the above copyright notice appear in all copies and that | - |
132 | both that copyright notice and this permission notice appear in | - |
133 | supporting documentation, and that the name of Digital not be | - |
134 | used in advertising or publicity pertaining to distribution of the | - |
135 | software without specific, written prior permission. | - |
136 | | - |
137 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | - |
138 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | - |
139 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | - |
140 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | - |
141 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | - |
142 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | - |
143 | SOFTWARE. | - |
144 | \endlegalese | - |
145 | | - |
146 | \sa QPainter::setClipRegion(), QPainter::setClipRect(), QPainterPath | - |
147 | */ | - |
148 | | - |
149 | | - |
150 | /*! | - |
151 | \enum QRegion::RegionType | - |
152 | | - |
153 | Specifies the shape of the region to be created. | - |
154 | | - |
155 | \value Rectangle the region covers the entire rectangle. | - |
156 | \value Ellipse the region is an ellipse inside the rectangle. | - |
157 | */ | - |
158 | | - |
159 | /*! | - |
160 | \fn void QRegion::translate(const QPoint &point) | - |
161 | | - |
162 | \overload | - |
163 | | - |
164 | Translates the region \a{point}\e{.x()} along the x axis and | - |
165 | \a{point}\e{.y()} along the y axis, relative to the current | - |
166 | position. Positive values move the region to the right and down. | - |
167 | | - |
168 | Translates to the given \a point. | - |
169 | */ | - |
170 | | - |
171 | /***************************************************************************** | - |
172 | QRegion member functions | - |
173 | *****************************************************************************/ | - |
174 | | - |
175 | /*! | - |
176 | \fn QRegion::QRegion() | - |
177 | | - |
178 | Constructs an empty region. | - |
179 | | - |
180 | \sa isEmpty() | - |
181 | */ | - |
182 | | - |
183 | /*! | - |
184 | \fn QRegion::QRegion(const QRect &r, RegionType t) | - |
185 | \overload | - |
186 | | - |
187 | Create a region based on the rectange \a r with region type \a t. | - |
188 | | - |
189 | If the rectangle is invalid a null region will be created. | - |
190 | | - |
191 | \sa QRegion::RegionType | - |
192 | */ | - |
193 | | - |
194 | /*! | - |
195 | \fn QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) | - |
196 | | - |
197 | Constructs a polygon region from the point array \a a with the fill rule | - |
198 | specified by \a fillRule. | - |
199 | | - |
200 | If \a fillRule is \l{Qt::WindingFill}, the polygon region is defined | - |
201 | using the winding algorithm; if it is \l{Qt::OddEvenFill}, the odd-even fill | - |
202 | algorithm is used. | - |
203 | | - |
204 | \warning This constructor can be used to create complex regions that will | - |
205 | slow down painting when used. | - |
206 | */ | - |
207 | | - |
208 | /*! | - |
209 | \fn QRegion::QRegion(const QRegion &r) | - |
210 | | - |
211 | Constructs a new region which is equal to region \a r. | - |
212 | */ | - |
213 | | - |
214 | /*! | - |
215 | \fn QRegion::QRegion(const QBitmap &bm) | - |
216 | | - |
217 | Constructs a region from the bitmap \a bm. | - |
218 | | - |
219 | The resulting region consists of the pixels in bitmap \a bm that | - |
220 | are Qt::color1, as if each pixel was a 1 by 1 rectangle. | - |
221 | | - |
222 | This constructor may create complex regions that will slow down | - |
223 | painting when used. Note that drawing masked pixmaps can be done | - |
224 | much faster using QPixmap::setMask(). | - |
225 | */ | - |
226 | | - |
227 | /*! | - |
228 | Constructs a rectangular or elliptic region. | - |
229 | | - |
230 | If \a t is \c Rectangle, the region is the filled rectangle (\a x, | - |
231 | \a y, \a w, \a h). If \a t is \c Ellipse, the region is the filled | - |
232 | ellipse with center at (\a x + \a w / 2, \a y + \a h / 2) and size | - |
233 | (\a w ,\a h). | - |
234 | */ | - |
235 | QRegion::QRegion(int x, int y, int w, int h, RegionType t) | - |
236 | { | - |
237 | QRegion tmp(QRect(x, y, w, h), t); executed (the execution status of this line is deduced): QRegion tmp(QRect(x, y, w, h), t); | - |
238 | tmp.d->ref.ref(); executed (the execution status of this line is deduced): tmp.d->ref.ref(); | - |
239 | d = tmp.d; executed (the execution status of this line is deduced): d = tmp.d; | - |
240 | } executed: } Execution Count:14706 | 14706 |
241 | | - |
242 | /*! | - |
243 | \fn QRegion::~QRegion() | - |
244 | \internal | - |
245 | | - |
246 | Destroys the region. | - |
247 | */ | - |
248 | | - |
249 | void QRegion::detach() | - |
250 | { | - |
251 | if (d->ref.load() != 1) evaluated: d->ref.load() != 1 yes Evaluation Count:64594 | yes Evaluation Count:42399 |
| 42399-64594 |
252 | *this = copy(); executed: *this = copy(); Execution Count:64594 | 64594 |
253 | } executed: } Execution Count:106993 | 106993 |
254 | | - |
255 | // duplicates in qregion_win.cpp and qregion_wce.cpp | - |
256 | #define QRGN_SETRECT 1 // region stream commands | - |
257 | #define QRGN_SETELLIPSE 2 // (these are internal) | - |
258 | #define QRGN_SETPTARRAY_ALT 3 | - |
259 | #define QRGN_SETPTARRAY_WIND 4 | - |
260 | #define QRGN_TRANSLATE 5 | - |
261 | #define QRGN_OR 6 | - |
262 | #define QRGN_AND 7 | - |
263 | #define QRGN_SUB 8 | - |
264 | #define QRGN_XOR 9 | - |
265 | #define QRGN_RECTS 10 | - |
266 | | - |
267 | | - |
268 | #ifndef QT_NO_DATASTREAM | - |
269 | | - |
270 | /* | - |
271 | Executes region commands in the internal buffer and rebuilds the | - |
272 | original region. | - |
273 | | - |
274 | We do this when we read a region from the data stream. | - |
275 | | - |
276 | If \a ver is non-0, uses the format version \a ver on reading the | - |
277 | byte array. | - |
278 | */ | - |
279 | void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byteOrder) | - |
280 | { | - |
281 | QByteArray copy = buffer; executed (the execution status of this line is deduced): QByteArray copy = buffer; | - |
282 | QDataStream s(©, QIODevice::ReadOnly); executed (the execution status of this line is deduced): QDataStream s(©, QIODevice::ReadOnly); | - |
283 | if (ver) partially evaluated: ver yes Evaluation Count:74 | no Evaluation Count:0 |
| 0-74 |
284 | s.setVersion(ver); executed: s.setVersion(ver); Execution Count:74 | 74 |
285 | s.setByteOrder(byteOrder); executed (the execution status of this line is deduced): s.setByteOrder(byteOrder); | - |
286 | QRegion rgn; executed (the execution status of this line is deduced): QRegion rgn; | - |
287 | #ifndef QT_NO_DEBUG | - |
288 | int test_cnt = 0; | - |
289 | #endif | - |
290 | while (!s.atEnd()) { evaluated: !s.atEnd() yes Evaluation Count:31 | yes Evaluation Count:74 |
| 31-74 |
291 | qint32 id; executed (the execution status of this line is deduced): qint32 id; | - |
292 | if (s.version() == 1) { partially evaluated: s.version() == 1 no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
293 | int id_int; never executed (the execution status of this line is deduced): int id_int; | - |
294 | s >> id_int; never executed (the execution status of this line is deduced): s >> id_int; | - |
295 | id = id_int; never executed (the execution status of this line is deduced): id = id_int; | - |
296 | } else { | 0 |
297 | s >> id; executed (the execution status of this line is deduced): s >> id; | - |
298 | } executed: } Execution Count:31 | 31 |
299 | #ifndef QT_NO_DEBUG | - |
300 | if (test_cnt > 0 && id != QRGN_TRANSLATE) | - |
301 | qWarning("QRegion::exec: Internal error"); | - |
302 | test_cnt++; | - |
303 | #endif | - |
304 | if (id == QRGN_SETRECT || id == QRGN_SETELLIPSE) { partially evaluated: id == 1 no Evaluation Count:0 | yes Evaluation Count:31 |
partially evaluated: id == 2 no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
305 | QRect r; never executed (the execution status of this line is deduced): QRect r; | - |
306 | s >> r; never executed (the execution status of this line is deduced): s >> r; | - |
307 | rgn = QRegion(r, id == QRGN_SETRECT ? Rectangle : Ellipse); never executed (the execution status of this line is deduced): rgn = QRegion(r, id == 1 ? Rectangle : Ellipse); | - |
308 | } else if (id == QRGN_SETPTARRAY_ALT || id == QRGN_SETPTARRAY_WIND) { never executed: } partially evaluated: id == 3 no Evaluation Count:0 | yes Evaluation Count:31 |
partially evaluated: id == 4 no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
309 | QPolygon a; never executed (the execution status of this line is deduced): QPolygon a; | - |
310 | s >> a; never executed (the execution status of this line is deduced): s >> a; | - |
311 | rgn = QRegion(a, id == QRGN_SETPTARRAY_WIND ? Qt::WindingFill : Qt::OddEvenFill); never executed (the execution status of this line is deduced): rgn = QRegion(a, id == 4 ? Qt::WindingFill : Qt::OddEvenFill); | - |
312 | } else if (id == QRGN_TRANSLATE) { never executed: } partially evaluated: id == 5 no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
313 | QPoint p; never executed (the execution status of this line is deduced): QPoint p; | - |
314 | s >> p; never executed (the execution status of this line is deduced): s >> p; | - |
315 | rgn.translate(p.x(), p.y()); never executed (the execution status of this line is deduced): rgn.translate(p.x(), p.y()); | - |
316 | } else if (id >= QRGN_OR && id <= QRGN_XOR) { never executed: } partially evaluated: id >= 6 yes Evaluation Count:31 | no Evaluation Count:0 |
partially evaluated: id <= 9 no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
317 | QByteArray bop1, bop2; never executed (the execution status of this line is deduced): QByteArray bop1, bop2; | - |
318 | QRegion r1, r2; never executed (the execution status of this line is deduced): QRegion r1, r2; | - |
319 | s >> bop1; never executed (the execution status of this line is deduced): s >> bop1; | - |
320 | r1.exec(bop1); never executed (the execution status of this line is deduced): r1.exec(bop1); | - |
321 | s >> bop2; never executed (the execution status of this line is deduced): s >> bop2; | - |
322 | r2.exec(bop2); never executed (the execution status of this line is deduced): r2.exec(bop2); | - |
323 | | - |
324 | switch (id) { | - |
325 | case QRGN_OR: | - |
326 | rgn = r1.united(r2); never executed (the execution status of this line is deduced): rgn = r1.united(r2); | - |
327 | break; | 0 |
328 | case QRGN_AND: | - |
329 | rgn = r1.intersected(r2); never executed (the execution status of this line is deduced): rgn = r1.intersected(r2); | - |
330 | break; | 0 |
331 | case QRGN_SUB: | - |
332 | rgn = r1.subtracted(r2); never executed (the execution status of this line is deduced): rgn = r1.subtracted(r2); | - |
333 | break; | 0 |
334 | case QRGN_XOR: | - |
335 | rgn = r1.xored(r2); never executed (the execution status of this line is deduced): rgn = r1.xored(r2); | - |
336 | break; | 0 |
337 | } | - |
338 | } else if (id == QRGN_RECTS) { never executed: } partially evaluated: id == 10 yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
339 | // (This is the only form used in Qt 2.0) | - |
340 | quint32 n; executed (the execution status of this line is deduced): quint32 n; | - |
341 | s >> n; executed (the execution status of this line is deduced): s >> n; | - |
342 | QRect r; executed (the execution status of this line is deduced): QRect r; | - |
343 | for (int i=0; i<(int)n; i++) { evaluated: i<(int)n yes Evaluation Count:31 | yes Evaluation Count:31 |
| 31 |
344 | s >> r; executed (the execution status of this line is deduced): s >> r; | - |
345 | rgn = rgn.united(QRegion(r)); executed (the execution status of this line is deduced): rgn = rgn.united(QRegion(r)); | - |
346 | } executed: } Execution Count:31 | 31 |
347 | } executed: } Execution Count:31 | 31 |
348 | } | - |
349 | *this = rgn; executed (the execution status of this line is deduced): *this = rgn; | - |
350 | } executed: } Execution Count:74 | 74 |
351 | | - |
352 | | - |
353 | /***************************************************************************** | - |
354 | QRegion stream functions | - |
355 | *****************************************************************************/ | - |
356 | | - |
357 | /*! | - |
358 | \fn QRegion &QRegion::operator=(const QRegion &r) | - |
359 | | - |
360 | Assigns \a r to this region and returns a reference to the region. | - |
361 | */ | - |
362 | | - |
363 | /*! | - |
364 | \fn void QRegion::swap(QRegion &other) | - |
365 | \since 4.8 | - |
366 | | - |
367 | Swaps region \a other with this region. This operation is very | - |
368 | fast and never fails. | - |
369 | */ | - |
370 | | - |
371 | /*! | - |
372 | \relates QRegion | - |
373 | | - |
374 | Writes the region \a r to the stream \a s and returns a reference | - |
375 | to the stream. | - |
376 | | - |
377 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - |
378 | */ | - |
379 | | - |
380 | QDataStream &operator<<(QDataStream &s, const QRegion &r) | - |
381 | { | - |
382 | QVector<QRect> a = r.rects(); executed (the execution status of this line is deduced): QVector<QRect> a = r.rects(); | - |
383 | if (a.isEmpty()) { evaluated: a.isEmpty() yes Evaluation Count:43 | yes Evaluation Count:31 |
| 31-43 |
384 | s << (quint32)0; executed (the execution status of this line is deduced): s << (quint32)0; | - |
385 | } else { executed: } Execution Count:43 | 43 |
386 | if (s.version() == 1) { partially evaluated: s.version() == 1 no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
387 | int i; never executed (the execution status of this line is deduced): int i; | - |
388 | for (i = a.size() - 1; i > 0; --i) { | 0 |
389 | s << (quint32)(12 + i * 24); never executed (the execution status of this line is deduced): s << (quint32)(12 + i * 24); | - |
390 | s << (int)QRGN_OR; never executed (the execution status of this line is deduced): s << (int)6; | - |
391 | } | 0 |
392 | for (i = 0; i < a.size(); ++i) { never evaluated: i < a.size() | 0 |
393 | s << (quint32)(4+8) << (int)QRGN_SETRECT << a[i]; never executed (the execution status of this line is deduced): s << (quint32)(4+8) << (int)1 << a[i]; | - |
394 | } | 0 |
395 | } else { | 0 |
396 | s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect executed (the execution status of this line is deduced): s << (quint32)(4 + 4 + 16 * a.size()); | - |
397 | s << (qint32)QRGN_RECTS; executed (the execution status of this line is deduced): s << (qint32)10; | - |
398 | s << a; executed (the execution status of this line is deduced): s << a; | - |
399 | } executed: } Execution Count:31 | 31 |
400 | } | - |
401 | return s; executed: return s; Execution Count:74 | 74 |
402 | } | - |
403 | | - |
404 | /*! | - |
405 | \relates QRegion | - |
406 | | - |
407 | Reads a region from the stream \a s into \a r and returns a | - |
408 | reference to the stream. | - |
409 | | - |
410 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - |
411 | */ | - |
412 | | - |
413 | QDataStream &operator>>(QDataStream &s, QRegion &r) | - |
414 | { | - |
415 | QByteArray b; executed (the execution status of this line is deduced): QByteArray b; | - |
416 | s >> b; executed (the execution status of this line is deduced): s >> b; | - |
417 | r.exec(b, s.version(), s.byteOrder()); executed (the execution status of this line is deduced): r.exec(b, s.version(), s.byteOrder()); | - |
418 | return s; executed: return s; Execution Count:74 | 74 |
419 | } | - |
420 | #endif //QT_NO_DATASTREAM | - |
421 | | - |
422 | #ifndef QT_NO_DEBUG_STREAM | - |
423 | QDebug operator<<(QDebug s, const QRegion &r) | - |
424 | { | - |
425 | QVector<QRect> rects = r.rects(); executed (the execution status of this line is deduced): QVector<QRect> rects = r.rects(); | - |
426 | s.nospace() << "QRegion(size=" << rects.size() << "), " executed (the execution status of this line is deduced): s.nospace() << "QRegion(size=" << rects.size() << "), " | - |
427 | << "bounds = " << r.boundingRect() << '\n'; executed (the execution status of this line is deduced): << "bounds = " << r.boundingRect() << '\n'; | - |
428 | for (int i=0; i<rects.size(); ++i) partially evaluated: i<rects.size() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
429 | s << "- " << i << rects.at(i) << '\n'; never executed: s << "- " << i << rects.at(i) << '\n'; | 0 |
430 | return s; executed: return s; Execution Count:1 | 1 |
431 | } | - |
432 | #endif | - |
433 | | - |
434 | | - |
435 | // These are not inline - they can be implemented better on some platforms | - |
436 | // (eg. Windows at least provides 3-variable operations). For now, simple. | - |
437 | | - |
438 | | - |
439 | /*! | - |
440 | Applies the united() function to this region and \a r. \c r1|r2 is | - |
441 | equivalent to \c r1.united(r2). | - |
442 | | - |
443 | \sa united(), operator+() | - |
444 | */ | - |
445 | const QRegion QRegion::operator|(const QRegion &r) const | - |
446 | { return united(r); } executed: return united(r); Execution Count:19683 | 19683 |
447 | | - |
448 | /*! | - |
449 | Applies the united() function to this region and \a r. \c r1+r2 is | - |
450 | equivalent to \c r1.united(r2). | - |
451 | | - |
452 | \sa united(), operator|() | - |
453 | */ | - |
454 | const QRegion QRegion::operator+(const QRegion &r) const | - |
455 | { return united(r); } executed: return united(r); Execution Count:56 | 56 |
456 | | - |
457 | /*! | - |
458 | \overload | - |
459 | \since 4.4 | - |
460 | */ | - |
461 | const QRegion QRegion::operator+(const QRect &r) const | - |
462 | { return united(r); } executed: return united(r); Execution Count:34 | 34 |
463 | | - |
464 | /*! | - |
465 | Applies the intersected() function to this region and \a r. \c r1&r2 | - |
466 | is equivalent to \c r1.intersected(r2). | - |
467 | | - |
468 | \sa intersected() | - |
469 | */ | - |
470 | const QRegion QRegion::operator&(const QRegion &r) const | - |
471 | { return intersected(r); } executed: return intersected(r); Execution Count:417 | 417 |
472 | | - |
473 | /*! | - |
474 | \overload | - |
475 | \since 4.4 | - |
476 | */ | - |
477 | const QRegion QRegion::operator&(const QRect &r) const | - |
478 | { | - |
479 | return intersected(r); executed: return intersected(r); Execution Count:94128 | 94128 |
480 | } | - |
481 | | - |
482 | /*! | - |
483 | Applies the subtracted() function to this region and \a r. \c r1-r2 | - |
484 | is equivalent to \c r1.subtracted(r2). | - |
485 | | - |
486 | \sa subtracted() | - |
487 | */ | - |
488 | const QRegion QRegion::operator-(const QRegion &r) const | - |
489 | { return subtracted(r); } executed: return subtracted(r); Execution Count:22593 | 22593 |
490 | | - |
491 | /*! | - |
492 | Applies the xored() function to this region and \a r. \c r1^r2 is | - |
493 | equivalent to \c r1.xored(r2). | - |
494 | | - |
495 | \sa xored() | - |
496 | */ | - |
497 | const QRegion QRegion::operator^(const QRegion &r) const | - |
498 | { return xored(r); } executed: return xored(r); Execution Count:21 | 21 |
499 | | - |
500 | /*! | - |
501 | Applies the united() function to this region and \a r and assigns | - |
502 | the result to this region. \c r1|=r2 is equivalent to \c | - |
503 | {r1 = r1.united(r2)}. | - |
504 | | - |
505 | \sa united() | - |
506 | */ | - |
507 | QRegion& QRegion::operator|=(const QRegion &r) | - |
508 | { return *this = *this | r; } executed: return *this = *this | r; Execution Count:3059 | 3059 |
509 | | - |
510 | /*! | - |
511 | \fn QRegion& QRegion::operator+=(const QRect &rect) | - |
512 | | - |
513 | Returns a region that is the union of this region with the specified \a rect. | - |
514 | | - |
515 | \sa united() | - |
516 | */ | - |
517 | /*! | - |
518 | \fn QRegion& QRegion::operator+=(const QRegion &r) | - |
519 | | - |
520 | Applies the united() function to this region and \a r and assigns | - |
521 | the result to this region. \c r1+=r2 is equivalent to \c | - |
522 | {r1 = r1.united(r2)}. | - |
523 | | - |
524 | \sa intersected() | - |
525 | */ | - |
526 | #if !defined (Q_OS_UNIX) && !defined (Q_OS_WIN) | - |
527 | QRegion& QRegion::operator+=(const QRect &r) | - |
528 | { | - |
529 | return operator+=(QRegion(r)); | - |
530 | } | - |
531 | #endif | - |
532 | | - |
533 | /*! | - |
534 | \fn QRegion& QRegion::operator&=(const QRegion &r) | - |
535 | | - |
536 | Applies the intersected() function to this region and \a r and | - |
537 | assigns the result to this region. \c r1&=r2 is equivalent to \c | - |
538 | r1 = r1.intersected(r2). | - |
539 | | - |
540 | \sa intersected() | - |
541 | */ | - |
542 | QRegion& QRegion::operator&=(const QRegion &r) | - |
543 | { return *this = *this & r; } executed: return *this = *this & r; Execution Count:103 | 103 |
544 | | - |
545 | /*! | - |
546 | \overload | - |
547 | \since 4.4 | - |
548 | */ | - |
549 | #if defined (Q_OS_UNIX) || defined (Q_OS_WIN) | - |
550 | QRegion& QRegion::operator&=(const QRect &r) | - |
551 | { | - |
552 | return *this = *this & r; executed: return *this = *this & r; Execution Count:50457 | 50457 |
553 | } | - |
554 | #else | - |
555 | QRegion& QRegion::operator&=(const QRect &r) | - |
556 | { | - |
557 | return *this &= (QRegion(r)); | - |
558 | } | - |
559 | #endif | - |
560 | | - |
561 | /*! | - |
562 | \fn QRegion& QRegion::operator-=(const QRegion &r) | - |
563 | | - |
564 | Applies the subtracted() function to this region and \a r and | - |
565 | assigns the result to this region. \c r1-=r2 is equivalent to \c | - |
566 | {r1 = r1.subtracted(r2)}. | - |
567 | | - |
568 | \sa subtracted() | - |
569 | */ | - |
570 | QRegion& QRegion::operator-=(const QRegion &r) | - |
571 | { return *this = *this - r; } executed: return *this = *this - r; Execution Count:18760 | 18760 |
572 | | - |
573 | /*! | - |
574 | Applies the xored() function to this region and \a r and | - |
575 | assigns the result to this region. \c r1^=r2 is equivalent to \c | - |
576 | {r1 = r1.xored(r2)}. | - |
577 | | - |
578 | \sa xored() | - |
579 | */ | - |
580 | QRegion& QRegion::operator^=(const QRegion &r) | - |
581 | { return *this = *this ^ r; } executed: return *this = *this ^ r; Execution Count:11 | 11 |
582 | | - |
583 | /*! | - |
584 | \fn bool QRegion::operator!=(const QRegion &other) const | - |
585 | | - |
586 | Returns true if this region is different from the \a other region; | - |
587 | otherwise returns false. | - |
588 | */ | - |
589 | | - |
590 | /*! | - |
591 | Returns the region as a QVariant | - |
592 | */ | - |
593 | QRegion::operator QVariant() const | - |
594 | { | - |
595 | return QVariant(QVariant::Region, this); executed: return QVariant(QVariant::Region, this); Execution Count:1 | 1 |
596 | } | - |
597 | | - |
598 | /*! | - |
599 | \fn bool QRegion::operator==(const QRegion &r) const | - |
600 | | - |
601 | Returns true if the region is equal to \a r; otherwise returns | - |
602 | false. | - |
603 | */ | - |
604 | | - |
605 | /*! | - |
606 | \fn void QRegion::translate(int dx, int dy) | - |
607 | | - |
608 | Translates (moves) the region \a dx along the X axis and \a dy | - |
609 | along the Y axis. | - |
610 | */ | - |
611 | | - |
612 | /*! | - |
613 | \fn QRegion QRegion::translated(const QPoint &p) const | - |
614 | \overload | - |
615 | \since 4.1 | - |
616 | | - |
617 | Returns a copy of the regtion that is translated \a{p}\e{.x()} | - |
618 | along the x axis and \a{p}\e{.y()} along the y axis, relative to | - |
619 | the current position. Positive values move the rectangle to the | - |
620 | right and down. | - |
621 | | - |
622 | \sa translate() | - |
623 | */ | - |
624 | | - |
625 | /*! | - |
626 | \since 4.1 | - |
627 | | - |
628 | Returns a copy of the region that is translated \a dx along the | - |
629 | x axis and \a dy along the y axis, relative to the current | - |
630 | position. Positive values move the region to the right and | - |
631 | down. | - |
632 | | - |
633 | \sa translate() | - |
634 | */ | - |
635 | | - |
636 | QRegion | - |
637 | QRegion::translated(int dx, int dy) const | - |
638 | { | - |
639 | QRegion ret(*this); executed (the execution status of this line is deduced): QRegion ret(*this); | - |
640 | ret.translate(dx, dy); executed (the execution status of this line is deduced): ret.translate(dx, dy); | - |
641 | return ret; executed: return ret; Execution Count:38831 | 38831 |
642 | } | - |
643 | | - |
644 | | - |
645 | inline bool rect_intersects(const QRect &r1, const QRect &r2) | - |
646 | { | - |
647 | return (r1.right() >= r2.left() && r1.left() <= r2.right() && executed: return (r1.right() >= r2.left() && r1.left() <= r2.right() && r1.bottom() >= r2.top() && r1.top() <= r2.bottom()); Execution Count:38201 | 38201 |
648 | r1.bottom() >= r2.top() && r1.top() <= r2.bottom()); executed: return (r1.right() >= r2.left() && r1.left() <= r2.right() && r1.bottom() >= r2.top() && r1.top() <= r2.bottom()); Execution Count:38201 | 38201 |
649 | } | - |
650 | | - |
651 | /*! | - |
652 | \since 4.2 | - |
653 | | - |
654 | Returns true if this region intersects with \a region, otherwise | - |
655 | returns false. | - |
656 | */ | - |
657 | bool QRegion::intersects(const QRegion ®ion) const | - |
658 | { | - |
659 | if (isEmpty() || region.isEmpty()) evaluated: isEmpty() yes Evaluation Count:3241 | yes Evaluation Count:4839 |
partially evaluated: region.isEmpty() no Evaluation Count:0 | yes Evaluation Count:4839 |
| 0-4839 |
660 | return false; executed: return false; Execution Count:3241 | 3241 |
661 | | - |
662 | if (!rect_intersects(boundingRect(), region.boundingRect())) evaluated: !rect_intersects(boundingRect(), region.boundingRect()) yes Evaluation Count:55 | yes Evaluation Count:4784 |
| 55-4784 |
663 | return false; executed: return false; Execution Count:55 | 55 |
664 | if (rectCount() == 1 && region.rectCount() == 1) evaluated: rectCount() == 1 yes Evaluation Count:3258 | yes Evaluation Count:1526 |
evaluated: region.rectCount() == 1 yes Evaluation Count:2614 | yes Evaluation Count:644 |
| 644-3258 |
665 | return true; executed: return true; Execution Count:2614 | 2614 |
666 | | - |
667 | const QVector<QRect> myRects = rects(); executed (the execution status of this line is deduced): const QVector<QRect> myRects = rects(); | - |
668 | const QVector<QRect> otherRects = region.rects(); executed (the execution status of this line is deduced): const QVector<QRect> otherRects = region.rects(); | - |
669 | | - |
670 | for (QVector<QRect>::const_iterator i1 = myRects.constBegin(); i1 < myRects.constEnd(); ++i1) evaluated: i1 < myRects.constEnd() yes Evaluation Count:3190 | yes Evaluation Count:182 |
| 182-3190 |
671 | for (QVector<QRect>::const_iterator i2 = otherRects.constBegin(); i2 < otherRects.constEnd(); ++i2) evaluated: i2 < otherRects.constEnd() yes Evaluation Count:13000 | yes Evaluation Count:1202 |
| 1202-13000 |
672 | if (rect_intersects(*i1, *i2)) evaluated: rect_intersects(*i1, *i2) yes Evaluation Count:1988 | yes Evaluation Count:11012 |
| 1988-11012 |
673 | return true; executed: return true; Execution Count:1988 | 1988 |
674 | return false; executed: return false; Execution Count:182 | 182 |
675 | } | - |
676 | | - |
677 | /*! | - |
678 | \fn bool QRegion::intersects(const QRect &rect) const | - |
679 | \since 4.2 | - |
680 | | - |
681 | Returns true if this region intersects with \a rect, otherwise | - |
682 | returns false. | - |
683 | */ | - |
684 | | - |
685 | | - |
686 | #if !defined (Q_OS_UNIX) && !defined (Q_OS_WIN) | - |
687 | /*! | - |
688 | \overload | - |
689 | \since 4.4 | - |
690 | */ | - |
691 | QRegion QRegion::intersect(const QRect &r) const | - |
692 | { | - |
693 | return intersect(QRegion(r)); | - |
694 | } | - |
695 | #endif | - |
696 | | - |
697 | /*! | - |
698 | \fn int QRegion::rectCount() const | - |
699 | \since 4.6 | - |
700 | | - |
701 | Returns the number of rectangles that will be returned in rects(). | - |
702 | */ | - |
703 | | - |
704 | /*! | - |
705 | \fn bool QRegion::isEmpty() const | - |
706 | | - |
707 | Returns true if the region is empty; otherwise returns false. An | - |
708 | empty region is a region that contains no points. | - |
709 | | - |
710 | Example: | - |
711 | \snippet code/src_gui_painting_qregion_unix.cpp 0 | - |
712 | */ | - |
713 | | - |
714 | /*! | - |
715 | \fn bool QRegion::isNull() const | - |
716 | \since 5.0 | - |
717 | | - |
718 | Returns true if the region is empty; otherwise returns false. An | - |
719 | empty region is a region that contains no points. This function is | - |
720 | the same as isEmpty | - |
721 | | - |
722 | \sa isEmpty() | - |
723 | */ | - |
724 | | - |
725 | /*! | - |
726 | \fn bool QRegion::contains(const QPoint &p) const | - |
727 | | - |
728 | Returns true if the region contains the point \a p; otherwise | - |
729 | returns false. | - |
730 | */ | - |
731 | | - |
732 | /*! | - |
733 | \fn bool QRegion::contains(const QRect &r) const | - |
734 | \overload | - |
735 | | - |
736 | Returns true if the region overlaps the rectangle \a r; otherwise | - |
737 | returns false. | - |
738 | */ | - |
739 | | - |
740 | /*! | - |
741 | \fn QRegion QRegion::unite(const QRegion &r) const | - |
742 | \obsolete | - |
743 | | - |
744 | Use united(\a r) instead. | - |
745 | */ | - |
746 | | - |
747 | /*! | - |
748 | \fn QRegion QRegion::unite(const QRect &rect) const | - |
749 | \since 4.4 | - |
750 | \obsolete | - |
751 | | - |
752 | Use united(\a rect) instead. | - |
753 | */ | - |
754 | | - |
755 | /*! | - |
756 | \fn QRegion QRegion::united(const QRect &rect) const | - |
757 | \since 4.4 | - |
758 | | - |
759 | Returns a region which is the union of this region and the given \a rect. | - |
760 | | - |
761 | \sa intersected(), subtracted(), xored() | - |
762 | */ | - |
763 | | - |
764 | /*! | - |
765 | \fn QRegion QRegion::united(const QRegion &r) const | - |
766 | \since 4.2 | - |
767 | | - |
768 | Returns a region which is the union of this region and \a r. | - |
769 | | - |
770 | \image runion.png Region Union | - |
771 | | - |
772 | The figure shows the union of two elliptical regions. | - |
773 | | - |
774 | \sa intersected(), subtracted(), xored() | - |
775 | */ | - |
776 | | - |
777 | /*! | - |
778 | \fn QRegion QRegion::intersect(const QRegion &r) const | - |
779 | \obsolete | - |
780 | | - |
781 | Use intersected(\a r) instead. | - |
782 | */ | - |
783 | | - |
784 | /*! | - |
785 | \fn QRegion QRegion::intersect(const QRect &rect) const | - |
786 | \since 4.4 | - |
787 | \obsolete | - |
788 | | - |
789 | Use intersected(\a rect) instead. | - |
790 | */ | - |
791 | | - |
792 | /*! | - |
793 | \fn QRegion QRegion::intersected(const QRect &rect) const | - |
794 | \since 4.4 | - |
795 | | - |
796 | Returns a region which is the intersection of this region and the given \a rect. | - |
797 | | - |
798 | \sa subtracted(), united(), xored() | - |
799 | */ | - |
800 | | - |
801 | /*! | - |
802 | \fn QRegion QRegion::intersected(const QRegion &r) const | - |
803 | \since 4.2 | - |
804 | | - |
805 | Returns a region which is the intersection of this region and \a r. | - |
806 | | - |
807 | \image rintersect.png Region Intersection | - |
808 | | - |
809 | The figure shows the intersection of two elliptical regions. | - |
810 | | - |
811 | \sa subtracted(), united(), xored() | - |
812 | */ | - |
813 | | - |
814 | /*! | - |
815 | \fn QRegion QRegion::subtract(const QRegion &r) const | - |
816 | \obsolete | - |
817 | | - |
818 | Use subtracted(\a r) instead. | - |
819 | */ | - |
820 | | - |
821 | /*! | - |
822 | \fn QRegion QRegion::subtracted(const QRegion &r) const | - |
823 | \since 4.2 | - |
824 | | - |
825 | Returns a region which is \a r subtracted from this region. | - |
826 | | - |
827 | \image rsubtract.png Region Subtraction | - |
828 | | - |
829 | The figure shows the result when the ellipse on the right is | - |
830 | subtracted from the ellipse on the left (\c {left - right}). | - |
831 | | - |
832 | \sa intersected(), united(), xored() | - |
833 | */ | - |
834 | | - |
835 | /*! | - |
836 | \fn QRegion QRegion::eor(const QRegion &r) const | - |
837 | \obsolete | - |
838 | | - |
839 | Use xored(\a r) instead. | - |
840 | */ | - |
841 | | - |
842 | /*! | - |
843 | \fn QRegion QRegion::xored(const QRegion &r) const | - |
844 | \since 4.2 | - |
845 | | - |
846 | Returns a region which is the exclusive or (XOR) of this region | - |
847 | and \a r. | - |
848 | | - |
849 | \image rxor.png Region XORed | - |
850 | | - |
851 | The figure shows the exclusive or of two elliptical regions. | - |
852 | | - |
853 | \sa intersected(), united(), subtracted() | - |
854 | */ | - |
855 | | - |
856 | /*! | - |
857 | \fn QRect QRegion::boundingRect() const | - |
858 | | - |
859 | Returns the bounding rectangle of this region. An empty region | - |
860 | gives a rectangle that is QRect::isNull(). | - |
861 | */ | - |
862 | | - |
863 | /*! | - |
864 | \fn QVector<QRect> QRegion::rects() const | - |
865 | | - |
866 | Returns an array of non-overlapping rectangles that make up the | - |
867 | region. | - |
868 | | - |
869 | The union of all the rectangles is equal to the original region. | - |
870 | */ | - |
871 | | - |
872 | /*! | - |
873 | \fn void QRegion::setRects(const QRect *rects, int number) | - |
874 | | - |
875 | Sets the region using the array of rectangles specified by \a rects and | - |
876 | \a number. | - |
877 | The rectangles \e must be optimally Y-X sorted and follow these restrictions: | - |
878 | | - |
879 | \list | - |
880 | \li The rectangles must not intersect. | - |
881 | \li All rectangles with a given top coordinate must have the same height. | - |
882 | \li No two rectangles may abut horizontally (they should be combined | - |
883 | into a single wider rectangle in that case). | - |
884 | \li The rectangles must be sorted in ascending order, with Y as the major | - |
885 | sort key and X as the minor sort key. | - |
886 | \endlist | - |
887 | \omit | - |
888 | Only some platforms have these restrictions (Qt for Embedded Linux, X11 and Mac OS X). | - |
889 | \endomit | - |
890 | */ | - |
891 | | - |
892 | namespace { | - |
893 | | - |
894 | struct Segment | - |
895 | { | - |
896 | Segment() {} | - |
897 | Segment(const QPoint &p) | - |
898 | : added(false) | - |
899 | , point(p) | - |
900 | { | - |
901 | } | 0 |
902 | | - |
903 | int left() const | - |
904 | { | - |
905 | return qMin(point.x(), next->point.x()); never executed: return qMin(point.x(), next->point.x()); | 0 |
906 | } | - |
907 | | - |
908 | int right() const | - |
909 | { | - |
910 | return qMax(point.x(), next->point.x()); never executed: return qMax(point.x(), next->point.x()); | 0 |
911 | } | - |
912 | | - |
913 | bool overlaps(const Segment &other) const | - |
914 | { | - |
915 | return left() < other.right() && other.left() < right(); never executed: return left() < other.right() && other.left() < right(); | 0 |
916 | } | - |
917 | | - |
918 | void connect(Segment &other) | - |
919 | { | - |
920 | next = &other; never executed (the execution status of this line is deduced): next = &other; | - |
921 | other.prev = this; never executed (the execution status of this line is deduced): other.prev = this; | - |
922 | | - |
923 | horizontal = (point.y() == other.point.y()); never executed (the execution status of this line is deduced): horizontal = (point.y() == other.point.y()); | - |
924 | } | 0 |
925 | | - |
926 | void merge(Segment &other) | - |
927 | { | - |
928 | if (right() <= other.right()) { never evaluated: right() <= other.right() | 0 |
929 | QPoint p = other.point; never executed (the execution status of this line is deduced): QPoint p = other.point; | - |
930 | Segment *oprev = other.prev; never executed (the execution status of this line is deduced): Segment *oprev = other.prev; | - |
931 | | - |
932 | other.point = point; never executed (the execution status of this line is deduced): other.point = point; | - |
933 | other.prev = prev; never executed (the execution status of this line is deduced): other.prev = prev; | - |
934 | prev->next = &other; never executed (the execution status of this line is deduced): prev->next = &other; | - |
935 | | - |
936 | point = p; never executed (the execution status of this line is deduced): point = p; | - |
937 | prev = oprev; never executed (the execution status of this line is deduced): prev = oprev; | - |
938 | oprev->next = this; never executed (the execution status of this line is deduced): oprev->next = this; | - |
939 | } else { | 0 |
940 | Segment *onext = other.next; never executed (the execution status of this line is deduced): Segment *onext = other.next; | - |
941 | other.next = next; never executed (the execution status of this line is deduced): other.next = next; | - |
942 | next->prev = &other; never executed (the execution status of this line is deduced): next->prev = &other; | - |
943 | | - |
944 | next = onext; never executed (the execution status of this line is deduced): next = onext; | - |
945 | next->prev = this; never executed (the execution status of this line is deduced): next->prev = this; | - |
946 | } | 0 |
947 | } | - |
948 | | - |
949 | int horizontal : 1; | - |
950 | int added : 1; | - |
951 | | - |
952 | QPoint point; | - |
953 | Segment *prev; | - |
954 | Segment *next; | - |
955 | }; | - |
956 | | - |
957 | void mergeSegments(Segment *a, int na, Segment *b, int nb) | - |
958 | { | - |
959 | int i = 0; never executed (the execution status of this line is deduced): int i = 0; | - |
960 | int j = 0; never executed (the execution status of this line is deduced): int j = 0; | - |
961 | | - |
962 | while (i != na && j != nb) { never evaluated: i != na never evaluated: j != nb | 0 |
963 | Segment &sa = a[i]; never executed (the execution status of this line is deduced): Segment &sa = a[i]; | - |
964 | Segment &sb = b[j]; never executed (the execution status of this line is deduced): Segment &sb = b[j]; | - |
965 | const int ra = sa.right(); never executed (the execution status of this line is deduced): const int ra = sa.right(); | - |
966 | const int rb = sb.right(); never executed (the execution status of this line is deduced): const int rb = sb.right(); | - |
967 | if (sa.overlaps(sb)) never evaluated: sa.overlaps(sb) | 0 |
968 | sa.merge(sb); never executed: sa.merge(sb); | 0 |
969 | i += (rb >= ra); never executed (the execution status of this line is deduced): i += (rb >= ra); | - |
970 | j += (ra >= rb); never executed (the execution status of this line is deduced): j += (ra >= rb); | - |
971 | } | 0 |
972 | } | 0 |
973 | | - |
974 | void addSegmentsToPath(Segment *segment, QPainterPath &path) | - |
975 | { | - |
976 | Segment *current = segment; never executed (the execution status of this line is deduced): Segment *current = segment; | - |
977 | path.moveTo(current->point); never executed (the execution status of this line is deduced): path.moveTo(current->point); | - |
978 | | - |
979 | current->added = true; never executed (the execution status of this line is deduced): current->added = true; | - |
980 | | - |
981 | Segment *last = current; never executed (the execution status of this line is deduced): Segment *last = current; | - |
982 | current = current->next; never executed (the execution status of this line is deduced): current = current->next; | - |
983 | while (current != segment) { never evaluated: current != segment | 0 |
984 | if (current->horizontal != last->horizontal) never evaluated: current->horizontal != last->horizontal | 0 |
985 | path.lineTo(current->point); never executed: path.lineTo(current->point); | 0 |
986 | current->added = true; never executed (the execution status of this line is deduced): current->added = true; | - |
987 | last = current; never executed (the execution status of this line is deduced): last = current; | - |
988 | current = current->next; never executed (the execution status of this line is deduced): current = current->next; | - |
989 | } | 0 |
990 | } | 0 |
991 | | - |
992 | } | - |
993 | | - |
994 | Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) | - |
995 | { | - |
996 | QPainterPath result; executed (the execution status of this line is deduced): QPainterPath result; | - |
997 | if (region.rectCount() == 1) { partially evaluated: region.rectCount() == 1 yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
998 | result.addRect(region.boundingRect()); executed (the execution status of this line is deduced): result.addRect(region.boundingRect()); | - |
999 | return result; executed: return result; Execution Count:7 | 7 |
1000 | } | - |
1001 | | - |
1002 | const QVector<QRect> rects = region.rects(); never executed (the execution status of this line is deduced): const QVector<QRect> rects = region.rects(); | - |
1003 | | - |
1004 | QVarLengthArray<Segment> segments; never executed (the execution status of this line is deduced): QVarLengthArray<Segment> segments; | - |
1005 | segments.resize(4 * rects.size()); never executed (the execution status of this line is deduced): segments.resize(4 * rects.size()); | - |
1006 | | - |
1007 | const QRect *rect = rects.constData(); never executed (the execution status of this line is deduced): const QRect *rect = rects.constData(); | - |
1008 | const QRect *end = rect + rects.size(); never executed (the execution status of this line is deduced): const QRect *end = rect + rects.size(); | - |
1009 | | - |
1010 | int lastRowSegmentCount = 0; never executed (the execution status of this line is deduced): int lastRowSegmentCount = 0; | - |
1011 | Segment *lastRowSegments = 0; never executed (the execution status of this line is deduced): Segment *lastRowSegments = 0; | - |
1012 | | - |
1013 | int lastSegment = 0; never executed (the execution status of this line is deduced): int lastSegment = 0; | - |
1014 | int lastY = 0; never executed (the execution status of this line is deduced): int lastY = 0; | - |
1015 | while (rect != end) { never evaluated: rect != end | 0 |
1016 | const int y = rect[0].y(); never executed (the execution status of this line is deduced): const int y = rect[0].y(); | - |
1017 | int count = 0; never executed (the execution status of this line is deduced): int count = 0; | - |
1018 | while (&rect[count] != end && rect[count].y() == y) never evaluated: &rect[count] != end never evaluated: rect[count].y() == y | 0 |
1019 | ++count; | 0 |
1020 | | - |
1021 | for (int i = 0; i < count; ++i) { never evaluated: i < count | 0 |
1022 | int offset = lastSegment + i; never executed (the execution status of this line is deduced): int offset = lastSegment + i; | - |
1023 | segments[offset] = Segment(rect[i].topLeft()); never executed (the execution status of this line is deduced): segments[offset] = Segment(rect[i].topLeft()); | - |
1024 | segments[offset += count] = Segment(rect[i].topRight() + QPoint(1, 0)); never executed (the execution status of this line is deduced): segments[offset += count] = Segment(rect[i].topRight() + QPoint(1, 0)); | - |
1025 | segments[offset += count] = Segment(rect[i].bottomRight() + QPoint(1, 1)); never executed (the execution status of this line is deduced): segments[offset += count] = Segment(rect[i].bottomRight() + QPoint(1, 1)); | - |
1026 | segments[offset += count] = Segment(rect[i].bottomLeft() + QPoint(0, 1)); never executed (the execution status of this line is deduced): segments[offset += count] = Segment(rect[i].bottomLeft() + QPoint(0, 1)); | - |
1027 | | - |
1028 | offset = lastSegment + i; never executed (the execution status of this line is deduced): offset = lastSegment + i; | - |
1029 | for (int j = 0; j < 4; ++j) | 0 |
1030 | segments[offset + j * count].connect(segments[offset + ((j + 1) % 4) * count]); never executed: segments[offset + j * count].connect(segments[offset + ((j + 1) % 4) * count]); | 0 |
1031 | } | 0 |
1032 | | - |
1033 | if (lastRowSegments && lastY == y) never evaluated: lastRowSegments never evaluated: lastY == y | 0 |
1034 | mergeSegments(lastRowSegments, lastRowSegmentCount, &segments[lastSegment], count); never executed: mergeSegments(lastRowSegments, lastRowSegmentCount, &segments[lastSegment], count); | 0 |
1035 | | - |
1036 | lastRowSegments = &segments[lastSegment + 2 * count]; never executed (the execution status of this line is deduced): lastRowSegments = &segments[lastSegment + 2 * count]; | - |
1037 | lastRowSegmentCount = count; never executed (the execution status of this line is deduced): lastRowSegmentCount = count; | - |
1038 | lastSegment += 4 * count; never executed (the execution status of this line is deduced): lastSegment += 4 * count; | - |
1039 | lastY = y + rect[0].height(); never executed (the execution status of this line is deduced): lastY = y + rect[0].height(); | - |
1040 | rect += count; never executed (the execution status of this line is deduced): rect += count; | - |
1041 | } | 0 |
1042 | | - |
1043 | for (int i = 0; i < lastSegment; ++i) { never evaluated: i < lastSegment | 0 |
1044 | Segment *segment = &segments[i]; never executed (the execution status of this line is deduced): Segment *segment = &segments[i]; | - |
1045 | if (!segment->added) never evaluated: !segment->added | 0 |
1046 | addSegmentsToPath(segment, result); never executed: addSegmentsToPath(segment, result); | 0 |
1047 | } | 0 |
1048 | | - |
1049 | return result; never executed: return result; | 0 |
1050 | } | - |
1051 | | - |
1052 | #if defined(Q_OS_UNIX) || defined(Q_OS_WIN) | - |
1053 | | - |
1054 | //#define QT_REGION_DEBUG | - |
1055 | /* | - |
1056 | * clip region | - |
1057 | */ | - |
1058 | | - |
1059 | struct QRegionPrivate { | - |
1060 | int numRects; | - |
1061 | QVector<QRect> rects; | - |
1062 | QRect extents; | - |
1063 | QRect innerRect; | - |
1064 | int innerArea; | - |
1065 | | - |
1066 | inline QRegionPrivate() : numRects(0), innerArea(-1) {} executed: } Execution Count:270 | 270 |
1067 | inline QRegionPrivate(const QRect &r) { | - |
1068 | numRects = 1; executed (the execution status of this line is deduced): numRects = 1; | - |
1069 | extents = r; executed (the execution status of this line is deduced): extents = r; | - |
1070 | innerRect = r; executed (the execution status of this line is deduced): innerRect = r; | - |
1071 | innerArea = r.width() * r.height(); executed (the execution status of this line is deduced): innerArea = r.width() * r.height(); | - |
1072 | } executed: } Execution Count:145820 | 145820 |
1073 | | - |
1074 | inline QRegionPrivate(const QRegionPrivate &r) { | - |
1075 | rects = r.rects; executed (the execution status of this line is deduced): rects = r.rects; | - |
1076 | numRects = r.numRects; executed (the execution status of this line is deduced): numRects = r.numRects; | - |
1077 | extents = r.extents; executed (the execution status of this line is deduced): extents = r.extents; | - |
1078 | innerRect = r.innerRect; executed (the execution status of this line is deduced): innerRect = r.innerRect; | - |
1079 | innerArea = r.innerArea; executed (the execution status of this line is deduced): innerArea = r.innerArea; | - |
1080 | } executed: } Execution Count:64594 | 64594 |
1081 | | - |
1082 | inline QRegionPrivate &operator=(const QRegionPrivate &r) { | - |
1083 | rects = r.rects; executed (the execution status of this line is deduced): rects = r.rects; | - |
1084 | numRects = r.numRects; executed (the execution status of this line is deduced): numRects = r.numRects; | - |
1085 | extents = r.extents; executed (the execution status of this line is deduced): extents = r.extents; | - |
1086 | innerRect = r.innerRect; executed (the execution status of this line is deduced): innerRect = r.innerRect; | - |
1087 | innerArea = r.innerArea; executed (the execution status of this line is deduced): innerArea = r.innerArea; | - |
1088 | return *this; executed: return *this; Execution Count:24 | 24 |
1089 | } | - |
1090 | | - |
1091 | void intersect(const QRect &r); | - |
1092 | | - |
1093 | /* | - |
1094 | * Returns true if r is guaranteed to be fully contained in this region. | - |
1095 | * A false return value does not guarantee the opposite. | - |
1096 | */ | - |
1097 | inline bool contains(const QRegionPrivate &r) const { | - |
1098 | return contains(r.extents); executed: return contains(r.extents); Execution Count:85126 | 85126 |
1099 | } | - |
1100 | | - |
1101 | inline bool contains(const QRect &r2) const { | - |
1102 | const QRect &r1 = innerRect; executed (the execution status of this line is deduced): const QRect &r1 = innerRect; | - |
1103 | return r2.left() >= r1.left() && r2.right() <= r1.right() executed: return r2.left() >= r1.left() && r2.right() <= r1.right() && r2.top() >= r1.top() && r2.bottom() <= r1.bottom(); Execution Count:124294 | 124294 |
1104 | && r2.top() >= r1.top() && r2.bottom() <= r1.bottom(); executed: return r2.left() >= r1.left() && r2.right() <= r1.right() && r2.top() >= r1.top() && r2.bottom() <= r1.bottom(); Execution Count:124294 | 124294 |
1105 | } | - |
1106 | | - |
1107 | /* | - |
1108 | * Returns true if this region is guaranteed to be fully contained in r. | - |
1109 | */ | - |
1110 | inline bool within(const QRect &r1) const { | - |
1111 | const QRect &r2 = extents; executed (the execution status of this line is deduced): const QRect &r2 = extents; | - |
1112 | return r2.left() >= r1.left() && r2.right() <= r1.right() executed: return r2.left() >= r1.left() && r2.right() <= r1.right() && r2.top() >= r1.top() && r2.bottom() <= r1.bottom(); Execution Count:98601 | 98601 |
1113 | && r2.top() >= r1.top() && r2.bottom() <= r1.bottom(); executed: return r2.left() >= r1.left() && r2.right() <= r1.right() && r2.top() >= r1.top() && r2.bottom() <= r1.bottom(); Execution Count:98601 | 98601 |
1114 | } | - |
1115 | | - |
1116 | inline void updateInnerRect(const QRect &rect) { | - |
1117 | const int area = rect.width() * rect.height(); executed (the execution status of this line is deduced): const int area = rect.width() * rect.height(); | - |
1118 | if (area > innerArea) { evaluated: area > innerArea yes Evaluation Count:40552 | yes Evaluation Count:101805 |
| 40552-101805 |
1119 | innerArea = area; executed (the execution status of this line is deduced): innerArea = area; | - |
1120 | innerRect = rect; executed (the execution status of this line is deduced): innerRect = rect; | - |
1121 | } executed: } Execution Count:40552 | 40552 |
1122 | } executed: } Execution Count:142357 | 142357 |
1123 | | - |
1124 | inline void vectorize() { | - |
1125 | if (numRects == 1) { evaluated: numRects == 1 yes Evaluation Count:57667 | yes Evaluation Count:49630 |
| 49630-57667 |
1126 | if (!rects.size()) evaluated: !rects.size() yes Evaluation Count:43040 | yes Evaluation Count:14627 |
| 14627-43040 |
1127 | rects.resize(1); executed: rects.resize(1); Execution Count:43040 | 43040 |
1128 | rects[0] = extents; executed (the execution status of this line is deduced): rects[0] = extents; | - |
1129 | } executed: } Execution Count:57667 | 57667 |
1130 | } executed: } Execution Count:107297 | 107297 |
1131 | | - |
1132 | inline void append(const QRect *r); | - |
1133 | void append(const QRegionPrivate *r); | - |
1134 | void prepend(const QRect *r); | - |
1135 | void prepend(const QRegionPrivate *r); | - |
1136 | inline bool canAppend(const QRect *r) const; | - |
1137 | inline bool canAppend(const QRegionPrivate *r) const; | - |
1138 | inline bool canPrepend(const QRect *r) const; | - |
1139 | inline bool canPrepend(const QRegionPrivate *r) const; | - |
1140 | | - |
1141 | inline bool mergeFromRight(QRect *left, const QRect *right); | - |
1142 | inline bool mergeFromLeft(QRect *left, const QRect *right); | - |
1143 | inline bool mergeFromBelow(QRect *top, const QRect *bottom, | - |
1144 | const QRect *nextToTop, | - |
1145 | const QRect *nextToBottom); | - |
1146 | inline bool mergeFromAbove(QRect *bottom, const QRect *top, | - |
1147 | const QRect *nextToBottom, | - |
1148 | const QRect *nextToTop); | - |
1149 | | - |
1150 | #ifdef QT_REGION_DEBUG | - |
1151 | void selfTest() const; | - |
1152 | #endif | - |
1153 | }; | - |
1154 | | - |
1155 | static inline bool isEmptyHelper(const QRegionPrivate *preg) | - |
1156 | { | - |
1157 | return !preg || preg->numRects == 0; executed: return !preg || preg->numRects == 0; Execution Count:696768 | 696768 |
1158 | } | - |
1159 | | - |
1160 | static inline bool canMergeFromRight(const QRect *left, const QRect *right) | - |
1161 | { | - |
1162 | return (right->top() == left->top() executed: return (right->top() == left->top() && right->bottom() == left->bottom() && right->left() <= (left->right() + 1)); Execution Count:16952 | 16952 |
1163 | && right->bottom() == left->bottom() executed: return (right->top() == left->top() && right->bottom() == left->bottom() && right->left() <= (left->right() + 1)); Execution Count:16952 | 16952 |
1164 | && right->left() <= (left->right() + 1)); executed: return (right->top() == left->top() && right->bottom() == left->bottom() && right->left() <= (left->right() + 1)); Execution Count:16952 | 16952 |
1165 | } | - |
1166 | | - |
1167 | static inline bool canMergeFromLeft(const QRect *right, const QRect *left) | - |
1168 | { | - |
1169 | return canMergeFromRight(left, right); executed: return canMergeFromRight(left, right); Execution Count:5071 | 5071 |
1170 | } | - |
1171 | | - |
1172 | bool QRegionPrivate::mergeFromRight(QRect *left, const QRect *right) | - |
1173 | { | - |
1174 | if (canMergeFromRight(left, right)) { evaluated: canMergeFromRight(left, right) yes Evaluation Count:1844 | yes Evaluation Count:10037 |
| 1844-10037 |
1175 | left->setRight(right->right()); executed (the execution status of this line is deduced): left->setRight(right->right()); | - |
1176 | updateInnerRect(*left); executed (the execution status of this line is deduced): updateInnerRect(*left); | - |
1177 | return true; executed: return true; Execution Count:1844 | 1844 |
1178 | } | - |
1179 | return false; executed: return false; Execution Count:10037 | 10037 |
1180 | } | - |
1181 | | - |
1182 | bool QRegionPrivate::mergeFromLeft(QRect *right, const QRect *left) | - |
1183 | { | - |
1184 | if (canMergeFromLeft(right, left)) { evaluated: canMergeFromLeft(right, left) yes Evaluation Count:1633 | yes Evaluation Count:3438 |
| 1633-3438 |
1185 | right->setLeft(left->left()); executed (the execution status of this line is deduced): right->setLeft(left->left()); | - |
1186 | updateInnerRect(*right); executed (the execution status of this line is deduced): updateInnerRect(*right); | - |
1187 | return true; executed: return true; Execution Count:1633 | 1633 |
1188 | } | - |
1189 | return false; executed: return false; Execution Count:3438 | 3438 |
1190 | } | - |
1191 | | - |
1192 | static inline bool canMergeFromBelow(const QRect *top, const QRect *bottom, | - |
1193 | const QRect *nextToTop, | - |
1194 | const QRect *nextToBottom) | - |
1195 | { | - |
1196 | if (nextToTop && nextToTop->y() == top->y()) evaluated: nextToTop yes Evaluation Count:6564 | yes Evaluation Count:11025 |
evaluated: nextToTop->y() == top->y() yes Evaluation Count:2247 | yes Evaluation Count:4317 |
| 2247-11025 |
1197 | return false; executed: return false; Execution Count:2247 | 2247 |
1198 | if (nextToBottom && nextToBottom->y() == bottom->y()) evaluated: nextToBottom yes Evaluation Count:447 | yes Evaluation Count:14895 |
evaluated: nextToBottom->y() == bottom->y() yes Evaluation Count:59 | yes Evaluation Count:388 |
| 59-14895 |
1199 | return false; executed: return false; Execution Count:59 | 59 |
1200 | | - |
1201 | return ((top->bottom() >= (bottom->top() - 1)) executed: return ((top->bottom() >= (bottom->top() - 1)) && top->left() == bottom->left() && top->right() == bottom->right()); Execution Count:15283 | 15283 |
1202 | && top->left() == bottom->left() executed: return ((top->bottom() >= (bottom->top() - 1)) && top->left() == bottom->left() && top->right() == bottom->right()); Execution Count:15283 | 15283 |
1203 | && top->right() == bottom->right()); executed: return ((top->bottom() >= (bottom->top() - 1)) && top->left() == bottom->left() && top->right() == bottom->right()); Execution Count:15283 | 15283 |
1204 | } | - |
1205 | | - |
1206 | bool QRegionPrivate::mergeFromBelow(QRect *top, const QRect *bottom, | - |
1207 | const QRect *nextToTop, | - |
1208 | const QRect *nextToBottom) | - |
1209 | { | - |
1210 | if (canMergeFromBelow(top, bottom, nextToTop, nextToBottom)) { evaluated: canMergeFromBelow(top, bottom, nextToTop, nextToBottom) yes Evaluation Count:1608 | yes Evaluation Count:9301 |
| 1608-9301 |
1211 | top->setBottom(bottom->bottom()); executed (the execution status of this line is deduced): top->setBottom(bottom->bottom()); | - |
1212 | updateInnerRect(*top); executed (the execution status of this line is deduced): updateInnerRect(*top); | - |
1213 | return true; executed: return true; Execution Count:1608 | 1608 |
1214 | } | - |
1215 | return false; executed: return false; Execution Count:9301 | 9301 |
1216 | } | - |
1217 | | - |
1218 | bool QRegionPrivate::mergeFromAbove(QRect *bottom, const QRect *top, | - |
1219 | const QRect *nextToBottom, | - |
1220 | const QRect *nextToTop) | - |
1221 | { | - |
1222 | if (canMergeFromBelow(top, bottom, nextToTop, nextToBottom)) { evaluated: canMergeFromBelow(top, bottom, nextToTop, nextToBottom) yes Evaluation Count:2201 | yes Evaluation Count:2428 |
| 2201-2428 |
1223 | bottom->setTop(top->top()); executed (the execution status of this line is deduced): bottom->setTop(top->top()); | - |
1224 | updateInnerRect(*bottom); executed (the execution status of this line is deduced): updateInnerRect(*bottom); | - |
1225 | return true; executed: return true; Execution Count:2201 | 2201 |
1226 | } | - |
1227 | return false; executed: return false; Execution Count:2428 | 2428 |
1228 | } | - |
1229 | | - |
1230 | static inline QRect qt_rect_intersect_normalized(const QRect &r1, | - |
1231 | const QRect &r2) | - |
1232 | { | - |
1233 | QRect r; executed (the execution status of this line is deduced): QRect r; | - |
1234 | r.setLeft(qMax(r1.left(), r2.left())); executed (the execution status of this line is deduced): r.setLeft(qMax(r1.left(), r2.left())); | - |
1235 | r.setRight(qMin(r1.right(), r2.right())); executed (the execution status of this line is deduced): r.setRight(qMin(r1.right(), r2.right())); | - |
1236 | r.setTop(qMax(r1.top(), r2.top())); executed (the execution status of this line is deduced): r.setTop(qMax(r1.top(), r2.top())); | - |
1237 | r.setBottom(qMin(r1.bottom(), r2.bottom())); executed (the execution status of this line is deduced): r.setBottom(qMin(r1.bottom(), r2.bottom())); | - |
1238 | return r; executed: return r; Execution Count:20026 | 20026 |
1239 | } | - |
1240 | | - |
1241 | void QRegionPrivate::intersect(const QRect &rect) | - |
1242 | { | - |
1243 | Q_ASSERT(extents.intersects(rect)); executed (the execution status of this line is deduced): qt_noop(); | - |
1244 | Q_ASSERT(numRects > 1); executed (the execution status of this line is deduced): qt_noop(); | - |
1245 | | - |
1246 | #ifdef QT_REGION_DEBUG | - |
1247 | selfTest(); | - |
1248 | #endif | - |
1249 | | - |
1250 | const QRect r = rect.normalized(); executed (the execution status of this line is deduced): const QRect r = rect.normalized(); | - |
1251 | extents = QRect(); executed (the execution status of this line is deduced): extents = QRect(); | - |
1252 | innerRect = QRect(); executed (the execution status of this line is deduced): innerRect = QRect(); | - |
1253 | innerArea = -1; executed (the execution status of this line is deduced): innerArea = -1; | - |
1254 | | - |
1255 | QRect *dest = rects.data(); executed (the execution status of this line is deduced): QRect *dest = rects.data(); | - |
1256 | const QRect *src = dest; executed (the execution status of this line is deduced): const QRect *src = dest; | - |
1257 | int n = numRects; executed (the execution status of this line is deduced): int n = numRects; | - |
1258 | numRects = 0; executed (the execution status of this line is deduced): numRects = 0; | - |
1259 | while (n--) { evaluated: n-- yes Evaluation Count:19373 | yes Evaluation Count:4145 |
| 4145-19373 |
1260 | *dest = qt_rect_intersect_normalized(*src++, r); executed (the execution status of this line is deduced): *dest = qt_rect_intersect_normalized(*src++, r); | - |
1261 | if (dest->isEmpty()) evaluated: dest->isEmpty() yes Evaluation Count:14988 | yes Evaluation Count:4385 |
| 4385-14988 |
1262 | continue; executed: continue; Execution Count:14988 | 14988 |
1263 | | - |
1264 | if (numRects == 0) { evaluated: numRects == 0 yes Evaluation Count:2334 | yes Evaluation Count:2051 |
| 2051-2334 |
1265 | extents = *dest; executed (the execution status of this line is deduced): extents = *dest; | - |
1266 | } else { executed: } Execution Count:2334 | 2334 |
1267 | extents.setLeft(qMin(extents.left(), dest->left())); executed (the execution status of this line is deduced): extents.setLeft(qMin(extents.left(), dest->left())); | - |
1268 | // hw: extents.top() will never change after initialization | - |
1269 | //extents.setTop(qMin(extents.top(), dest->top())); | - |
1270 | extents.setRight(qMax(extents.right(), dest->right())); executed (the execution status of this line is deduced): extents.setRight(qMax(extents.right(), dest->right())); | - |
1271 | extents.setBottom(qMax(extents.bottom(), dest->bottom())); executed (the execution status of this line is deduced): extents.setBottom(qMax(extents.bottom(), dest->bottom())); | - |
1272 | | - |
1273 | const QRect *nextToLast = (numRects > 1 ? dest - 2 : 0); evaluated: numRects > 1 yes Evaluation Count:1207 | yes Evaluation Count:844 |
| 844-1207 |
1274 | | - |
1275 | // mergeFromBelow inlined and optimized | - |
1276 | if (canMergeFromBelow(dest - 1, dest, nextToLast, 0)) { evaluated: canMergeFromBelow(dest - 1, dest, nextToLast, 0) yes Evaluation Count:255 | yes Evaluation Count:1796 |
| 255-1796 |
1277 | if (!n || src->y() != dest->y() || src->left() > r.right()) { evaluated: !n yes Evaluation Count:56 | yes Evaluation Count:199 |
evaluated: src->y() != dest->y() yes Evaluation Count:159 | yes Evaluation Count:40 |
evaluated: src->left() > r.right() yes Evaluation Count:33 | yes Evaluation Count:7 |
| 7-199 |
1278 | QRect *prev = dest - 1; executed (the execution status of this line is deduced): QRect *prev = dest - 1; | - |
1279 | prev->setBottom(dest->bottom()); executed (the execution status of this line is deduced): prev->setBottom(dest->bottom()); | - |
1280 | updateInnerRect(*prev); executed (the execution status of this line is deduced): updateInnerRect(*prev); | - |
1281 | continue; executed: continue; Execution Count:248 | 248 |
1282 | } | - |
1283 | } executed: } Execution Count:7 | 7 |
1284 | } executed: } Execution Count:1803 | 1803 |
1285 | updateInnerRect(*dest); executed (the execution status of this line is deduced): updateInnerRect(*dest); | - |
1286 | ++dest; executed (the execution status of this line is deduced): ++dest; | - |
1287 | ++numRects; executed (the execution status of this line is deduced): ++numRects; | - |
1288 | } executed: } Execution Count:4137 | 4137 |
1289 | #ifdef QT_REGION_DEBUG | - |
1290 | selfTest(); | - |
1291 | #endif | - |
1292 | } executed: } Execution Count:4145 | 4145 |
1293 | | - |
1294 | void QRegionPrivate::append(const QRect *r) | - |
1295 | { | - |
1296 | Q_ASSERT(!r->isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
1297 | | - |
1298 | QRect *myLast = (numRects == 1 ? &extents : rects.data() + (numRects - 1)); evaluated: numRects == 1 yes Evaluation Count:6553 | yes Evaluation Count:4946 |
| 4946-6553 |
1299 | if (mergeFromRight(myLast, r)) { evaluated: mergeFromRight(myLast, r) yes Evaluation Count:1505 | yes Evaluation Count:9994 |
| 1505-9994 |
1300 | if (numRects > 1) { evaluated: numRects > 1 yes Evaluation Count:530 | yes Evaluation Count:975 |
| 530-975 |
1301 | const QRect *nextToTop = (numRects > 2 ? myLast - 2 : 0); evaluated: numRects > 2 yes Evaluation Count:461 | yes Evaluation Count:69 |
| 69-461 |
1302 | if (mergeFromBelow(myLast - 1, myLast, nextToTop, 0)) evaluated: mergeFromBelow(myLast - 1, myLast, nextToTop, 0) yes Evaluation Count:47 | yes Evaluation Count:483 |
| 47-483 |
1303 | --numRects; executed: --numRects; Execution Count:47 | 47 |
1304 | } executed: } Execution Count:530 | 530 |
1305 | } else if (mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : 0), 0)) { executed: } Execution Count:1505 evaluated: mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : 0), 0) yes Evaluation Count:1211 | yes Evaluation Count:8783 |
| 1211-8783 |
1306 | // nothing | - |
1307 | } else { executed: } Execution Count:1211 | 1211 |
1308 | vectorize(); executed (the execution status of this line is deduced): vectorize(); | - |
1309 | ++numRects; executed (the execution status of this line is deduced): ++numRects; | - |
1310 | updateInnerRect(*r); executed (the execution status of this line is deduced): updateInnerRect(*r); | - |
1311 | if (rects.size() < numRects) evaluated: rects.size() < numRects yes Evaluation Count:8101 | yes Evaluation Count:682 |
| 682-8101 |
1312 | rects.resize(numRects); executed: rects.resize(numRects); Execution Count:8101 | 8101 |
1313 | rects[numRects - 1] = *r; executed (the execution status of this line is deduced): rects[numRects - 1] = *r; | - |
1314 | } executed: } Execution Count:8783 | 8783 |
1315 | extents.setCoords(qMin(extents.left(), r->left()), executed (the execution status of this line is deduced): extents.setCoords(qMin(extents.left(), r->left()), | - |
1316 | qMin(extents.top(), r->top()), executed (the execution status of this line is deduced): qMin(extents.top(), r->top()), | - |
1317 | qMax(extents.right(), r->right()), executed (the execution status of this line is deduced): qMax(extents.right(), r->right()), | - |
1318 | qMax(extents.bottom(), r->bottom())); executed (the execution status of this line is deduced): qMax(extents.bottom(), r->bottom())); | - |
1319 | | - |
1320 | #ifdef QT_REGION_DEBUG | - |
1321 | selfTest(); | - |
1322 | #endif | - |
1323 | } executed: } Execution Count:11499 | 11499 |
1324 | | - |
1325 | void QRegionPrivate::append(const QRegionPrivate *r) | - |
1326 | { | - |
1327 | Q_ASSERT(!isEmptyHelper(r)); executed (the execution status of this line is deduced): qt_noop(); | - |
1328 | | - |
1329 | if (r->numRects == 1) { evaluated: r->numRects == 1 yes Evaluation Count:8960 | yes Evaluation Count:382 |
| 382-8960 |
1330 | append(&r->extents); executed (the execution status of this line is deduced): append(&r->extents); | - |
1331 | return; executed: return; Execution Count:8960 | 8960 |
1332 | } | - |
1333 | | - |
1334 | vectorize(); executed (the execution status of this line is deduced): vectorize(); | - |
1335 | | - |
1336 | QRect *destRect = rects.data() + numRects; executed (the execution status of this line is deduced): QRect *destRect = rects.data() + numRects; | - |
1337 | const QRect *srcRect = r->rects.constData(); executed (the execution status of this line is deduced): const QRect *srcRect = r->rects.constData(); | - |
1338 | int numAppend = r->numRects; executed (the execution status of this line is deduced): int numAppend = r->numRects; | - |
1339 | | - |
1340 | // try merging | - |
1341 | { | - |
1342 | const QRect *rFirst = srcRect; executed (the execution status of this line is deduced): const QRect *rFirst = srcRect; | - |
1343 | QRect *myLast = destRect - 1; executed (the execution status of this line is deduced): QRect *myLast = destRect - 1; | - |
1344 | const QRect *nextToLast = (numRects > 1 ? myLast - 1 : 0); evaluated: numRects > 1 yes Evaluation Count:3 | yes Evaluation Count:379 |
| 3-379 |
1345 | if (mergeFromRight(myLast, rFirst)) { evaluated: mergeFromRight(myLast, rFirst) yes Evaluation Count:339 | yes Evaluation Count:43 |
| 43-339 |
1346 | ++srcRect; executed (the execution status of this line is deduced): ++srcRect; | - |
1347 | --numAppend; executed (the execution status of this line is deduced): --numAppend; | - |
1348 | const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : 0); partially evaluated: numAppend > 1 no Evaluation Count:0 | yes Evaluation Count:339 |
| 0-339 |
1349 | if (mergeFromBelow(myLast, rFirst + 1, nextToLast, rNextToFirst)) { partially evaluated: mergeFromBelow(myLast, rFirst + 1, nextToLast, rNextToFirst) yes Evaluation Count:339 | no Evaluation Count:0 |
| 0-339 |
1350 | ++srcRect; executed (the execution status of this line is deduced): ++srcRect; | - |
1351 | --numAppend; executed (the execution status of this line is deduced): --numAppend; | - |
1352 | } executed: } Execution Count:339 | 339 |
1353 | if (numRects > 1) { evaluated: numRects > 1 yes Evaluation Count:3 | yes Evaluation Count:336 |
| 3-336 |
1354 | nextToLast = (numRects > 2 ? myLast - 2 : 0); partially evaluated: numRects > 2 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1355 | rNextToFirst = (numAppend > 0 ? srcRect : 0); partially evaluated: numAppend > 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1356 | if (mergeFromBelow(myLast - 1, myLast, nextToLast, rNextToFirst)) { partially evaluated: mergeFromBelow(myLast - 1, myLast, nextToLast, rNextToFirst) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1357 | --destRect; executed (the execution status of this line is deduced): --destRect; | - |
1358 | --numRects; executed (the execution status of this line is deduced): --numRects; | - |
1359 | } executed: } Execution Count:3 | 3 |
1360 | } executed: } Execution Count:3 | 3 |
1361 | } else if (mergeFromBelow(myLast, rFirst, nextToLast, rFirst + 1)) { executed: } Execution Count:339 evaluated: mergeFromBelow(myLast, rFirst, nextToLast, rFirst + 1) yes Evaluation Count:8 | yes Evaluation Count:35 |
| 8-339 |
1362 | ++srcRect; executed (the execution status of this line is deduced): ++srcRect; | - |
1363 | --numAppend; executed (the execution status of this line is deduced): --numAppend; | - |
1364 | } executed: } Execution Count:8 | 8 |
1365 | } | - |
1366 | | - |
1367 | // append rectangles | - |
1368 | if (numAppend > 0) { evaluated: numAppend > 0 yes Evaluation Count:43 | yes Evaluation Count:339 |
| 43-339 |
1369 | const int newNumRects = numRects + numAppend; executed (the execution status of this line is deduced): const int newNumRects = numRects + numAppend; | - |
1370 | if (newNumRects > rects.size()) { partially evaluated: newNumRects > rects.size() yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-43 |
1371 | rects.resize(newNumRects); executed (the execution status of this line is deduced): rects.resize(newNumRects); | - |
1372 | destRect = rects.data() + numRects; executed (the execution status of this line is deduced): destRect = rects.data() + numRects; | - |
1373 | } executed: } Execution Count:43 | 43 |
1374 | memcpy(destRect, srcRect, numAppend * sizeof(QRect)); executed (the execution status of this line is deduced): memcpy(destRect, srcRect, numAppend * sizeof(QRect)); | - |
1375 | | - |
1376 | numRects = newNumRects; executed (the execution status of this line is deduced): numRects = newNumRects; | - |
1377 | } executed: } Execution Count:43 | 43 |
1378 | | - |
1379 | // update inner rectangle | - |
1380 | if (innerArea < r->innerArea) { evaluated: innerArea < r->innerArea yes Evaluation Count:8 | yes Evaluation Count:374 |
| 8-374 |
1381 | innerArea = r->innerArea; executed (the execution status of this line is deduced): innerArea = r->innerArea; | - |
1382 | innerRect = r->innerRect; executed (the execution status of this line is deduced): innerRect = r->innerRect; | - |
1383 | } executed: } Execution Count:8 | 8 |
1384 | | - |
1385 | // update extents | - |
1386 | destRect = &extents; executed (the execution status of this line is deduced): destRect = &extents; | - |
1387 | srcRect = &r->extents; executed (the execution status of this line is deduced): srcRect = &r->extents; | - |
1388 | extents.setCoords(qMin(destRect->left(), srcRect->left()), executed (the execution status of this line is deduced): extents.setCoords(qMin(destRect->left(), srcRect->left()), | - |
1389 | qMin(destRect->top(), srcRect->top()), executed (the execution status of this line is deduced): qMin(destRect->top(), srcRect->top()), | - |
1390 | qMax(destRect->right(), srcRect->right()), executed (the execution status of this line is deduced): qMax(destRect->right(), srcRect->right()), | - |
1391 | qMax(destRect->bottom(), srcRect->bottom())); executed (the execution status of this line is deduced): qMax(destRect->bottom(), srcRect->bottom())); | - |
1392 | | - |
1393 | #ifdef QT_REGION_DEBUG | - |
1394 | selfTest(); | - |
1395 | #endif | - |
1396 | } executed: } Execution Count:382 | 382 |
1397 | | - |
1398 | void QRegionPrivate::prepend(const QRegionPrivate *r) | - |
1399 | { | - |
1400 | Q_ASSERT(!isEmptyHelper(r)); executed (the execution status of this line is deduced): qt_noop(); | - |
1401 | | - |
1402 | if (r->numRects == 1) { evaluated: r->numRects == 1 yes Evaluation Count:3988 | yes Evaluation Count:495 |
| 495-3988 |
1403 | prepend(&r->extents); executed (the execution status of this line is deduced): prepend(&r->extents); | - |
1404 | return; executed: return; Execution Count:3988 | 3988 |
1405 | } | - |
1406 | | - |
1407 | vectorize(); executed (the execution status of this line is deduced): vectorize(); | - |
1408 | | - |
1409 | int numPrepend = r->numRects; executed (the execution status of this line is deduced): int numPrepend = r->numRects; | - |
1410 | int numSkip = 0; executed (the execution status of this line is deduced): int numSkip = 0; | - |
1411 | | - |
1412 | // try merging | - |
1413 | { | - |
1414 | QRect *myFirst = rects.data(); executed (the execution status of this line is deduced): QRect *myFirst = rects.data(); | - |
1415 | const QRect *nextToFirst = (numRects > 1 ? myFirst + 1 : 0); evaluated: numRects > 1 yes Evaluation Count:5 | yes Evaluation Count:490 |
| 5-490 |
1416 | const QRect *rLast = r->rects.constData() + r->numRects - 1; executed (the execution status of this line is deduced): const QRect *rLast = r->rects.constData() + r->numRects - 1; | - |
1417 | const QRect *rNextToLast = (r->numRects > 1 ? rLast - 1 : 0); partially evaluated: r->numRects > 1 yes Evaluation Count:495 | no Evaluation Count:0 |
| 0-495 |
1418 | if (mergeFromLeft(myFirst, rLast)) { evaluated: mergeFromLeft(myFirst, rLast) yes Evaluation Count:18 | yes Evaluation Count:477 |
| 18-477 |
1419 | --numPrepend; executed (the execution status of this line is deduced): --numPrepend; | - |
1420 | --rLast; executed (the execution status of this line is deduced): --rLast; | - |
1421 | rNextToLast = (numPrepend > 1 ? rLast - 1 : 0); partially evaluated: numPrepend > 1 no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1422 | if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) { partially evaluated: mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast) yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
1423 | --numPrepend; executed (the execution status of this line is deduced): --numPrepend; | - |
1424 | --rLast; executed (the execution status of this line is deduced): --rLast; | - |
1425 | } executed: } Execution Count:18 | 18 |
1426 | if (numRects > 1) { evaluated: numRects > 1 yes Evaluation Count:3 | yes Evaluation Count:15 |
| 3-15 |
1427 | nextToFirst = (numRects > 2? myFirst + 2 : 0); partially evaluated: numRects > 2 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1428 | rNextToLast = (numPrepend > 0 ? rLast : 0); partially evaluated: numPrepend > 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1429 | if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, rNextToLast)) { partially evaluated: mergeFromAbove(myFirst + 1, myFirst, nextToFirst, rNextToLast) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1430 | --numRects; executed (the execution status of this line is deduced): --numRects; | - |
1431 | ++numSkip; executed (the execution status of this line is deduced): ++numSkip; | - |
1432 | } executed: } Execution Count:3 | 3 |
1433 | } executed: } Execution Count:3 | 3 |
1434 | } else if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) { executed: } Execution Count:18 evaluated: mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast) yes Evaluation Count:263 | yes Evaluation Count:214 |
| 18-263 |
1435 | --numPrepend; executed (the execution status of this line is deduced): --numPrepend; | - |
1436 | } executed: } Execution Count:263 | 263 |
1437 | } | - |
1438 | | - |
1439 | if (numPrepend > 0) { evaluated: numPrepend > 0 yes Evaluation Count:477 | yes Evaluation Count:18 |
| 18-477 |
1440 | const int newNumRects = numRects + numPrepend; executed (the execution status of this line is deduced): const int newNumRects = numRects + numPrepend; | - |
1441 | if (newNumRects > rects.size()) evaluated: newNumRects > rects.size() yes Evaluation Count:475 | yes Evaluation Count:2 |
| 2-475 |
1442 | rects.resize(newNumRects); executed: rects.resize(newNumRects); Execution Count:475 | 475 |
1443 | | - |
1444 | // move existing rectangles | - |
1445 | memmove(rects.data() + numPrepend, rects.constData() + numSkip, executed (the execution status of this line is deduced): memmove(rects.data() + numPrepend, rects.constData() + numSkip, | - |
1446 | numRects * sizeof(QRect)); executed (the execution status of this line is deduced): numRects * sizeof(QRect)); | - |
1447 | | - |
1448 | // prepend new rectangles | - |
1449 | memcpy(rects.data(), r->rects.constData(), numPrepend * sizeof(QRect)); executed (the execution status of this line is deduced): memcpy(rects.data(), r->rects.constData(), numPrepend * sizeof(QRect)); | - |
1450 | | - |
1451 | numRects = newNumRects; executed (the execution status of this line is deduced): numRects = newNumRects; | - |
1452 | } executed: } Execution Count:477 | 477 |
1453 | | - |
1454 | // update inner rectangle | - |
1455 | if (innerArea < r->innerArea) { evaluated: innerArea < r->innerArea yes Evaluation Count:12 | yes Evaluation Count:483 |
| 12-483 |
1456 | innerArea = r->innerArea; executed (the execution status of this line is deduced): innerArea = r->innerArea; | - |
1457 | innerRect = r->innerRect; executed (the execution status of this line is deduced): innerRect = r->innerRect; | - |
1458 | } executed: } Execution Count:12 | 12 |
1459 | | - |
1460 | // update extents | - |
1461 | extents.setCoords(qMin(extents.left(), r->extents.left()), executed (the execution status of this line is deduced): extents.setCoords(qMin(extents.left(), r->extents.left()), | - |
1462 | qMin(extents.top(), r->extents.top()), executed (the execution status of this line is deduced): qMin(extents.top(), r->extents.top()), | - |
1463 | qMax(extents.right(), r->extents.right()), executed (the execution status of this line is deduced): qMax(extents.right(), r->extents.right()), | - |
1464 | qMax(extents.bottom(), r->extents.bottom())); executed (the execution status of this line is deduced): qMax(extents.bottom(), r->extents.bottom())); | - |
1465 | | - |
1466 | #ifdef QT_REGION_DEBUG | - |
1467 | selfTest(); | - |
1468 | #endif | - |
1469 | } executed: } Execution Count:495 | 495 |
1470 | | - |
1471 | void QRegionPrivate::prepend(const QRect *r) | - |
1472 | { | - |
1473 | Q_ASSERT(!r->isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
1474 | | - |
1475 | QRect *myFirst = (numRects == 1 ? &extents : rects.data()); evaluated: numRects == 1 yes Evaluation Count:3041 | yes Evaluation Count:1535 |
| 1535-3041 |
1476 | if (mergeFromLeft(myFirst, r)) { evaluated: mergeFromLeft(myFirst, r) yes Evaluation Count:1615 | yes Evaluation Count:2961 |
| 1615-2961 |
1477 | if (numRects > 1) { evaluated: numRects > 1 yes Evaluation Count:1170 | yes Evaluation Count:445 |
| 445-1170 |
1478 | const QRect *nextToFirst = (numRects > 2 ? myFirst + 2 : 0); evaluated: numRects > 2 yes Evaluation Count:34 | yes Evaluation Count:1136 |
| 34-1136 |
1479 | if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, 0)) { evaluated: mergeFromAbove(myFirst + 1, myFirst, nextToFirst, 0) yes Evaluation Count:1100 | yes Evaluation Count:70 |
| 70-1100 |
1480 | --numRects; executed (the execution status of this line is deduced): --numRects; | - |
1481 | memmove(rects.data(), rects.constData() + 1, executed (the execution status of this line is deduced): memmove(rects.data(), rects.constData() + 1, | - |
1482 | numRects * sizeof(QRect)); executed (the execution status of this line is deduced): numRects * sizeof(QRect)); | - |
1483 | } executed: } Execution Count:1100 | 1100 |
1484 | } executed: } Execution Count:1170 | 1170 |
1485 | } else if (mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : 0), 0)) { executed: } Execution Count:1615 evaluated: mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : 0), 0) yes Evaluation Count:817 | yes Evaluation Count:2144 |
| 817-2144 |
1486 | // nothing | - |
1487 | } else { executed: } Execution Count:817 | 817 |
1488 | vectorize(); executed (the execution status of this line is deduced): vectorize(); | - |
1489 | ++numRects; executed (the execution status of this line is deduced): ++numRects; | - |
1490 | updateInnerRect(*r); executed (the execution status of this line is deduced): updateInnerRect(*r); | - |
1491 | rects.prepend(*r); executed (the execution status of this line is deduced): rects.prepend(*r); | - |
1492 | } executed: } Execution Count:2144 | 2144 |
1493 | extents.setCoords(qMin(extents.left(), r->left()), executed (the execution status of this line is deduced): extents.setCoords(qMin(extents.left(), r->left()), | - |
1494 | qMin(extents.top(), r->top()), executed (the execution status of this line is deduced): qMin(extents.top(), r->top()), | - |
1495 | qMax(extents.right(), r->right()), executed (the execution status of this line is deduced): qMax(extents.right(), r->right()), | - |
1496 | qMax(extents.bottom(), r->bottom())); executed (the execution status of this line is deduced): qMax(extents.bottom(), r->bottom())); | - |
1497 | | - |
1498 | #ifdef QT_REGION_DEBUG | - |
1499 | selfTest(); | - |
1500 | #endif | - |
1501 | } executed: } Execution Count:4576 | 4576 |
1502 | | - |
1503 | bool QRegionPrivate::canAppend(const QRect *r) const | - |
1504 | { | - |
1505 | Q_ASSERT(!r->isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
1506 | | - |
1507 | const QRect *myLast = (numRects == 1) ? &extents : (rects.constData() + (numRects - 1)); evaluated: (numRects == 1) yes Evaluation Count:13429 | yes Evaluation Count:23598 |
| 13429-23598 |
1508 | if (r->top() > myLast->bottom()) evaluated: r->top() > myLast->bottom() yes Evaluation Count:7528 | yes Evaluation Count:29499 |
| 7528-29499 |
1509 | return true; executed: return true; Execution Count:7528 | 7528 |
1510 | if (r->top() == myLast->top() evaluated: r->top() == myLast->top() yes Evaluation Count:7364 | yes Evaluation Count:22135 |
| 7364-22135 |
1511 | && r->height() == myLast->height() evaluated: r->height() == myLast->height() yes Evaluation Count:6009 | yes Evaluation Count:1355 |
| 1355-6009 |
1512 | && r->left() > myLast->right()) evaluated: r->left() > myLast->right() yes Evaluation Count:4353 | yes Evaluation Count:1656 |
| 1656-4353 |
1513 | { | - |
1514 | return true; executed: return true; Execution Count:4353 | 4353 |
1515 | } | - |
1516 | | - |
1517 | return false; executed: return false; Execution Count:25146 | 25146 |
1518 | } | - |
1519 | | - |
1520 | bool QRegionPrivate::canAppend(const QRegionPrivate *r) const | - |
1521 | { | - |
1522 | return canAppend(r->numRects == 1 ? &r->extents : r->rects.constData()); executed: return canAppend(r->numRects == 1 ? &r->extents : r->rects.constData()); Execution Count:27912 | 27912 |
1523 | } | - |
1524 | | - |
1525 | bool QRegionPrivate::canPrepend(const QRect *r) const | - |
1526 | { | - |
1527 | Q_ASSERT(!r->isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
1528 | | - |
1529 | const QRect *myFirst = (numRects == 1) ? &extents : rects.constData(); evaluated: (numRects == 1) yes Evaluation Count:6497 | yes Evaluation Count:18649 |
| 6497-18649 |
1530 | if (r->bottom() < myFirst->top()) // not overlapping evaluated: r->bottom() < myFirst->top() yes Evaluation Count:3070 | yes Evaluation Count:22076 |
| 3070-22076 |
1531 | return true; executed: return true; Execution Count:3070 | 3070 |
1532 | if (r->top() == myFirst->top() evaluated: r->top() == myFirst->top() yes Evaluation Count:11999 | yes Evaluation Count:10077 |
| 10077-11999 |
1533 | && r->height() == myFirst->height() evaluated: r->height() == myFirst->height() yes Evaluation Count:7254 | yes Evaluation Count:4745 |
| 4745-7254 |
1534 | && r->right() < myFirst->left()) evaluated: r->right() < myFirst->left() yes Evaluation Count:2001 | yes Evaluation Count:5253 |
| 2001-5253 |
1535 | { | - |
1536 | return true; executed: return true; Execution Count:2001 | 2001 |
1537 | } | - |
1538 | | - |
1539 | return false; executed: return false; Execution Count:20075 | 20075 |
1540 | } | - |
1541 | | - |
1542 | bool QRegionPrivate::canPrepend(const QRegionPrivate *r) const | - |
1543 | { | - |
1544 | return canPrepend(r->numRects == 1 ? &r->extents : r->rects.constData() + r->numRects - 1); executed: return canPrepend(r->numRects == 1 ? &r->extents : r->rects.constData() + r->numRects - 1); Execution Count:18570 | 18570 |
1545 | } | - |
1546 | | - |
1547 | #ifdef QT_REGION_DEBUG | - |
1548 | void QRegionPrivate::selfTest() const | - |
1549 | { | - |
1550 | if (numRects == 0) { | - |
1551 | Q_ASSERT(extents.isEmpty()); | - |
1552 | Q_ASSERT(innerRect.isEmpty()); | - |
1553 | return; | - |
1554 | } | - |
1555 | | - |
1556 | Q_ASSERT(innerArea == (innerRect.width() * innerRect.height())); | - |
1557 | | - |
1558 | if (numRects == 1) { | - |
1559 | Q_ASSERT(innerRect == extents); | - |
1560 | Q_ASSERT(!innerRect.isEmpty()); | - |
1561 | return; | - |
1562 | } | - |
1563 | | - |
1564 | for (int i = 0; i < numRects; ++i) { | - |
1565 | const QRect r = rects.at(i); | - |
1566 | if ((r.width() * r.height()) > innerArea) | - |
1567 | qDebug() << "selfTest(): innerRect" << innerRect << '<' << r; | - |
1568 | } | - |
1569 | | - |
1570 | QRect r = rects.first(); | - |
1571 | for (int i = 1; i < numRects; ++i) { | - |
1572 | const QRect r2 = rects.at(i); | - |
1573 | Q_ASSERT(!r2.isEmpty()); | - |
1574 | if (r2.y() == r.y()) { | - |
1575 | Q_ASSERT(r.bottom() == r2.bottom()); | - |
1576 | Q_ASSERT(r.right() < (r2.left() + 1)); | - |
1577 | } else { | - |
1578 | Q_ASSERT(r2.y() >= r.bottom()); | - |
1579 | } | - |
1580 | r = r2; | - |
1581 | } | - |
1582 | } | - |
1583 | #endif // QT_REGION_DEBUG | - |
1584 | | - |
1585 | static QRegionPrivate qrp; | - |
1586 | QRegion::QRegionData QRegion::shared_empty = {Q_BASIC_ATOMIC_INITIALIZER(1), &qrp}; | - |
1587 | | - |
1588 | typedef void (*OverlapFunc)(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, | - |
1589 | register const QRect *r2, const QRect *r2End, register int y1, register int y2); | - |
1590 | typedef void (*NonOverlapFunc)(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd, | - |
1591 | register int y1, register int y2); | - |
1592 | | - |
1593 | static bool EqualRegion(const QRegionPrivate *r1, const QRegionPrivate *r2); | - |
1594 | static void UnionRegion(const QRegionPrivate *reg1, const QRegionPrivate *reg2, QRegionPrivate &dest); | - |
1595 | static void miRegionOp(register QRegionPrivate &dest, const QRegionPrivate *reg1, const QRegionPrivate *reg2, | - |
1596 | OverlapFunc overlapFunc, NonOverlapFunc nonOverlap1Func, | - |
1597 | NonOverlapFunc nonOverlap2Func); | - |
1598 | | - |
1599 | #define RectangleOut 0 | - |
1600 | #define RectangleIn 1 | - |
1601 | #define RectanglePart 2 | - |
1602 | #define EvenOddRule 0 | - |
1603 | #define WindingRule 1 | - |
1604 | | - |
1605 | // START OF region.h extract | - |
1606 | /* $XConsortium: region.h,v 11.14 94/04/17 20:22:20 rws Exp $ */ | - |
1607 | /************************************************************************ | - |
1608 | | - |
1609 | Copyright (c) 1987 X Consortium | - |
1610 | | - |
1611 | Permission is hereby granted, free of charge, to any person obtaining a copy | - |
1612 | of this software and associated documentation files (the "Software"), to deal | - |
1613 | in the Software without restriction, including without limitation the rights | - |
1614 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | - |
1615 | copies of the Software, and to permit persons to whom the Software is | - |
1616 | furnished to do so, subject to the following conditions: | - |
1617 | | - |
1618 | The above copyright notice and this permission notice shall be included in | - |
1619 | all copies or substantial portions of the Software. | - |
1620 | | - |
1621 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | - |
1622 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | - |
1623 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | - |
1624 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | - |
1625 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | - |
1626 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | - |
1627 | | - |
1628 | Except as contained in this notice, the name of the X Consortium shall not be | - |
1629 | used in advertising or otherwise to promote the sale, use or other dealings | - |
1630 | in this Software without prior written authorization from the X Consortium. | - |
1631 | | - |
1632 | | - |
1633 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. | - |
1634 | | - |
1635 | All Rights Reserved | - |
1636 | | - |
1637 | Permission to use, copy, modify, and distribute this software and its | - |
1638 | documentation for any purpose and without fee is hereby granted, | - |
1639 | provided that the above copyright notice appear in all copies and that | - |
1640 | both that copyright notice and this permission notice appear in | - |
1641 | supporting documentation, and that the name of Digital not be | - |
1642 | used in advertising or publicity pertaining to distribution of the | - |
1643 | software without specific, written prior permission. | - |
1644 | | - |
1645 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | - |
1646 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | - |
1647 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | - |
1648 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | - |
1649 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | - |
1650 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | - |
1651 | SOFTWARE. | - |
1652 | | - |
1653 | ************************************************************************/ | - |
1654 | | - |
1655 | #ifndef _XREGION_H | - |
1656 | #define _XREGION_H | - |
1657 | | - |
1658 | QT_BEGIN_INCLUDE_NAMESPACE | - |
1659 | #include <limits.h> | - |
1660 | QT_END_INCLUDE_NAMESPACE | - |
1661 | | - |
1662 | /* 1 if two BOXes overlap. | - |
1663 | * 0 if two BOXes do not overlap. | - |
1664 | * Remember, x2 and y2 are not in the region | - |
1665 | */ | - |
1666 | #define EXTENTCHECK(r1, r2) \ | - |
1667 | ((r1)->right() >= (r2)->left() && \ | - |
1668 | (r1)->left() <= (r2)->right() && \ | - |
1669 | (r1)->bottom() >= (r2)->top() && \ | - |
1670 | (r1)->top() <= (r2)->bottom()) | - |
1671 | | - |
1672 | /* | - |
1673 | * update region extents | - |
1674 | */ | - |
1675 | #define EXTENTS(r,idRect){\ | - |
1676 | if((r)->left() < (idRect)->extents.left())\ | - |
1677 | (idRect)->extents.setLeft((r)->left());\ | - |
1678 | if((r)->top() < (idRect)->extents.top())\ | - |
1679 | (idRect)->extents.setTop((r)->top());\ | - |
1680 | if((r)->right() > (idRect)->extents.right())\ | - |
1681 | (idRect)->extents.setRight((r)->right());\ | - |
1682 | if((r)->bottom() > (idRect)->extents.bottom())\ | - |
1683 | (idRect)->extents.setBottom((r)->bottom());\ | - |
1684 | } | - |
1685 | | - |
1686 | /* | - |
1687 | * Check to see if there is enough memory in the present region. | - |
1688 | */ | - |
1689 | #define MEMCHECK(dest, rect, firstrect){\ | - |
1690 | if ((dest).numRects >= ((dest).rects.size()-1)){\ | - |
1691 | firstrect.resize(firstrect.size() * 2); \ | - |
1692 | (rect) = (firstrect).data() + (dest).numRects;\ | - |
1693 | }\ | - |
1694 | } | - |
1695 | | - |
1696 | | - |
1697 | /* | - |
1698 | * number of points to buffer before sending them off | - |
1699 | * to scanlines(): Must be an even number | - |
1700 | */ | - |
1701 | #define NUMPTSTOBUFFER 200 | - |
1702 | | - |
1703 | /* | - |
1704 | * used to allocate buffers for points and link | - |
1705 | * the buffers together | - |
1706 | */ | - |
1707 | typedef struct _POINTBLOCK { | - |
1708 | int data[NUMPTSTOBUFFER * sizeof(QPoint)]; | - |
1709 | QPoint *pts; | - |
1710 | struct _POINTBLOCK *next; | - |
1711 | } POINTBLOCK; | - |
1712 | | - |
1713 | #endif | - |
1714 | // END OF region.h extract | - |
1715 | | - |
1716 | // START OF Region.c extract | - |
1717 | /* $XConsortium: Region.c /main/30 1996/10/22 14:21:24 kaleb $ */ | - |
1718 | /************************************************************************ | - |
1719 | | - |
1720 | Copyright (c) 1987, 1988 X Consortium | - |
1721 | | - |
1722 | Permission is hereby granted, free of charge, to any person obtaining a copy | - |
1723 | of this software and associated documentation files (the "Software"), to deal | - |
1724 | in the Software without restriction, including without limitation the rights | - |
1725 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | - |
1726 | copies of the Software, and to permit persons to whom the Software is | - |
1727 | furnished to do so, subject to the following conditions: | - |
1728 | | - |
1729 | The above copyright notice and this permission notice shall be included in | - |
1730 | all copies or substantial portions of the Software. | - |
1731 | | - |
1732 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | - |
1733 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | - |
1734 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | - |
1735 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | - |
1736 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | - |
1737 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | - |
1738 | | - |
1739 | Except as contained in this notice, the name of the X Consortium shall not be | - |
1740 | used in advertising or otherwise to promote the sale, use or other dealings | - |
1741 | in this Software without prior written authorization from the X Consortium. | - |
1742 | | - |
1743 | | - |
1744 | Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. | - |
1745 | | - |
1746 | All Rights Reserved | - |
1747 | | - |
1748 | Permission to use, copy, modify, and distribute this software and its | - |
1749 | documentation for any purpose and without fee is hereby granted, | - |
1750 | provided that the above copyright notice appear in all copies and that | - |
1751 | both that copyright notice and this permission notice appear in | - |
1752 | supporting documentation, and that the name of Digital not be | - |
1753 | used in advertising or publicity pertaining to distribution of the | - |
1754 | software without specific, written prior permission. | - |
1755 | | - |
1756 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | - |
1757 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | - |
1758 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | - |
1759 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | - |
1760 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | - |
1761 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | - |
1762 | SOFTWARE. | - |
1763 | | - |
1764 | ************************************************************************/ | - |
1765 | /* | - |
1766 | * The functions in this file implement the Region abstraction, similar to one | - |
1767 | * used in the X11 sample server. A Region is simply an area, as the name | - |
1768 | * implies, and is implemented as a "y-x-banded" array of rectangles. To | - |
1769 | * explain: Each Region is made up of a certain number of rectangles sorted | - |
1770 | * by y coordinate first, and then by x coordinate. | - |
1771 | * | - |
1772 | * Furthermore, the rectangles are banded such that every rectangle with a | - |
1773 | * given upper-left y coordinate (y1) will have the same lower-right y | - |
1774 | * coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it | - |
1775 | * will span the entire vertical distance of the band. This means that some | - |
1776 | * areas that could be merged into a taller rectangle will be represented as | - |
1777 | * several shorter rectangles to account for shorter rectangles to its left | - |
1778 | * or right but within its "vertical scope". | - |
1779 | * | - |
1780 | * An added constraint on the rectangles is that they must cover as much | - |
1781 | * horizontal area as possible. E.g. no two rectangles in a band are allowed | - |
1782 | * to touch. | - |
1783 | * | - |
1784 | * Whenever possible, bands will be merged together to cover a greater vertical | - |
1785 | * distance (and thus reduce the number of rectangles). Two bands can be merged | - |
1786 | * only if the bottom of one touches the top of the other and they have | - |
1787 | * rectangles in the same places (of the same width, of course). This maintains | - |
1788 | * the y-x-banding that's so nice to have... | - |
1789 | */ | - |
1790 | /* $XFree86: xc/lib/X11/Region.c,v 1.1.1.2.2.2 1998/10/04 15:22:50 hohndel Exp $ */ | - |
1791 | | - |
1792 | static void UnionRectWithRegion(register const QRect *rect, const QRegionPrivate *source, | - |
1793 | QRegionPrivate &dest) | - |
1794 | { | - |
1795 | if (rect->isEmpty()) partially evaluated: rect->isEmpty() no Evaluation Count:0 | yes Evaluation Count:315 |
| 0-315 |
1796 | return; | 0 |
1797 | | - |
1798 | Q_ASSERT(EqualRegion(source, &dest)); executed (the execution status of this line is deduced): qt_noop(); | - |
1799 | | - |
1800 | if (dest.numRects == 0) { evaluated: dest.numRects == 0 yes Evaluation Count:5 | yes Evaluation Count:310 |
| 5-310 |
1801 | dest = QRegionPrivate(*rect); executed (the execution status of this line is deduced): dest = QRegionPrivate(*rect); | - |
1802 | } else if (dest.canAppend(rect)) { executed: } Execution Count:5 partially evaluated: dest.canAppend(rect) yes Evaluation Count:310 | no Evaluation Count:0 |
| 0-310 |
1803 | dest.append(rect); executed (the execution status of this line is deduced): dest.append(rect); | - |
1804 | } else { executed: } Execution Count:310 | 310 |
1805 | QRegionPrivate p(*rect); never executed (the execution status of this line is deduced): QRegionPrivate p(*rect); | - |
1806 | UnionRegion(&p, source, dest); never executed (the execution status of this line is deduced): UnionRegion(&p, source, dest); | - |
1807 | } | 0 |
1808 | } | - |
1809 | | - |
1810 | /*- | - |
1811 | *----------------------------------------------------------------------- | - |
1812 | * miSetExtents -- | - |
1813 | * Reset the extents and innerRect of a region to what they should be. | - |
1814 | * Called by miSubtract and miIntersect b/c they can't figure it out | - |
1815 | * along the way or do so easily, as miUnion can. | - |
1816 | * | - |
1817 | * Results: | - |
1818 | * None. | - |
1819 | * | - |
1820 | * Side Effects: | - |
1821 | * The region's 'extents' and 'innerRect' structure is overwritten. | - |
1822 | * | - |
1823 | *----------------------------------------------------------------------- | - |
1824 | */ | - |
1825 | static void miSetExtents(QRegionPrivate &dest) | - |
1826 | { | - |
1827 | register const QRect *pBox, executed (the execution status of this line is deduced): register const QRect *pBox, | - |
1828 | *pBoxEnd; executed (the execution status of this line is deduced): *pBoxEnd; | - |
1829 | register QRect *pExtents; executed (the execution status of this line is deduced): register QRect *pExtents; | - |
1830 | | - |
1831 | dest.innerRect.setCoords(0, 0, -1, -1); executed (the execution status of this line is deduced): dest.innerRect.setCoords(0, 0, -1, -1); | - |
1832 | dest.innerArea = -1; executed (the execution status of this line is deduced): dest.innerArea = -1; | - |
1833 | if (dest.numRects == 0) { evaluated: dest.numRects == 0 yes Evaluation Count:121 | yes Evaluation Count:15074 |
| 121-15074 |
1834 | dest.extents.setCoords(0, 0, -1, -1); executed (the execution status of this line is deduced): dest.extents.setCoords(0, 0, -1, -1); | - |
1835 | return; executed: return; Execution Count:121 | 121 |
1836 | } | - |
1837 | | - |
1838 | pExtents = &dest.extents; executed (the execution status of this line is deduced): pExtents = &dest.extents; | - |
1839 | if (dest.rects.isEmpty()) partially evaluated: dest.rects.isEmpty() no Evaluation Count:0 | yes Evaluation Count:15074 |
| 0-15074 |
1840 | pBox = &dest.extents; never executed: pBox = &dest.extents; | 0 |
1841 | else | - |
1842 | pBox = dest.rects.constData(); executed: pBox = dest.rects.constData(); Execution Count:15074 | 15074 |
1843 | pBoxEnd = pBox + dest.numRects - 1; executed (the execution status of this line is deduced): pBoxEnd = pBox + dest.numRects - 1; | - |
1844 | | - |
1845 | /* | - |
1846 | * Since pBox is the first rectangle in the region, it must have the | - |
1847 | * smallest y1 and since pBoxEnd is the last rectangle in the region, | - |
1848 | * it must have the largest y2, because of banding. Initialize x1 and | - |
1849 | * x2 from pBox and pBoxEnd, resp., as good things to initialize them | - |
1850 | * to... | - |
1851 | */ | - |
1852 | pExtents->setLeft(pBox->left()); executed (the execution status of this line is deduced): pExtents->setLeft(pBox->left()); | - |
1853 | pExtents->setTop(pBox->top()); executed (the execution status of this line is deduced): pExtents->setTop(pBox->top()); | - |
1854 | pExtents->setRight(pBoxEnd->right()); executed (the execution status of this line is deduced): pExtents->setRight(pBoxEnd->right()); | - |
1855 | pExtents->setBottom(pBoxEnd->bottom()); executed (the execution status of this line is deduced): pExtents->setBottom(pBoxEnd->bottom()); | - |
1856 | | - |
1857 | Q_ASSERT(pExtents->top() <= pExtents->bottom()); executed (the execution status of this line is deduced): qt_noop(); | - |
1858 | while (pBox <= pBoxEnd) { evaluated: pBox <= pBoxEnd yes Evaluation Count:54212 | yes Evaluation Count:15074 |
| 15074-54212 |
1859 | if (pBox->left() < pExtents->left()) evaluated: pBox->left() < pExtents->left() yes Evaluation Count:1293 | yes Evaluation Count:52919 |
| 1293-52919 |
1860 | pExtents->setLeft(pBox->left()); executed: pExtents->setLeft(pBox->left()); Execution Count:1293 | 1293 |
1861 | if (pBox->right() > pExtents->right()) evaluated: pBox->right() > pExtents->right() yes Evaluation Count:1352 | yes Evaluation Count:52860 |
| 1352-52860 |
1862 | pExtents->setRight(pBox->right()); executed: pExtents->setRight(pBox->right()); Execution Count:1352 | 1352 |
1863 | dest.updateInnerRect(*pBox); executed (the execution status of this line is deduced): dest.updateInnerRect(*pBox); | - |
1864 | ++pBox; executed (the execution status of this line is deduced): ++pBox; | - |
1865 | } executed: } Execution Count:54212 | 54212 |
1866 | Q_ASSERT(pExtents->left() <= pExtents->right()); executed (the execution status of this line is deduced): qt_noop(); | - |
1867 | } executed: } Execution Count:15074 | 15074 |
1868 | | - |
1869 | /* TranslateRegion(pRegion, x, y) | - |
1870 | translates in place | - |
1871 | added by raymond | - |
1872 | */ | - |
1873 | | - |
1874 | static void OffsetRegion(register QRegionPrivate ®ion, register int x, register int y) | - |
1875 | { | - |
1876 | if (region.rects.size()) { evaluated: region.rects.size() yes Evaluation Count:14078 | yes Evaluation Count:37047 |
| 14078-37047 |
1877 | register QRect *pbox = region.rects.data(); executed (the execution status of this line is deduced): register QRect *pbox = region.rects.data(); | - |
1878 | register int nbox = region.numRects; executed (the execution status of this line is deduced): register int nbox = region.numRects; | - |
1879 | | - |
1880 | while (nbox--) { evaluated: nbox-- yes Evaluation Count:376133 | yes Evaluation Count:14078 |
| 14078-376133 |
1881 | pbox->translate(x, y); executed (the execution status of this line is deduced): pbox->translate(x, y); | - |
1882 | ++pbox; executed (the execution status of this line is deduced): ++pbox; | - |
1883 | } executed: } Execution Count:376133 | 376133 |
1884 | } executed: } Execution Count:14078 | 14078 |
1885 | region.extents.translate(x, y); executed (the execution status of this line is deduced): region.extents.translate(x, y); | - |
1886 | region.innerRect.translate(x, y); executed (the execution status of this line is deduced): region.innerRect.translate(x, y); | - |
1887 | } executed: } Execution Count:51125 | 51125 |
1888 | | - |
1889 | /*====================================================================== | - |
1890 | * Region Intersection | - |
1891 | *====================================================================*/ | - |
1892 | /*- | - |
1893 | *----------------------------------------------------------------------- | - |
1894 | * miIntersectO -- | - |
1895 | * Handle an overlapping band for miIntersect. | - |
1896 | * | - |
1897 | * Results: | - |
1898 | * None. | - |
1899 | * | - |
1900 | * Side Effects: | - |
1901 | * Rectangles may be added to the region. | - |
1902 | * | - |
1903 | *----------------------------------------------------------------------- | - |
1904 | */ | - |
1905 | static void miIntersectO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, | - |
1906 | register const QRect *r2, const QRect *r2End, int y1, int y2) | - |
1907 | { | - |
1908 | register int x1; executed (the execution status of this line is deduced): register int x1; | - |
1909 | register int x2; executed (the execution status of this line is deduced): register int x2; | - |
1910 | register QRect *pNextRect; executed (the execution status of this line is deduced): register QRect *pNextRect; | - |
1911 | | - |
1912 | pNextRect = dest.rects.data() + dest.numRects; executed (the execution status of this line is deduced): pNextRect = dest.rects.data() + dest.numRects; | - |
1913 | | - |
1914 | while (r1 != r1End && r2 != r2End) { evaluated: r1 != r1End yes Evaluation Count:977 | yes Evaluation Count:495 |
evaluated: r2 != r2End yes Evaluation Count:768 | yes Evaluation Count:209 |
| 209-977 |
1915 | x1 = qMax(r1->left(), r2->left()); executed (the execution status of this line is deduced): x1 = qMax(r1->left(), r2->left()); | - |
1916 | x2 = qMin(r1->right(), r2->right()); executed (the execution status of this line is deduced): x2 = qMin(r1->right(), r2->right()); | - |
1917 | | - |
1918 | /* | - |
1919 | * If there's any overlap between the two rectangles, add that | - |
1920 | * overlap to the new region. | - |
1921 | * There's no need to check for subsumption because the only way | - |
1922 | * such a need could arise is if some region has two rectangles | - |
1923 | * right next to each other. Since that should never happen... | - |
1924 | */ | - |
1925 | if (x1 <= x2) { partially evaluated: x1 <= x2 yes Evaluation Count:768 | no Evaluation Count:0 |
| 0-768 |
1926 | Q_ASSERT(y1 <= y2); executed (the execution status of this line is deduced): qt_noop(); | - |
1927 | MEMCHECK(dest, pNextRect, dest.rects) never executed: } partially evaluated: (dest).numRects >= ((dest).rects.size()-1) no Evaluation Count:0 | yes Evaluation Count:768 |
| 0-768 |
1928 | pNextRect->setCoords(x1, y1, x2, y2); executed (the execution status of this line is deduced): pNextRect->setCoords(x1, y1, x2, y2); | - |
1929 | ++dest.numRects; executed (the execution status of this line is deduced): ++dest.numRects; | - |
1930 | ++pNextRect; executed (the execution status of this line is deduced): ++pNextRect; | - |
1931 | } executed: } Execution Count:768 | 768 |
1932 | | - |
1933 | /* | - |
1934 | * Need to advance the pointers. Shift the one that extends | - |
1935 | * to the right the least, since the other still has a chance to | - |
1936 | * overlap with that region's next rectangle, if you see what I mean. | - |
1937 | */ | - |
1938 | if (r1->right() < r2->right()) { evaluated: r1->right() < r2->right() yes Evaluation Count:199 | yes Evaluation Count:569 |
| 199-569 |
1939 | ++r1; executed (the execution status of this line is deduced): ++r1; | - |
1940 | } else if (r2->right() < r1->right()) { executed: } Execution Count:199 evaluated: r2->right() < r1->right() yes Evaluation Count:235 | yes Evaluation Count:334 |
| 199-334 |
1941 | ++r2; executed (the execution status of this line is deduced): ++r2; | - |
1942 | } else { executed: } Execution Count:235 | 235 |
1943 | ++r1; executed (the execution status of this line is deduced): ++r1; | - |
1944 | ++r2; executed (the execution status of this line is deduced): ++r2; | - |
1945 | } executed: } Execution Count:334 | 334 |
1946 | } | - |
1947 | } executed: } Execution Count:704 | 704 |
1948 | | - |
1949 | /*====================================================================== | - |
1950 | * Generic Region Operator | - |
1951 | *====================================================================*/ | - |
1952 | | - |
1953 | /*- | - |
1954 | *----------------------------------------------------------------------- | - |
1955 | * miCoalesce -- | - |
1956 | * Attempt to merge the boxes in the current band with those in the | - |
1957 | * previous one. Used only by miRegionOp. | - |
1958 | * | - |
1959 | * Results: | - |
1960 | * The new index for the previous band. | - |
1961 | * | - |
1962 | * Side Effects: | - |
1963 | * If coalescing takes place: | - |
1964 | * - rectangles in the previous band will have their y2 fields | - |
1965 | * altered. | - |
1966 | * - dest.numRects will be decreased. | - |
1967 | * | - |
1968 | *----------------------------------------------------------------------- | - |
1969 | */ | - |
1970 | static int miCoalesce(register QRegionPrivate &dest, int prevStart, int curStart) | - |
1971 | { | - |
1972 | register QRect *pPrevBox; /* Current box in previous band */ executed (the execution status of this line is deduced): register QRect *pPrevBox; | - |
1973 | register QRect *pCurBox; /* Current box in current band */ executed (the execution status of this line is deduced): register QRect *pCurBox; | - |
1974 | register QRect *pRegEnd; /* End of region */ executed (the execution status of this line is deduced): register QRect *pRegEnd; | - |
1975 | int curNumRects; /* Number of rectangles in current band */ executed (the execution status of this line is deduced): int curNumRects; | - |
1976 | int prevNumRects; /* Number of rectangles in previous band */ executed (the execution status of this line is deduced): int prevNumRects; | - |
1977 | int bandY1; /* Y1 coordinate for current band */ executed (the execution status of this line is deduced): int bandY1; | - |
1978 | QRect *rData = dest.rects.data(); executed (the execution status of this line is deduced): QRect *rData = dest.rects.data(); | - |
1979 | | - |
1980 | pRegEnd = rData + dest.numRects; executed (the execution status of this line is deduced): pRegEnd = rData + dest.numRects; | - |
1981 | | - |
1982 | pPrevBox = rData + prevStart; executed (the execution status of this line is deduced): pPrevBox = rData + prevStart; | - |
1983 | prevNumRects = curStart - prevStart; executed (the execution status of this line is deduced): prevNumRects = curStart - prevStart; | - |
1984 | | - |
1985 | /* | - |
1986 | * Figure out how many rectangles are in the current band. Have to do | - |
1987 | * this because multiple bands could have been added in miRegionOp | - |
1988 | * at the end when one region has been exhausted. | - |
1989 | */ | - |
1990 | pCurBox = rData + curStart; executed (the execution status of this line is deduced): pCurBox = rData + curStart; | - |
1991 | bandY1 = pCurBox->top(); executed (the execution status of this line is deduced): bandY1 = pCurBox->top(); | - |
1992 | for (curNumRects = 0; pCurBox != pRegEnd && pCurBox->top() == bandY1; ++curNumRects) { evaluated: pCurBox != pRegEnd yes Evaluation Count:132327 | yes Evaluation Count:92085 |
evaluated: pCurBox->top() == bandY1 yes Evaluation Count:127488 | yes Evaluation Count:4839 |
| 4839-132327 |
1993 | ++pCurBox; executed (the execution status of this line is deduced): ++pCurBox; | - |
1994 | } executed: } Execution Count:127488 | 127488 |
1995 | | - |
1996 | if (pCurBox != pRegEnd) { evaluated: pCurBox != pRegEnd yes Evaluation Count:4839 | yes Evaluation Count:92085 |
| 4839-92085 |
1997 | /* | - |
1998 | * If more than one band was added, we have to find the start | - |
1999 | * of the last band added so the next coalescing job can start | - |
2000 | * at the right place... (given when multiple bands are added, | - |
2001 | * this may be pointless -- see above). | - |
2002 | */ | - |
2003 | --pRegEnd; executed (the execution status of this line is deduced): --pRegEnd; | - |
2004 | while ((pRegEnd - 1)->top() == pRegEnd->top()) evaluated: (pRegEnd - 1)->top() == pRegEnd->top() yes Evaluation Count:217 | yes Evaluation Count:4839 |
| 217-4839 |
2005 | --pRegEnd; executed: --pRegEnd; Execution Count:217 | 217 |
2006 | curStart = pRegEnd - rData; executed (the execution status of this line is deduced): curStart = pRegEnd - rData; | - |
2007 | pRegEnd = rData + dest.numRects; executed (the execution status of this line is deduced): pRegEnd = rData + dest.numRects; | - |
2008 | } executed: } Execution Count:4839 | 4839 |
2009 | | - |
2010 | if (curNumRects == prevNumRects && curNumRects != 0) { evaluated: curNumRects == prevNumRects yes Evaluation Count:40656 | yes Evaluation Count:56268 |
partially evaluated: curNumRects != 0 yes Evaluation Count:40656 | no Evaluation Count:0 |
| 0-56268 |
2011 | pCurBox -= curNumRects; executed (the execution status of this line is deduced): pCurBox -= curNumRects; | - |
2012 | /* | - |
2013 | * The bands may only be coalesced if the bottom of the previous | - |
2014 | * matches the top scanline of the current. | - |
2015 | */ | - |
2016 | if (pPrevBox->bottom() == pCurBox->top() - 1) { evaluated: pPrevBox->bottom() == pCurBox->top() - 1 yes Evaluation Count:37167 | yes Evaluation Count:3489 |
| 3489-37167 |
2017 | /* | - |
2018 | * Make sure the bands have boxes in the same places. This | - |
2019 | * assumes that boxes have been added in such a way that they | - |
2020 | * cover the most area possible. I.e. two boxes in a band must | - |
2021 | * have some horizontal space between them. | - |
2022 | */ | - |
2023 | do { | - |
2024 | if (pPrevBox->left() != pCurBox->left() || pPrevBox->right() != pCurBox->right()) { evaluated: pPrevBox->left() != pCurBox->left() yes Evaluation Count:20526 | yes Evaluation Count:17493 |
evaluated: pPrevBox->right() != pCurBox->right() yes Evaluation Count:12043 | yes Evaluation Count:5450 |
| 5450-20526 |
2025 | // The bands don't line up so they can't be coalesced. | - |
2026 | return curStart; executed: return curStart; Execution Count:32569 | 32569 |
2027 | } | - |
2028 | ++pPrevBox; executed (the execution status of this line is deduced): ++pPrevBox; | - |
2029 | ++pCurBox; executed (the execution status of this line is deduced): ++pCurBox; | - |
2030 | --prevNumRects; executed (the execution status of this line is deduced): --prevNumRects; | - |
2031 | } while (prevNumRects != 0); executed: } Execution Count:5450 evaluated: prevNumRects != 0 yes Evaluation Count:852 | yes Evaluation Count:4598 |
| 852-5450 |
2032 | | - |
2033 | dest.numRects -= curNumRects; executed (the execution status of this line is deduced): dest.numRects -= curNumRects; | - |
2034 | pCurBox -= curNumRects; executed (the execution status of this line is deduced): pCurBox -= curNumRects; | - |
2035 | pPrevBox -= curNumRects; executed (the execution status of this line is deduced): pPrevBox -= curNumRects; | - |
2036 | | - |
2037 | /* | - |
2038 | * The bands may be merged, so set the bottom y of each box | - |
2039 | * in the previous band to that of the corresponding box in | - |
2040 | * the current band. | - |
2041 | */ | - |
2042 | do { | - |
2043 | pPrevBox->setBottom(pCurBox->bottom()); executed (the execution status of this line is deduced): pPrevBox->setBottom(pCurBox->bottom()); | - |
2044 | dest.updateInnerRect(*pPrevBox); executed (the execution status of this line is deduced): dest.updateInnerRect(*pPrevBox); | - |
2045 | ++pPrevBox; executed (the execution status of this line is deduced): ++pPrevBox; | - |
2046 | ++pCurBox; executed (the execution status of this line is deduced): ++pCurBox; | - |
2047 | curNumRects -= 1; executed (the execution status of this line is deduced): curNumRects -= 1; | - |
2048 | } while (curNumRects != 0); executed: } Execution Count:4914 evaluated: curNumRects != 0 yes Evaluation Count:316 | yes Evaluation Count:4598 |
| 316-4914 |
2049 | | - |
2050 | /* | - |
2051 | * If only one band was added to the region, we have to backup | - |
2052 | * curStart to the start of the previous band. | - |
2053 | * | - |
2054 | * If more than one band was added to the region, copy the | - |
2055 | * other bands down. The assumption here is that the other bands | - |
2056 | * came from the same region as the current one and no further | - |
2057 | * coalescing can be done on them since it's all been done | - |
2058 | * already... curStart is already in the right place. | - |
2059 | */ | - |
2060 | if (pCurBox == pRegEnd) { evaluated: pCurBox == pRegEnd yes Evaluation Count:4500 | yes Evaluation Count:98 |
| 98-4500 |
2061 | curStart = prevStart; executed (the execution status of this line is deduced): curStart = prevStart; | - |
2062 | } else { executed: } Execution Count:4500 | 4500 |
2063 | do { | - |
2064 | *pPrevBox++ = *pCurBox++; executed (the execution status of this line is deduced): *pPrevBox++ = *pCurBox++; | - |
2065 | dest.updateInnerRect(*pPrevBox); executed (the execution status of this line is deduced): dest.updateInnerRect(*pPrevBox); | - |
2066 | } while (pCurBox != pRegEnd); executed: } Execution Count:184 evaluated: pCurBox != pRegEnd yes Evaluation Count:86 | yes Evaluation Count:98 |
| 86-184 |
2067 | } executed: } Execution Count:98 | 98 |
2068 | } | - |
2069 | } executed: } Execution Count:8087 | 8087 |
2070 | return curStart; executed: return curStart; Execution Count:64355 | 64355 |
2071 | } | - |
2072 | | - |
2073 | /*- | - |
2074 | *----------------------------------------------------------------------- | - |
2075 | * miRegionOp -- | - |
2076 | * Apply an operation to two regions. Called by miUnion, miInverse, | - |
2077 | * miSubtract, miIntersect... | - |
2078 | * | - |
2079 | * Results: | - |
2080 | * None. | - |
2081 | * | - |
2082 | * Side Effects: | - |
2083 | * The new region is overwritten. | - |
2084 | * | - |
2085 | * Notes: | - |
2086 | * The idea behind this function is to view the two regions as sets. | - |
2087 | * Together they cover a rectangle of area that this function divides | - |
2088 | * into horizontal bands where points are covered only by one region | - |
2089 | * or by both. For the first case, the nonOverlapFunc is called with | - |
2090 | * each the band and the band's upper and lower extents. For the | - |
2091 | * second, the overlapFunc is called to process the entire band. It | - |
2092 | * is responsible for clipping the rectangles in the band, though | - |
2093 | * this function provides the boundaries. | - |
2094 | * At the end of each band, the new region is coalesced, if possible, | - |
2095 | * to reduce the number of rectangles in the region. | - |
2096 | * | - |
2097 | *----------------------------------------------------------------------- | - |
2098 | */ | - |
2099 | static void miRegionOp(register QRegionPrivate &dest, | - |
2100 | const QRegionPrivate *reg1, const QRegionPrivate *reg2, | - |
2101 | OverlapFunc overlapFunc, NonOverlapFunc nonOverlap1Func, | - |
2102 | NonOverlapFunc nonOverlap2Func) | - |
2103 | { | - |
2104 | register const QRect *r1; // Pointer into first region executed (the execution status of this line is deduced): register const QRect *r1; | - |
2105 | register const QRect *r2; // Pointer into 2d region executed (the execution status of this line is deduced): register const QRect *r2; | - |
2106 | const QRect *r1End; // End of 1st region executed (the execution status of this line is deduced): const QRect *r1End; | - |
2107 | const QRect *r2End; // End of 2d region executed (the execution status of this line is deduced): const QRect *r2End; | - |
2108 | register int ybot; // Bottom of intersection executed (the execution status of this line is deduced): register int ybot; | - |
2109 | register int ytop; // Top of intersection executed (the execution status of this line is deduced): register int ytop; | - |
2110 | int prevBand; // Index of start of previous band in dest executed (the execution status of this line is deduced): int prevBand; | - |
2111 | int curBand; // Index of start of current band in dest executed (the execution status of this line is deduced): int curBand; | - |
2112 | register const QRect *r1BandEnd; // End of current band in r1 executed (the execution status of this line is deduced): register const QRect *r1BandEnd; | - |
2113 | register const QRect *r2BandEnd; // End of current band in r2 executed (the execution status of this line is deduced): register const QRect *r2BandEnd; | - |
2114 | int top; // Top of non-overlapping band executed (the execution status of this line is deduced): int top; | - |
2115 | int bot; // Bottom of non-overlapping band executed (the execution status of this line is deduced): int bot; | - |
2116 | | - |
2117 | /* | - |
2118 | * Initialization: | - |
2119 | * set r1, r2, r1End and r2End appropriately, preserve the important | - |
2120 | * parts of the destination region until the end in case it's one of | - |
2121 | * the two source regions, then mark the "new" region empty, allocating | - |
2122 | * another array of rectangles for it to use. | - |
2123 | */ | - |
2124 | if (reg1->numRects == 1) evaluated: reg1->numRects == 1 yes Evaluation Count:13480 | yes Evaluation Count:21576 |
| 13480-21576 |
2125 | r1 = ®1->extents; executed: r1 = ®1->extents; Execution Count:13480 | 13480 |
2126 | else | - |
2127 | r1 = reg1->rects.constData(); executed: r1 = reg1->rects.constData(); Execution Count:21576 | 21576 |
2128 | if (reg2->numRects == 1) evaluated: reg2->numRects == 1 yes Evaluation Count:32302 | yes Evaluation Count:2754 |
| 2754-32302 |
2129 | r2 = ®2->extents; executed: r2 = ®2->extents; Execution Count:32302 | 32302 |
2130 | else | - |
2131 | r2 = reg2->rects.constData(); executed: r2 = reg2->rects.constData(); Execution Count:2754 | 2754 |
2132 | | - |
2133 | r1End = r1 + reg1->numRects; executed (the execution status of this line is deduced): r1End = r1 + reg1->numRects; | - |
2134 | r2End = r2 + reg2->numRects; executed (the execution status of this line is deduced): r2End = r2 + reg2->numRects; | - |
2135 | | - |
2136 | dest.vectorize(); executed (the execution status of this line is deduced): dest.vectorize(); | - |
2137 | | - |
2138 | QVector<QRect> oldRects = dest.rects; executed (the execution status of this line is deduced): QVector<QRect> oldRects = dest.rects; | - |
2139 | | - |
2140 | dest.numRects = 0; executed (the execution status of this line is deduced): dest.numRects = 0; | - |
2141 | | - |
2142 | /* | - |
2143 | * Allocate a reasonable number of rectangles for the new region. The idea | - |
2144 | * is to allocate enough so the individual functions don't need to | - |
2145 | * reallocate and copy the array, which is time consuming, yet we don't | - |
2146 | * have to worry about using too much memory. I hope to be able to | - |
2147 | * nuke the realloc() at the end of this function eventually. | - |
2148 | */ | - |
2149 | dest.rects.resize(qMax(reg1->numRects,reg2->numRects) * 2); executed (the execution status of this line is deduced): dest.rects.resize(qMax(reg1->numRects,reg2->numRects) * 2); | - |
2150 | | - |
2151 | /* | - |
2152 | * Initialize ybot and ytop. | - |
2153 | * In the upcoming loop, ybot and ytop serve different functions depending | - |
2154 | * on whether the band being handled is an overlapping or non-overlapping | - |
2155 | * band. | - |
2156 | * In the case of a non-overlapping band (only one of the regions | - |
2157 | * has points in the band), ybot is the bottom of the most recent | - |
2158 | * intersection and thus clips the top of the rectangles in that band. | - |
2159 | * ytop is the top of the next intersection between the two regions and | - |
2160 | * serves to clip the bottom of the rectangles in the current band. | - |
2161 | * For an overlapping band (where the two regions intersect), ytop clips | - |
2162 | * the top of the rectangles of both regions and ybot clips the bottoms. | - |
2163 | */ | - |
2164 | if (reg1->extents.top() < reg2->extents.top()) evaluated: reg1->extents.top() < reg2->extents.top() yes Evaluation Count:18733 | yes Evaluation Count:16323 |
| 16323-18733 |
2165 | ybot = reg1->extents.top() - 1; executed: ybot = reg1->extents.top() - 1; Execution Count:18733 | 18733 |
2166 | else | - |
2167 | ybot = reg2->extents.top() - 1; executed: ybot = reg2->extents.top() - 1; Execution Count:16323 | 16323 |
2168 | | - |
2169 | /* | - |
2170 | * prevBand serves to mark the start of the previous band so rectangles | - |
2171 | * can be coalesced into larger rectangles. qv. miCoalesce, above. | - |
2172 | * In the beginning, there is no previous band, so prevBand == curBand | - |
2173 | * (curBand is set later on, of course, but the first band will always | - |
2174 | * start at index 0). prevBand and curBand must be indices because of | - |
2175 | * the possible expansion, and resultant moving, of the new region's | - |
2176 | * array of rectangles. | - |
2177 | */ | - |
2178 | prevBand = 0; executed (the execution status of this line is deduced): prevBand = 0; | - |
2179 | | - |
2180 | do { | - |
2181 | curBand = dest.numRects; executed (the execution status of this line is deduced): curBand = dest.numRects; | - |
2182 | | - |
2183 | /* | - |
2184 | * This algorithm proceeds one source-band (as opposed to a | - |
2185 | * destination band, which is determined by where the two regions | - |
2186 | * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the | - |
2187 | * rectangle after the last one in the current band for their | - |
2188 | * respective regions. | - |
2189 | */ | - |
2190 | r1BandEnd = r1; executed (the execution status of this line is deduced): r1BandEnd = r1; | - |
2191 | while (r1BandEnd != r1End && r1BandEnd->top() == r1->top()) evaluated: r1BandEnd != r1End yes Evaluation Count:128573 | yes Evaluation Count:24365 |
evaluated: r1BandEnd->top() == r1->top() yes Evaluation Count:86971 | yes Evaluation Count:41602 |
| 24365-128573 |
2192 | ++r1BandEnd; executed: ++r1BandEnd; Execution Count:86971 | 86971 |
2193 | | - |
2194 | r2BandEnd = r2; executed (the execution status of this line is deduced): r2BandEnd = r2; | - |
2195 | while (r2BandEnd != r2End && r2BandEnd->top() == r2->top()) evaluated: r2BandEnd != r2End yes Evaluation Count:75476 | yes Evaluation Count:58436 |
evaluated: r2BandEnd->top() == r2->top() yes Evaluation Count:67945 | yes Evaluation Count:7531 |
| 7531-75476 |
2196 | ++r2BandEnd; executed: ++r2BandEnd; Execution Count:67945 | 67945 |
2197 | | - |
2198 | /* | - |
2199 | * First handle the band that doesn't intersect, if any. | - |
2200 | * | - |
2201 | * Note that attention is restricted to one band in the | - |
2202 | * non-intersecting region at once, so if a region has n | - |
2203 | * bands between the current position and the next place it overlaps | - |
2204 | * the other, this entire loop will be passed through n times. | - |
2205 | */ | - |
2206 | if (r1->top() < r2->top()) { evaluated: r1->top() < r2->top() yes Evaluation Count:25210 | yes Evaluation Count:40757 |
| 25210-40757 |
2207 | top = qMax(r1->top(), ybot + 1); executed (the execution status of this line is deduced): top = qMax(r1->top(), ybot + 1); | - |
2208 | bot = qMin(r1->bottom(), r2->top() - 1); executed (the execution status of this line is deduced): bot = qMin(r1->bottom(), r2->top() - 1); | - |
2209 | | - |
2210 | if (nonOverlap1Func != 0 && bot >= top) evaluated: nonOverlap1Func != 0 yes Evaluation Count:24975 | yes Evaluation Count:235 |
evaluated: bot >= top yes Evaluation Count:22867 | yes Evaluation Count:2108 |
| 235-24975 |
2211 | (*nonOverlap1Func)(dest, r1, r1BandEnd, top, bot); executed: (*nonOverlap1Func)(dest, r1, r1BandEnd, top, bot); Execution Count:22867 | 22867 |
2212 | ytop = r2->top(); executed (the execution status of this line is deduced): ytop = r2->top(); | - |
2213 | } else if (r2->top() < r1->top()) { executed: } Execution Count:25210 evaluated: r2->top() < r1->top() yes Evaluation Count:13188 | yes Evaluation Count:27569 |
| 13188-27569 |
2214 | top = qMax(r2->top(), ybot + 1); executed (the execution status of this line is deduced): top = qMax(r2->top(), ybot + 1); | - |
2215 | bot = qMin(r2->bottom(), r1->top() - 1); executed (the execution status of this line is deduced): bot = qMin(r2->bottom(), r1->top() - 1); | - |
2216 | | - |
2217 | if (nonOverlap2Func != 0 && bot >= top) evaluated: nonOverlap2Func != 0 yes Evaluation Count:12366 | yes Evaluation Count:822 |
evaluated: bot >= top yes Evaluation Count:1739 | yes Evaluation Count:10627 |
| 822-12366 |
2218 | (*nonOverlap2Func)(dest, r2, r2BandEnd, top, bot); executed: (*nonOverlap2Func)(dest, r2, r2BandEnd, top, bot); Execution Count:1739 | 1739 |
2219 | ytop = r1->top(); executed (the execution status of this line is deduced): ytop = r1->top(); | - |
2220 | } else { executed: } Execution Count:13188 | 13188 |
2221 | ytop = r1->top(); executed (the execution status of this line is deduced): ytop = r1->top(); | - |
2222 | } executed: } Execution Count:27569 | 27569 |
2223 | | - |
2224 | /* | - |
2225 | * If any rectangles got added to the region, try and coalesce them | - |
2226 | * with rectangles from the previous band. Note we could just do | - |
2227 | * this test in miCoalesce, but some machines incur a not | - |
2228 | * inconsiderable cost for function calls, so... | - |
2229 | */ | - |
2230 | if (dest.numRects != curBand) evaluated: dest.numRects != curBand yes Evaluation Count:24606 | yes Evaluation Count:41361 |
| 24606-41361 |
2231 | prevBand = miCoalesce(dest, prevBand, curBand); executed: prevBand = miCoalesce(dest, prevBand, curBand); Execution Count:24606 | 24606 |
2232 | | - |
2233 | /* | - |
2234 | * Now see if we've hit an intersecting band. The two bands only | - |
2235 | * intersect if ybot >= ytop | - |
2236 | */ | - |
2237 | ybot = qMin(r1->bottom(), r2->bottom()); executed (the execution status of this line is deduced): ybot = qMin(r1->bottom(), r2->bottom()); | - |
2238 | curBand = dest.numRects; executed (the execution status of this line is deduced): curBand = dest.numRects; | - |
2239 | if (ybot >= ytop) evaluated: ybot >= ytop yes Evaluation Count:50028 | yes Evaluation Count:15939 |
| 15939-50028 |
2240 | (*overlapFunc)(dest, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot); executed: (*overlapFunc)(dest, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot); Execution Count:50028 | 50028 |
2241 | | - |
2242 | if (dest.numRects != curBand) evaluated: dest.numRects != curBand yes Evaluation Count:48108 | yes Evaluation Count:17859 |
| 17859-48108 |
2243 | prevBand = miCoalesce(dest, prevBand, curBand); executed: prevBand = miCoalesce(dest, prevBand, curBand); Execution Count:48108 | 48108 |
2244 | | - |
2245 | /* | - |
2246 | * If we've finished with a band (y2 == ybot) we skip forward | - |
2247 | * in the region to the next band. | - |
2248 | */ | - |
2249 | if (r1->bottom() == ybot) evaluated: r1->bottom() == ybot yes Evaluation Count:53500 | yes Evaluation Count:12467 |
| 12467-53500 |
2250 | r1 = r1BandEnd; executed: r1 = r1BandEnd; Execution Count:53500 | 53500 |
2251 | if (r2->bottom() == ybot) evaluated: r2->bottom() == ybot yes Evaluation Count:38387 | yes Evaluation Count:27580 |
| 27580-38387 |
2252 | r2 = r2BandEnd; executed: r2 = r2BandEnd; Execution Count:38387 | 38387 |
2253 | } while (r1 != r1End && r2 != r2End); executed: } Execution Count:65967 evaluated: r1 != r1End yes Evaluation Count:53220 | yes Evaluation Count:12747 |
evaluated: r2 != r2End yes Evaluation Count:30911 | yes Evaluation Count:22309 |
| 12747-65967 |
2254 | | - |
2255 | /* | - |
2256 | * Deal with whichever region still has rectangles left. | - |
2257 | */ | - |
2258 | curBand = dest.numRects; executed (the execution status of this line is deduced): curBand = dest.numRects; | - |
2259 | if (r1 != r1End) { evaluated: r1 != r1End yes Evaluation Count:22309 | yes Evaluation Count:12747 |
| 12747-22309 |
2260 | if (nonOverlap1Func != 0) { evaluated: nonOverlap1Func != 0 yes Evaluation Count:22305 | yes Evaluation Count:4 |
| 4-22305 |
2261 | do { | - |
2262 | r1BandEnd = r1; executed (the execution status of this line is deduced): r1BandEnd = r1; | - |
2263 | while (r1BandEnd < r1End && r1BandEnd->top() == r1->top()) evaluated: r1BandEnd < r1End yes Evaluation Count:33554 | yes Evaluation Count:22305 |
evaluated: r1BandEnd->top() == r1->top() yes Evaluation Count:28361 | yes Evaluation Count:5193 |
| 5193-33554 |
2264 | ++r1BandEnd; executed: ++r1BandEnd; Execution Count:28361 | 28361 |
2265 | (*nonOverlap1Func)(dest, r1, r1BandEnd, qMax(r1->top(), ybot + 1), r1->bottom()); executed (the execution status of this line is deduced): (*nonOverlap1Func)(dest, r1, r1BandEnd, qMax(r1->top(), ybot + 1), r1->bottom()); | - |
2266 | r1 = r1BandEnd; executed (the execution status of this line is deduced): r1 = r1BandEnd; | - |
2267 | } while (r1 != r1End); executed: } Execution Count:27498 evaluated: r1 != r1End yes Evaluation Count:5193 | yes Evaluation Count:22305 |
| 5193-27498 |
2268 | } executed: } Execution Count:22305 | 22305 |
2269 | } else if ((r2 != r2End) && (nonOverlap2Func != 0)) { executed: } Execution Count:22309 evaluated: (r2 != r2End) yes Evaluation Count:2311 | yes Evaluation Count:10436 |
evaluated: (nonOverlap2Func != 0) yes Evaluation Count:1905 | yes Evaluation Count:406 |
| 406-22309 |
2270 | do { | - |
2271 | r2BandEnd = r2; executed (the execution status of this line is deduced): r2BandEnd = r2; | - |
2272 | while (r2BandEnd < r2End && r2BandEnd->top() == r2->top()) evaluated: r2BandEnd < r2End yes Evaluation Count:2198 | yes Evaluation Count:1905 |
evaluated: r2BandEnd->top() == r2->top() yes Evaluation Count:2092 | yes Evaluation Count:106 |
| 106-2198 |
2273 | ++r2BandEnd; executed: ++r2BandEnd; Execution Count:2092 | 2092 |
2274 | (*nonOverlap2Func)(dest, r2, r2BandEnd, qMax(r2->top(), ybot + 1), r2->bottom()); executed (the execution status of this line is deduced): (*nonOverlap2Func)(dest, r2, r2BandEnd, qMax(r2->top(), ybot + 1), r2->bottom()); | - |
2275 | r2 = r2BandEnd; executed (the execution status of this line is deduced): r2 = r2BandEnd; | - |
2276 | } while (r2 != r2End); executed: } Execution Count:2011 evaluated: r2 != r2End yes Evaluation Count:106 | yes Evaluation Count:1905 |
| 106-2011 |
2277 | } executed: } Execution Count:1905 | 1905 |
2278 | | - |
2279 | if (dest.numRects != curBand) evaluated: dest.numRects != curBand yes Evaluation Count:24210 | yes Evaluation Count:10846 |
| 10846-24210 |
2280 | (void)miCoalesce(dest, prevBand, curBand); executed: (void)miCoalesce(dest, prevBand, curBand); Execution Count:24210 | 24210 |
2281 | | - |
2282 | /* | - |
2283 | * A bit of cleanup. To keep regions from growing without bound, | - |
2284 | * we shrink the array of rectangles to match the new number of | - |
2285 | * rectangles in the region. | - |
2286 | * | - |
2287 | * Only do this stuff if the number of rectangles allocated is more than | - |
2288 | * twice the number of rectangles in the region (a simple optimization). | - |
2289 | */ | - |
2290 | if (qMax(4, dest.numRects) < (dest.rects.size() >> 1)) evaluated: qMax(4, dest.numRects) < (dest.rects.size() >> 1) yes Evaluation Count:337 | yes Evaluation Count:34719 |
| 337-34719 |
2291 | dest.rects.resize(dest.numRects); executed: dest.rects.resize(dest.numRects); Execution Count:337 | 337 |
2292 | } executed: } Execution Count:35056 | 35056 |
2293 | | - |
2294 | /*====================================================================== | - |
2295 | * Region Union | - |
2296 | *====================================================================*/ | - |
2297 | | - |
2298 | /*- | - |
2299 | *----------------------------------------------------------------------- | - |
2300 | * miUnionNonO -- | - |
2301 | * Handle a non-overlapping band for the union operation. Just | - |
2302 | * Adds the rectangles into the region. Doesn't have to check for | - |
2303 | * subsumption or anything. | - |
2304 | * | - |
2305 | * Results: | - |
2306 | * None. | - |
2307 | * | - |
2308 | * Side Effects: | - |
2309 | * dest.numRects is incremented and the final rectangles overwritten | - |
2310 | * with the rectangles we're passed. | - |
2311 | * | - |
2312 | *----------------------------------------------------------------------- | - |
2313 | */ | - |
2314 | | - |
2315 | static void miUnionNonO(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd, | - |
2316 | register int y1, register int y2) | - |
2317 | { | - |
2318 | register QRect *pNextRect; executed (the execution status of this line is deduced): register QRect *pNextRect; | - |
2319 | | - |
2320 | pNextRect = dest.rects.data() + dest.numRects; executed (the execution status of this line is deduced): pNextRect = dest.rects.data() + dest.numRects; | - |
2321 | | - |
2322 | Q_ASSERT(y1 <= y2); executed (the execution status of this line is deduced): qt_noop(); | - |
2323 | | - |
2324 | while (r != rEnd) { evaluated: r != rEnd yes Evaluation Count:37295 | yes Evaluation Count:31946 |
| 31946-37295 |
2325 | Q_ASSERT(r->left() <= r->right()); executed (the execution status of this line is deduced): qt_noop(); | - |
2326 | MEMCHECK(dest, pNextRect, dest.rects) executed: } Execution Count:10187 evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:10187 | yes Evaluation Count:27108 |
| 10187-27108 |
2327 | pNextRect->setCoords(r->left(), y1, r->right(), y2); executed (the execution status of this line is deduced): pNextRect->setCoords(r->left(), y1, r->right(), y2); | - |
2328 | dest.numRects++; executed (the execution status of this line is deduced): dest.numRects++; | - |
2329 | ++pNextRect; executed (the execution status of this line is deduced): ++pNextRect; | - |
2330 | ++r; executed (the execution status of this line is deduced): ++r; | - |
2331 | } executed: } Execution Count:37295 | 37295 |
2332 | } executed: } Execution Count:31946 | 31946 |
2333 | | - |
2334 | | - |
2335 | /*- | - |
2336 | *----------------------------------------------------------------------- | - |
2337 | * miUnionO -- | - |
2338 | * Handle an overlapping band for the union operation. Picks the | - |
2339 | * left-most rectangle each time and merges it into the region. | - |
2340 | * | - |
2341 | * Results: | - |
2342 | * None. | - |
2343 | * | - |
2344 | * Side Effects: | - |
2345 | * Rectangles are overwritten in dest.rects and dest.numRects will | - |
2346 | * be changed. | - |
2347 | * | - |
2348 | *----------------------------------------------------------------------- | - |
2349 | */ | - |
2350 | | - |
2351 | static void miUnionO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, | - |
2352 | register const QRect *r2, const QRect *r2End, register int y1, register int y2) | - |
2353 | { | - |
2354 | register QRect *pNextRect; executed (the execution status of this line is deduced): register QRect *pNextRect; | - |
2355 | | - |
2356 | pNextRect = dest.rects.data() + dest.numRects; executed (the execution status of this line is deduced): pNextRect = dest.rects.data() + dest.numRects; | - |
2357 | | - |
2358 | #define MERGERECT(r) \ | - |
2359 | if ((dest.numRects != 0) && \ | - |
2360 | (pNextRect[-1].top() == y1) && \ | - |
2361 | (pNextRect[-1].bottom() == y2) && \ | - |
2362 | (pNextRect[-1].right() >= r->left()-1)) { \ | - |
2363 | if (pNextRect[-1].right() < r->right()) { \ | - |
2364 | pNextRect[-1].setRight(r->right()); \ | - |
2365 | dest.updateInnerRect(pNextRect[-1]); \ | - |
2366 | Q_ASSERT(pNextRect[-1].left() <= pNextRect[-1].right()); \ | - |
2367 | } \ | - |
2368 | } else { \ | - |
2369 | MEMCHECK(dest, pNextRect, dest.rects) \ | - |
2370 | pNextRect->setCoords(r->left(), y1, r->right(), y2); \ | - |
2371 | dest.updateInnerRect(*pNextRect); \ | - |
2372 | dest.numRects++; \ | - |
2373 | pNextRect++; \ | - |
2374 | } \ | - |
2375 | r++; | - |
2376 | | - |
2377 | Q_ASSERT(y1 <= y2); executed (the execution status of this line is deduced): qt_noop(); | - |
2378 | while (r1 != r1End && r2 != r2End) { evaluated: r1 != r1End yes Evaluation Count:56341 | yes Evaluation Count:14479 |
evaluated: r2 != r2End yes Evaluation Count:38238 | yes Evaluation Count:18103 |
| 14479-56341 |
2379 | if (r1->left() < r2->left()) { evaluated: r1->left() < r2->left() yes Evaluation Count:19133 | yes Evaluation Count:19105 |
| 19105-19133 |
2380 | MERGERECT(r1) executed: } Execution Count:864 executed: } Execution Count:900 executed: } Execution Count:8578 executed: } Execution Count:18233 evaluated: pNextRect[-1].right() < r1->right() yes Evaluation Count:864 | yes Evaluation Count:36 |
evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:8578 | yes Evaluation Count:9655 |
evaluated: (dest.numRects != 0) yes Evaluation Count:17041 | yes Evaluation Count:2092 |
evaluated: (pNextRect[-1].top() == y1) yes Evaluation Count:4843 | yes Evaluation Count:12198 |
partially evaluated: (pNextRect[-1].bottom() == y2) yes Evaluation Count:4843 | no Evaluation Count:0 |
evaluated: (pNextRect[-1].right() >= r1->left()-1) yes Evaluation Count:900 | yes Evaluation Count:3943 |
| 0-18233 |
2381 | } else { executed: } Execution Count:19133 | 19133 |
2382 | MERGERECT(r2) executed: } Execution Count:285 executed: } Execution Count:357 executed: } Execution Count:2966 executed: } Execution Count:18748 evaluated: pNextRect[-1].right() < r2->right() yes Evaluation Count:285 | yes Evaluation Count:72 |
evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:2966 | yes Evaluation Count:15782 |
evaluated: (dest.numRects != 0) yes Evaluation Count:10259 | yes Evaluation Count:8846 |
evaluated: (pNextRect[-1].top() == y1) yes Evaluation Count:813 | yes Evaluation Count:9446 |
partially evaluated: (pNextRect[-1].bottom() == y2) yes Evaluation Count:813 | no Evaluation Count:0 |
evaluated: (pNextRect[-1].right() >= r2->left()-1) yes Evaluation Count:357 | yes Evaluation Count:456 |
| 0-18748 |
2383 | } executed: } Execution Count:19105 | 19105 |
2384 | } | - |
2385 | | - |
2386 | if (r1 != r1End) { evaluated: r1 != r1End yes Evaluation Count:18103 | yes Evaluation Count:14479 |
| 14479-18103 |
2387 | do { | - |
2388 | MERGERECT(r1) executed: } Execution Count:10634 executed: } Execution Count:17764 executed: } Execution Count:507 executed: } Execution Count:2709 evaluated: pNextRect[-1].right() < r1->right() yes Evaluation Count:10634 | yes Evaluation Count:7130 |
evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:507 | yes Evaluation Count:2202 |
partially evaluated: (dest.numRects != 0) yes Evaluation Count:20473 | no Evaluation Count:0 |
partially evaluated: (pNextRect[-1].top() == y1) yes Evaluation Count:20473 | no Evaluation Count:0 |
partially evaluated: (pNextRect[-1].bottom() == y2) yes Evaluation Count:20473 | no Evaluation Count:0 |
evaluated: (pNextRect[-1].right() >= r1->left()-1) yes Evaluation Count:17764 | yes Evaluation Count:2709 |
| 0-20473 |
2389 | } while (r1 != r1End); executed: } Execution Count:20473 evaluated: r1 != r1End yes Evaluation Count:2370 | yes Evaluation Count:18103 |
| 2370-20473 |
2390 | } else { executed: } Execution Count:18103 | 18103 |
2391 | while (r2 != r2End) { evaluated: r2 != r2End yes Evaluation Count:14945 | yes Evaluation Count:14479 |
| 14479-14945 |
2392 | MERGERECT(r2) executed: } Execution Count:5045 executed: } Execution Count:13537 executed: } Execution Count:250 executed: } Execution Count:1408 evaluated: pNextRect[-1].right() < r2->right() yes Evaluation Count:5045 | yes Evaluation Count:8492 |
evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:250 | yes Evaluation Count:1158 |
partially evaluated: (dest.numRects != 0) yes Evaluation Count:14945 | no Evaluation Count:0 |
partially evaluated: (pNextRect[-1].top() == y1) yes Evaluation Count:14945 | no Evaluation Count:0 |
partially evaluated: (pNextRect[-1].bottom() == y2) yes Evaluation Count:14945 | no Evaluation Count:0 |
evaluated: (pNextRect[-1].right() >= r2->left()-1) yes Evaluation Count:13537 | yes Evaluation Count:1408 |
| 0-14945 |
2393 | } executed: } Execution Count:14945 | 14945 |
2394 | } executed: } Execution Count:14479 | 14479 |
2395 | } | - |
2396 | | - |
2397 | static void UnionRegion(const QRegionPrivate *reg1, const QRegionPrivate *reg2, QRegionPrivate &dest) | - |
2398 | { | - |
2399 | Q_ASSERT(!isEmptyHelper(reg1) && !isEmptyHelper(reg2)); executed (the execution status of this line is deduced): qt_noop(); | - |
2400 | Q_ASSERT(!reg1->contains(*reg2)); executed (the execution status of this line is deduced): qt_noop(); | - |
2401 | Q_ASSERT(!reg2->contains(*reg1)); executed (the execution status of this line is deduced): qt_noop(); | - |
2402 | Q_ASSERT(!EqualRegion(reg1, reg2)); executed (the execution status of this line is deduced): qt_noop(); | - |
2403 | Q_ASSERT(!reg1->canAppend(reg2)); executed (the execution status of this line is deduced): qt_noop(); | - |
2404 | Q_ASSERT(!reg2->canAppend(reg1)); executed (the execution status of this line is deduced): qt_noop(); | - |
2405 | | - |
2406 | if (reg1->innerArea > reg2->innerArea) { evaluated: reg1->innerArea > reg2->innerArea yes Evaluation Count:16866 | yes Evaluation Count:2995 |
| 2995-16866 |
2407 | dest.innerArea = reg1->innerArea; executed (the execution status of this line is deduced): dest.innerArea = reg1->innerArea; | - |
2408 | dest.innerRect = reg1->innerRect; executed (the execution status of this line is deduced): dest.innerRect = reg1->innerRect; | - |
2409 | } else { executed: } Execution Count:16866 | 16866 |
2410 | dest.innerArea = reg2->innerArea; executed (the execution status of this line is deduced): dest.innerArea = reg2->innerArea; | - |
2411 | dest.innerRect = reg2->innerRect; executed (the execution status of this line is deduced): dest.innerRect = reg2->innerRect; | - |
2412 | } executed: } Execution Count:2995 | 2995 |
2413 | miRegionOp(dest, reg1, reg2, miUnionO, miUnionNonO, miUnionNonO); executed (the execution status of this line is deduced): miRegionOp(dest, reg1, reg2, miUnionO, miUnionNonO, miUnionNonO); | - |
2414 | | - |
2415 | dest.extents.setCoords(qMin(reg1->extents.left(), reg2->extents.left()), executed (the execution status of this line is deduced): dest.extents.setCoords(qMin(reg1->extents.left(), reg2->extents.left()), | - |
2416 | qMin(reg1->extents.top(), reg2->extents.top()), executed (the execution status of this line is deduced): qMin(reg1->extents.top(), reg2->extents.top()), | - |
2417 | qMax(reg1->extents.right(), reg2->extents.right()), executed (the execution status of this line is deduced): qMax(reg1->extents.right(), reg2->extents.right()), | - |
2418 | qMax(reg1->extents.bottom(), reg2->extents.bottom())); executed (the execution status of this line is deduced): qMax(reg1->extents.bottom(), reg2->extents.bottom())); | - |
2419 | } executed: } Execution Count:19861 | 19861 |
2420 | | - |
2421 | /*====================================================================== | - |
2422 | * Region Subtraction | - |
2423 | *====================================================================*/ | - |
2424 | | - |
2425 | /*- | - |
2426 | *----------------------------------------------------------------------- | - |
2427 | * miSubtractNonO -- | - |
2428 | * Deal with non-overlapping band for subtraction. Any parts from | - |
2429 | * region 2 we discard. Anything from region 1 we add to the region. | - |
2430 | * | - |
2431 | * Results: | - |
2432 | * None. | - |
2433 | * | - |
2434 | * Side Effects: | - |
2435 | * dest may be affected. | - |
2436 | * | - |
2437 | *----------------------------------------------------------------------- | - |
2438 | */ | - |
2439 | | - |
2440 | static void miSubtractNonO1(register QRegionPrivate &dest, register const QRect *r, | - |
2441 | const QRect *rEnd, register int y1, register int y2) | - |
2442 | { | - |
2443 | register QRect *pNextRect; executed (the execution status of this line is deduced): register QRect *pNextRect; | - |
2444 | | - |
2445 | pNextRect = dest.rects.data() + dest.numRects; executed (the execution status of this line is deduced): pNextRect = dest.rects.data() + dest.numRects; | - |
2446 | | - |
2447 | Q_ASSERT(y1<=y2); executed (the execution status of this line is deduced): qt_noop(); | - |
2448 | | - |
2449 | while (r != rEnd) { evaluated: r != rEnd yes Evaluation Count:22270 | yes Evaluation Count:22169 |
| 22169-22270 |
2450 | Q_ASSERT(r->left() <= r->right()); executed (the execution status of this line is deduced): qt_noop(); | - |
2451 | MEMCHECK(dest, pNextRect, dest.rects) executed: } Execution Count:5312 evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:5312 | yes Evaluation Count:16958 |
| 5312-16958 |
2452 | pNextRect->setCoords(r->left(), y1, r->right(), y2); executed (the execution status of this line is deduced): pNextRect->setCoords(r->left(), y1, r->right(), y2); | - |
2453 | ++dest.numRects; executed (the execution status of this line is deduced): ++dest.numRects; | - |
2454 | ++pNextRect; executed (the execution status of this line is deduced): ++pNextRect; | - |
2455 | ++r; executed (the execution status of this line is deduced): ++r; | - |
2456 | } executed: } Execution Count:22270 | 22270 |
2457 | } executed: } Execution Count:22169 | 22169 |
2458 | | - |
2459 | /*- | - |
2460 | *----------------------------------------------------------------------- | - |
2461 | * miSubtractO -- | - |
2462 | * Overlapping band subtraction. x1 is the left-most point not yet | - |
2463 | * checked. | - |
2464 | * | - |
2465 | * Results: | - |
2466 | * None. | - |
2467 | * | - |
2468 | * Side Effects: | - |
2469 | * dest may have rectangles added to it. | - |
2470 | * | - |
2471 | *----------------------------------------------------------------------- | - |
2472 | */ | - |
2473 | | - |
2474 | static void miSubtractO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, | - |
2475 | register const QRect *r2, const QRect *r2End, register int y1, register int y2) | - |
2476 | { | - |
2477 | register QRect *pNextRect; executed (the execution status of this line is deduced): register QRect *pNextRect; | - |
2478 | register int x1; executed (the execution status of this line is deduced): register int x1; | - |
2479 | | - |
2480 | x1 = r1->left(); executed (the execution status of this line is deduced): x1 = r1->left(); | - |
2481 | | - |
2482 | Q_ASSERT(y1 <= y2); executed (the execution status of this line is deduced): qt_noop(); | - |
2483 | pNextRect = dest.rects.data() + dest.numRects; executed (the execution status of this line is deduced): pNextRect = dest.rects.data() + dest.numRects; | - |
2484 | | - |
2485 | while (r1 != r1End && r2 != r2End) { evaluated: r1 != r1End yes Evaluation Count:36788 | yes Evaluation Count:4669 |
evaluated: r2 != r2End yes Evaluation Count:24715 | yes Evaluation Count:12073 |
| 4669-36788 |
2486 | if (r2->right() < x1) { evaluated: r2->right() < x1 yes Evaluation Count:2076 | yes Evaluation Count:22639 |
| 2076-22639 |
2487 | /* | - |
2488 | * Subtrahend missed the boat: go to next subtrahend. | - |
2489 | */ | - |
2490 | ++r2; executed (the execution status of this line is deduced): ++r2; | - |
2491 | } else if (r2->left() <= x1) { executed: } Execution Count:2076 evaluated: r2->left() <= x1 yes Evaluation Count:4859 | yes Evaluation Count:17780 |
| 2076-17780 |
2492 | /* | - |
2493 | * Subtrahend precedes minuend: nuke left edge of minuend. | - |
2494 | */ | - |
2495 | x1 = r2->right() + 1; executed (the execution status of this line is deduced): x1 = r2->right() + 1; | - |
2496 | if (x1 > r1->right()) { evaluated: x1 > r1->right() yes Evaluation Count:2007 | yes Evaluation Count:2852 |
| 2007-2852 |
2497 | /* | - |
2498 | * Minuend completely covered: advance to next minuend and | - |
2499 | * reset left fence to edge of new minuend. | - |
2500 | */ | - |
2501 | ++r1; executed (the execution status of this line is deduced): ++r1; | - |
2502 | if (r1 != r1End) evaluated: r1 != r1End yes Evaluation Count:74 | yes Evaluation Count:1933 |
| 74-1933 |
2503 | x1 = r1->left(); executed: x1 = r1->left(); Execution Count:74 | 74 |
2504 | } else { executed: } Execution Count:2007 | 2007 |
2505 | // Subtrahend now used up since it doesn't extend beyond minuend | - |
2506 | ++r2; executed (the execution status of this line is deduced): ++r2; | - |
2507 | } executed: } Execution Count:2852 | 2852 |
2508 | } else if (r2->left() <= r1->right()) { evaluated: r2->left() <= r1->right() yes Evaluation Count:10177 | yes Evaluation Count:7603 |
| 7603-10177 |
2509 | /* | - |
2510 | * Left part of subtrahend covers part of minuend: add uncovered | - |
2511 | * part of minuend to region and skip to next subtrahend. | - |
2512 | */ | - |
2513 | Q_ASSERT(x1 < r2->left()); executed (the execution status of this line is deduced): qt_noop(); | - |
2514 | MEMCHECK(dest, pNextRect, dest.rects) executed: } Execution Count:4942 evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:4942 | yes Evaluation Count:5235 |
| 4942-5235 |
2515 | pNextRect->setCoords(x1, y1, r2->left() - 1, y2); executed (the execution status of this line is deduced): pNextRect->setCoords(x1, y1, r2->left() - 1, y2); | - |
2516 | ++dest.numRects; executed (the execution status of this line is deduced): ++dest.numRects; | - |
2517 | ++pNextRect; executed (the execution status of this line is deduced): ++pNextRect; | - |
2518 | | - |
2519 | x1 = r2->right() + 1; executed (the execution status of this line is deduced): x1 = r2->right() + 1; | - |
2520 | if (x1 > r1->right()) { evaluated: x1 > r1->right() yes Evaluation Count:2709 | yes Evaluation Count:7468 |
| 2709-7468 |
2521 | /* | - |
2522 | * Minuend used up: advance to new... | - |
2523 | */ | - |
2524 | ++r1; executed (the execution status of this line is deduced): ++r1; | - |
2525 | if (r1 != r1End) evaluated: r1 != r1End yes Evaluation Count:35 | yes Evaluation Count:2674 |
| 35-2674 |
2526 | x1 = r1->left(); executed: x1 = r1->left(); Execution Count:35 | 35 |
2527 | } else { executed: } Execution Count:2709 | 2709 |
2528 | // Subtrahend used up | - |
2529 | ++r2; executed (the execution status of this line is deduced): ++r2; | - |
2530 | } executed: } Execution Count:7468 | 7468 |
2531 | } else { | - |
2532 | /* | - |
2533 | * Minuend used up: add any remaining piece before advancing. | - |
2534 | */ | - |
2535 | if (r1->right() >= x1) { partially evaluated: r1->right() >= x1 yes Evaluation Count:7603 | no Evaluation Count:0 |
| 0-7603 |
2536 | MEMCHECK(dest, pNextRect, dest.rects) never executed: } partially evaluated: (dest).numRects >= ((dest).rects.size()-1) no Evaluation Count:0 | yes Evaluation Count:7603 |
| 0-7603 |
2537 | pNextRect->setCoords(x1, y1, r1->right(), y2); executed (the execution status of this line is deduced): pNextRect->setCoords(x1, y1, r1->right(), y2); | - |
2538 | ++dest.numRects; executed (the execution status of this line is deduced): ++dest.numRects; | - |
2539 | ++pNextRect; executed (the execution status of this line is deduced): ++pNextRect; | - |
2540 | } executed: } Execution Count:7603 | 7603 |
2541 | ++r1; executed (the execution status of this line is deduced): ++r1; | - |
2542 | if (r1 != r1End) evaluated: r1 != r1End yes Evaluation Count:7541 | yes Evaluation Count:62 |
| 62-7541 |
2543 | x1 = r1->left(); executed: x1 = r1->left(); Execution Count:7541 | 7541 |
2544 | } executed: } Execution Count:7603 | 7603 |
2545 | } | - |
2546 | | - |
2547 | /* | - |
2548 | * Add remaining minuend rectangles to region. | - |
2549 | */ | - |
2550 | while (r1 != r1End) { evaluated: r1 != r1End yes Evaluation Count:14055 | yes Evaluation Count:16742 |
| 14055-16742 |
2551 | Q_ASSERT(x1 <= r1->right()); executed (the execution status of this line is deduced): qt_noop(); | - |
2552 | MEMCHECK(dest, pNextRect, dest.rects) executed: } Execution Count:1112 evaluated: (dest).numRects >= ((dest).rects.size()-1) yes Evaluation Count:1112 | yes Evaluation Count:12943 |
| 1112-12943 |
2553 | pNextRect->setCoords(x1, y1, r1->right(), y2); executed (the execution status of this line is deduced): pNextRect->setCoords(x1, y1, r1->right(), y2); | - |
2554 | ++dest.numRects; executed (the execution status of this line is deduced): ++dest.numRects; | - |
2555 | ++pNextRect; executed (the execution status of this line is deduced): ++pNextRect; | - |
2556 | | - |
2557 | ++r1; executed (the execution status of this line is deduced): ++r1; | - |
2558 | if (r1 != r1End) evaluated: r1 != r1End yes Evaluation Count:1982 | yes Evaluation Count:12073 |
| 1982-12073 |
2559 | x1 = r1->left(); executed: x1 = r1->left(); Execution Count:1982 | 1982 |
2560 | } executed: } Execution Count:14055 | 14055 |
2561 | } executed: } Execution Count:16742 | 16742 |
2562 | | - |
2563 | /*- | - |
2564 | *----------------------------------------------------------------------- | - |
2565 | * miSubtract -- | - |
2566 | * Subtract regS from regM and leave the result in regD. | - |
2567 | * S stands for subtrahend, M for minuend and D for difference. | - |
2568 | * | - |
2569 | * Side Effects: | - |
2570 | * regD is overwritten. | - |
2571 | * | - |
2572 | *----------------------------------------------------------------------- | - |
2573 | */ | - |
2574 | | - |
2575 | static void SubtractRegion(QRegionPrivate *regM, QRegionPrivate *regS, | - |
2576 | register QRegionPrivate &dest) | - |
2577 | { | - |
2578 | Q_ASSERT(!isEmptyHelper(regM)); executed (the execution status of this line is deduced): qt_noop(); | - |
2579 | Q_ASSERT(!isEmptyHelper(regS)); executed (the execution status of this line is deduced): qt_noop(); | - |
2580 | Q_ASSERT(EXTENTCHECK(®M->extents, ®S->extents)); executed (the execution status of this line is deduced): qt_noop(); | - |
2581 | Q_ASSERT(!regS->contains(*regM)); executed (the execution status of this line is deduced): qt_noop(); | - |
2582 | Q_ASSERT(!EqualRegion(regM, regS)); executed (the execution status of this line is deduced): qt_noop(); | - |
2583 | | - |
2584 | miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, 0); executed (the execution status of this line is deduced): miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, 0); | - |
2585 | | - |
2586 | /* | - |
2587 | * Can't alter dest's extents before we call miRegionOp because | - |
2588 | * it might be one of the source regions and miRegionOp depends | - |
2589 | * on the extents of those regions being the unaltered. Besides, this | - |
2590 | * way there's no checking against rectangles that will be nuked | - |
2591 | * due to coalescing, so we have to examine fewer rectangles. | - |
2592 | */ | - |
2593 | miSetExtents(dest); executed (the execution status of this line is deduced): miSetExtents(dest); | - |
2594 | } executed: } Execution Count:15171 | 15171 |
2595 | | - |
2596 | static void XorRegion(QRegionPrivate *sra, QRegionPrivate *srb, QRegionPrivate &dest) | - |
2597 | { | - |
2598 | Q_ASSERT(!isEmptyHelper(sra) && !isEmptyHelper(srb)); executed (the execution status of this line is deduced): qt_noop(); | - |
2599 | Q_ASSERT(EXTENTCHECK(&sra->extents, &srb->extents)); executed (the execution status of this line is deduced): qt_noop(); | - |
2600 | Q_ASSERT(!EqualRegion(sra, srb)); executed (the execution status of this line is deduced): qt_noop(); | - |
2601 | | - |
2602 | QRegionPrivate tra, trb; executed (the execution status of this line is deduced): QRegionPrivate tra, trb; | - |
2603 | | - |
2604 | if (!srb->contains(*sra)) evaluated: !srb->contains(*sra) yes Evaluation Count:16 | yes Evaluation Count:3 |
| 3-16 |
2605 | SubtractRegion(sra, srb, tra); executed: SubtractRegion(sra, srb, tra); Execution Count:16 | 16 |
2606 | if (!sra->contains(*srb)) evaluated: !sra->contains(*srb) yes Evaluation Count:7 | yes Evaluation Count:12 |
| 7-12 |
2607 | SubtractRegion(srb, sra, trb); executed: SubtractRegion(srb, sra, trb); Execution Count:7 | 7 |
2608 | | - |
2609 | Q_ASSERT(isEmptyHelper(&trb) || !tra.contains(trb)); executed (the execution status of this line is deduced): qt_noop(); | - |
2610 | Q_ASSERT(isEmptyHelper(&tra) || !trb.contains(tra)); executed (the execution status of this line is deduced): qt_noop(); | - |
2611 | | - |
2612 | if (isEmptyHelper(&tra)) { evaluated: isEmptyHelper(&tra) yes Evaluation Count:3 | yes Evaluation Count:16 |
| 3-16 |
2613 | dest = trb; executed (the execution status of this line is deduced): dest = trb; | - |
2614 | } else if (isEmptyHelper(&trb)) { executed: } Execution Count:3 partially evaluated: isEmptyHelper(&trb) yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
2615 | dest = tra; executed (the execution status of this line is deduced): dest = tra; | - |
2616 | } else if (tra.canAppend(&trb)) { executed: } Execution Count:16 never evaluated: tra.canAppend(&trb) | 0-16 |
2617 | dest = tra; never executed (the execution status of this line is deduced): dest = tra; | - |
2618 | dest.append(&trb); never executed (the execution status of this line is deduced): dest.append(&trb); | - |
2619 | } else if (trb.canAppend(&tra)) { never executed: } never evaluated: trb.canAppend(&tra) | 0 |
2620 | dest = trb; never executed (the execution status of this line is deduced): dest = trb; | - |
2621 | dest.append(&tra); never executed (the execution status of this line is deduced): dest.append(&tra); | - |
2622 | } else { | 0 |
2623 | UnionRegion(&tra, &trb, dest); never executed (the execution status of this line is deduced): UnionRegion(&tra, &trb, dest); | - |
2624 | } | 0 |
2625 | } | - |
2626 | | - |
2627 | /* | - |
2628 | * Check to see if two regions are equal | - |
2629 | */ | - |
2630 | static bool EqualRegion(const QRegionPrivate *r1, const QRegionPrivate *r2) | - |
2631 | { | - |
2632 | if (r1->numRects != r2->numRects) { evaluated: r1->numRects != r2->numRects yes Evaluation Count:17244 | yes Evaluation Count:12519 |
| 12519-17244 |
2633 | return false; executed: return false; Execution Count:17244 | 17244 |
2634 | } else if (r1->numRects == 0) { evaluated: r1->numRects == 0 yes Evaluation Count:10 | yes Evaluation Count:12509 |
| 10-12509 |
2635 | return true; executed: return true; Execution Count:10 | 10 |
2636 | } else if (r1->extents != r2->extents) { evaluated: r1->extents != r2->extents yes Evaluation Count:11650 | yes Evaluation Count:859 |
| 859-11650 |
2637 | return false; executed: return false; Execution Count:11650 | 11650 |
2638 | } else if (r1->numRects == 1 && r2->numRects == 1) { evaluated: r1->numRects == 1 yes Evaluation Count:345 | yes Evaluation Count:514 |
partially evaluated: r2->numRects == 1 yes Evaluation Count:345 | no Evaluation Count:0 |
| 0-514 |
2639 | return true; // equality tested in previous if-statement executed: return true; Execution Count:345 | 345 |
2640 | } else { | - |
2641 | const QRect *rr1 = (r1->numRects == 1) ? &r1->extents : r1->rects.constData(); partially evaluated: (r1->numRects == 1) no Evaluation Count:0 | yes Evaluation Count:514 |
| 0-514 |
2642 | const QRect *rr2 = (r2->numRects == 1) ? &r2->extents : r2->rects.constData(); partially evaluated: (r2->numRects == 1) no Evaluation Count:0 | yes Evaluation Count:514 |
| 0-514 |
2643 | for (int i = 0; i < r1->numRects; ++i, ++rr1, ++rr2) { evaluated: i < r1->numRects yes Evaluation Count:1566 | yes Evaluation Count:319 |
| 319-1566 |
2644 | if (*rr1 != *rr2) evaluated: *rr1 != *rr2 yes Evaluation Count:195 | yes Evaluation Count:1371 |
| 195-1371 |
2645 | return false; executed: return false; Execution Count:195 | 195 |
2646 | } executed: } Execution Count:1371 | 1371 |
2647 | } executed: } Execution Count:319 | 319 |
2648 | | - |
2649 | return true; executed: return true; Execution Count:319 | 319 |
2650 | } | - |
2651 | | - |
2652 | static bool PointInRegion(QRegionPrivate *pRegion, int x, int y) | - |
2653 | { | - |
2654 | int i; executed (the execution status of this line is deduced): int i; | - |
2655 | | - |
2656 | if (isEmptyHelper(pRegion)) evaluated: isEmptyHelper(pRegion) yes Evaluation Count:1 | yes Evaluation Count:200047 |
| 1-200047 |
2657 | return false; executed: return false; Execution Count:1 | 1 |
2658 | if (!pRegion->extents.contains(x, y)) evaluated: !pRegion->extents.contains(x, y) yes Evaluation Count:45120 | yes Evaluation Count:154927 |
| 45120-154927 |
2659 | return false; executed: return false; Execution Count:45120 | 45120 |
2660 | if (pRegion->numRects == 1) evaluated: pRegion->numRects == 1 yes Evaluation Count:20 | yes Evaluation Count:154907 |
| 20-154907 |
2661 | return pRegion->extents.contains(x, y); executed: return pRegion->extents.contains(x, y); Execution Count:20 | 20 |
2662 | if (pRegion->innerRect.contains(x, y)) evaluated: pRegion->innerRect.contains(x, y) yes Evaluation Count:19711 | yes Evaluation Count:135196 |
| 19711-135196 |
2663 | return true; executed: return true; Execution Count:19711 | 19711 |
2664 | for (i = 0; i < pRegion->numRects; ++i) { evaluated: i < pRegion->numRects yes Evaluation Count:4551005 | yes Evaluation Count:60214 |
| 60214-4551005 |
2665 | if (pRegion->rects[i].contains(x, y)) evaluated: pRegion->rects[i].contains(x, y) yes Evaluation Count:74982 | yes Evaluation Count:4476023 |
| 74982-4476023 |
2666 | return true; executed: return true; Execution Count:74982 | 74982 |
2667 | } executed: } Execution Count:4476023 | 4476023 |
2668 | return false; executed: return false; Execution Count:60214 | 60214 |
2669 | } | - |
2670 | | - |
2671 | static bool RectInRegion(register QRegionPrivate *region, int rx, int ry, uint rwidth, uint rheight) | - |
2672 | { | - |
2673 | register const QRect *pbox; executed (the execution status of this line is deduced): register const QRect *pbox; | - |
2674 | register const QRect *pboxEnd; executed (the execution status of this line is deduced): register const QRect *pboxEnd; | - |
2675 | QRect rect(rx, ry, rwidth, rheight); executed (the execution status of this line is deduced): QRect rect(rx, ry, rwidth, rheight); | - |
2676 | register QRect *prect = ▭ executed (the execution status of this line is deduced): register QRect *prect = ▭ | - |
2677 | int partIn, partOut; executed (the execution status of this line is deduced): int partIn, partOut; | - |
2678 | | - |
2679 | if (!region || region->numRects == 0 || !EXTENTCHECK(®ion->extents, prect)) partially evaluated: !region no Evaluation Count:0 | yes Evaluation Count:41 |
partially evaluated: region->numRects == 0 no Evaluation Count:0 | yes Evaluation Count:41 |
evaluated: (®ion->extents)->right() >= (prect)->left() yes Evaluation Count:35 | yes Evaluation Count:6 |
evaluated: (®ion->extents)->left() <= (prect)->right() yes Evaluation Count:32 | yes Evaluation Count:3 |
partially evaluated: (®ion->extents)->bottom() >= (prect)->top() yes Evaluation Count:32 | no Evaluation Count:0 |
partially evaluated: (®ion->extents)->top() <= (prect)->bottom() yes Evaluation Count:32 | no Evaluation Count:0 |
| 0-41 |
2680 | return RectangleOut; executed: return 0; Execution Count:9 | 9 |
2681 | | - |
2682 | partOut = false; executed (the execution status of this line is deduced): partOut = false; | - |
2683 | partIn = false; executed (the execution status of this line is deduced): partIn = false; | - |
2684 | | - |
2685 | /* can stop when both partOut and partIn are true, or we reach prect->y2 */ | - |
2686 | pbox = (region->numRects == 1) ? ®ion->extents : region->rects.constData(); evaluated: (region->numRects == 1) yes Evaluation Count:21 | yes Evaluation Count:11 |
| 11-21 |
2687 | pboxEnd = pbox + region->numRects; executed (the execution status of this line is deduced): pboxEnd = pbox + region->numRects; | - |
2688 | for (; pbox < pboxEnd; ++pbox) { evaluated: pbox < pboxEnd yes Evaluation Count:43 | yes Evaluation Count:9 |
| 9-43 |
2689 | if (pbox->bottom() < ry) evaluated: pbox->bottom() < ry yes Evaluation Count:4 | yes Evaluation Count:39 |
| 4-39 |
2690 | continue; executed: continue; Execution Count:4 | 4 |
2691 | | - |
2692 | if (pbox->top() > ry) { evaluated: pbox->top() > ry yes Evaluation Count:5 | yes Evaluation Count:34 |
| 5-34 |
2693 | partOut = true; executed (the execution status of this line is deduced): partOut = true; | - |
2694 | if (partIn || pbox->top() > prect->bottom()) evaluated: partIn yes Evaluation Count:3 | yes Evaluation Count:2 |
partially evaluated: pbox->top() > prect->bottom() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-3 |
2695 | break; executed: break; Execution Count:5 | 5 |
2696 | ry = pbox->top(); never executed (the execution status of this line is deduced): ry = pbox->top(); | - |
2697 | } | 0 |
2698 | | - |
2699 | if (pbox->right() < rx) evaluated: pbox->right() < rx yes Evaluation Count:4 | yes Evaluation Count:30 |
| 4-30 |
2700 | continue; /* not far enough over yet */ executed: continue; Execution Count:4 | 4 |
2701 | | - |
2702 | if (pbox->left() > rx) { evaluated: pbox->left() > rx yes Evaluation Count:2 | yes Evaluation Count:28 |
| 2-28 |
2703 | partOut = true; /* missed part of rectangle to left */ executed (the execution status of this line is deduced): partOut = true; | - |
2704 | if (partIn) partially evaluated: partIn no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2705 | break; | 0 |
2706 | } executed: } Execution Count:2 | 2 |
2707 | | - |
2708 | if (pbox->left() <= prect->right()) { evaluated: pbox->left() <= prect->right() yes Evaluation Count:28 | yes Evaluation Count:2 |
| 2-28 |
2709 | partIn = true; /* definitely overlap */ executed (the execution status of this line is deduced): partIn = true; | - |
2710 | if (partOut) partially evaluated: partOut no Evaluation Count:0 | yes Evaluation Count:28 |
| 0-28 |
2711 | break; | 0 |
2712 | } executed: } Execution Count:28 | 28 |
2713 | | - |
2714 | if (pbox->right() >= prect->right()) { partially evaluated: pbox->right() >= prect->right() yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
2715 | ry = pbox->bottom() + 1; /* finished with this band */ executed (the execution status of this line is deduced): ry = pbox->bottom() + 1; | - |
2716 | if (ry > prect->bottom()) evaluated: ry > prect->bottom() yes Evaluation Count:18 | yes Evaluation Count:12 |
| 12-18 |
2717 | break; executed: break; Execution Count:18 | 18 |
2718 | rx = prect->left(); /* reset x out to left again */ executed (the execution status of this line is deduced): rx = prect->left(); | - |
2719 | } else { executed: } Execution Count:12 | 12 |
2720 | /* | - |
2721 | * Because boxes in a band are maximal width, if the first box | - |
2722 | * to overlap the rectangle doesn't completely cover it in that | - |
2723 | * band, the rectangle must be partially out, since some of it | - |
2724 | * will be uncovered in that band. partIn will have been set true | - |
2725 | * by now... | - |
2726 | */ | - |
2727 | break; | 0 |
2728 | } | - |
2729 | } | - |
2730 | return partIn ? ((ry <= prect->bottom()) ? RectanglePart : RectangleIn) : RectangleOut; executed: return partIn ? ((ry <= prect->bottom()) ? 2 : 1) : 0; Execution Count:32 | 32 |
2731 | } | - |
2732 | // END OF Region.c extract | - |
2733 | // START OF poly.h extract | - |
2734 | /* $XConsortium: poly.h,v 1.4 94/04/17 20:22:19 rws Exp $ */ | - |
2735 | /************************************************************************ | - |
2736 | | - |
2737 | Copyright (c) 1987 X Consortium | - |
2738 | | - |
2739 | Permission is hereby granted, free of charge, to any person obtaining a copy | - |
2740 | of this software and associated documentation files (the "Software"), to deal | - |
2741 | in the Software without restriction, including without limitation the rights | - |
2742 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | - |
2743 | copies of the Software, and to permit persons to whom the Software is | - |
2744 | furnished to do so, subject to the following conditions: | - |
2745 | | - |
2746 | The above copyright notice and this permission notice shall be included in | - |
2747 | all copies or substantial portions of the Software. | - |
2748 | | - |
2749 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | - |
2750 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | - |
2751 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | - |
2752 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | - |
2753 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | - |
2754 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | - |
2755 | | - |
2756 | Except as contained in this notice, the name of the X Consortium shall not be | - |
2757 | used in advertising or otherwise to promote the sale, use or other dealings | - |
2758 | in this Software without prior written authorization from the X Consortium. | - |
2759 | | - |
2760 | | - |
2761 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. | - |
2762 | | - |
2763 | All Rights Reserved | - |
2764 | | - |
2765 | Permission to use, copy, modify, and distribute this software and its | - |
2766 | documentation for any purpose and without fee is hereby granted, | - |
2767 | provided that the above copyright notice appear in all copies and that | - |
2768 | both that copyright notice and this permission notice appear in | - |
2769 | supporting documentation, and that the name of Digital not be | - |
2770 | used in advertising or publicity pertaining to distribution of the | - |
2771 | software without specific, written prior permission. | - |
2772 | | - |
2773 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | - |
2774 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | - |
2775 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | - |
2776 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | - |
2777 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | - |
2778 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | - |
2779 | SOFTWARE. | - |
2780 | | - |
2781 | ************************************************************************/ | - |
2782 | | - |
2783 | /* | - |
2784 | * This file contains a few macros to help track | - |
2785 | * the edge of a filled object. The object is assumed | - |
2786 | * to be filled in scanline order, and thus the | - |
2787 | * algorithm used is an extension of Bresenham's line | - |
2788 | * drawing algorithm which assumes that y is always the | - |
2789 | * major axis. | - |
2790 | * Since these pieces of code are the same for any filled shape, | - |
2791 | * it is more convenient to gather the library in one | - |
2792 | * place, but since these pieces of code are also in | - |
2793 | * the inner loops of output primitives, procedure call | - |
2794 | * overhead is out of the question. | - |
2795 | * See the author for a derivation if needed. | - |
2796 | */ | - |
2797 | | - |
2798 | | - |
2799 | /* | - |
2800 | * In scan converting polygons, we want to choose those pixels | - |
2801 | * which are inside the polygon. Thus, we add .5 to the starting | - |
2802 | * x coordinate for both left and right edges. Now we choose the | - |
2803 | * first pixel which is inside the pgon for the left edge and the | - |
2804 | * first pixel which is outside the pgon for the right edge. | - |
2805 | * Draw the left pixel, but not the right. | - |
2806 | * | - |
2807 | * How to add .5 to the starting x coordinate: | - |
2808 | * If the edge is moving to the right, then subtract dy from the | - |
2809 | * error term from the general form of the algorithm. | - |
2810 | * If the edge is moving to the left, then add dy to the error term. | - |
2811 | * | - |
2812 | * The reason for the difference between edges moving to the left | - |
2813 | * and edges moving to the right is simple: If an edge is moving | - |
2814 | * to the right, then we want the algorithm to flip immediately. | - |
2815 | * If it is moving to the left, then we don't want it to flip until | - |
2816 | * we traverse an entire pixel. | - |
2817 | */ | - |
2818 | #define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ | - |
2819 | int dx; /* local storage */ \ | - |
2820 | \ | - |
2821 | /* \ | - |
2822 | * if the edge is horizontal, then it is ignored \ | - |
2823 | * and assumed not to be processed. Otherwise, do this stuff. \ | - |
2824 | */ \ | - |
2825 | if ((dy) != 0) { \ | - |
2826 | xStart = (x1); \ | - |
2827 | dx = (x2) - xStart; \ | - |
2828 | if (dx < 0) { \ | - |
2829 | m = dx / (dy); \ | - |
2830 | m1 = m - 1; \ | - |
2831 | incr1 = -2 * dx + 2 * (dy) * m1; \ | - |
2832 | incr2 = -2 * dx + 2 * (dy) * m; \ | - |
2833 | d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ | - |
2834 | } else { \ | - |
2835 | m = dx / (dy); \ | - |
2836 | m1 = m + 1; \ | - |
2837 | incr1 = 2 * dx - 2 * (dy) * m1; \ | - |
2838 | incr2 = 2 * dx - 2 * (dy) * m; \ | - |
2839 | d = -2 * m * (dy) + 2 * dx; \ | - |
2840 | } \ | - |
2841 | } \ | - |
2842 | } | - |
2843 | | - |
2844 | #define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ | - |
2845 | if (m1 > 0) { \ | - |
2846 | if (d > 0) { \ | - |
2847 | minval += m1; \ | - |
2848 | d += incr1; \ | - |
2849 | } \ | - |
2850 | else { \ | - |
2851 | minval += m; \ | - |
2852 | d += incr2; \ | - |
2853 | } \ | - |
2854 | } else {\ | - |
2855 | if (d >= 0) { \ | - |
2856 | minval += m1; \ | - |
2857 | d += incr1; \ | - |
2858 | } \ | - |
2859 | else { \ | - |
2860 | minval += m; \ | - |
2861 | d += incr2; \ | - |
2862 | } \ | - |
2863 | } \ | - |
2864 | } | - |
2865 | | - |
2866 | | - |
2867 | /* | - |
2868 | * This structure contains all of the information needed | - |
2869 | * to run the bresenham algorithm. | - |
2870 | * The variables may be hardcoded into the declarations | - |
2871 | * instead of using this structure to make use of | - |
2872 | * register declarations. | - |
2873 | */ | - |
2874 | typedef struct { | - |
2875 | int minor_axis; /* minor axis */ | - |
2876 | int d; /* decision variable */ | - |
2877 | int m, m1; /* slope and slope+1 */ | - |
2878 | int incr1, incr2; /* error increments */ | - |
2879 | } BRESINFO; | - |
2880 | | - |
2881 | | - |
2882 | #define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ | - |
2883 | BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \ | - |
2884 | bres.m, bres.m1, bres.incr1, bres.incr2) | - |
2885 | | - |
2886 | #define BRESINCRPGONSTRUCT(bres) \ | - |
2887 | BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2) | - |
2888 | | - |
2889 | | - |
2890 | | - |
2891 | /* | - |
2892 | * These are the data structures needed to scan | - |
2893 | * convert regions. Two different scan conversion | - |
2894 | * methods are available -- the even-odd method, and | - |
2895 | * the winding number method. | - |
2896 | * The even-odd rule states that a point is inside | - |
2897 | * the polygon if a ray drawn from that point in any | - |
2898 | * direction will pass through an odd number of | - |
2899 | * path segments. | - |
2900 | * By the winding number rule, a point is decided | - |
2901 | * to be inside the polygon if a ray drawn from that | - |
2902 | * point in any direction passes through a different | - |
2903 | * number of clockwise and counter-clockwise path | - |
2904 | * segments. | - |
2905 | * | - |
2906 | * These data structures are adapted somewhat from | - |
2907 | * the algorithm in (Foley/Van Dam) for scan converting | - |
2908 | * polygons. | - |
2909 | * The basic algorithm is to start at the top (smallest y) | - |
2910 | * of the polygon, stepping down to the bottom of | - |
2911 | * the polygon by incrementing the y coordinate. We | - |
2912 | * keep a list of edges which the current scanline crosses, | - |
2913 | * sorted by x. This list is called the Active Edge Table (AET) | - |
2914 | * As we change the y-coordinate, we update each entry in | - |
2915 | * in the active edge table to reflect the edges new xcoord. | - |
2916 | * This list must be sorted at each scanline in case | - |
2917 | * two edges intersect. | - |
2918 | * We also keep a data structure known as the Edge Table (ET), | - |
2919 | * which keeps track of all the edges which the current | - |
2920 | * scanline has not yet reached. The ET is basically a | - |
2921 | * list of ScanLineList structures containing a list of | - |
2922 | * edges which are entered at a given scanline. There is one | - |
2923 | * ScanLineList per scanline at which an edge is entered. | - |
2924 | * When we enter a new edge, we move it from the ET to the AET. | - |
2925 | * | - |
2926 | * From the AET, we can implement the even-odd rule as in | - |
2927 | * (Foley/Van Dam). | - |
2928 | * The winding number rule is a little trickier. We also | - |
2929 | * keep the EdgeTableEntries in the AET linked by the | - |
2930 | * nextWETE (winding EdgeTableEntry) link. This allows | - |
2931 | * the edges to be linked just as before for updating | - |
2932 | * purposes, but only uses the edges linked by the nextWETE | - |
2933 | * link as edges representing spans of the polygon to | - |
2934 | * drawn (as with the even-odd rule). | - |
2935 | */ | - |
2936 | | - |
2937 | /* | - |
2938 | * for the winding number rule | - |
2939 | */ | - |
2940 | #define CLOCKWISE 1 | - |
2941 | #define COUNTERCLOCKWISE -1 | - |
2942 | | - |
2943 | typedef struct _EdgeTableEntry { | - |
2944 | int ymax; /* ycoord at which we exit this edge. */ | - |
2945 | BRESINFO bres; /* Bresenham info to run the edge */ | - |
2946 | struct _EdgeTableEntry *next; /* next in the list */ | - |
2947 | struct _EdgeTableEntry *back; /* for insertion sort */ | - |
2948 | struct _EdgeTableEntry *nextWETE; /* for winding num rule */ | - |
2949 | int ClockWise; /* flag for winding number rule */ | - |
2950 | } EdgeTableEntry; | - |
2951 | | - |
2952 | | - |
2953 | typedef struct _ScanLineList{ | - |
2954 | int scanline; /* the scanline represented */ | - |
2955 | EdgeTableEntry *edgelist; /* header node */ | - |
2956 | struct _ScanLineList *next; /* next in the list */ | - |
2957 | } ScanLineList; | - |
2958 | | - |
2959 | | - |
2960 | typedef struct { | - |
2961 | int ymax; /* ymax for the polygon */ | - |
2962 | int ymin; /* ymin for the polygon */ | - |
2963 | ScanLineList scanlines; /* header node */ | - |
2964 | } EdgeTable; | - |
2965 | | - |
2966 | | - |
2967 | /* | - |
2968 | * Here is a struct to help with storage allocation | - |
2969 | * so we can allocate a big chunk at a time, and then take | - |
2970 | * pieces from this heap when we need to. | - |
2971 | */ | - |
2972 | #define SLLSPERBLOCK 25 | - |
2973 | | - |
2974 | typedef struct _ScanLineListBlock { | - |
2975 | ScanLineList SLLs[SLLSPERBLOCK]; | - |
2976 | struct _ScanLineListBlock *next; | - |
2977 | } ScanLineListBlock; | - |
2978 | | - |
2979 | | - |
2980 | | - |
2981 | /* | - |
2982 | * | - |
2983 | * a few macros for the inner loops of the fill code where | - |
2984 | * performance considerations don't allow a procedure call. | - |
2985 | * | - |
2986 | * Evaluate the given edge at the given scanline. | - |
2987 | * If the edge has expired, then we leave it and fix up | - |
2988 | * the active edge table; otherwise, we increment the | - |
2989 | * x value to be ready for the next scanline. | - |
2990 | * The winding number rule is in effect, so we must notify | - |
2991 | * the caller when the edge has been removed so he | - |
2992 | * can reorder the Winding Active Edge Table. | - |
2993 | */ | - |
2994 | #define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ | - |
2995 | if (pAET->ymax == y) { /* leaving this edge */ \ | - |
2996 | pPrevAET->next = pAET->next; \ | - |
2997 | pAET = pPrevAET->next; \ | - |
2998 | fixWAET = 1; \ | - |
2999 | if (pAET) \ | - |
3000 | pAET->back = pPrevAET; \ | - |
3001 | } \ | - |
3002 | else { \ | - |
3003 | BRESINCRPGONSTRUCT(pAET->bres) \ | - |
3004 | pPrevAET = pAET; \ | - |
3005 | pAET = pAET->next; \ | - |
3006 | } \ | - |
3007 | } | - |
3008 | | - |
3009 | | - |
3010 | /* | - |
3011 | * Evaluate the given edge at the given scanline. | - |
3012 | * If the edge has expired, then we leave it and fix up | - |
3013 | * the active edge table; otherwise, we increment the | - |
3014 | * x value to be ready for the next scanline. | - |
3015 | * The even-odd rule is in effect. | - |
3016 | */ | - |
3017 | #define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ | - |
3018 | if (pAET->ymax == y) { /* leaving this edge */ \ | - |
3019 | pPrevAET->next = pAET->next; \ | - |
3020 | pAET = pPrevAET->next; \ | - |
3021 | if (pAET) \ | - |
3022 | pAET->back = pPrevAET; \ | - |
3023 | } \ | - |
3024 | else { \ | - |
3025 | BRESINCRPGONSTRUCT(pAET->bres) \ | - |
3026 | pPrevAET = pAET; \ | - |
3027 | pAET = pAET->next; \ | - |
3028 | } \ | - |
3029 | } | - |
3030 | // END OF poly.h extract | - |
3031 | // START OF PolyReg.c extract | - |
3032 | /* $XConsortium: PolyReg.c,v 11.23 94/11/17 21:59:37 converse Exp $ */ | - |
3033 | /************************************************************************ | - |
3034 | | - |
3035 | Copyright (c) 1987 X Consortium | - |
3036 | | - |
3037 | Permission is hereby granted, free of charge, to any person obtaining a copy | - |
3038 | of this software and associated documentation files (the "Software"), to deal | - |
3039 | in the Software without restriction, including without limitation the rights | - |
3040 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | - |
3041 | copies of the Software, and to permit persons to whom the Software is | - |
3042 | furnished to do so, subject to the following conditions: | - |
3043 | | - |
3044 | The above copyright notice and this permission notice shall be included in | - |
3045 | all copies or substantial portions of the Software. | - |
3046 | | - |
3047 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | - |
3048 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | - |
3049 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | - |
3050 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | - |
3051 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | - |
3052 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | - |
3053 | | - |
3054 | Except as contained in this notice, the name of the X Consortium shall not be | - |
3055 | used in advertising or otherwise to promote the sale, use or other dealings | - |
3056 | in this Software without prior written authorization from the X Consortium. | - |
3057 | | - |
3058 | | - |
3059 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. | - |
3060 | | - |
3061 | All Rights Reserved | - |
3062 | | - |
3063 | Permission to use, copy, modify, and distribute this software and its | - |
3064 | documentation for any purpose and without fee is hereby granted, | - |
3065 | provided that the above copyright notice appear in all copies and that | - |
3066 | both that copyright notice and this permission notice appear in | - |
3067 | supporting documentation, and that the name of Digital not be | - |
3068 | used in advertising or publicity pertaining to distribution of the | - |
3069 | software without specific, written prior permission. | - |
3070 | | - |
3071 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | - |
3072 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | - |
3073 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | - |
3074 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | - |
3075 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | - |
3076 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | - |
3077 | SOFTWARE. | - |
3078 | | - |
3079 | ************************************************************************/ | - |
3080 | /* $XFree86: xc/lib/X11/PolyReg.c,v 1.1.1.2.8.2 1998/10/04 15:22:49 hohndel Exp $ */ | - |
3081 | | - |
3082 | #define LARGE_COORDINATE INT_MAX | - |
3083 | #define SMALL_COORDINATE INT_MIN | - |
3084 | | - |
3085 | /* | - |
3086 | * InsertEdgeInET | - |
3087 | * | - |
3088 | * Insert the given edge into the edge table. | - |
3089 | * First we must find the correct bucket in the | - |
3090 | * Edge table, then find the right slot in the | - |
3091 | * bucket. Finally, we can insert it. | - |
3092 | * | - |
3093 | */ | - |
3094 | static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, | - |
3095 | ScanLineListBlock **SLLBlock, int *iSLLBlock) | - |
3096 | { | - |
3097 | register EdgeTableEntry *start, *prev; executed (the execution status of this line is deduced): register EdgeTableEntry *start, *prev; | - |
3098 | register ScanLineList *pSLL, *pPrevSLL; executed (the execution status of this line is deduced): register ScanLineList *pSLL, *pPrevSLL; | - |
3099 | ScanLineListBlock *tmpSLLBlock; executed (the execution status of this line is deduced): ScanLineListBlock *tmpSLLBlock; | - |
3100 | | - |
3101 | /* | - |
3102 | * find the right bucket to put the edge into | - |
3103 | */ | - |
3104 | pPrevSLL = &ET->scanlines; executed (the execution status of this line is deduced): pPrevSLL = &ET->scanlines; | - |
3105 | pSLL = pPrevSLL->next; executed (the execution status of this line is deduced): pSLL = pPrevSLL->next; | - |
3106 | while (pSLL && (pSLL->scanline < scanline)) { evaluated: pSLL yes Evaluation Count:3866 | yes Evaluation Count:181 |
evaluated: (pSLL->scanline < scanline) yes Evaluation Count:3352 | yes Evaluation Count:514 |
| 181-3866 |
3107 | pPrevSLL = pSLL; executed (the execution status of this line is deduced): pPrevSLL = pSLL; | - |
3108 | pSLL = pSLL->next; executed (the execution status of this line is deduced): pSLL = pSLL->next; | - |
3109 | } executed: } Execution Count:3352 | 3352 |
3110 | | - |
3111 | /* | - |
3112 | * reassign pSLL (pointer to ScanLineList) if necessary | - |
3113 | */ | - |
3114 | if ((!pSLL) || (pSLL->scanline > scanline)) { evaluated: (!pSLL) yes Evaluation Count:181 | yes Evaluation Count:514 |
evaluated: (pSLL->scanline > scanline) yes Evaluation Count:165 | yes Evaluation Count:349 |
| 165-514 |
3115 | if (*iSLLBlock > SLLSPERBLOCK-1) evaluated: *iSLLBlock > 25 -1 yes Evaluation Count:8 | yes Evaluation Count:338 |
| 8-338 |
3116 | { | - |
3117 | tmpSLLBlock = executed (the execution status of this line is deduced): tmpSLLBlock = | - |
3118 | (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); executed (the execution status of this line is deduced): (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); | - |
3119 | Q_CHECK_PTR(tmpSLLBlock); executed (the execution status of this line is deduced): qt_noop(); | - |
3120 | (*SLLBlock)->next = tmpSLLBlock; executed (the execution status of this line is deduced): (*SLLBlock)->next = tmpSLLBlock; | - |
3121 | tmpSLLBlock->next = (ScanLineListBlock *)NULL; executed (the execution status of this line is deduced): tmpSLLBlock->next = (ScanLineListBlock *)__null; | - |
3122 | *SLLBlock = tmpSLLBlock; executed (the execution status of this line is deduced): *SLLBlock = tmpSLLBlock; | - |
3123 | *iSLLBlock = 0; executed (the execution status of this line is deduced): *iSLLBlock = 0; | - |
3124 | } executed: } Execution Count:8 | 8 |
3125 | pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); executed (the execution status of this line is deduced): pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); | - |
3126 | | - |
3127 | pSLL->next = pPrevSLL->next; executed (the execution status of this line is deduced): pSLL->next = pPrevSLL->next; | - |
3128 | pSLL->edgelist = (EdgeTableEntry *)NULL; executed (the execution status of this line is deduced): pSLL->edgelist = (EdgeTableEntry *)__null; | - |
3129 | pPrevSLL->next = pSLL; executed (the execution status of this line is deduced): pPrevSLL->next = pSLL; | - |
3130 | } executed: } Execution Count:346 | 346 |
3131 | pSLL->scanline = scanline; executed (the execution status of this line is deduced): pSLL->scanline = scanline; | - |
3132 | | - |
3133 | /* | - |
3134 | * now insert the edge in the right bucket | - |
3135 | */ | - |
3136 | prev = 0; executed (the execution status of this line is deduced): prev = 0; | - |
3137 | start = pSLL->edgelist; executed (the execution status of this line is deduced): start = pSLL->edgelist; | - |
3138 | while (start && (start->bres.minor_axis < ETE->bres.minor_axis)) { evaluated: start yes Evaluation Count:355 | yes Evaluation Count:509 |
evaluated: (start->bres.minor_axis < ETE->bres.minor_axis) yes Evaluation Count:169 | yes Evaluation Count:186 |
| 169-509 |
3139 | prev = start; executed (the execution status of this line is deduced): prev = start; | - |
3140 | start = start->next; executed (the execution status of this line is deduced): start = start->next; | - |
3141 | } executed: } Execution Count:169 | 169 |
3142 | ETE->next = start; executed (the execution status of this line is deduced): ETE->next = start; | - |
3143 | | - |
3144 | if (prev) evaluated: prev yes Evaluation Count:163 | yes Evaluation Count:532 |
| 163-532 |
3145 | prev->next = ETE; executed: prev->next = ETE; Execution Count:163 | 163 |
3146 | else | - |
3147 | pSLL->edgelist = ETE; executed: pSLL->edgelist = ETE; Execution Count:532 | 532 |
3148 | } | - |
3149 | | - |
3150 | /* | - |
3151 | * CreateEdgeTable | - |
3152 | * | - |
3153 | * This routine creates the edge table for | - |
3154 | * scan converting polygons. | - |
3155 | * The Edge Table (ET) looks like: | - |
3156 | * | - |
3157 | * EdgeTable | - |
3158 | * -------- | - |
3159 | * | ymax | ScanLineLists | - |
3160 | * |scanline|-->------------>-------------->... | - |
3161 | * -------- |scanline| |scanline| | - |
3162 | * |edgelist| |edgelist| | - |
3163 | * --------- --------- | - |
3164 | * | | | - |
3165 | * | | | - |
3166 | * V V | - |
3167 | * list of ETEs list of ETEs | - |
3168 | * | - |
3169 | * where ETE is an EdgeTableEntry data structure, | - |
3170 | * and there is one ScanLineList per scanline at | - |
3171 | * which an edge is initially entered. | - |
3172 | * | - |
3173 | */ | - |
3174 | | - |
3175 | static void CreateETandAET(register int count, register const QPoint *pts, | - |
3176 | EdgeTable *ET, EdgeTableEntry *AET, register EdgeTableEntry *pETEs, | - |
3177 | ScanLineListBlock *pSLLBlock) | - |
3178 | { | - |
3179 | register const QPoint *top, executed (the execution status of this line is deduced): register const QPoint *top, | - |
3180 | *bottom, executed (the execution status of this line is deduced): *bottom, | - |
3181 | *PrevPt, executed (the execution status of this line is deduced): *PrevPt, | - |
3182 | *CurrPt; executed (the execution status of this line is deduced): *CurrPt; | - |
3183 | int iSLLBlock = 0; executed (the execution status of this line is deduced): int iSLLBlock = 0; | - |
3184 | int dy; executed (the execution status of this line is deduced): int dy; | - |
3185 | | - |
3186 | if (count < 2) partially evaluated: count < 2 no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
3187 | return; | 0 |
3188 | | - |
3189 | /* | - |
3190 | * initialize the Active Edge Table | - |
3191 | */ | - |
3192 | AET->next = 0; executed (the execution status of this line is deduced): AET->next = 0; | - |
3193 | AET->back = 0; executed (the execution status of this line is deduced): AET->back = 0; | - |
3194 | AET->nextWETE = 0; executed (the execution status of this line is deduced): AET->nextWETE = 0; | - |
3195 | AET->bres.minor_axis = SMALL_COORDINATE; executed (the execution status of this line is deduced): AET->bres.minor_axis = (-2147483647 - 1); | - |
3196 | | - |
3197 | /* | - |
3198 | * initialize the Edge Table. | - |
3199 | */ | - |
3200 | ET->scanlines.next = 0; executed (the execution status of this line is deduced): ET->scanlines.next = 0; | - |
3201 | ET->ymax = SMALL_COORDINATE; executed (the execution status of this line is deduced): ET->ymax = (-2147483647 - 1); | - |
3202 | ET->ymin = LARGE_COORDINATE; executed (the execution status of this line is deduced): ET->ymin = 2147483647; | - |
3203 | pSLLBlock->next = 0; executed (the execution status of this line is deduced): pSLLBlock->next = 0; | - |
3204 | | - |
3205 | PrevPt = &pts[count - 1]; executed (the execution status of this line is deduced): PrevPt = &pts[count - 1]; | - |
3206 | | - |
3207 | /* | - |
3208 | * for each vertex in the array of points. | - |
3209 | * In this loop we are dealing with two vertices at | - |
3210 | * a time -- these make up one edge of the polygon. | - |
3211 | */ | - |
3212 | while (count--) { evaluated: count-- yes Evaluation Count:750 | yes Evaluation Count:21 |
| 21-750 |
3213 | CurrPt = pts++; executed (the execution status of this line is deduced): CurrPt = pts++; | - |
3214 | | - |
3215 | /* | - |
3216 | * find out which point is above and which is below. | - |
3217 | */ | - |
3218 | if (PrevPt->y() > CurrPt->y()) { evaluated: PrevPt->y() > CurrPt->y() yes Evaluation Count:346 | yes Evaluation Count:404 |
| 346-404 |
3219 | bottom = PrevPt; executed (the execution status of this line is deduced): bottom = PrevPt; | - |
3220 | top = CurrPt; executed (the execution status of this line is deduced): top = CurrPt; | - |
3221 | pETEs->ClockWise = 0; executed (the execution status of this line is deduced): pETEs->ClockWise = 0; | - |
3222 | } else { executed: } Execution Count:346 | 346 |
3223 | bottom = CurrPt; executed (the execution status of this line is deduced): bottom = CurrPt; | - |
3224 | top = PrevPt; executed (the execution status of this line is deduced): top = PrevPt; | - |
3225 | pETEs->ClockWise = 1; executed (the execution status of this line is deduced): pETEs->ClockWise = 1; | - |
3226 | } executed: } Execution Count:404 | 404 |
3227 | | - |
3228 | /* | - |
3229 | * don't add horizontal edges to the Edge table. | - |
3230 | */ | - |
3231 | if (bottom->y() != top->y()) { evaluated: bottom->y() != top->y() yes Evaluation Count:695 | yes Evaluation Count:55 |
| 55-695 |
3232 | pETEs->ymax = bottom->y() - 1; /* -1 so we don't get last scanline */ executed (the execution status of this line is deduced): pETEs->ymax = bottom->y() - 1; | - |
3233 | | - |
3234 | /* | - |
3235 | * initialize integer edge algorithm | - |
3236 | */ | - |
3237 | dy = bottom->y() - top->y(); executed (the execution status of this line is deduced): dy = bottom->y() - top->y(); | - |
3238 | BRESINITPGONSTRUCT(dy, top->x(), bottom->x(), pETEs->bres) executed: } Execution Count:324 executed: } Execution Count:371 partially evaluated: (dy) != 0 yes Evaluation Count:695 | no Evaluation Count:0 |
evaluated: dx < 0 yes Evaluation Count:324 | yes Evaluation Count:371 |
| 0-695 |
3239 | | - |
3240 | InsertEdgeInET(ET, pETEs, top->y(), &pSLLBlock, &iSLLBlock); executed (the execution status of this line is deduced): InsertEdgeInET(ET, pETEs, top->y(), &pSLLBlock, &iSLLBlock); | - |
3241 | | - |
3242 | if (PrevPt->y() > ET->ymax) evaluated: PrevPt->y() > ET->ymax yes Evaluation Count:199 | yes Evaluation Count:496 |
| 199-496 |
3243 | ET->ymax = PrevPt->y(); executed: ET->ymax = PrevPt->y(); Execution Count:199 | 199 |
3244 | if (PrevPt->y() < ET->ymin) evaluated: PrevPt->y() < ET->ymin yes Evaluation Count:188 | yes Evaluation Count:507 |
| 188-507 |
3245 | ET->ymin = PrevPt->y(); executed: ET->ymin = PrevPt->y(); Execution Count:188 | 188 |
3246 | ++pETEs; executed (the execution status of this line is deduced): ++pETEs; | - |
3247 | } executed: } Execution Count:695 | 695 |
3248 | | - |
3249 | PrevPt = CurrPt; executed (the execution status of this line is deduced): PrevPt = CurrPt; | - |
3250 | } executed: } Execution Count:750 | 750 |
3251 | } executed: } Execution Count:21 | 21 |
3252 | | - |
3253 | /* | - |
3254 | * loadAET | - |
3255 | * | - |
3256 | * This routine moves EdgeTableEntries from the | - |
3257 | * EdgeTable into the Active Edge Table, | - |
3258 | * leaving them sorted by smaller x coordinate. | - |
3259 | * | - |
3260 | */ | - |
3261 | | - |
3262 | static void loadAET(register EdgeTableEntry *AET, register EdgeTableEntry *ETEs) | - |
3263 | { | - |
3264 | register EdgeTableEntry *pPrevAET; executed (the execution status of this line is deduced): register EdgeTableEntry *pPrevAET; | - |
3265 | register EdgeTableEntry *tmp; executed (the execution status of this line is deduced): register EdgeTableEntry *tmp; | - |
3266 | | - |
3267 | pPrevAET = AET; executed (the execution status of this line is deduced): pPrevAET = AET; | - |
3268 | AET = AET->next; executed (the execution status of this line is deduced): AET = AET->next; | - |
3269 | while (ETEs) { evaluated: ETEs yes Evaluation Count:695 | yes Evaluation Count:346 |
| 346-695 |
3270 | while (AET && AET->bres.minor_axis < ETEs->bres.minor_axis) { evaluated: AET yes Evaluation Count:8 | yes Evaluation Count:689 |
evaluated: AET->bres.minor_axis < ETEs->bres.minor_axis yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-689 |
3271 | pPrevAET = AET; executed (the execution status of this line is deduced): pPrevAET = AET; | - |
3272 | AET = AET->next; executed (the execution status of this line is deduced): AET = AET->next; | - |
3273 | } executed: } Execution Count:2 | 2 |
3274 | tmp = ETEs->next; executed (the execution status of this line is deduced): tmp = ETEs->next; | - |
3275 | ETEs->next = AET; executed (the execution status of this line is deduced): ETEs->next = AET; | - |
3276 | if (AET) evaluated: AET yes Evaluation Count:6 | yes Evaluation Count:689 |
| 6-689 |
3277 | AET->back = ETEs; executed: AET->back = ETEs; Execution Count:6 | 6 |
3278 | ETEs->back = pPrevAET; executed (the execution status of this line is deduced): ETEs->back = pPrevAET; | - |
3279 | pPrevAET->next = ETEs; executed (the execution status of this line is deduced): pPrevAET->next = ETEs; | - |
3280 | pPrevAET = ETEs; executed (the execution status of this line is deduced): pPrevAET = ETEs; | - |
3281 | | - |
3282 | ETEs = tmp; executed (the execution status of this line is deduced): ETEs = tmp; | - |
3283 | } executed: } Execution Count:695 | 695 |
3284 | } executed: } Execution Count:346 | 346 |
3285 | | - |
3286 | /* | - |
3287 | * computeWAET | - |
3288 | * | - |
3289 | * This routine links the AET by the | - |
3290 | * nextWETE (winding EdgeTableEntry) link for | - |
3291 | * use by the winding number rule. The final | - |
3292 | * Active Edge Table (AET) might look something | - |
3293 | * like: | - |
3294 | * | - |
3295 | * AET | - |
3296 | * ---------- --------- --------- | - |
3297 | * |ymax | |ymax | |ymax | | - |
3298 | * | ... | |... | |... | | - |
3299 | * |next |->|next |->|next |->... | - |
3300 | * |nextWETE| |nextWETE| |nextWETE| | - |
3301 | * --------- --------- ^-------- | - |
3302 | * | | | | - |
3303 | * V-------------------> V---> ... | - |
3304 | * | - |
3305 | */ | - |
3306 | static void computeWAET(register EdgeTableEntry *AET) | - |
3307 | { | - |
3308 | register EdgeTableEntry *pWETE; never executed (the execution status of this line is deduced): register EdgeTableEntry *pWETE; | - |
3309 | register int inside = 1; never executed (the execution status of this line is deduced): register int inside = 1; | - |
3310 | register int isInside = 0; never executed (the execution status of this line is deduced): register int isInside = 0; | - |
3311 | | - |
3312 | AET->nextWETE = 0; never executed (the execution status of this line is deduced): AET->nextWETE = 0; | - |
3313 | pWETE = AET; never executed (the execution status of this line is deduced): pWETE = AET; | - |
3314 | AET = AET->next; never executed (the execution status of this line is deduced): AET = AET->next; | - |
3315 | while (AET) { | 0 |
3316 | if (AET->ClockWise) never evaluated: AET->ClockWise | 0 |
3317 | ++isInside; never executed: ++isInside; | 0 |
3318 | else | - |
3319 | --isInside; never executed: --isInside; | 0 |
3320 | | - |
3321 | if ((!inside && !isInside) || (inside && isInside)) { never evaluated: !inside never evaluated: !isInside never evaluated: inside never evaluated: isInside | 0 |
3322 | pWETE->nextWETE = AET; never executed (the execution status of this line is deduced): pWETE->nextWETE = AET; | - |
3323 | pWETE = AET; never executed (the execution status of this line is deduced): pWETE = AET; | - |
3324 | inside = !inside; never executed (the execution status of this line is deduced): inside = !inside; | - |
3325 | } | 0 |
3326 | AET = AET->next; never executed (the execution status of this line is deduced): AET = AET->next; | - |
3327 | } | 0 |
3328 | pWETE->nextWETE = 0; never executed (the execution status of this line is deduced): pWETE->nextWETE = 0; | - |
3329 | } | 0 |
3330 | | - |
3331 | /* | - |
3332 | * InsertionSort | - |
3333 | * | - |
3334 | * Just a simple insertion sort using | - |
3335 | * pointers and back pointers to sort the Active | - |
3336 | * Edge Table. | - |
3337 | * | - |
3338 | */ | - |
3339 | | - |
3340 | static int InsertionSort(register EdgeTableEntry *AET) | - |
3341 | { | - |
3342 | register EdgeTableEntry *pETEchase; executed (the execution status of this line is deduced): register EdgeTableEntry *pETEchase; | - |
3343 | register EdgeTableEntry *pETEinsert; executed (the execution status of this line is deduced): register EdgeTableEntry *pETEinsert; | - |
3344 | register EdgeTableEntry *pETEchaseBackTMP; executed (the execution status of this line is deduced): register EdgeTableEntry *pETEchaseBackTMP; | - |
3345 | register int changed = 0; executed (the execution status of this line is deduced): register int changed = 0; | - |
3346 | | - |
3347 | AET = AET->next; executed (the execution status of this line is deduced): AET = AET->next; | - |
3348 | while (AET) { evaluated: AET yes Evaluation Count:8639 | yes Evaluation Count:4477 |
| 4477-8639 |
3349 | pETEinsert = AET; executed (the execution status of this line is deduced): pETEinsert = AET; | - |
3350 | pETEchase = AET; executed (the execution status of this line is deduced): pETEchase = AET; | - |
3351 | while (pETEchase->back->bres.minor_axis > AET->bres.minor_axis) evaluated: pETEchase->back->bres.minor_axis > AET->bres.minor_axis yes Evaluation Count:3 | yes Evaluation Count:8639 |
| 3-8639 |
3352 | pETEchase = pETEchase->back; executed: pETEchase = pETEchase->back; Execution Count:3 | 3 |
3353 | | - |
3354 | AET = AET->next; executed (the execution status of this line is deduced): AET = AET->next; | - |
3355 | if (pETEchase != pETEinsert) { evaluated: pETEchase != pETEinsert yes Evaluation Count:2 | yes Evaluation Count:8637 |
| 2-8637 |
3356 | pETEchaseBackTMP = pETEchase->back; executed (the execution status of this line is deduced): pETEchaseBackTMP = pETEchase->back; | - |
3357 | pETEinsert->back->next = AET; executed (the execution status of this line is deduced): pETEinsert->back->next = AET; | - |
3358 | if (AET) evaluated: AET yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
3359 | AET->back = pETEinsert->back; executed: AET->back = pETEinsert->back; Execution Count:1 | 1 |
3360 | pETEinsert->next = pETEchase; executed (the execution status of this line is deduced): pETEinsert->next = pETEchase; | - |
3361 | pETEchase->back->next = pETEinsert; executed (the execution status of this line is deduced): pETEchase->back->next = pETEinsert; | - |
3362 | pETEchase->back = pETEinsert; executed (the execution status of this line is deduced): pETEchase->back = pETEinsert; | - |
3363 | pETEinsert->back = pETEchaseBackTMP; executed (the execution status of this line is deduced): pETEinsert->back = pETEchaseBackTMP; | - |
3364 | changed = 1; executed (the execution status of this line is deduced): changed = 1; | - |
3365 | } executed: } Execution Count:2 | 2 |
3366 | } executed: } Execution Count:8639 | 8639 |
3367 | return changed; executed: return changed; Execution Count:4477 | 4477 |
3368 | } | - |
3369 | | - |
3370 | /* | - |
3371 | * Clean up our act. | - |
3372 | */ | - |
3373 | static void FreeStorage(register ScanLineListBlock *pSLLBlock) | - |
3374 | { | - |
3375 | register ScanLineListBlock *tmpSLLBlock; executed (the execution status of this line is deduced): register ScanLineListBlock *tmpSLLBlock; | - |
3376 | | - |
3377 | while (pSLLBlock) { evaluated: pSLLBlock yes Evaluation Count:8 | yes Evaluation Count:21 |
| 8-21 |
3378 | tmpSLLBlock = pSLLBlock->next; executed (the execution status of this line is deduced): tmpSLLBlock = pSLLBlock->next; | - |
3379 | free(pSLLBlock); executed (the execution status of this line is deduced): free(pSLLBlock); | - |
3380 | pSLLBlock = tmpSLLBlock; executed (the execution status of this line is deduced): pSLLBlock = tmpSLLBlock; | - |
3381 | } executed: } Execution Count:8 | 8 |
3382 | } executed: } Execution Count:21 | 21 |
3383 | | - |
3384 | struct QRegionSpan { | - |
3385 | QRegionSpan() {} | - |
3386 | QRegionSpan(int x1_, int x2_) : x1(x1_), x2(x2_) {} executed: } Execution Count:4544 | 4544 |
3387 | | - |
3388 | int x1; | - |
3389 | int x2; | - |
3390 | int width() const { return x2 - x1; } executed: return x2 - x1; Execution Count:2464 | 2464 |
3391 | }; | - |
3392 | | - |
3393 | Q_DECLARE_TYPEINFO(QRegionSpan, Q_PRIMITIVE_TYPE); | - |
3394 | | - |
3395 | static inline void flushRow(const QRegionSpan *spans, int y, int numSpans, QRegionPrivate *reg, int *lastRow, int *extendTo, bool *needsExtend) | - |
3396 | { | - |
3397 | QRect *regRects = reg->rects.data() + *lastRow; executed (the execution status of this line is deduced): QRect *regRects = reg->rects.data() + *lastRow; | - |
3398 | bool canExtend = reg->rects.size() - *lastRow == numSpans evaluated: reg->rects.size() - *lastRow == numSpans yes Evaluation Count:4349 | yes Evaluation Count:25 |
| 25-4349 |
3399 | && !(*needsExtend && *extendTo + 1 != y) evaluated: *needsExtend yes Evaluation Count:1904 | yes Evaluation Count:2445 |
evaluated: *extendTo + 1 != y yes Evaluation Count:1 | yes Evaluation Count:1903 |
| 1-2445 |
3400 | && (*needsExtend || regRects[0].y() + regRects[0].height() == y); evaluated: *needsExtend yes Evaluation Count:1903 | yes Evaluation Count:2445 |
evaluated: regRects[0].y() + regRects[0].height() == y yes Evaluation Count:2444 | yes Evaluation Count:1 |
| 1-2445 |
3401 | | - |
3402 | for (int i = 0; i < numSpans && canExtend; ++i) { evaluated: i < numSpans yes Evaluation Count:4541 | yes Evaluation Count:4347 |
evaluated: canExtend yes Evaluation Count:4514 | yes Evaluation Count:27 |
| 27-4541 |
3403 | if (regRects[i].x() != spans[i].x1 || regRects[i].right() != spans[i].x2 - 1) evaluated: regRects[i].x() != spans[i].x1 yes Evaluation Count:2138 | yes Evaluation Count:2376 |
evaluated: regRects[i].right() != spans[i].x2 - 1 yes Evaluation Count:296 | yes Evaluation Count:2080 |
| 296-2376 |
3404 | canExtend = false; executed: canExtend = false; Execution Count:2434 | 2434 |
3405 | } executed: } Execution Count:4514 | 4514 |
3406 | | - |
3407 | if (canExtend) { evaluated: canExtend yes Evaluation Count:1913 | yes Evaluation Count:2461 |
| 1913-2461 |
3408 | *extendTo = y; executed (the execution status of this line is deduced): *extendTo = y; | - |
3409 | *needsExtend = true; executed (the execution status of this line is deduced): *needsExtend = true; | - |
3410 | } else { executed: } Execution Count:1913 | 1913 |
3411 | if (*needsExtend) { evaluated: *needsExtend yes Evaluation Count:254 | yes Evaluation Count:2207 |
| 254-2207 |
3412 | for (int i = 0; i < reg->rects.size() - *lastRow; ++i) evaluated: i < reg->rects.size() - *lastRow yes Evaluation Count:257 | yes Evaluation Count:254 |
| 254-257 |
3413 | regRects[i].setBottom(*extendTo); executed: regRects[i].setBottom(*extendTo); Execution Count:257 | 257 |
3414 | } executed: } Execution Count:254 | 254 |
3415 | | - |
3416 | *lastRow = reg->rects.size(); executed (the execution status of this line is deduced): *lastRow = reg->rects.size(); | - |
3417 | reg->rects.reserve(*lastRow + numSpans); executed (the execution status of this line is deduced): reg->rects.reserve(*lastRow + numSpans); | - |
3418 | for (int i = 0; i < numSpans; ++i) evaluated: i < numSpans yes Evaluation Count:2464 | yes Evaluation Count:2461 |
| 2461-2464 |
3419 | reg->rects << QRect(spans[i].x1, y, spans[i].width(), 1); executed: reg->rects << QRect(spans[i].x1, y, spans[i].width(), 1); Execution Count:2464 | 2464 |
3420 | | - |
3421 | if (spans[0].x1 < reg->extents.left()) evaluated: spans[0].x1 < reg->extents.left() yes Evaluation Count:966 | yes Evaluation Count:1495 |
| 966-1495 |
3422 | reg->extents.setLeft(spans[0].x1); executed: reg->extents.setLeft(spans[0].x1); Execution Count:966 | 966 |
3423 | | - |
3424 | if (spans[numSpans-1].x2 - 1 > reg->extents.right()) evaluated: spans[numSpans-1].x2 - 1 > reg->extents.right() yes Evaluation Count:1124 | yes Evaluation Count:1337 |
| 1124-1337 |
3425 | reg->extents.setRight(spans[numSpans-1].x2 - 1); executed: reg->extents.setRight(spans[numSpans-1].x2 - 1); Execution Count:1124 | 1124 |
3426 | | - |
3427 | *needsExtend = false; executed (the execution status of this line is deduced): *needsExtend = false; | - |
3428 | } executed: } Execution Count:2461 | 2461 |
3429 | } | - |
3430 | | - |
3431 | /* | - |
3432 | * Create an array of rectangles from a list of points. | - |
3433 | * If indeed these things (POINTS, RECTS) are the same, | - |
3434 | * then this proc is still needed, because it allocates | - |
3435 | * storage for the array, which was allocated on the | - |
3436 | * stack by the calling procedure. | - |
3437 | * | - |
3438 | */ | - |
3439 | static void PtsToRegion(register int numFullPtBlocks, register int iCurPtBlock, | - |
3440 | POINTBLOCK *FirstPtBlock, QRegionPrivate *reg) | - |
3441 | { | - |
3442 | int lastRow = 0; executed (the execution status of this line is deduced): int lastRow = 0; | - |
3443 | int extendTo = 0; executed (the execution status of this line is deduced): int extendTo = 0; | - |
3444 | bool needsExtend = false; executed (the execution status of this line is deduced): bool needsExtend = false; | - |
3445 | QVarLengthArray<QRegionSpan> row; executed (the execution status of this line is deduced): QVarLengthArray<QRegionSpan> row; | - |
3446 | int rowSize = 0; executed (the execution status of this line is deduced): int rowSize = 0; | - |
3447 | | - |
3448 | reg->extents.setLeft(INT_MAX); executed (the execution status of this line is deduced): reg->extents.setLeft(2147483647); | - |
3449 | reg->extents.setRight(INT_MIN); executed (the execution status of this line is deduced): reg->extents.setRight((-2147483647 - 1)); | - |
3450 | reg->innerArea = -1; executed (the execution status of this line is deduced): reg->innerArea = -1; | - |
3451 | | - |
3452 | POINTBLOCK *CurPtBlock = FirstPtBlock; executed (the execution status of this line is deduced): POINTBLOCK *CurPtBlock = FirstPtBlock; | - |
3453 | for (; numFullPtBlocks >= 0; --numFullPtBlocks) { evaluated: numFullPtBlocks >= 0 yes Evaluation Count:63 | yes Evaluation Count:21 |
| 21-63 |
3454 | /* the loop uses 2 points per iteration */ | - |
3455 | int i = NUMPTSTOBUFFER >> 1; executed (the execution status of this line is deduced): int i = 200 >> 1; | - |
3456 | if (!numFullPtBlocks) evaluated: !numFullPtBlocks yes Evaluation Count:21 | yes Evaluation Count:42 |
| 21-42 |
3457 | i = iCurPtBlock >> 1; executed: i = iCurPtBlock >> 1; Execution Count:21 | 21 |
3458 | if(i) { evaluated: i yes Evaluation Count:52 | yes Evaluation Count:11 |
| 11-52 |
3459 | row.resize(qMax(row.size(), rowSize + i)); executed (the execution status of this line is deduced): row.resize(qMax(row.size(), rowSize + i)); | - |
3460 | for (QPoint *pts = CurPtBlock->pts; i--; pts += 2) { evaluated: i-- yes Evaluation Count:4667 | yes Evaluation Count:52 |
| 52-4667 |
3461 | const int width = pts[1].x() - pts[0].x(); executed (the execution status of this line is deduced): const int width = pts[1].x() - pts[0].x(); | - |
3462 | if (width) { evaluated: width yes Evaluation Count:4553 | yes Evaluation Count:114 |
| 114-4553 |
3463 | if (rowSize && row[rowSize-1].x2 == pts[0].x()) evaluated: rowSize yes Evaluation Count:179 | yes Evaluation Count:4374 |
evaluated: row[rowSize-1].x2 == pts[0].x() yes Evaluation Count:9 | yes Evaluation Count:170 |
| 9-4374 |
3464 | row[rowSize-1].x2 = pts[1].x(); executed: row[rowSize-1].x2 = pts[1].x(); Execution Count:9 | 9 |
3465 | else | - |
3466 | row[rowSize++] = QRegionSpan(pts[0].x(), pts[1].x()); executed: row[rowSize++] = QRegionSpan(pts[0].x(), pts[1].x()); Execution Count:4544 | 4544 |
3467 | } | - |
3468 | | - |
3469 | if (rowSize) { evaluated: rowSize yes Evaluation Count:4553 | yes Evaluation Count:114 |
| 114-4553 |
3470 | QPoint *next = i ? &pts[2] : (numFullPtBlocks ? CurPtBlock->next->pts : 0); evaluated: i yes Evaluation Count:4502 | yes Evaluation Count:51 |
| 51-4502 |
3471 | | - |
3472 | if (!next || next->y() != pts[0].y()) { evaluated: !next yes Evaluation Count:10 | yes Evaluation Count:4543 |
evaluated: next->y() != pts[0].y() yes Evaluation Count:4364 | yes Evaluation Count:179 |
| 10-4543 |
3473 | flushRow(row.data(), pts[0].y(), rowSize, reg, &lastRow, &extendTo, &needsExtend); executed (the execution status of this line is deduced): flushRow(row.data(), pts[0].y(), rowSize, reg, &lastRow, &extendTo, &needsExtend); | - |
3474 | rowSize = 0; executed (the execution status of this line is deduced): rowSize = 0; | - |
3475 | } executed: } Execution Count:4374 | 4374 |
3476 | } executed: } Execution Count:4553 | 4553 |
3477 | } executed: } Execution Count:4667 | 4667 |
3478 | } executed: } Execution Count:52 | 52 |
3479 | CurPtBlock = CurPtBlock->next; executed (the execution status of this line is deduced): CurPtBlock = CurPtBlock->next; | - |
3480 | } executed: } Execution Count:63 | 63 |
3481 | | - |
3482 | if (needsExtend) { evaluated: needsExtend yes Evaluation Count:5 | yes Evaluation Count:16 |
| 5-16 |
3483 | for (int i = lastRow; i < reg->rects.size(); ++i) evaluated: i < reg->rects.size() yes Evaluation Count:5 | yes Evaluation Count:5 |
| 5 |
3484 | reg->rects[i].setBottom(extendTo); executed: reg->rects[i].setBottom(extendTo); Execution Count:5 | 5 |
3485 | } executed: } Execution Count:5 | 5 |
3486 | | - |
3487 | reg->numRects = reg->rects.size(); executed (the execution status of this line is deduced): reg->numRects = reg->rects.size(); | - |
3488 | | - |
3489 | if (reg->numRects) { partially evaluated: reg->numRects yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
3490 | reg->extents.setTop(reg->rects[0].top()); executed (the execution status of this line is deduced): reg->extents.setTop(reg->rects[0].top()); | - |
3491 | reg->extents.setBottom(reg->rects[lastRow].bottom()); executed (the execution status of this line is deduced): reg->extents.setBottom(reg->rects[lastRow].bottom()); | - |
3492 | | - |
3493 | for (int i = 0; i < reg->rects.size(); ++i) evaluated: i < reg->rects.size() yes Evaluation Count:2464 | yes Evaluation Count:21 |
| 21-2464 |
3494 | reg->updateInnerRect(reg->rects[i]); executed: reg->updateInnerRect(reg->rects[i]); Execution Count:2464 | 2464 |
3495 | } else { executed: } Execution Count:21 | 21 |
3496 | reg->extents.setCoords(0, 0, 0, 0); never executed (the execution status of this line is deduced): reg->extents.setCoords(0, 0, 0, 0); | - |
3497 | } | 0 |
3498 | } | - |
3499 | | - |
3500 | /* | - |
3501 | * polytoregion | - |
3502 | * | - |
3503 | * Scan converts a polygon by returning a run-length | - |
3504 | * encoding of the resultant bitmap -- the run-length | - |
3505 | * encoding is in the form of an array of rectangles. | - |
3506 | * | - |
3507 | * Can return 0 in case of errors. | - |
3508 | */ | - |
3509 | static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) | - |
3510 | //Point *Pts; /* the pts */ | - |
3511 | //int Count; /* number of pts */ | - |
3512 | //int rule; /* winding rule */ | - |
3513 | { | - |
3514 | QRegionPrivate *region; executed (the execution status of this line is deduced): QRegionPrivate *region; | - |
3515 | register EdgeTableEntry *pAET; /* Active Edge Table */ executed (the execution status of this line is deduced): register EdgeTableEntry *pAET; | - |
3516 | register int y; /* current scanline */ executed (the execution status of this line is deduced): register int y; | - |
3517 | register int iPts = 0; /* number of pts in buffer */ executed (the execution status of this line is deduced): register int iPts = 0; | - |
3518 | register EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/ executed (the execution status of this line is deduced): register EdgeTableEntry *pWETE; | - |
3519 | register ScanLineList *pSLL; /* current scanLineList */ executed (the execution status of this line is deduced): register ScanLineList *pSLL; | - |
3520 | register QPoint *pts; /* output buffer */ executed (the execution status of this line is deduced): register QPoint *pts; | - |
3521 | EdgeTableEntry *pPrevAET; /* ptr to previous AET */ executed (the execution status of this line is deduced): EdgeTableEntry *pPrevAET; | - |
3522 | EdgeTable ET; /* header node for ET */ executed (the execution status of this line is deduced): EdgeTable ET; | - |
3523 | EdgeTableEntry AET; /* header node for AET */ executed (the execution status of this line is deduced): EdgeTableEntry AET; | - |
3524 | EdgeTableEntry *pETEs; /* EdgeTableEntries pool */ executed (the execution status of this line is deduced): EdgeTableEntry *pETEs; | - |
3525 | ScanLineListBlock SLLBlock; /* header for scanlinelist */ executed (the execution status of this line is deduced): ScanLineListBlock SLLBlock; | - |
3526 | int fixWAET = false; executed (the execution status of this line is deduced): int fixWAET = false; | - |
3527 | POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */ executed (the execution status of this line is deduced): POINTBLOCK FirstPtBlock, *curPtBlock; | - |
3528 | FirstPtBlock.pts = reinterpret_cast<QPoint *>(FirstPtBlock.data); executed (the execution status of this line is deduced): FirstPtBlock.pts = reinterpret_cast<QPoint *>(FirstPtBlock.data); | - |
3529 | POINTBLOCK *tmpPtBlock; executed (the execution status of this line is deduced): POINTBLOCK *tmpPtBlock; | - |
3530 | int numFullPtBlocks = 0; executed (the execution status of this line is deduced): int numFullPtBlocks = 0; | - |
3531 | | - |
3532 | if (!(region = new QRegionPrivate)) partially evaluated: !(region = new QRegionPrivate) no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
3533 | return 0; never executed: return 0; | 0 |
3534 | | - |
3535 | /* special case a rectangle */ | - |
3536 | if (((Count == 4) || evaluated: (Count == 4) yes Evaluation Count:2 | yes Evaluation Count:25 |
| 2-25 |
3537 | ((Count == 5) && (Pts[4].x() == Pts[0].x()) && (Pts[4].y() == Pts[0].y()))) evaluated: (Count == 5) yes Evaluation Count:7 | yes Evaluation Count:18 |
partially evaluated: (Pts[4].x() == Pts[0].x()) yes Evaluation Count:7 | no Evaluation Count:0 |
partially evaluated: (Pts[4].y() == Pts[0].y()) yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-18 |
3538 | && (((Pts[0].y() == Pts[1].y()) && (Pts[1].x() == Pts[2].x()) && (Pts[2].y() == Pts[3].y()) evaluated: (Pts[0].y() == Pts[1].y()) yes Evaluation Count:1 | yes Evaluation Count:8 |
partially evaluated: (Pts[1].x() == Pts[2].x()) yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: (Pts[2].y() == Pts[3].y()) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-8 |
3539 | && (Pts[3].x() == Pts[0].x())) || ((Pts[0].x() == Pts[1].x()) partially evaluated: (Pts[3].x() == Pts[0].x()) yes Evaluation Count:1 | no Evaluation Count:0 |
evaluated: (Pts[0].x() == Pts[1].x()) yes Evaluation Count:5 | yes Evaluation Count:3 |
| 0-5 |
3540 | && (Pts[1].y() == Pts[2].y()) && (Pts[2].x() == Pts[3].x()) partially evaluated: (Pts[1].y() == Pts[2].y()) yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: (Pts[2].x() == Pts[3].x()) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
3541 | && (Pts[3].y() == Pts[0].y())))) { partially evaluated: (Pts[3].y() == Pts[0].y()) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
3542 | int x = qMin(Pts[0].x(), Pts[2].x()); executed (the execution status of this line is deduced): int x = qMin(Pts[0].x(), Pts[2].x()); | - |
3543 | region->extents.setLeft(x); executed (the execution status of this line is deduced): region->extents.setLeft(x); | - |
3544 | int y = qMin(Pts[0].y(), Pts[2].y()); executed (the execution status of this line is deduced): int y = qMin(Pts[0].y(), Pts[2].y()); | - |
3545 | region->extents.setTop(y); executed (the execution status of this line is deduced): region->extents.setTop(y); | - |
3546 | region->extents.setWidth(qMax(Pts[0].x(), Pts[2].x()) - x); executed (the execution status of this line is deduced): region->extents.setWidth(qMax(Pts[0].x(), Pts[2].x()) - x); | - |
3547 | region->extents.setHeight(qMax(Pts[0].y(), Pts[2].y()) - y); executed (the execution status of this line is deduced): region->extents.setHeight(qMax(Pts[0].y(), Pts[2].y()) - y); | - |
3548 | if ((region->extents.left() <= region->extents.right()) && partially evaluated: (region->extents.left() <= region->extents.right()) yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
3549 | (region->extents.top() <= region->extents.bottom())) { partially evaluated: (region->extents.top() <= region->extents.bottom()) yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
3550 | region->numRects = 1; executed (the execution status of this line is deduced): region->numRects = 1; | - |
3551 | region->innerRect = region->extents; executed (the execution status of this line is deduced): region->innerRect = region->extents; | - |
3552 | region->innerArea = region->innerRect.width() * region->innerRect.height(); executed (the execution status of this line is deduced): region->innerArea = region->innerRect.width() * region->innerRect.height(); | - |
3553 | } executed: } Execution Count:6 | 6 |
3554 | return region; executed: return region; Execution Count:6 | 6 |
3555 | } | - |
3556 | | - |
3557 | if (!(pETEs = static_cast<EdgeTableEntry *>(malloc(sizeof(EdgeTableEntry) * Count)))) partially evaluated: !(pETEs = static_cast<EdgeTableEntry *>(malloc(sizeof(EdgeTableEntry) * Count))) no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
3558 | return 0; never executed: return 0; | 0 |
3559 | | - |
3560 | region->vectorize(); executed (the execution status of this line is deduced): region->vectorize(); | - |
3561 | | - |
3562 | pts = FirstPtBlock.pts; executed (the execution status of this line is deduced): pts = FirstPtBlock.pts; | - |
3563 | CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock); executed (the execution status of this line is deduced): CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock); | - |
3564 | | - |
3565 | pSLL = ET.scanlines.next; executed (the execution status of this line is deduced): pSLL = ET.scanlines.next; | - |
3566 | curPtBlock = &FirstPtBlock; executed (the execution status of this line is deduced): curPtBlock = &FirstPtBlock; | - |
3567 | | - |
3568 | // sanity check that the region won't become too big... | - |
3569 | if (ET.ymax - ET.ymin > 100000) { partially evaluated: ET.ymax - ET.ymin > 100000 no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
3570 | // clean up region ptr | - |
3571 | #ifndef QT_NO_DEBUG | - |
3572 | qWarning("QRegion: creating region from big polygon failed...!"); | - |
3573 | #endif | - |
3574 | delete region; never executed (the execution status of this line is deduced): delete region; | - |
3575 | return 0; never executed: return 0; | 0 |
3576 | } | - |
3577 | | - |
3578 | | - |
3579 | QT_TRY { partially evaluated: true yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
3580 | if (rule == EvenOddRule) { partially evaluated: rule == 0 yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
3581 | /* | - |
3582 | * for each scanline | - |
3583 | */ | - |
3584 | for (y = ET.ymin; y < ET.ymax; ++y) { evaluated: y < ET.ymax yes Evaluation Count:4477 | yes Evaluation Count:21 |
| 21-4477 |
3585 | | - |
3586 | /* | - |
3587 | * Add a new edge to the active edge table when we | - |
3588 | * get to the next edge. | - |
3589 | */ | - |
3590 | if (pSLL && y == pSLL->scanline) { evaluated: pSLL yes Evaluation Count:2660 | yes Evaluation Count:1817 |
evaluated: y == pSLL->scanline yes Evaluation Count:346 | yes Evaluation Count:2314 |
| 346-2660 |
3591 | loadAET(&AET, pSLL->edgelist); executed (the execution status of this line is deduced): loadAET(&AET, pSLL->edgelist); | - |
3592 | pSLL = pSLL->next; executed (the execution status of this line is deduced): pSLL = pSLL->next; | - |
3593 | } executed: } Execution Count:346 | 346 |
3594 | pPrevAET = &AET; executed (the execution status of this line is deduced): pPrevAET = &AET; | - |
3595 | pAET = AET.next; executed (the execution status of this line is deduced): pAET = AET.next; | - |
3596 | | - |
3597 | /* | - |
3598 | * for each active edge | - |
3599 | */ | - |
3600 | while (pAET) { evaluated: pAET yes Evaluation Count:9334 | yes Evaluation Count:4477 |
| 4477-9334 |
3601 | pts->setX(pAET->bres.minor_axis); executed (the execution status of this line is deduced): pts->setX(pAET->bres.minor_axis); | - |
3602 | pts->setY(y); executed (the execution status of this line is deduced): pts->setY(y); | - |
3603 | ++pts; executed (the execution status of this line is deduced): ++pts; | - |
3604 | ++iPts; executed (the execution status of this line is deduced): ++iPts; | - |
3605 | | - |
3606 | /* | - |
3607 | * send out the buffer | - |
3608 | */ | - |
3609 | if (iPts == NUMPTSTOBUFFER) { evaluated: iPts == 200 yes Evaluation Count:42 | yes Evaluation Count:9292 |
| 42-9292 |
3610 | tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK)); executed (the execution status of this line is deduced): tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK)); | - |
3611 | Q_CHECK_PTR(tmpPtBlock); executed (the execution status of this line is deduced): qt_noop(); | - |
3612 | tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); executed (the execution status of this line is deduced): tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); | - |
3613 | curPtBlock->next = tmpPtBlock; executed (the execution status of this line is deduced): curPtBlock->next = tmpPtBlock; | - |
3614 | curPtBlock = tmpPtBlock; executed (the execution status of this line is deduced): curPtBlock = tmpPtBlock; | - |
3615 | pts = curPtBlock->pts; executed (the execution status of this line is deduced): pts = curPtBlock->pts; | - |
3616 | ++numFullPtBlocks; executed (the execution status of this line is deduced): ++numFullPtBlocks; | - |
3617 | iPts = 0; executed (the execution status of this line is deduced): iPts = 0; | - |
3618 | } executed: } Execution Count:42 | 42 |
3619 | EVALUATEEDGEEVENODD(pAET, pPrevAET, y) executed: pAET->back = pPrevAET; Execution Count:353 executed: } Execution Count:695 executed: } Execution Count:1204 executed: } Execution Count:5157 executed: } Execution Count:500 executed: } Execution Count:1778 executed: } Execution Count:8639 evaluated: pAET yes Evaluation Count:353 | yes Evaluation Count:342 |
evaluated: pAET->ymax == y yes Evaluation Count:695 | yes Evaluation Count:8639 |
evaluated: pAET->bres.m1 > 0 yes Evaluation Count:6361 | yes Evaluation Count:2278 |
evaluated: pAET->bres.d > 0 yes Evaluation Count:1204 | yes Evaluation Count:5157 |
evaluated: pAET->bres.d >= 0 yes Evaluation Count:500 | yes Evaluation Count:1778 |
| 342-8639 |
3620 | } | - |
3621 | InsertionSort(&AET); executed (the execution status of this line is deduced): InsertionSort(&AET); | - |
3622 | } executed: } Execution Count:4477 | 4477 |
3623 | } else { executed: } Execution Count:21 | 21 |
3624 | /* | - |
3625 | * for each scanline | - |
3626 | */ | - |
3627 | for (y = ET.ymin; y < ET.ymax; ++y) { never evaluated: y < ET.ymax | 0 |
3628 | /* | - |
3629 | * Add a new edge to the active edge table when we | - |
3630 | * get to the next edge. | - |
3631 | */ | - |
3632 | if (pSLL && y == pSLL->scanline) { never evaluated: pSLL never evaluated: y == pSLL->scanline | 0 |
3633 | loadAET(&AET, pSLL->edgelist); never executed (the execution status of this line is deduced): loadAET(&AET, pSLL->edgelist); | - |
3634 | computeWAET(&AET); never executed (the execution status of this line is deduced): computeWAET(&AET); | - |
3635 | pSLL = pSLL->next; never executed (the execution status of this line is deduced): pSLL = pSLL->next; | - |
3636 | } | 0 |
3637 | pPrevAET = &AET; never executed (the execution status of this line is deduced): pPrevAET = &AET; | - |
3638 | pAET = AET.next; never executed (the execution status of this line is deduced): pAET = AET.next; | - |
3639 | pWETE = pAET; never executed (the execution status of this line is deduced): pWETE = pAET; | - |
3640 | | - |
3641 | /* | - |
3642 | * for each active edge | - |
3643 | */ | - |
3644 | while (pAET) { | 0 |
3645 | /* | - |
3646 | * add to the buffer only those edges that | - |
3647 | * are in the Winding active edge table. | - |
3648 | */ | - |
3649 | if (pWETE == pAET) { never evaluated: pWETE == pAET | 0 |
3650 | pts->setX(pAET->bres.minor_axis); never executed (the execution status of this line is deduced): pts->setX(pAET->bres.minor_axis); | - |
3651 | pts->setY(y); never executed (the execution status of this line is deduced): pts->setY(y); | - |
3652 | ++pts; never executed (the execution status of this line is deduced): ++pts; | - |
3653 | ++iPts; never executed (the execution status of this line is deduced): ++iPts; | - |
3654 | | - |
3655 | /* | - |
3656 | * send out the buffer | - |
3657 | */ | - |
3658 | if (iPts == NUMPTSTOBUFFER) { never evaluated: iPts == 200 | 0 |
3659 | tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK))); never executed (the execution status of this line is deduced): tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK))); | - |
3660 | tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); never executed (the execution status of this line is deduced): tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); | - |
3661 | curPtBlock->next = tmpPtBlock; never executed (the execution status of this line is deduced): curPtBlock->next = tmpPtBlock; | - |
3662 | curPtBlock = tmpPtBlock; never executed (the execution status of this line is deduced): curPtBlock = tmpPtBlock; | - |
3663 | pts = curPtBlock->pts; never executed (the execution status of this line is deduced): pts = curPtBlock->pts; | - |
3664 | ++numFullPtBlocks; never executed (the execution status of this line is deduced): ++numFullPtBlocks; | - |
3665 | iPts = 0; never executed (the execution status of this line is deduced): iPts = 0; | - |
3666 | } | 0 |
3667 | pWETE = pWETE->nextWETE; never executed (the execution status of this line is deduced): pWETE = pWETE->nextWETE; | - |
3668 | } | 0 |
3669 | EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) never executed: pAET->back = pPrevAET; never executed: } never executed: } never executed: } never executed: } never executed: } never executed: } never evaluated: pAET never evaluated: pAET->ymax == y never evaluated: pAET->bres.m1 > 0 never evaluated: pAET->bres.d > 0 never evaluated: pAET->bres.d >= 0 | 0 |
3670 | } | - |
3671 | | - |
3672 | /* | - |
3673 | * recompute the winding active edge table if | - |
3674 | * we just resorted or have exited an edge. | - |
3675 | */ | - |
3676 | if (InsertionSort(&AET) || fixWAET) { never evaluated: InsertionSort(&AET) never evaluated: fixWAET | 0 |
3677 | computeWAET(&AET); never executed (the execution status of this line is deduced): computeWAET(&AET); | - |
3678 | fixWAET = false; never executed (the execution status of this line is deduced): fixWAET = false; | - |
3679 | } | 0 |
3680 | } | 0 |
3681 | } | 0 |
3682 | } QT_CATCH(...) { | - |
3683 | FreeStorage(SLLBlock.next); never executed (the execution status of this line is deduced): FreeStorage(SLLBlock.next); | - |
3684 | PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); never executed (the execution status of this line is deduced): PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); | - |
3685 | for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) { never evaluated: --numFullPtBlocks >= 0 | 0 |
3686 | tmpPtBlock = curPtBlock->next; never executed (the execution status of this line is deduced): tmpPtBlock = curPtBlock->next; | - |
3687 | free(curPtBlock); never executed (the execution status of this line is deduced): free(curPtBlock); | - |
3688 | curPtBlock = tmpPtBlock; never executed (the execution status of this line is deduced): curPtBlock = tmpPtBlock; | - |
3689 | } | 0 |
3690 | free(pETEs); never executed (the execution status of this line is deduced): free(pETEs); | - |
3691 | return 0; // this function returns 0 in case of an error never executed: return 0; | 0 |
3692 | } | - |
3693 | | - |
3694 | FreeStorage(SLLBlock.next); executed (the execution status of this line is deduced): FreeStorage(SLLBlock.next); | - |
3695 | PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); executed (the execution status of this line is deduced): PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); | - |
3696 | for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) { evaluated: --numFullPtBlocks >= 0 yes Evaluation Count:42 | yes Evaluation Count:21 |
| 21-42 |
3697 | tmpPtBlock = curPtBlock->next; executed (the execution status of this line is deduced): tmpPtBlock = curPtBlock->next; | - |
3698 | free(curPtBlock); executed (the execution status of this line is deduced): free(curPtBlock); | - |
3699 | curPtBlock = tmpPtBlock; executed (the execution status of this line is deduced): curPtBlock = tmpPtBlock; | - |
3700 | } executed: } Execution Count:42 | 42 |
3701 | free(pETEs); executed (the execution status of this line is deduced): free(pETEs); | - |
3702 | return region; executed: return region; Execution Count:21 | 21 |
3703 | } | - |
3704 | // END OF PolyReg.c extract | - |
3705 | | - |
3706 | QRegionPrivate *qt_bitmapToRegion(const QBitmap& bitmap) | - |
3707 | { | - |
3708 | QImage image = bitmap.toImage(); executed (the execution status of this line is deduced): QImage image = bitmap.toImage(); | - |
3709 | | - |
3710 | QRegionPrivate *region = new QRegionPrivate; executed (the execution status of this line is deduced): QRegionPrivate *region = new QRegionPrivate; | - |
3711 | | - |
3712 | QRect xr; executed (the execution status of this line is deduced): QRect xr; | - |
3713 | | - |
3714 | #define AddSpan \ | - |
3715 | { \ | - |
3716 | xr.setCoords(prev1, y, x-1, y); \ | - |
3717 | UnionRectWithRegion(&xr, region, *region); \ | - |
3718 | } | - |
3719 | | - |
3720 | const uchar zero = 0; executed (the execution status of this line is deduced): const uchar zero = 0; | - |
3721 | bool little = image.format() == QImage::Format_MonoLSB; executed (the execution status of this line is deduced): bool little = image.format() == QImage::Format_MonoLSB; | - |
3722 | | - |
3723 | int x, executed (the execution status of this line is deduced): int x, | - |
3724 | y; executed (the execution status of this line is deduced): y; | - |
3725 | for (y = 0; y < image.height(); ++y) { evaluated: y < image.height() yes Evaluation Count:315 | yes Evaluation Count:5 |
| 5-315 |
3726 | uchar *line = image.scanLine(y); executed (the execution status of this line is deduced): uchar *line = image.scanLine(y); | - |
3727 | int w = image.width(); executed (the execution status of this line is deduced): int w = image.width(); | - |
3728 | uchar all = zero; executed (the execution status of this line is deduced): uchar all = zero; | - |
3729 | int prev1 = -1; executed (the execution status of this line is deduced): int prev1 = -1; | - |
3730 | for (x = 0; x < w;) { evaluated: x < w yes Evaluation Count:4485 | yes Evaluation Count:315 |
| 315-4485 |
3731 | uchar byte = line[x / 8]; executed (the execution status of this line is deduced): uchar byte = line[x / 8]; | - |
3732 | if (x > w - 8 || byte!=all) { evaluated: x > w - 8 yes Evaluation Count:315 | yes Evaluation Count:4170 |
evaluated: byte!=all yes Evaluation Count:391 | yes Evaluation Count:3779 |
| 315-4170 |
3733 | if (little) { partially evaluated: little yes Evaluation Count:706 | no Evaluation Count:0 |
| 0-706 |
3734 | for (int b = 8; b > 0 && x < w; --b) { evaluated: b > 0 yes Evaluation Count:4113 | yes Evaluation Count:391 |
evaluated: x < w yes Evaluation Count:3798 | yes Evaluation Count:315 |
| 315-4113 |
3735 | if (!(byte & 0x01) == !all) { evaluated: !(byte & 0x01) == !all yes Evaluation Count:3337 | yes Evaluation Count:461 |
| 461-3337 |
3736 | // More of the same | - |
3737 | } else { executed: } Execution Count:3337 | 3337 |
3738 | // A change. | - |
3739 | if (all!=zero) { evaluated: all!=zero yes Evaluation Count:146 | yes Evaluation Count:315 |
| 146-315 |
3740 | AddSpan executed (the execution status of this line is deduced): { xr.setCoords(prev1, y, x-1, y); UnionRectWithRegion(&xr, region, *region); } | - |
3741 | all = zero; executed (the execution status of this line is deduced): all = zero; | - |
3742 | } else { executed: } Execution Count:146 | 146 |
3743 | prev1 = x; executed (the execution status of this line is deduced): prev1 = x; | - |
3744 | all = ~zero; executed (the execution status of this line is deduced): all = ~zero; | - |
3745 | } executed: } Execution Count:315 | 315 |
3746 | } | - |
3747 | byte >>= 1; executed (the execution status of this line is deduced): byte >>= 1; | - |
3748 | ++x; executed (the execution status of this line is deduced): ++x; | - |
3749 | } executed: } Execution Count:3798 | 3798 |
3750 | } else { executed: } Execution Count:706 | 706 |
3751 | for (int b = 8; b > 0 && x < w; --b) { never evaluated: b > 0 never evaluated: x < w | 0 |
3752 | if (!(byte & 0x80) == !all) { never evaluated: !(byte & 0x80) == !all | 0 |
3753 | // More of the same | - |
3754 | } else { | 0 |
3755 | // A change. | - |
3756 | if (all != zero) { never evaluated: all != zero | 0 |
3757 | AddSpan never executed (the execution status of this line is deduced): { xr.setCoords(prev1, y, x-1, y); UnionRectWithRegion(&xr, region, *region); } | - |
3758 | all = zero; never executed (the execution status of this line is deduced): all = zero; | - |
3759 | } else { | 0 |
3760 | prev1 = x; never executed (the execution status of this line is deduced): prev1 = x; | - |
3761 | all = ~zero; never executed (the execution status of this line is deduced): all = ~zero; | - |
3762 | } | 0 |
3763 | } | - |
3764 | byte <<= 1; never executed (the execution status of this line is deduced): byte <<= 1; | - |
3765 | ++x; never executed (the execution status of this line is deduced): ++x; | - |
3766 | } | 0 |
3767 | } | 0 |
3768 | } else { | - |
3769 | x += 8; executed (the execution status of this line is deduced): x += 8; | - |
3770 | } executed: } Execution Count:3779 | 3779 |
3771 | } | - |
3772 | if (all != zero) { evaluated: all != zero yes Evaluation Count:169 | yes Evaluation Count:146 |
| 146-169 |
3773 | AddSpan executed (the execution status of this line is deduced): { xr.setCoords(prev1, y, x-1, y); UnionRectWithRegion(&xr, region, *region); } | - |
3774 | } executed: } Execution Count:169 | 169 |
3775 | } executed: } Execution Count:315 | 315 |
3776 | #undef AddSpan | - |
3777 | | - |
3778 | return region; executed: return region; Execution Count:5 | 5 |
3779 | } | - |
3780 | | - |
3781 | QRegion::QRegion() | - |
3782 | : d(&shared_empty) | - |
3783 | { | - |
3784 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
3785 | } executed: } Execution Count:499990 | 499990 |
3786 | | - |
3787 | QRegion::QRegion(const QRect &r, RegionType t) | - |
3788 | { | - |
3789 | if (r.isEmpty()) { evaluated: r.isEmpty() yes Evaluation Count:8172 | yes Evaluation Count:139839 |
| 8172-139839 |
3790 | d = &shared_empty; executed (the execution status of this line is deduced): d = &shared_empty; | - |
3791 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
3792 | } else { executed: } Execution Count:8172 | 8172 |
3793 | d = new QRegionData; executed (the execution status of this line is deduced): d = new QRegionData; | - |
3794 | d->ref.store(1); executed (the execution status of this line is deduced): d->ref.store(1); | - |
3795 | if (t == Rectangle) { evaluated: t == Rectangle yes Evaluation Count:139827 | yes Evaluation Count:12 |
| 12-139827 |
3796 | d->qt_rgn = new QRegionPrivate(r); executed (the execution status of this line is deduced): d->qt_rgn = new QRegionPrivate(r); | - |
3797 | } else if (t == Ellipse) { executed: } Execution Count:139827 partially evaluated: t == Ellipse yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-139827 |
3798 | QPainterPath path; executed (the execution status of this line is deduced): QPainterPath path; | - |
3799 | path.addEllipse(r.x(), r.y(), r.width(), r.height()); executed (the execution status of this line is deduced): path.addEllipse(r.x(), r.y(), r.width(), r.height()); | - |
3800 | QPolygon a = path.toSubpathPolygons().at(0).toPolygon(); executed (the execution status of this line is deduced): QPolygon a = path.toSubpathPolygons().at(0).toPolygon(); | - |
3801 | d->qt_rgn = PolygonRegion(a.constData(), a.size(), EvenOddRule); executed (the execution status of this line is deduced): d->qt_rgn = PolygonRegion(a.constData(), a.size(), 0); | - |
3802 | } executed: } Execution Count:12 | 12 |
3803 | } | - |
3804 | } | - |
3805 | | - |
3806 | QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) | - |
3807 | { | - |
3808 | if (a.count() > 2) { evaluated: a.count() > 2 yes Evaluation Count:15 | yes Evaluation Count:6 |
| 6-15 |
3809 | QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), executed (the execution status of this line is deduced): QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), | - |
3810 | fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); executed (the execution status of this line is deduced): fillRule == Qt::WindingFill ? 1 : 0); | - |
3811 | if (qt_rgn) { partially evaluated: qt_rgn yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
3812 | d = new QRegionData; executed (the execution status of this line is deduced): d = new QRegionData; | - |
3813 | d->ref.store(1); executed (the execution status of this line is deduced): d->ref.store(1); | - |
3814 | d->qt_rgn = qt_rgn; executed (the execution status of this line is deduced): d->qt_rgn = qt_rgn; | - |
3815 | } else { executed: } Execution Count:15 | 15 |
3816 | d = &shared_empty; never executed (the execution status of this line is deduced): d = &shared_empty; | - |
3817 | d->ref.ref(); never executed (the execution status of this line is deduced): d->ref.ref(); | - |
3818 | } | 0 |
3819 | } else { | - |
3820 | d = &shared_empty; executed (the execution status of this line is deduced): d = &shared_empty; | - |
3821 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
3822 | } executed: } Execution Count:6 | 6 |
3823 | } | - |
3824 | | - |
3825 | QRegion::QRegion(const QRegion &r) | - |
3826 | { | - |
3827 | d = r.d; executed (the execution status of this line is deduced): d = r.d; | - |
3828 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
3829 | } executed: } Execution Count:372035 | 372035 |
3830 | | - |
3831 | | - |
3832 | QRegion::QRegion(const QBitmap &bm) | - |
3833 | { | - |
3834 | if (bm.isNull()) { evaluated: bm.isNull() yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
3835 | d = &shared_empty; executed (the execution status of this line is deduced): d = &shared_empty; | - |
3836 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
3837 | } else { executed: } Execution Count:1 | 1 |
3838 | d = new QRegionData; executed (the execution status of this line is deduced): d = new QRegionData; | - |
3839 | d->ref.store(1); executed (the execution status of this line is deduced): d->ref.store(1); | - |
3840 | d->qt_rgn = qt_bitmapToRegion(bm); executed (the execution status of this line is deduced): d->qt_rgn = qt_bitmapToRegion(bm); | - |
3841 | } executed: } Execution Count:5 | 5 |
3842 | } | - |
3843 | | - |
3844 | void QRegion::cleanUp(QRegion::QRegionData *x) | - |
3845 | { | - |
3846 | delete x->qt_rgn; executed (the execution status of this line is deduced): delete x->qt_rgn; | - |
3847 | delete x; executed (the execution status of this line is deduced): delete x; | - |
3848 | } executed: } Execution Count:204421 | 204421 |
3849 | | - |
3850 | QRegion::~QRegion() | - |
3851 | { | - |
3852 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:172111 | yes Evaluation Count:853049 |
| 172111-853049 |
3853 | cleanUp(d); executed: cleanUp(d); Execution Count:172111 | 172111 |
3854 | } executed: } Execution Count:1025160 | 1025160 |
3855 | | - |
3856 | | - |
3857 | QRegion &QRegion::operator=(const QRegion &r) | - |
3858 | { | - |
3859 | r.d->ref.ref(); executed (the execution status of this line is deduced): r.d->ref.ref(); | - |
3860 | if (!d->ref.deref()) evaluated: !d->ref.deref() yes Evaluation Count:32310 | yes Evaluation Count:127335 |
| 32310-127335 |
3861 | cleanUp(d); executed: cleanUp(d); Execution Count:32310 | 32310 |
3862 | d = r.d; executed (the execution status of this line is deduced): d = r.d; | - |
3863 | return *this; executed: return *this; Execution Count:159645 | 159645 |
3864 | } | - |
3865 | | - |
3866 | | - |
3867 | /*! | - |
3868 | \internal | - |
3869 | */ | - |
3870 | QRegion QRegion::copy() const | - |
3871 | { | - |
3872 | QRegion r; executed (the execution status of this line is deduced): QRegion r; | - |
3873 | QScopedPointer<QRegionData> x(new QRegionData); executed (the execution status of this line is deduced): QScopedPointer<QRegionData> x(new QRegionData); | - |
3874 | x->ref.store(1); executed (the execution status of this line is deduced): x->ref.store(1); | - |
3875 | if (d->qt_rgn) partially evaluated: d->qt_rgn yes Evaluation Count:64594 | no Evaluation Count:0 |
| 0-64594 |
3876 | x->qt_rgn = new QRegionPrivate(*d->qt_rgn); executed: x->qt_rgn = new QRegionPrivate(*d->qt_rgn); Execution Count:64594 | 64594 |
3877 | else | - |
3878 | x->qt_rgn = new QRegionPrivate; never executed: x->qt_rgn = new QRegionPrivate; | 0 |
3879 | if (!r.d->ref.deref()) partially evaluated: !r.d->ref.deref() no Evaluation Count:0 | yes Evaluation Count:64594 |
| 0-64594 |
3880 | cleanUp(r.d); never executed: cleanUp(r.d); | 0 |
3881 | r.d = x.take(); executed (the execution status of this line is deduced): r.d = x.take(); | - |
3882 | return r; executed: return r; Execution Count:64594 | 64594 |
3883 | } | - |
3884 | | - |
3885 | bool QRegion::isEmpty() const | - |
3886 | { | - |
3887 | return d == &shared_empty || d->qt_rgn->numRects == 0; executed: return d == &shared_empty || d->qt_rgn->numRects == 0; Execution Count:310727 | 310727 |
3888 | } | - |
3889 | | - |
3890 | bool QRegion::isNull() const | - |
3891 | { | - |
3892 | return d == &shared_empty || d->qt_rgn->numRects == 0; executed: return d == &shared_empty || d->qt_rgn->numRects == 0; Execution Count:3369 | 3369 |
3893 | } | - |
3894 | | - |
3895 | bool QRegion::contains(const QPoint &p) const | - |
3896 | { | - |
3897 | return PointInRegion(d->qt_rgn, p.x(), p.y()); executed: return PointInRegion(d->qt_rgn, p.x(), p.y()); Execution Count:200048 | 200048 |
3898 | } | - |
3899 | | - |
3900 | bool QRegion::contains(const QRect &r) const | - |
3901 | { | - |
3902 | return RectInRegion(d->qt_rgn, r.left(), r.top(), r.width(), r.height()) != RectangleOut; executed: return RectInRegion(d->qt_rgn, r.left(), r.top(), r.width(), r.height()) != 0; Execution Count:41 | 41 |
3903 | } | - |
3904 | | - |
3905 | | - |
3906 | | - |
3907 | void QRegion::translate(int dx, int dy) | - |
3908 | { | - |
3909 | if ((dx == 0 && dy == 0) || isEmptyHelper(d->qt_rgn)) evaluated: dx == 0 yes Evaluation Count:15945 | yes Evaluation Count:52449 |
evaluated: dy == 0 yes Evaluation Count:12033 | yes Evaluation Count:3912 |
evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:5236 | yes Evaluation Count:51125 |
| 3912-52449 |
3910 | return; executed: return; Execution Count:17269 | 17269 |
3911 | | - |
3912 | detach(); executed (the execution status of this line is deduced): detach(); | - |
3913 | OffsetRegion(*d->qt_rgn, dx, dy); executed (the execution status of this line is deduced): OffsetRegion(*d->qt_rgn, dx, dy); | - |
3914 | } executed: } Execution Count:51125 | 51125 |
3915 | | - |
3916 | QRegion QRegion::united(const QRegion &r) const | - |
3917 | { | - |
3918 | if (isEmptyHelper(d->qt_rgn)) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:7375 | yes Evaluation Count:12395 |
| 7375-12395 |
3919 | return r; executed: return r; Execution Count:7375 | 7375 |
3920 | if (isEmptyHelper(r.d->qt_rgn)) evaluated: isEmptyHelper(r.d->qt_rgn) yes Evaluation Count:688 | yes Evaluation Count:11707 |
| 688-11707 |
3921 | return *this; executed: return *this; Execution Count:688 | 688 |
3922 | if (d == r.d) evaluated: d == r.d yes Evaluation Count:4 | yes Evaluation Count:11703 |
| 4-11703 |
3923 | return *this; executed: return *this; Execution Count:4 | 4 |
3924 | | - |
3925 | if (d->qt_rgn->contains(*r.d->qt_rgn)) { evaluated: d->qt_rgn->contains(*r.d->qt_rgn) yes Evaluation Count:2477 | yes Evaluation Count:9226 |
| 2477-9226 |
3926 | return *this; executed: return *this; Execution Count:2477 | 2477 |
3927 | } else if (r.d->qt_rgn->contains(*d->qt_rgn)) { evaluated: r.d->qt_rgn->contains(*d->qt_rgn) yes Evaluation Count:86 | yes Evaluation Count:9140 |
| 86-9140 |
3928 | return r; executed: return r; Execution Count:86 | 86 |
3929 | } else if (d->qt_rgn->canAppend(r.d->qt_rgn)) { evaluated: d->qt_rgn->canAppend(r.d->qt_rgn) yes Evaluation Count:7006 | yes Evaluation Count:2134 |
| 2134-7006 |
3930 | QRegion result(*this); executed (the execution status of this line is deduced): QRegion result(*this); | - |
3931 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
3932 | result.d->qt_rgn->append(r.d->qt_rgn); executed (the execution status of this line is deduced): result.d->qt_rgn->append(r.d->qt_rgn); | - |
3933 | return result; executed: return result; Execution Count:7006 | 7006 |
3934 | } else if (d->qt_rgn->canPrepend(r.d->qt_rgn)) { evaluated: d->qt_rgn->canPrepend(r.d->qt_rgn) yes Evaluation Count:1870 | yes Evaluation Count:264 |
| 264-1870 |
3935 | QRegion result(*this); executed (the execution status of this line is deduced): QRegion result(*this); | - |
3936 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
3937 | result.d->qt_rgn->prepend(r.d->qt_rgn); executed (the execution status of this line is deduced): result.d->qt_rgn->prepend(r.d->qt_rgn); | - |
3938 | return result; executed: return result; Execution Count:1870 | 1870 |
3939 | } else if (EqualRegion(d->qt_rgn, r.d->qt_rgn)) { partially evaluated: EqualRegion(d->qt_rgn, r.d->qt_rgn) no Evaluation Count:0 | yes Evaluation Count:264 |
| 0-264 |
3940 | return *this; never executed: return *this; | 0 |
3941 | } else { | - |
3942 | QRegion result; executed (the execution status of this line is deduced): QRegion result; | - |
3943 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
3944 | UnionRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn); executed (the execution status of this line is deduced): UnionRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn); | - |
3945 | return result; executed: return result; Execution Count:264 | 264 |
3946 | } | - |
3947 | } | - |
3948 | | - |
3949 | QRegion& QRegion::operator+=(const QRegion &r) | - |
3950 | { | - |
3951 | if (isEmptyHelper(d->qt_rgn)) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:15939 | yes Evaluation Count:26096 |
| 15939-26096 |
3952 | return *this = r; executed: return *this = r; Execution Count:15939 | 15939 |
3953 | if (isEmptyHelper(r.d->qt_rgn)) evaluated: isEmptyHelper(r.d->qt_rgn) yes Evaluation Count:2 | yes Evaluation Count:26094 |
| 2-26094 |
3954 | return *this; executed: return *this; Execution Count:2 | 2 |
3955 | if (d == r.d) evaluated: d == r.d yes Evaluation Count:12 | yes Evaluation Count:26082 |
| 12-26082 |
3956 | return *this; executed: return *this; Execution Count:12 | 12 |
3957 | | - |
3958 | if (d->qt_rgn->contains(*r.d->qt_rgn)) { evaluated: d->qt_rgn->contains(*r.d->qt_rgn) yes Evaluation Count:6685 | yes Evaluation Count:19397 |
| 6685-19397 |
3959 | return *this; executed: return *this; Execution Count:6685 | 6685 |
3960 | } else if (r.d->qt_rgn->contains(*d->qt_rgn)) { evaluated: r.d->qt_rgn->contains(*d->qt_rgn) yes Evaluation Count:625 | yes Evaluation Count:18772 |
| 625-18772 |
3961 | return *this = r; executed: return *this = r; Execution Count:625 | 625 |
3962 | } else if (d->qt_rgn->canAppend(r.d->qt_rgn)) { evaluated: d->qt_rgn->canAppend(r.d->qt_rgn) yes Evaluation Count:2336 | yes Evaluation Count:16436 |
| 2336-16436 |
3963 | detach(); executed (the execution status of this line is deduced): detach(); | - |
3964 | d->qt_rgn->append(r.d->qt_rgn); executed (the execution status of this line is deduced): d->qt_rgn->append(r.d->qt_rgn); | - |
3965 | return *this; executed: return *this; Execution Count:2336 | 2336 |
3966 | } else if (d->qt_rgn->canPrepend(r.d->qt_rgn)) { evaluated: d->qt_rgn->canPrepend(r.d->qt_rgn) yes Evaluation Count:2613 | yes Evaluation Count:13823 |
| 2613-13823 |
3967 | detach(); executed (the execution status of this line is deduced): detach(); | - |
3968 | d->qt_rgn->prepend(r.d->qt_rgn); executed (the execution status of this line is deduced): d->qt_rgn->prepend(r.d->qt_rgn); | - |
3969 | return *this; executed: return *this; Execution Count:2613 | 2613 |
3970 | } else if (EqualRegion(d->qt_rgn, r.d->qt_rgn)) { evaluated: EqualRegion(d->qt_rgn, r.d->qt_rgn) yes Evaluation Count:214 | yes Evaluation Count:13609 |
| 214-13609 |
3971 | return *this; executed: return *this; Execution Count:214 | 214 |
3972 | } else { | - |
3973 | detach(); executed (the execution status of this line is deduced): detach(); | - |
3974 | UnionRegion(d->qt_rgn, r.d->qt_rgn, *d->qt_rgn); executed (the execution status of this line is deduced): UnionRegion(d->qt_rgn, r.d->qt_rgn, *d->qt_rgn); | - |
3975 | return *this; executed: return *this; Execution Count:13609 | 13609 |
3976 | } | - |
3977 | } | - |
3978 | | - |
3979 | QRegion QRegion::united(const QRect &r) const | - |
3980 | { | - |
3981 | if (isEmptyHelper(d->qt_rgn)) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:3 | yes Evaluation Count:31 |
| 3-31 |
3982 | return r; executed: return r; Execution Count:3 | 3 |
3983 | if (r.isEmpty()) evaluated: r.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:30 |
| 1-30 |
3984 | return *this; executed: return *this; Execution Count:1 | 1 |
3985 | | - |
3986 | if (d->qt_rgn->contains(r)) { evaluated: d->qt_rgn->contains(r) yes Evaluation Count:4 | yes Evaluation Count:26 |
| 4-26 |
3987 | return *this; executed: return *this; Execution Count:4 | 4 |
3988 | } else if (d->qt_rgn->within(r)) { partially evaluated: d->qt_rgn->within(r) no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
3989 | return r; never executed: return r; | 0 |
3990 | } else if (d->qt_rgn->numRects == 1 && d->qt_rgn->extents == r) { evaluated: d->qt_rgn->numRects == 1 yes Evaluation Count:20 | yes Evaluation Count:6 |
partially evaluated: d->qt_rgn->extents == r no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
3991 | return *this; never executed: return *this; | 0 |
3992 | } else if (d->qt_rgn->canAppend(&r)) { evaluated: d->qt_rgn->canAppend(&r) yes Evaluation Count:13 | yes Evaluation Count:13 |
| 13 |
3993 | QRegion result(*this); executed (the execution status of this line is deduced): QRegion result(*this); | - |
3994 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
3995 | result.d->qt_rgn->append(&r); executed (the execution status of this line is deduced): result.d->qt_rgn->append(&r); | - |
3996 | return result; executed: return result; Execution Count:13 | 13 |
3997 | } else if (d->qt_rgn->canPrepend(&r)) { evaluated: d->qt_rgn->canPrepend(&r) yes Evaluation Count:5 | yes Evaluation Count:8 |
| 5-8 |
3998 | QRegion result(*this); executed (the execution status of this line is deduced): QRegion result(*this); | - |
3999 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4000 | result.d->qt_rgn->prepend(&r); executed (the execution status of this line is deduced): result.d->qt_rgn->prepend(&r); | - |
4001 | return result; executed: return result; Execution Count:5 | 5 |
4002 | } else { | - |
4003 | QRegion result; executed (the execution status of this line is deduced): QRegion result; | - |
4004 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4005 | QRegionPrivate rp(r); executed (the execution status of this line is deduced): QRegionPrivate rp(r); | - |
4006 | UnionRegion(d->qt_rgn, &rp, *result.d->qt_rgn); executed (the execution status of this line is deduced): UnionRegion(d->qt_rgn, &rp, *result.d->qt_rgn); | - |
4007 | return result; executed: return result; Execution Count:8 | 8 |
4008 | } | - |
4009 | } | - |
4010 | | - |
4011 | QRegion& QRegion::operator+=(const QRect &r) | - |
4012 | { | - |
4013 | if (isEmptyHelper(d->qt_rgn)) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:8183 | yes Evaluation Count:11051 |
| 8183-11051 |
4014 | return *this = r; executed: return *this = r; Execution Count:8183 | 8183 |
4015 | if (r.isEmpty()) partially evaluated: r.isEmpty() no Evaluation Count:0 | yes Evaluation Count:11051 |
| 0-11051 |
4016 | return *this; never executed: return *this; | 0 |
4017 | | - |
4018 | if (d->qt_rgn->contains(r)) { evaluated: d->qt_rgn->contains(r) yes Evaluation Count:426 | yes Evaluation Count:10625 |
| 426-10625 |
4019 | return *this; executed: return *this; Execution Count:426 | 426 |
4020 | } else if (d->qt_rgn->within(r)) { evaluated: d->qt_rgn->within(r) yes Evaluation Count:1846 | yes Evaluation Count:8779 |
| 1846-8779 |
4021 | return *this = r; executed: return *this = r; Execution Count:1846 | 1846 |
4022 | } else if (d->qt_rgn->canAppend(&r)) { evaluated: d->qt_rgn->canAppend(&r) yes Evaluation Count:2216 | yes Evaluation Count:6563 |
| 2216-6563 |
4023 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4024 | d->qt_rgn->append(&r); executed (the execution status of this line is deduced): d->qt_rgn->append(&r); | - |
4025 | return *this; executed: return *this; Execution Count:2216 | 2216 |
4026 | } else if (d->qt_rgn->canPrepend(&r)) { evaluated: d->qt_rgn->canPrepend(&r) yes Evaluation Count:583 | yes Evaluation Count:5980 |
| 583-5980 |
4027 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4028 | d->qt_rgn->prepend(&r); executed (the execution status of this line is deduced): d->qt_rgn->prepend(&r); | - |
4029 | return *this; executed: return *this; Execution Count:583 | 583 |
4030 | } else if (d->qt_rgn->numRects == 1 && d->qt_rgn->extents == r) { evaluated: d->qt_rgn->numRects == 1 yes Evaluation Count:821 | yes Evaluation Count:5159 |
partially evaluated: d->qt_rgn->extents == r no Evaluation Count:0 | yes Evaluation Count:821 |
| 0-5159 |
4031 | return *this; never executed: return *this; | 0 |
4032 | } else { | - |
4033 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4034 | QRegionPrivate p(r); executed (the execution status of this line is deduced): QRegionPrivate p(r); | - |
4035 | UnionRegion(d->qt_rgn, &p, *d->qt_rgn); executed (the execution status of this line is deduced): UnionRegion(d->qt_rgn, &p, *d->qt_rgn); | - |
4036 | return *this; executed: return *this; Execution Count:5980 | 5980 |
4037 | } | - |
4038 | } | - |
4039 | | - |
4040 | QRegion QRegion::intersected(const QRegion &r) const | - |
4041 | { | - |
4042 | if (isEmptyHelper(d->qt_rgn) || isEmptyHelper(r.d->qt_rgn) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:268 | yes Evaluation Count:150 |
evaluated: isEmptyHelper(r.d->qt_rgn) yes Evaluation Count:5 | yes Evaluation Count:145 |
| 5-268 |
4043 | || !EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents)) partially evaluated: (&d->qt_rgn->extents)->right() >= (&r.d->qt_rgn->extents)->left() yes Evaluation Count:145 | no Evaluation Count:0 |
evaluated: (&d->qt_rgn->extents)->left() <= (&r.d->qt_rgn->extents)->right() yes Evaluation Count:144 | yes Evaluation Count:1 |
partially evaluated: (&d->qt_rgn->extents)->bottom() >= (&r.d->qt_rgn->extents)->top() yes Evaluation Count:144 | no Evaluation Count:0 |
evaluated: (&d->qt_rgn->extents)->top() <= (&r.d->qt_rgn->extents)->bottom() yes Evaluation Count:142 | yes Evaluation Count:2 |
| 0-145 |
4044 | return QRegion(); executed: return QRegion(); Execution Count:276 | 276 |
4045 | | - |
4046 | /* this is fully contained in r */ | - |
4047 | if (r.d->qt_rgn->contains(*d->qt_rgn)) evaluated: r.d->qt_rgn->contains(*d->qt_rgn) yes Evaluation Count:33 | yes Evaluation Count:109 |
| 33-109 |
4048 | return *this; executed: return *this; Execution Count:33 | 33 |
4049 | | - |
4050 | /* r is fully contained in this */ | - |
4051 | if (d->qt_rgn->contains(*r.d->qt_rgn)) evaluated: d->qt_rgn->contains(*r.d->qt_rgn) yes Evaluation Count:44 | yes Evaluation Count:65 |
| 44-65 |
4052 | return r; executed: return r; Execution Count:44 | 44 |
4053 | | - |
4054 | if (r.d->qt_rgn->numRects == 1 && d->qt_rgn->numRects == 1) { evaluated: r.d->qt_rgn->numRects == 1 yes Evaluation Count:29 | yes Evaluation Count:36 |
evaluated: d->qt_rgn->numRects == 1 yes Evaluation Count:3 | yes Evaluation Count:26 |
| 3-36 |
4055 | const QRect rect = qt_rect_intersect_normalized(r.d->qt_rgn->extents, executed (the execution status of this line is deduced): const QRect rect = qt_rect_intersect_normalized(r.d->qt_rgn->extents, | - |
4056 | d->qt_rgn->extents); executed (the execution status of this line is deduced): d->qt_rgn->extents); | - |
4057 | return QRegion(rect); executed: return QRegion(rect); Execution Count:3 | 3 |
4058 | } else if (r.d->qt_rgn->numRects == 1) { evaluated: r.d->qt_rgn->numRects == 1 yes Evaluation Count:26 | yes Evaluation Count:36 |
| 26-36 |
4059 | QRegion result(*this); executed (the execution status of this line is deduced): QRegion result(*this); | - |
4060 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4061 | result.d->qt_rgn->intersect(r.d->qt_rgn->extents); executed (the execution status of this line is deduced): result.d->qt_rgn->intersect(r.d->qt_rgn->extents); | - |
4062 | return result; executed: return result; Execution Count:26 | 26 |
4063 | } else if (d->qt_rgn->numRects == 1) { evaluated: d->qt_rgn->numRects == 1 yes Evaluation Count:12 | yes Evaluation Count:24 |
| 12-24 |
4064 | QRegion result(r); executed (the execution status of this line is deduced): QRegion result(r); | - |
4065 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4066 | result.d->qt_rgn->intersect(d->qt_rgn->extents); executed (the execution status of this line is deduced): result.d->qt_rgn->intersect(d->qt_rgn->extents); | - |
4067 | return result; executed: return result; Execution Count:12 | 12 |
4068 | } | - |
4069 | | - |
4070 | QRegion result; executed (the execution status of this line is deduced): QRegion result; | - |
4071 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4072 | miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, 0, 0); executed (the execution status of this line is deduced): miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, 0, 0); | - |
4073 | | - |
4074 | /* | - |
4075 | * Can't alter dest's extents before we call miRegionOp because | - |
4076 | * it might be one of the source regions and miRegionOp depends | - |
4077 | * on the extents of those regions being the same. Besides, this | - |
4078 | * way there's no checking against rectangles that will be nuked | - |
4079 | * due to coalescing, so we have to examine fewer rectangles. | - |
4080 | */ | - |
4081 | miSetExtents(*result.d->qt_rgn); executed (the execution status of this line is deduced): miSetExtents(*result.d->qt_rgn); | - |
4082 | return result; executed: return result; Execution Count:24 | 24 |
4083 | } | - |
4084 | | - |
4085 | QRegion QRegion::intersected(const QRect &r) const | - |
4086 | { | - |
4087 | if (isEmptyHelper(d->qt_rgn) || r.isEmpty() evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:5647 | yes Evaluation Count:88481 |
evaluated: r.isEmpty() yes Evaluation Count:522 | yes Evaluation Count:87959 |
| 522-88481 |
4088 | || !EXTENTCHECK(&d->qt_rgn->extents, &r)) evaluated: (&d->qt_rgn->extents)->right() >= (&r)->left() yes Evaluation Count:87956 | yes Evaluation Count:3 |
evaluated: (&d->qt_rgn->extents)->left() <= (&r)->right() yes Evaluation Count:87951 | yes Evaluation Count:5 |
partially evaluated: (&d->qt_rgn->extents)->bottom() >= (&r)->top() yes Evaluation Count:87951 | no Evaluation Count:0 |
evaluated: (&d->qt_rgn->extents)->top() <= (&r)->bottom() yes Evaluation Count:87950 | yes Evaluation Count:1 |
| 0-87956 |
4089 | return QRegion(); executed: return QRegion(); Execution Count:6178 | 6178 |
4090 | | - |
4091 | /* this is fully contained in r */ | - |
4092 | if (d->qt_rgn->within(r)) evaluated: d->qt_rgn->within(r) yes Evaluation Count:59863 | yes Evaluation Count:28087 |
| 28087-59863 |
4093 | return *this; executed: return *this; Execution Count:59863 | 59863 |
4094 | | - |
4095 | /* r is fully contained in this */ | - |
4096 | if (d->qt_rgn->contains(r)) evaluated: d->qt_rgn->contains(r) yes Evaluation Count:23330 | yes Evaluation Count:4757 |
| 4757-23330 |
4097 | return r; executed: return r; Execution Count:23330 | 23330 |
4098 | | - |
4099 | if (d->qt_rgn->numRects == 1) { evaluated: d->qt_rgn->numRects == 1 yes Evaluation Count:650 | yes Evaluation Count:4107 |
| 650-4107 |
4100 | const QRect rect = qt_rect_intersect_normalized(d->qt_rgn->extents, executed (the execution status of this line is deduced): const QRect rect = qt_rect_intersect_normalized(d->qt_rgn->extents, | - |
4101 | r.normalized()); executed (the execution status of this line is deduced): r.normalized()); | - |
4102 | return QRegion(rect); executed: return QRegion(rect); Execution Count:650 | 650 |
4103 | } | - |
4104 | | - |
4105 | QRegion result(*this); executed (the execution status of this line is deduced): QRegion result(*this); | - |
4106 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4107 | result.d->qt_rgn->intersect(r); executed (the execution status of this line is deduced): result.d->qt_rgn->intersect(r); | - |
4108 | return result; executed: return result; Execution Count:4107 | 4107 |
4109 | } | - |
4110 | | - |
4111 | QRegion QRegion::subtracted(const QRegion &r) const | - |
4112 | { | - |
4113 | if (isEmptyHelper(d->qt_rgn) || isEmptyHelper(r.d->qt_rgn)) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:1221 | yes Evaluation Count:21375 |
evaluated: isEmptyHelper(r.d->qt_rgn) yes Evaluation Count:2946 | yes Evaluation Count:18429 |
| 1221-21375 |
4114 | return *this; executed: return *this; Execution Count:4167 | 4167 |
4115 | if (r.d->qt_rgn->contains(*d->qt_rgn)) evaluated: r.d->qt_rgn->contains(*d->qt_rgn) yes Evaluation Count:3022 | yes Evaluation Count:15407 |
| 3022-15407 |
4116 | return QRegion(); executed: return QRegion(); Execution Count:3022 | 3022 |
4117 | if (!EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents)) evaluated: (&d->qt_rgn->extents)->right() >= (&r.d->qt_rgn->extents)->left() yes Evaluation Count:15375 | yes Evaluation Count:32 |
evaluated: (&d->qt_rgn->extents)->left() <= (&r.d->qt_rgn->extents)->right() yes Evaluation Count:15348 | yes Evaluation Count:27 |
evaluated: (&d->qt_rgn->extents)->bottom() >= (&r.d->qt_rgn->extents)->top() yes Evaluation Count:15302 | yes Evaluation Count:46 |
evaluated: (&d->qt_rgn->extents)->top() <= (&r.d->qt_rgn->extents)->bottom() yes Evaluation Count:15148 | yes Evaluation Count:154 |
| 27-15375 |
4118 | return *this; executed: return *this; Execution Count:259 | 259 |
4119 | if (d == r.d || EqualRegion(d->qt_rgn, r.d->qt_rgn)) partially evaluated: d == r.d no Evaluation Count:0 | yes Evaluation Count:15148 |
partially evaluated: EqualRegion(d->qt_rgn, r.d->qt_rgn) no Evaluation Count:0 | yes Evaluation Count:15148 |
| 0-15148 |
4120 | return QRegion(); never executed: return QRegion(); | 0 |
4121 | | - |
4122 | #ifdef QT_REGION_DEBUG | - |
4123 | d->qt_rgn->selfTest(); | - |
4124 | r.d->qt_rgn->selfTest(); | - |
4125 | #endif | - |
4126 | | - |
4127 | QRegion result; executed (the execution status of this line is deduced): QRegion result; | - |
4128 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4129 | SubtractRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn); executed (the execution status of this line is deduced): SubtractRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn); | - |
4130 | #ifdef QT_REGION_DEBUG | - |
4131 | result.d->qt_rgn->selfTest(); | - |
4132 | #endif | - |
4133 | return result; executed: return result; Execution Count:15148 | 15148 |
4134 | } | - |
4135 | | - |
4136 | QRegion QRegion::xored(const QRegion &r) const | - |
4137 | { | - |
4138 | if (isEmptyHelper(d->qt_rgn)) { evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:6 | yes Evaluation Count:25 |
| 6-25 |
4139 | return r; executed: return r; Execution Count:6 | 6 |
4140 | } else if (isEmptyHelper(r.d->qt_rgn)) { evaluated: isEmptyHelper(r.d->qt_rgn) yes Evaluation Count:3 | yes Evaluation Count:22 |
| 3-22 |
4141 | return *this; executed: return *this; Execution Count:3 | 3 |
4142 | } else if (!EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents)) { partially evaluated: (&d->qt_rgn->extents)->right() >= (&r.d->qt_rgn->extents)->left() yes Evaluation Count:22 | no Evaluation Count:0 |
partially evaluated: (&d->qt_rgn->extents)->left() <= (&r.d->qt_rgn->extents)->right() yes Evaluation Count:22 | no Evaluation Count:0 |
partially evaluated: (&d->qt_rgn->extents)->bottom() >= (&r.d->qt_rgn->extents)->top() yes Evaluation Count:22 | no Evaluation Count:0 |
partially evaluated: (&d->qt_rgn->extents)->top() <= (&r.d->qt_rgn->extents)->bottom() yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
4143 | return (*this + r); never executed: return (*this + r); | 0 |
4144 | } else if (d == r.d || EqualRegion(d->qt_rgn, r.d->qt_rgn)) { evaluated: d == r.d yes Evaluation Count:3 | yes Evaluation Count:19 |
partially evaluated: EqualRegion(d->qt_rgn, r.d->qt_rgn) no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
4145 | return QRegion(); executed: return QRegion(); Execution Count:3 | 3 |
4146 | } else { | - |
4147 | QRegion result; executed (the execution status of this line is deduced): QRegion result; | - |
4148 | result.detach(); executed (the execution status of this line is deduced): result.detach(); | - |
4149 | XorRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn); executed (the execution status of this line is deduced): XorRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn); | - |
4150 | return result; executed: return result; Execution Count:19 | 19 |
4151 | } | - |
4152 | } | - |
4153 | | - |
4154 | QRect QRegion::boundingRect() const | - |
4155 | { | - |
4156 | if (isEmpty()) evaluated: isEmpty() yes Evaluation Count:3419 | yes Evaluation Count:75877 |
| 3419-75877 |
4157 | return QRect(); executed: return QRect(); Execution Count:3419 | 3419 |
4158 | return d->qt_rgn->extents; executed: return d->qt_rgn->extents; Execution Count:75877 | 75877 |
4159 | } | - |
4160 | | - |
4161 | /*! \internal | - |
4162 | Returns true if \a rect is guaranteed to be fully contained in \a region. | - |
4163 | A false return value does not guarantee the opposite. | - |
4164 | */ | - |
4165 | Q_GUI_EXPORT | - |
4166 | bool qt_region_strictContains(const QRegion ®ion, const QRect &rect) | - |
4167 | { | - |
4168 | if (isEmptyHelper(region.d->qt_rgn) || !rect.isValid()) evaluated: isEmptyHelper(region.d->qt_rgn) yes Evaluation Count:35005 | yes Evaluation Count:122253 |
evaluated: !rect.isValid() yes Evaluation Count:13 | yes Evaluation Count:122240 |
| 13-122253 |
4169 | return false; executed: return false; Execution Count:35018 | 35018 |
4170 | | - |
4171 | #if 0 // TEST_INNERRECT | - |
4172 | static bool guard = false; | - |
4173 | if (guard) | - |
4174 | return false; | - |
4175 | guard = true; | - |
4176 | QRegion inner = region.d->qt_rgn->innerRect; | - |
4177 | Q_ASSERT((inner - region).isEmpty()); | - |
4178 | guard = false; | - |
4179 | | - |
4180 | int maxArea = 0; | - |
4181 | for (int i = 0; i < region.d->qt_rgn->numRects; ++i) { | - |
4182 | const QRect r = region.d->qt_rgn->rects.at(i); | - |
4183 | if (r.width() * r.height() > maxArea) | - |
4184 | maxArea = r.width() * r.height(); | - |
4185 | } | - |
4186 | | - |
4187 | if (maxArea > region.d->qt_rgn->innerArea) { | - |
4188 | qDebug() << "not largest rectangle" << region << region.d->qt_rgn->innerRect; | - |
4189 | } | - |
4190 | Q_ASSERT(maxArea <= region.d->qt_rgn->innerArea); | - |
4191 | #endif | - |
4192 | | - |
4193 | const QRect r1 = region.d->qt_rgn->innerRect; executed (the execution status of this line is deduced): const QRect r1 = region.d->qt_rgn->innerRect; | - |
4194 | return (rect.left() >= r1.left() && rect.right() <= r1.right() executed: return (rect.left() >= r1.left() && rect.right() <= r1.right() && rect.top() >= r1.top() && rect.bottom() <= r1.bottom()); Execution Count:122240 | 122240 |
4195 | && rect.top() >= r1.top() && rect.bottom() <= r1.bottom()); executed: return (rect.left() >= r1.left() && rect.right() <= r1.right() && rect.top() >= r1.top() && rect.bottom() <= r1.bottom()); Execution Count:122240 | 122240 |
4196 | } | - |
4197 | | - |
4198 | QVector<QRect> QRegion::rects() const | - |
4199 | { | - |
4200 | if (d->qt_rgn) { partially evaluated: d->qt_rgn yes Evaluation Count:60416 | no Evaluation Count:0 |
| 0-60416 |
4201 | d->qt_rgn->vectorize(); executed (the execution status of this line is deduced): d->qt_rgn->vectorize(); | - |
4202 | d->qt_rgn->rects.reserve(d->qt_rgn->numRects); executed (the execution status of this line is deduced): d->qt_rgn->rects.reserve(d->qt_rgn->numRects); | - |
4203 | d->qt_rgn->rects.resize(d->qt_rgn->numRects); executed (the execution status of this line is deduced): d->qt_rgn->rects.resize(d->qt_rgn->numRects); | - |
4204 | return d->qt_rgn->rects; executed: return d->qt_rgn->rects; Execution Count:60416 | 60416 |
4205 | } else { | - |
4206 | return QVector<QRect>(); never executed: return QVector<QRect>(); | 0 |
4207 | } | - |
4208 | } | - |
4209 | | - |
4210 | void QRegion::setRects(const QRect *rects, int num) | - |
4211 | { | - |
4212 | *this = QRegion(); executed (the execution status of this line is deduced): *this = QRegion(); | - |
4213 | if (!rects || num == 0 || (num == 1 && rects->isEmpty())) evaluated: !rects yes Evaluation Count:1 | yes Evaluation Count:31 |
evaluated: num == 0 yes Evaluation Count:1 | yes Evaluation Count:30 |
evaluated: num == 1 yes Evaluation Count:5 | yes Evaluation Count:25 |
evaluated: rects->isEmpty() yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-31 |
4214 | return; executed: return; Execution Count:3 | 3 |
4215 | | - |
4216 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4217 | | - |
4218 | d->qt_rgn->numRects = num; executed (the execution status of this line is deduced): d->qt_rgn->numRects = num; | - |
4219 | if (num == 1) { evaluated: num == 1 yes Evaluation Count:4 | yes Evaluation Count:25 |
| 4-25 |
4220 | d->qt_rgn->extents = *rects; executed (the execution status of this line is deduced): d->qt_rgn->extents = *rects; | - |
4221 | d->qt_rgn->innerRect = *rects; executed (the execution status of this line is deduced): d->qt_rgn->innerRect = *rects; | - |
4222 | } else { executed: } Execution Count:4 | 4 |
4223 | d->qt_rgn->rects.resize(num); executed (the execution status of this line is deduced): d->qt_rgn->rects.resize(num); | - |
4224 | | - |
4225 | int left = INT_MAX, executed (the execution status of this line is deduced): int left = 2147483647, | - |
4226 | right = INT_MIN, executed (the execution status of this line is deduced): right = (-2147483647 - 1), | - |
4227 | top = INT_MAX, executed (the execution status of this line is deduced): top = 2147483647, | - |
4228 | bottom = INT_MIN; executed (the execution status of this line is deduced): bottom = (-2147483647 - 1); | - |
4229 | for (int i = 0; i < num; ++i) { evaluated: i < num yes Evaluation Count:59 | yes Evaluation Count:25 |
| 25-59 |
4230 | const QRect &rect = rects[i]; executed (the execution status of this line is deduced): const QRect &rect = rects[i]; | - |
4231 | d->qt_rgn->rects[i] = rect; executed (the execution status of this line is deduced): d->qt_rgn->rects[i] = rect; | - |
4232 | left = qMin(rect.left(), left); executed (the execution status of this line is deduced): left = qMin(rect.left(), left); | - |
4233 | right = qMax(rect.right(), right); executed (the execution status of this line is deduced): right = qMax(rect.right(), right); | - |
4234 | top = qMin(rect.top(), top); executed (the execution status of this line is deduced): top = qMin(rect.top(), top); | - |
4235 | bottom = qMax(rect.bottom(), bottom); executed (the execution status of this line is deduced): bottom = qMax(rect.bottom(), bottom); | - |
4236 | d->qt_rgn->updateInnerRect(rect); executed (the execution status of this line is deduced): d->qt_rgn->updateInnerRect(rect); | - |
4237 | } executed: } Execution Count:59 | 59 |
4238 | d->qt_rgn->extents = QRect(QPoint(left, top), QPoint(right, bottom)); executed (the execution status of this line is deduced): d->qt_rgn->extents = QRect(QPoint(left, top), QPoint(right, bottom)); | - |
4239 | } executed: } Execution Count:25 | 25 |
4240 | } | - |
4241 | | - |
4242 | int QRegion::rectCount() const | - |
4243 | { | - |
4244 | return (d->qt_rgn ? d->qt_rgn->numRects : 0); executed: return (d->qt_rgn ? d->qt_rgn->numRects : 0); Execution Count:48459 | 48459 |
4245 | } | - |
4246 | | - |
4247 | | - |
4248 | bool QRegion::operator==(const QRegion &r) const | - |
4249 | { | - |
4250 | if (!d->qt_rgn) partially evaluated: !d->qt_rgn no Evaluation Count:0 | yes Evaluation Count:698 |
| 0-698 |
4251 | return r.isEmpty(); never executed: return r.isEmpty(); | 0 |
4252 | if (!r.d->qt_rgn) partially evaluated: !r.d->qt_rgn no Evaluation Count:0 | yes Evaluation Count:698 |
| 0-698 |
4253 | return isEmpty(); never executed: return isEmpty(); | 0 |
4254 | | - |
4255 | if (d == r.d) evaluated: d == r.d yes Evaluation Count:189 | yes Evaluation Count:509 |
| 189-509 |
4256 | return true; executed: return true; Execution Count:189 | 189 |
4257 | else | - |
4258 | return EqualRegion(d->qt_rgn, r.d->qt_rgn); executed: return EqualRegion(d->qt_rgn, r.d->qt_rgn); Execution Count:509 | 509 |
4259 | } | - |
4260 | | - |
4261 | bool QRegion::intersects(const QRect &rect) const | - |
4262 | { | - |
4263 | if (isEmptyHelper(d->qt_rgn) || rect.isNull()) evaluated: isEmptyHelper(d->qt_rgn) yes Evaluation Count:8129 | yes Evaluation Count:16650 |
partially evaluated: rect.isNull() no Evaluation Count:0 | yes Evaluation Count:16650 |
| 0-16650 |
4264 | return false; executed: return false; Execution Count:8129 | 8129 |
4265 | | - |
4266 | const QRect r = rect.normalized(); executed (the execution status of this line is deduced): const QRect r = rect.normalized(); | - |
4267 | if (!rect_intersects(d->qt_rgn->extents, r)) evaluated: !rect_intersects(d->qt_rgn->extents, r) yes Evaluation Count:1023 | yes Evaluation Count:15627 |
| 1023-15627 |
4268 | return false; executed: return false; Execution Count:1023 | 1023 |
4269 | if (d->qt_rgn->numRects == 1) evaluated: d->qt_rgn->numRects == 1 yes Evaluation Count:13444 | yes Evaluation Count:2183 |
| 2183-13444 |
4270 | return true; executed: return true; Execution Count:13444 | 13444 |
4271 | | - |
4272 | const QVector<QRect> myRects = rects(); executed (the execution status of this line is deduced): const QVector<QRect> myRects = rects(); | - |
4273 | for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) evaluated: it < myRects.constEnd() yes Evaluation Count:3712 | yes Evaluation Count:709 |
| 709-3712 |
4274 | if (rect_intersects(r, *it)) evaluated: rect_intersects(r, *it) yes Evaluation Count:1474 | yes Evaluation Count:2238 |
| 1474-2238 |
4275 | return true; executed: return true; Execution Count:1474 | 1474 |
4276 | return false; executed: return false; Execution Count:709 | 709 |
4277 | } | - |
4278 | | - |
4279 | | - |
4280 | #endif | - |
4281 | QT_END_NAMESPACE | - |
4282 | | - |
| | |