Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | const uchar *qt_patternForBrush(int brushStyle, bool invert) | - |
5 | { | - |
6 | qt_noop(); | - |
7 | if(invert) { evaluated: invert yes Evaluation Count:715 | yes Evaluation Count:715 |
| 715 |
8 | static const uchar dense1_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff }; | - |
9 | static const uchar dense2_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff }; | - |
10 | static const uchar dense3_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee }; | - |
11 | static const uchar dense4_pat[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }; | - |
12 | static const uchar dense5_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 }; | - |
13 | static const uchar dense6_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }; | - |
14 | static const uchar dense7_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 }; | - |
15 | static const uchar hor_pat[] = { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }; | - |
16 | static const uchar ver_pat[] = { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }; | - |
17 | static const uchar cross_pat[] = { 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10 }; | - |
18 | static const uchar bdiag_pat[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; | - |
19 | static const uchar fdiag_pat[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; | - |
20 | static const uchar dcross_pat[] = { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }; | - |
21 | static const uchar *const pat_tbl[] = { | - |
22 | dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat, | - |
23 | dense6_pat, dense7_pat, | - |
24 | hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat }; | - |
25 | return pat_tbl[brushStyle - Qt::Dense1Pattern]; executed: return pat_tbl[brushStyle - Qt::Dense1Pattern]; Execution Count:715 | 715 |
26 | } | - |
27 | static const uchar dense1_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 }; | - |
28 | static const uchar dense2_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }; | - |
29 | static const uchar dense3_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 }; | - |
30 | static const uchar dense4_pat[] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }; | - |
31 | static const uchar dense5_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee }; | - |
32 | static const uchar dense6_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff }; | - |
33 | static const uchar dense7_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff }; | - |
34 | static const uchar hor_pat[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff }; | - |
35 | static const uchar ver_pat[] = { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef }; | - |
36 | static const uchar cross_pat[] = { 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef, 0xef }; | - |
37 | static const uchar bdiag_pat[] = { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe }; | - |
38 | static const uchar fdiag_pat[] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f }; | - |
39 | static const uchar dcross_pat[] = { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e }; | - |
40 | static const uchar *const pat_tbl[] = { | - |
41 | dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat, | - |
42 | dense6_pat, dense7_pat, | - |
43 | hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat }; | - |
44 | return pat_tbl[brushStyle - Qt::Dense1Pattern]; executed: return pat_tbl[brushStyle - Qt::Dense1Pattern]; Execution Count:715 | 715 |
45 | } | - |
46 | | - |
47 | QPixmap qt_pixmapForBrush(int brushStyle, bool invert) | - |
48 | { | - |
49 | | - |
50 | QPixmap pm; | - |
51 | QString key = QLatin1String("$qt-brush$") | - |
52 | % HexString<uint>(brushStyle) | - |
53 | % QLatin1Char(invert ? '1' : '0'); | - |
54 | if (!QPixmapCache::find(key, pm)) { never evaluated: !QPixmapCache::find(key, pm) | 0 |
55 | pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert), | - |
56 | QImage::Format_MonoLSB); | - |
57 | QPixmapCache::insert(key, pm); | - |
58 | } | 0 |
59 | | - |
60 | return pm; never executed: return pm; | 0 |
61 | } | - |
62 | | - |
63 | static void qt_cleanup_brush_pattern_image_cache(); | - |
64 | class QBrushPatternImageCache | - |
65 | { | - |
66 | public: | - |
67 | QBrushPatternImageCache() | - |
68 | : m_initialized(false) | - |
69 | { | - |
70 | init(); | - |
71 | } executed: } Execution Count:55 | 55 |
72 | | - |
73 | void init() | - |
74 | { | - |
75 | qAddPostRoutine(qt_cleanup_brush_pattern_image_cache); | - |
76 | for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) { evaluated: style <= Qt::DiagCrossPattern yes Evaluation Count:715 | yes Evaluation Count:55 |
| 55-715 |
77 | int i = style - Qt::Dense1Pattern; | - |
78 | m_images[i][0] = QImage(qt_patternForBrush(style, 0), 8, 8, 1, QImage::Format_MonoLSB); | - |
79 | m_images[i][1] = QImage(qt_patternForBrush(style, 1), 8, 8, 1, QImage::Format_MonoLSB); | - |
80 | } executed: } Execution Count:715 | 715 |
81 | m_initialized = true; | - |
82 | } executed: } Execution Count:55 | 55 |
83 | | - |
84 | QImage getImage(int brushStyle, bool invert) const | - |
85 | { | - |
86 | qt_noop(); | - |
87 | if (!m_initialized) partially evaluated: !m_initialized no Evaluation Count:0 | yes Evaluation Count:9554 |
| 0-9554 |
88 | const_cast<QBrushPatternImageCache*>(this)->init(); never executed: const_cast<QBrushPatternImageCache*>(this)->init(); | 0 |
89 | return m_images[brushStyle - Qt::Dense1Pattern][invert]; executed: return m_images[brushStyle - Qt::Dense1Pattern][invert]; Execution Count:9554 | 9554 |
90 | } | - |
91 | | - |
92 | void cleanup() { | - |
93 | for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) { evaluated: style <= Qt::DiagCrossPattern yes Evaluation Count:715 | yes Evaluation Count:55 |
| 55-715 |
94 | int i = style - Qt::Dense1Pattern; | - |
95 | m_images[i][0] = QImage(); | - |
96 | m_images[i][1] = QImage(); | - |
97 | } executed: } Execution Count:715 | 715 |
98 | m_initialized = false; | - |
99 | } executed: } Execution Count:55 | 55 |
100 | | - |
101 | private: | - |
102 | QImage m_images[Qt::DiagCrossPattern - Qt::Dense1Pattern + 1][2]; | - |
103 | bool m_initialized; | - |
104 | }; | - |
105 | | - |
106 | static QBrushPatternImageCache *qt_brushPatternImageCache() { static QGlobalStatic<QBrushPatternImageCache > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QBrushPatternImageCache *x = new QBrushPatternImageCache; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QBrushPatternImageCache > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:9609 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:55 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:55 | yes Evaluation Count:9554 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:55 | no Evaluation Count:0 |
| 0-9609 |
107 | | - |
108 | static void qt_cleanup_brush_pattern_image_cache() | - |
109 | { | - |
110 | qt_brushPatternImageCache()->cleanup(); | - |
111 | } executed: } Execution Count:55 | 55 |
112 | | - |
113 | __attribute__((visibility("default"))) QImage qt_imageForBrush(int brushStyle, bool invert) | - |
114 | { | - |
115 | return qt_brushPatternImageCache()->getImage(brushStyle, invert); executed: return qt_brushPatternImageCache()->getImage(brushStyle, invert); Execution Count:9554 | 9554 |
116 | } | - |
117 | | - |
118 | struct QTexturedBrushData : public QBrushData | - |
119 | { | - |
120 | QTexturedBrushData() { | - |
121 | m_has_pixmap_texture = false; | - |
122 | m_pixmap = 0; | - |
123 | } executed: } Execution Count:89 | 89 |
124 | ~QTexturedBrushData() { | - |
125 | delete m_pixmap; | - |
126 | } executed: } Execution Count:89 | 89 |
127 | | - |
128 | void setPixmap(const QPixmap &pm) { | - |
129 | delete m_pixmap; | - |
130 | | - |
131 | if (pm.isNull()) { partially evaluated: pm.isNull() no Evaluation Count:0 | yes Evaluation Count:60 |
| 0-60 |
132 | m_pixmap = 0; | - |
133 | m_has_pixmap_texture = false; | - |
134 | } else { | 0 |
135 | m_pixmap = new QPixmap(pm); | - |
136 | m_has_pixmap_texture = true; | - |
137 | } executed: } Execution Count:60 | 60 |
138 | | - |
139 | m_image = QImage(); | - |
140 | } executed: } Execution Count:60 | 60 |
141 | | - |
142 | void setImage(const QImage &image) { | - |
143 | m_image = image; | - |
144 | delete m_pixmap; | - |
145 | m_pixmap = 0; | - |
146 | m_has_pixmap_texture = false; | - |
147 | } executed: } Execution Count:29 | 29 |
148 | | - |
149 | QPixmap &pixmap() { | - |
150 | if (!m_pixmap) { evaluated: !m_pixmap yes Evaluation Count:4 | yes Evaluation Count:100 |
| 4-100 |
151 | m_pixmap = new QPixmap(QPixmap::fromImage(m_image)); | - |
152 | } executed: } Execution Count:4 | 4 |
153 | return *m_pixmap; executed: return *m_pixmap; Execution Count:104 | 104 |
154 | } | - |
155 | | - |
156 | QImage &image() { | - |
157 | if (m_image.isNull() && m_pixmap) evaluated: m_image.isNull() yes Evaluation Count:3 | yes Evaluation Count:200 |
partially evaluated: m_pixmap yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-200 |
158 | m_image = m_pixmap->toImage(); executed: m_image = m_pixmap->toImage(); Execution Count:3 | 3 |
159 | return m_image; executed: return m_image; Execution Count:203 | 203 |
160 | } | - |
161 | | - |
162 | QPixmap *m_pixmap; | - |
163 | QImage m_image; | - |
164 | bool m_has_pixmap_texture; | - |
165 | }; | - |
166 | | - |
167 | | - |
168 | | - |
169 | bool __attribute__((visibility("default"))) qHasPixmapTexture(const QBrush& brush) | - |
170 | { | - |
171 | if (brush.style() != Qt::TexturePattern) partially evaluated: brush.style() != Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:200 |
| 0-200 |
172 | return false; never executed: return false; | 0 |
173 | QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data()); | - |
174 | return tx_data->m_has_pixmap_texture; executed: return tx_data->m_has_pixmap_texture; Execution Count:200 | 200 |
175 | } | - |
176 | | - |
177 | struct QGradientBrushData : public QBrushData | - |
178 | { | - |
179 | QGradient gradient; | - |
180 | }; | - |
181 | | - |
182 | struct QBrushDataPointerDeleter | - |
183 | { | - |
184 | static inline void deleteData(QBrushData *d) | - |
185 | { | - |
186 | switch (d->style) { | - |
187 | case Qt::TexturePattern: | - |
188 | delete static_cast<QTexturedBrushData*>(d); | - |
189 | break; executed: break; Execution Count:89 | 89 |
190 | case Qt::LinearGradientPattern: | - |
191 | case Qt::RadialGradientPattern: | - |
192 | case Qt::ConicalGradientPattern: | - |
193 | delete static_cast<QGradientBrushData*>(d); | - |
194 | break; executed: break; Execution Count:16966 | 16966 |
195 | default: | - |
196 | delete d; | - |
197 | } executed: } Execution Count:370595 | 370595 |
198 | } executed: } Execution Count:387650 | 387650 |
199 | | - |
200 | static inline void cleanup(QBrushData *d) | - |
201 | { | - |
202 | if (d && !d->ref.deref()) { evaluated: d yes Evaluation Count:10812165 | yes Evaluation Count:392365 |
evaluated: !d->ref.deref() yes Evaluation Count:387657 | yes Evaluation Count:10424528 |
| 387657-10812165 |
203 | deleteData(d); | - |
204 | } executed: } Execution Count:387651 | 387651 |
205 | } executed: } Execution Count:11204524 | 11204524 |
206 | }; | - |
207 | class QNullBrushData | - |
208 | { | - |
209 | public: | - |
210 | QBrushData *brush; | - |
211 | QNullBrushData() : brush(new QBrushData) | - |
212 | { | - |
213 | brush->ref.store(1); | - |
214 | brush->style = Qt::BrushStyle(0); | - |
215 | brush->color = Qt::black; | - |
216 | } executed: } Execution Count:151 | 151 |
217 | ~QNullBrushData() | - |
218 | { | - |
219 | if (!brush->ref.deref()) evaluated: !brush->ref.deref() yes Evaluation Count:125 | yes Evaluation Count:26 |
| 26-125 |
220 | delete brush; executed: delete brush; Execution Count:125 | 125 |
221 | brush = 0; | - |
222 | } executed: } Execution Count:151 | 151 |
223 | }; | - |
224 | | - |
225 | static QNullBrushData *nullBrushInstance_holder() { static QGlobalStatic<QNullBrushData > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QNullBrushData *x = new QNullBrushData; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QNullBrushData > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:151 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:151 | yes Evaluation Count:5099842 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:151 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:5099993 | 0-5099993 |
226 | static QBrushData *nullBrushInstance() | - |
227 | { | - |
228 | return nullBrushInstance_holder()->brush; executed: return nullBrushInstance_holder()->brush; Execution Count:5099993 | 5099993 |
229 | } | - |
230 | | - |
231 | static bool qbrush_check_type(Qt::BrushStyle style) { | - |
232 | switch (style) { | - |
233 | case Qt::TexturePattern: | - |
234 | QMessageLogger("painting/qbrush.cpp", 368, __PRETTY_FUNCTION__).warning("QBrush: Incorrect use of TexturePattern"); | - |
235 | break; executed: break; Execution Count:4 | 4 |
236 | case Qt::LinearGradientPattern: | - |
237 | case Qt::RadialGradientPattern: | - |
238 | case Qt::ConicalGradientPattern: | - |
239 | QMessageLogger("painting/qbrush.cpp", 373, __PRETTY_FUNCTION__).warning("QBrush: Wrong use of a gradient pattern"); | - |
240 | break; executed: break; Execution Count:12 | 12 |
241 | default: | - |
242 | return true; executed: return true; Execution Count:375302 | 375302 |
243 | } | - |
244 | return false; executed: return false; Execution Count:16 | 16 |
245 | } | - |
246 | | - |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
252 | void QBrush::init(const QColor &color, Qt::BrushStyle style) | - |
253 | { | - |
254 | switch(style) { | - |
255 | case Qt::NoBrush: | - |
256 | d.reset(nullBrushInstance()); | - |
257 | d->ref.ref(); | - |
258 | if (d->color != color) setColor(color); evaluated: d->color != color yes Evaluation Count:27 | yes Evaluation Count:4117 |
executed: setColor(color); Execution Count:27 | 27-4117 |
259 | return; executed: return; Execution Count:4144 | 4144 |
260 | case Qt::TexturePattern: | - |
261 | d.reset(new QTexturedBrushData); | - |
262 | break; executed: break; Execution Count:85 | 85 |
263 | case Qt::LinearGradientPattern: | - |
264 | case Qt::RadialGradientPattern: | - |
265 | case Qt::ConicalGradientPattern: | - |
266 | d.reset(new QGradientBrushData); | - |
267 | break; executed: break; Execution Count:16967 | 16967 |
268 | default: | - |
269 | d.reset(new QBrushData); | - |
270 | break; executed: break; Execution Count:371158 | 371158 |
271 | } | - |
272 | d->ref.store(1); | - |
273 | d->style = style; | - |
274 | d->color = color; | - |
275 | } executed: } Execution Count:388209 | 388209 |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | QBrush::QBrush() | - |
283 | : d(nullBrushInstance()) | - |
284 | { | - |
285 | qt_noop(); | - |
286 | d->ref.ref(); | - |
287 | } executed: } Execution Count:5095837 | 5095837 |
288 | QBrush::QBrush(const QPixmap &pixmap) | - |
289 | { | - |
290 | init(Qt::black, Qt::TexturePattern); | - |
291 | setTexture(pixmap); | - |
292 | } executed: } Execution Count:58 | 58 |
293 | QBrush::QBrush(const QImage &image) | - |
294 | { | - |
295 | init(Qt::black, Qt::TexturePattern); | - |
296 | setTextureImage(image); | - |
297 | } executed: } Execution Count:27 | 27 |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | QBrush::QBrush(Qt::BrushStyle style) | - |
306 | { | - |
307 | if (qbrush_check_type(style)) evaluated: qbrush_check_type(style) yes Evaluation Count:3776 | yes Evaluation Count:4 |
| 4-3776 |
308 | init(Qt::black, style); executed: init(Qt::black, style); Execution Count:3776 | 3776 |
309 | else { | - |
310 | d.reset(nullBrushInstance()); | - |
311 | d->ref.ref(); | - |
312 | } executed: } Execution Count:4 | 4 |
313 | } | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | QBrush::QBrush(const QColor &color, Qt::BrushStyle style) | - |
322 | { | - |
323 | if (qbrush_check_type(style)) evaluated: qbrush_check_type(style) yes Evaluation Count:213038 | yes Evaluation Count:4 |
| 4-213038 |
324 | init(color, style); executed: init(color, style); Execution Count:213038 | 213038 |
325 | else { | - |
326 | d.reset(nullBrushInstance()); | - |
327 | d->ref.ref(); | - |
328 | } executed: } Execution Count:4 | 4 |
329 | } | - |
330 | QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style) | - |
331 | { | - |
332 | if (qbrush_check_type(style)) evaluated: qbrush_check_type(style) yes Evaluation Count:158488 | yes Evaluation Count:4 |
| 4-158488 |
333 | init(color, style); executed: init(color, style); Execution Count:158488 | 158488 |
334 | else { | - |
335 | d.reset(nullBrushInstance()); | - |
336 | d->ref.ref(); | - |
337 | } executed: } Execution Count:4 | 4 |
338 | } | - |
339 | QBrush::QBrush(const QColor &color, const QPixmap &pixmap) | - |
340 | { | - |
341 | init(color, Qt::TexturePattern); | - |
342 | setTexture(pixmap); | - |
343 | } | 0 |
344 | QBrush::QBrush(Qt::GlobalColor color, const QPixmap &pixmap) | - |
345 | { | - |
346 | init(color, Qt::TexturePattern); | - |
347 | setTexture(pixmap); | - |
348 | } | 0 |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | QBrush::QBrush(const QBrush &other) | - |
355 | : d(other.d.data()) | - |
356 | { | - |
357 | d->ref.ref(); | - |
358 | } executed: } Execution Count:778119 | 778119 |
359 | QBrush::QBrush(const QGradient &gradient) | - |
360 | { | - |
361 | qt_noop(); | - |
362 | | - |
363 | | - |
364 | | - |
365 | const Qt::BrushStyle enum_table[] = { | - |
366 | Qt::LinearGradientPattern, | - |
367 | Qt::RadialGradientPattern, | - |
368 | Qt::ConicalGradientPattern | - |
369 | }; | - |
370 | | - |
371 | init(QColor(), enum_table[gradient.type()]); | - |
372 | QGradientBrushData *grad = static_cast<QGradientBrushData *>(d.data()); | - |
373 | grad->gradient = gradient; | - |
374 | } executed: } Execution Count:16967 | 16967 |
375 | | - |
376 | | - |
377 | | - |
378 | | - |
379 | | - |
380 | QBrush::~QBrush() | - |
381 | { | - |
382 | } | - |
383 | | - |
384 | void QBrush::cleanUp(QBrushData *x) | - |
385 | { | - |
386 | QBrushDataPointerDeleter::deleteData(x); | - |
387 | } | 0 |
388 | | - |
389 | | - |
390 | void QBrush::detach(Qt::BrushStyle newStyle) | - |
391 | { | - |
392 | if (newStyle == d->style && d->ref.load() == 1) evaluated: newStyle == d->style yes Evaluation Count:862 | yes Evaluation Count:4 |
evaluated: d->ref.load() == 1 yes Evaluation Count:821 | yes Evaluation Count:41 |
| 4-862 |
393 | return; executed: return; Execution Count:821 | 821 |
394 | | - |
395 | QScopedPointer<QBrushData> x; | - |
396 | switch(newStyle) { | - |
397 | case Qt::TexturePattern: { | - |
398 | QTexturedBrushData *tbd = new QTexturedBrushData; | - |
399 | if (d->style == Qt::TexturePattern) { partially evaluated: d->style == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
400 | QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); | - |
401 | if (data->m_has_pixmap_texture) never evaluated: data->m_has_pixmap_texture | 0 |
402 | tbd->setPixmap(data->pixmap()); never executed: tbd->setPixmap(data->pixmap()); | 0 |
403 | else | - |
404 | tbd->setImage(data->image()); never executed: tbd->setImage(data->image()); | 0 |
405 | } | - |
406 | x.reset(tbd); | - |
407 | break; executed: break; Execution Count:4 | 4 |
408 | } | - |
409 | case Qt::LinearGradientPattern: | - |
410 | case Qt::RadialGradientPattern: | - |
411 | case Qt::ConicalGradientPattern: | - |
412 | x.reset(new QGradientBrushData); | - |
413 | static_cast<QGradientBrushData *>(x.data())->gradient = | - |
414 | static_cast<QGradientBrushData *>(d.data())->gradient; | - |
415 | break; executed: break; Execution Count:4 | 4 |
416 | default: | - |
417 | x.reset(new QBrushData); | - |
418 | break; executed: break; Execution Count:37 | 37 |
419 | } | - |
420 | x->ref.store(1); | - |
421 | x->style = newStyle; | - |
422 | x->color = d->color; | - |
423 | x->transform = d->transform; | - |
424 | d.reset(x.take()); | - |
425 | } executed: } Execution Count:45 | 45 |
426 | QBrush &QBrush::operator=(const QBrush &b) | - |
427 | { | - |
428 | if (d == b.d) evaluated: d == b.d yes Evaluation Count:456054 | yes Evaluation Count:4547676 |
| 456054-4547676 |
429 | return *this; executed: return *this; Execution Count:456054 | 456054 |
430 | | - |
431 | b.d->ref.ref(); | - |
432 | d.reset(b.d.data()); | - |
433 | return *this; executed: return *this; Execution Count:4547690 | 4547690 |
434 | } | - |
435 | QBrush::operator QVariant() const | - |
436 | { | - |
437 | return QVariant(QVariant::Brush, this); executed: return QVariant(QVariant::Brush, this); Execution Count:33550 | 33550 |
438 | } | - |
439 | void QBrush::setStyle(Qt::BrushStyle style) | - |
440 | { | - |
441 | if (d->style == style) partially evaluated: d->style == style no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
442 | return; | 0 |
443 | | - |
444 | if (qbrush_check_type(style)) { partially evaluated: qbrush_check_type(style) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
445 | detach(style); | - |
446 | d->style = style; | - |
447 | } | 0 |
448 | } executed: } Execution Count:4 | 4 |
449 | void QBrush::setColor(const QColor &c) | - |
450 | { | - |
451 | detach(d->style); | - |
452 | d->color = c; | - |
453 | } executed: } Execution Count:27 | 27 |
454 | QPixmap QBrush::texture() const | - |
455 | { | - |
456 | return d->style == Qt::TexturePattern | 6574 |
457 | ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() | 6574 |
458 | : QPixmap(); executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap(); Execution Count:6574 | 6574 |
459 | } | - |
460 | void QBrush::setTexture(const QPixmap &pixmap) | - |
461 | { | - |
462 | if (!pixmap.isNull()) { partially evaluated: !pixmap.isNull() yes Evaluation Count:60 | no Evaluation Count:0 |
| 0-60 |
463 | detach(Qt::TexturePattern); | - |
464 | QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); | - |
465 | data->setPixmap(pixmap); | - |
466 | } else { executed: } Execution Count:60 | 60 |
467 | detach(Qt::NoBrush); | - |
468 | } | 0 |
469 | } | - |
470 | QImage QBrush::textureImage() const | - |
471 | { | - |
472 | return d->style == Qt::TexturePattern | 203 |
473 | ? (static_cast<QTexturedBrushData *>(d.data()))->image() | 203 |
474 | : QImage(); executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage(); Execution Count:203 | 203 |
475 | } | - |
476 | void QBrush::setTextureImage(const QImage &image) | - |
477 | { | - |
478 | if (!image.isNull()) { partially evaluated: !image.isNull() yes Evaluation Count:29 | no Evaluation Count:0 |
| 0-29 |
479 | detach(Qt::TexturePattern); | - |
480 | QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); | - |
481 | data->setImage(image); | - |
482 | } else { executed: } Execution Count:29 | 29 |
483 | detach(Qt::NoBrush); | - |
484 | } | 0 |
485 | } | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | const QGradient *QBrush::gradient() const | - |
492 | { | - |
493 | if (d->style == Qt::LinearGradientPattern evaluated: d->style == Qt::LinearGradientPattern yes Evaluation Count:50416 | yes Evaluation Count:275458 |
| 50416-275458 |
494 | || d->style == Qt::RadialGradientPattern evaluated: d->style == Qt::RadialGradientPattern yes Evaluation Count:2051 | yes Evaluation Count:273407 |
| 2051-273407 |
495 | || d->style == Qt::ConicalGradientPattern) { evaluated: d->style == Qt::ConicalGradientPattern yes Evaluation Count:22 | yes Evaluation Count:273385 |
| 22-273385 |
496 | return &static_cast<const QGradientBrushData *>(d.data())->gradient; executed: return &static_cast<const QGradientBrushData *>(d.data())->gradient; Execution Count:52488 | 52488 |
497 | } | - |
498 | return 0; executed: return 0; Execution Count:273385 | 273385 |
499 | } | - |
500 | | - |
501 | __attribute__((visibility("default"))) bool qt_isExtendedRadialGradient(const QBrush &brush) | - |
502 | { | - |
503 | if (brush.style() == Qt::RadialGradientPattern) { evaluated: brush.style() == Qt::RadialGradientPattern yes Evaluation Count:506 | yes Evaluation Count:16716 |
| 506-16716 |
504 | const QGradient *g = brush.gradient(); | - |
505 | const QRadialGradient *rg = static_cast<const QRadialGradient *>(g); | - |
506 | | - |
507 | if (!qFuzzyIsNull(rg->focalRadius())) partially evaluated: !qFuzzyIsNull(rg->focalRadius()) no Evaluation Count:0 | yes Evaluation Count:506 |
| 0-506 |
508 | return true; never executed: return true; | 0 |
509 | | - |
510 | QPointF delta = rg->focalPoint() - rg->center(); | - |
511 | if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius()) partially evaluated: delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius() no Evaluation Count:0 | yes Evaluation Count:506 |
| 0-506 |
512 | return true; never executed: return true; | 0 |
513 | } executed: } Execution Count:506 | 506 |
514 | | - |
515 | return false; executed: return false; Execution Count:17220 | 17220 |
516 | } | - |
517 | bool QBrush::isOpaque() const | - |
518 | { | - |
519 | bool opaqueColor = d->color.alpha() == 255; | - |
520 | | - |
521 | | - |
522 | if (d->style == Qt::SolidPattern) evaluated: d->style == Qt::SolidPattern yes Evaluation Count:34168 | yes Evaluation Count:17219 |
| 17219-34168 |
523 | return opaqueColor; executed: return opaqueColor; Execution Count:34168 | 34168 |
524 | | - |
525 | if (qt_isExtendedRadialGradient(*this)) partially evaluated: qt_isExtendedRadialGradient(*this) no Evaluation Count:0 | yes Evaluation Count:17219 |
| 0-17219 |
526 | return false; never executed: return false; | 0 |
527 | | - |
528 | if (d->style == Qt::LinearGradientPattern evaluated: d->style == Qt::LinearGradientPattern yes Evaluation Count:16705 | yes Evaluation Count:513 |
| 513-16705 |
529 | || d->style == Qt::RadialGradientPattern evaluated: d->style == Qt::RadialGradientPattern yes Evaluation Count:506 | yes Evaluation Count:7 |
| 7-506 |
530 | || d->style == Qt::ConicalGradientPattern) { partially evaluated: d->style == Qt::ConicalGradientPattern no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
531 | QGradientStops stops = gradient()->stops(); | - |
532 | for (int i=0; i<stops.size(); ++i) evaluated: i<stops.size() yes Evaluation Count:34216 | yes Evaluation Count:16712 |
| 16712-34216 |
533 | if (stops.at(i).second.alpha() != 255) evaluated: stops.at(i).second.alpha() != 255 yes Evaluation Count:506 | yes Evaluation Count:33716 |
| 506-33716 |
534 | return false; executed: return false; Execution Count:506 | 506 |
535 | return true; executed: return true; Execution Count:16712 | 16712 |
536 | } else if (d->style == Qt::TexturePattern) { evaluated: d->style == Qt::TexturePattern yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
537 | return qHasPixmapTexture(*this) | 5 |
538 | ? !texture().hasAlphaChannel() && !texture().isQBitmap() | 5 |
539 | : !textureImage().hasAlphaChannel(); executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel(); Execution Count:5 | 5 |
540 | } | - |
541 | | - |
542 | return false; executed: return false; Execution Count:2 | 2 |
543 | } | - |
544 | void QBrush::setMatrix(const QMatrix &matrix) | - |
545 | { | - |
546 | setTransform(QTransform(matrix)); | - |
547 | } | 0 |
548 | void QBrush::setTransform(const QTransform &matrix) | - |
549 | { | - |
550 | detach(d->style); | - |
551 | d->transform = matrix; | - |
552 | } executed: } Execution Count:750 | 750 |
553 | bool QBrush::operator==(const QBrush &b) const | - |
554 | { | - |
555 | if (b.d == d) evaluated: b.d == d yes Evaluation Count:300544 | yes Evaluation Count:103770 |
| 103770-300544 |
556 | return true; executed: return true; Execution Count:300544 | 300544 |
557 | if (b.d->style != d->style || b.d->color != d->color || b.d->transform != d->transform) evaluated: b.d->style != d->style yes Evaluation Count:584 | yes Evaluation Count:103186 |
evaluated: b.d->color != d->color yes Evaluation Count:80815 | yes Evaluation Count:22371 |
evaluated: b.d->transform != d->transform yes Evaluation Count:1 | yes Evaluation Count:22370 |
| 1-103186 |
558 | return false; executed: return false; Execution Count:81400 | 81400 |
559 | switch (d->style) { | - |
560 | case Qt::TexturePattern: | - |
561 | { | - |
562 | const QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap(); | - |
563 | const QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap(); | - |
564 | return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); executed: return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); Execution Count:21 | 21 |
565 | } | - |
566 | case Qt::LinearGradientPattern: | - |
567 | case Qt::RadialGradientPattern: | - |
568 | case Qt::ConicalGradientPattern: | - |
569 | { | - |
570 | const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data()); | - |
571 | const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data()); | - |
572 | return d1->gradient == d2->gradient; executed: return d1->gradient == d2->gradient; Execution Count:19 | 19 |
573 | } | - |
574 | default: | - |
575 | return true; executed: return true; Execution Count:22330 | 22330 |
576 | } | - |
577 | } | 0 |
578 | | - |
579 | | - |
580 | | - |
581 | | - |
582 | | - |
583 | QDebug operator<<(QDebug dbg, const QBrush &b) | - |
584 | { | - |
585 | static const char *BRUSH_STYLES[] = { | - |
586 | "NoBrush", | - |
587 | "SolidPattern", | - |
588 | "Dense1Pattern", | - |
589 | "Dense2Pattern", | - |
590 | "Dense3Pattern", | - |
591 | "Dense4Pattern", | - |
592 | "Dense5Pattern", | - |
593 | "Dense6Pattern", | - |
594 | "Dense7Pattern", | - |
595 | "HorPattern", | - |
596 | "VerPattern", | - |
597 | "CrossPattern", | - |
598 | "BDiagPattern", | - |
599 | "FDiagPattern", | - |
600 | "DiagCrossPattern", | - |
601 | "LinearGradientPattern", | - |
602 | "RadialGradientPattern", | - |
603 | "ConicalGradientPattern", | - |
604 | 0, 0, 0, 0, 0, 0, | - |
605 | "TexturePattern" | - |
606 | }; | - |
607 | | - |
608 | dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; | - |
609 | return dbg.space(); executed: return dbg.space(); Execution Count:3 | 3 |
610 | } | - |
611 | QDataStream &operator<<(QDataStream &s, const QBrush &b) | - |
612 | { | - |
613 | quint8 style = (quint8) b.style(); | - |
614 | bool gradient_style = false; | - |
615 | | - |
616 | if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern evaluated: style == Qt::LinearGradientPattern yes Evaluation Count:16 | yes Evaluation Count:1537 |
evaluated: style == Qt::RadialGradientPattern yes Evaluation Count:2 | yes Evaluation Count:1535 |
| 2-1537 |
617 | || style == Qt::ConicalGradientPattern) evaluated: style == Qt::ConicalGradientPattern yes Evaluation Count:2 | yes Evaluation Count:1533 |
| 2-1533 |
618 | gradient_style = true; executed: gradient_style = true; Execution Count:20 | 20 |
619 | | - |
620 | if (s.version() < QDataStream::Qt_4_0 && gradient_style) evaluated: s.version() < QDataStream::Qt_4_0 yes Evaluation Count:569 | yes Evaluation Count:984 |
evaluated: gradient_style yes Evaluation Count:8 | yes Evaluation Count:561 |
| 8-984 |
621 | style = Qt::NoBrush; executed: style = Qt::NoBrush; Execution Count:8 | 8 |
622 | | - |
623 | s << style << b.color(); | - |
624 | if (b.style() == Qt::TexturePattern) { partially evaluated: b.style() == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:1553 |
| 0-1553 |
625 | s << b.texture(); | - |
626 | } else if (s.version() >= QDataStream::Qt_4_0 && gradient_style) { evaluated: s.version() >= QDataStream::Qt_4_0 yes Evaluation Count:984 | yes Evaluation Count:569 |
evaluated: gradient_style yes Evaluation Count:12 | yes Evaluation Count:972 |
| 0-984 |
627 | const QGradient *gradient = b.gradient(); | - |
628 | int type_as_int = int(gradient->type()); | - |
629 | s << type_as_int; | - |
630 | if (s.version() >= QDataStream::Qt_4_3) { evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:10 | yes Evaluation Count:2 |
| 2-10 |
631 | s << int(gradient->spread()); | - |
632 | s << int(gradient->coordinateMode()); | - |
633 | } executed: } Execution Count:10 | 10 |
634 | | - |
635 | if (s.version() >= QDataStream::Qt_4_5) evaluated: s.version() >= QDataStream::Qt_4_5 yes Evaluation Count:10 | yes Evaluation Count:2 |
| 2-10 |
636 | s << int(gradient->interpolationMode()); executed: s << int(gradient->interpolationMode()); Execution Count:10 | 10 |
637 | | - |
638 | if (sizeof(qreal) == sizeof(double)) { partially evaluated: sizeof(qreal) == sizeof(double) yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
639 | s << gradient->stops(); | - |
640 | } else { executed: } Execution Count:12 | 12 |
641 | | - |
642 | | - |
643 | | - |
644 | QVector<QGradientStop> stops = gradient->stops(); | - |
645 | s << quint32(stops.size()); | - |
646 | for (int i = 0; i < stops.size(); ++i) { never evaluated: i < stops.size() | 0 |
647 | const QGradientStop &stop = stops.at(i); | - |
648 | s << QPair<double, QColor>(double(stop.first), stop.second); | - |
649 | } | 0 |
650 | } | 0 |
651 | | - |
652 | if (gradient->type() == QGradient::LinearGradient) { evaluated: gradient->type() == QGradient::LinearGradient yes Evaluation Count:8 | yes Evaluation Count:4 |
| 4-8 |
653 | s << static_cast<const QLinearGradient *>(gradient)->start(); | - |
654 | s << static_cast<const QLinearGradient *>(gradient)->finalStop(); | - |
655 | } else if (gradient->type() == QGradient::RadialGradient) { executed: } Execution Count:8 evaluated: gradient->type() == QGradient::RadialGradient yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2-8 |
656 | s << static_cast<const QRadialGradient *>(gradient)->center(); | - |
657 | s << static_cast<const QRadialGradient *>(gradient)->focalPoint(); | - |
658 | s << (double) static_cast<const QRadialGradient *>(gradient)->radius(); | - |
659 | } else { executed: } Execution Count:2 | 2 |
660 | s << static_cast<const QConicalGradient *>(gradient)->center(); | - |
661 | s << (double) static_cast<const QConicalGradient *>(gradient)->angle(); | - |
662 | } executed: } Execution Count:2 | 2 |
663 | } | - |
664 | if (s.version() >= QDataStream::Qt_4_3) evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:777 | yes Evaluation Count:776 |
| 776-777 |
665 | s << b.transform(); executed: s << b.transform(); Execution Count:777 | 777 |
666 | return s; executed: return s; Execution Count:1553 | 1553 |
667 | } | - |
668 | QDataStream &operator>>(QDataStream &s, QBrush &b) | - |
669 | { | - |
670 | quint8 style; | - |
671 | QColor color; | - |
672 | s >> style; | - |
673 | s >> color; | - |
674 | if (style == Qt::TexturePattern) { partially evaluated: style == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:1524 |
| 0-1524 |
675 | QPixmap pm; | - |
676 | s >> pm; | - |
677 | b = QBrush(color, pm); | - |
678 | } else if (style == Qt::LinearGradientPattern evaluated: style == Qt::LinearGradientPattern yes Evaluation Count:8 | yes Evaluation Count:1516 |
| 0-1516 |
679 | || style == Qt::RadialGradientPattern evaluated: style == Qt::RadialGradientPattern yes Evaluation Count:3 | yes Evaluation Count:1513 |
| 3-1513 |
680 | || style == Qt::ConicalGradientPattern) { evaluated: style == Qt::ConicalGradientPattern yes Evaluation Count:3 | yes Evaluation Count:1510 |
| 3-1510 |
681 | | - |
682 | int type_as_int; | - |
683 | QGradient::Type type; | - |
684 | QGradientStops stops; | - |
685 | QGradient::CoordinateMode cmode = QGradient::LogicalMode; | - |
686 | QGradient::Spread spread = QGradient::PadSpread; | - |
687 | QGradient::InterpolationMode imode = QGradient::ColorInterpolation; | - |
688 | | - |
689 | s >> type_as_int; | - |
690 | type = QGradient::Type(type_as_int); | - |
691 | if (s.version() >= QDataStream::Qt_4_3) { evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:10 | yes Evaluation Count:4 |
| 4-10 |
692 | s >> type_as_int; | - |
693 | spread = QGradient::Spread(type_as_int); | - |
694 | s >> type_as_int; | - |
695 | cmode = QGradient::CoordinateMode(type_as_int); | - |
696 | } executed: } Execution Count:10 | 10 |
697 | | - |
698 | if (s.version() >= QDataStream::Qt_4_5) { evaluated: s.version() >= QDataStream::Qt_4_5 yes Evaluation Count:10 | yes Evaluation Count:4 |
| 4-10 |
699 | s >> type_as_int; | - |
700 | imode = QGradient::InterpolationMode(type_as_int); | - |
701 | } executed: } Execution Count:10 | 10 |
702 | | - |
703 | if (sizeof(qreal) == sizeof(double)) { partially evaluated: sizeof(qreal) == sizeof(double) yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
704 | s >> stops; | - |
705 | } else { executed: } Execution Count:14 | 14 |
706 | quint32 numStops; | - |
707 | double n; | - |
708 | QColor c; | - |
709 | | - |
710 | s >> numStops; | - |
711 | for (quint32 i = 0; i < numStops; ++i) { never evaluated: i < numStops | 0 |
712 | s >> n >> c; | - |
713 | stops << QPair<qreal, QColor>(n, c); | - |
714 | } | 0 |
715 | } | 0 |
716 | | - |
717 | if (type == QGradient::LinearGradient) { evaluated: type == QGradient::LinearGradient yes Evaluation Count:8 | yes Evaluation Count:6 |
| 6-8 |
718 | QPointF p1, p2; | - |
719 | s >> p1; | - |
720 | s >> p2; | - |
721 | QLinearGradient lg(p1, p2); | - |
722 | lg.setStops(stops); | - |
723 | lg.setSpread(spread); | - |
724 | lg.setCoordinateMode(cmode); | - |
725 | lg.setInterpolationMode(imode); | - |
726 | b = QBrush(lg); | - |
727 | } else if (type == QGradient::RadialGradient) { executed: } Execution Count:8 evaluated: type == QGradient::RadialGradient yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-8 |
728 | QPointF center, focal; | - |
729 | double radius; | - |
730 | s >> center; | - |
731 | s >> focal; | - |
732 | s >> radius; | - |
733 | QRadialGradient rg(center, radius, focal); | - |
734 | rg.setStops(stops); | - |
735 | rg.setSpread(spread); | - |
736 | rg.setCoordinateMode(cmode); | - |
737 | rg.setInterpolationMode(imode); | - |
738 | b = QBrush(rg); | - |
739 | } else { executed: } Execution Count:3 | 3 |
740 | QPointF center; | - |
741 | double angle; | - |
742 | s >> center; | - |
743 | s >> angle; | - |
744 | QConicalGradient cg(center, angle); | - |
745 | cg.setStops(stops); | - |
746 | cg.setSpread(spread); | - |
747 | cg.setCoordinateMode(cmode); | - |
748 | cg.setInterpolationMode(imode); | - |
749 | b = QBrush(cg); | - |
750 | } executed: } Execution Count:3 | 3 |
751 | } else { | - |
752 | b = QBrush(color, (Qt::BrushStyle)style); | - |
753 | } executed: } Execution Count:1510 | 1510 |
754 | if (s.version() >= QDataStream::Qt_4_3) { evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:745 | yes Evaluation Count:779 |
| 745-779 |
755 | QTransform transform; | - |
756 | s >> transform; | - |
757 | b.setTransform(transform); | - |
758 | } executed: } Execution Count:745 | 745 |
759 | return s; executed: return s; Execution Count:1524 | 1524 |
760 | } | - |
761 | QGradient::QGradient() | - |
762 | : m_type(NoGradient), dummy(0) | - |
763 | { | - |
764 | } executed: } Execution Count:33850 | 33850 |
765 | void QGradient::setColorAt(qreal pos, const QColor &color) | - |
766 | { | - |
767 | if ((pos > 1 || pos < 0) && !qIsNaN(pos)) { partially evaluated: pos > 1 no Evaluation Count:0 | yes Evaluation Count:34150 |
partially evaluated: pos < 0 no Evaluation Count:0 | yes Evaluation Count:34160 |
never evaluated: !qIsNaN(pos) | 0-34160 |
768 | QMessageLogger("painting/qbrush.cpp", 1348, __PRETTY_FUNCTION__).warning("QGradient::setColorAt: Color position must be specified in the range 0 to 1"); | - |
769 | return; | 0 |
770 | } | - |
771 | | - |
772 | int index = 0; | - |
773 | if (!qIsNaN(pos)) evaluated: !qIsNaN(pos) yes Evaluation Count:34156 | yes Evaluation Count:1 |
| 1-34156 |
774 | while (index < m_stops.size() && m_stops.at(index).first < pos) ++index; executed: ++index; Execution Count:18082 evaluated: index < m_stops.size() yes Evaluation Count:18096 | yes Evaluation Count:34142 |
evaluated: m_stops.at(index).first < pos yes Evaluation Count:18086 | yes Evaluation Count:11 |
| 11-34142 |
775 | | - |
776 | if (index < m_stops.size() && m_stops.at(index).first == pos) evaluated: index < m_stops.size() yes Evaluation Count:11 | yes Evaluation Count:34144 |
evaluated: m_stops.at(index).first == pos yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-34144 |
777 | m_stops[index].second = color; executed: m_stops[index].second = color; Execution Count:2 | 2 |
778 | else | - |
779 | m_stops.insert(index, QGradientStop(pos, color)); executed: m_stops.insert(index, QGradientStop(pos, color)); Execution Count:34151 | 34151 |
780 | } | - |
781 | void QGradient::setStops(const QGradientStops &stops) | - |
782 | { | - |
783 | m_stops.clear(); | - |
784 | for (int i=0; i<stops.size(); ++i) evaluated: i<stops.size() yes Evaluation Count:54 | yes Evaluation Count:21 |
| 21-54 |
785 | setColorAt(stops.at(i).first, stops.at(i).second); executed: setColorAt(stops.at(i).first, stops.at(i).second); Execution Count:54 | 54 |
786 | } executed: } Execution Count:21 | 21 |
787 | QGradientStops QGradient::stops() const | - |
788 | { | - |
789 | if (m_stops.isEmpty()) { evaluated: m_stops.isEmpty() yes Evaluation Count:33 | yes Evaluation Count:59049 |
| 33-59049 |
790 | QGradientStops tmp; | - |
791 | tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white); | - |
792 | return tmp; executed: return tmp; Execution Count:33 | 33 |
793 | } | - |
794 | return m_stops; executed: return m_stops; Execution Count:59028 | 59028 |
795 | } | - |
796 | QGradient::CoordinateMode QGradient::coordinateMode() const | - |
797 | { | - |
798 | union {void *p; uint i;}; p = dummy; | - |
799 | return CoordinateMode(i & 0x03); executed: return CoordinateMode(i & 0x03); Execution Count:17529 | 17529 |
800 | } | - |
801 | | - |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | void QGradient::setCoordinateMode(CoordinateMode mode) | - |
809 | { | - |
810 | union {void *p; uint i;}; p = dummy; | - |
811 | i &= ~0x03; | - |
812 | i |= uint(mode); | - |
813 | dummy = p; | - |
814 | } executed: } Execution Count:28 | 28 |
815 | QGradient::InterpolationMode QGradient::interpolationMode() const | - |
816 | { | - |
817 | union {void *p; uint i;}; p = dummy; | - |
818 | return InterpolationMode((i >> 2) & 0x01); executed: return InterpolationMode((i >> 2) & 0x01); Execution Count:29580 | 29580 |
819 | } | - |
820 | void QGradient::setInterpolationMode(InterpolationMode mode) | - |
821 | { | - |
822 | union {void *p; uint i;}; p = dummy; | - |
823 | i &= ~(1 << 2); | - |
824 | i |= (uint(mode) << 2); | - |
825 | dummy = p; | - |
826 | } executed: } Execution Count:27 | 27 |
827 | bool QGradient::operator==(const QGradient &gradient) const | - |
828 | { | - |
829 | if (gradient.m_type != m_type partially evaluated: gradient.m_type != m_type no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
830 | || gradient.m_spread != m_spread partially evaluated: gradient.m_spread != m_spread no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
831 | || gradient.dummy != dummy) return false; never executed: return false; partially evaluated: gradient.dummy != dummy no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
832 | | - |
833 | if (m_type == LinearGradient) { evaluated: m_type == LinearGradient yes Evaluation Count:13 | yes Evaluation Count:6 |
| 6-13 |
834 | if (m_data.linear.x1 != gradient.m_data.linear.x1 evaluated: m_data.linear.x1 != gradient.m_data.linear.x1 yes Evaluation Count:1 | yes Evaluation Count:12 |
| 1-12 |
835 | || m_data.linear.y1 != gradient.m_data.linear.y1 partially evaluated: m_data.linear.y1 != gradient.m_data.linear.y1 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
836 | || m_data.linear.x2 != gradient.m_data.linear.x2 partially evaluated: m_data.linear.x2 != gradient.m_data.linear.x2 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
837 | || m_data.linear.y2 != gradient.m_data.linear.y2) partially evaluated: m_data.linear.y2 != gradient.m_data.linear.y2 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
838 | return false; executed: return false; Execution Count:1 | 1 |
839 | } else if (m_type == RadialGradient) { executed: } Execution Count:12 evaluated: m_type == RadialGradient yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-12 |
840 | if (m_data.radial.cx != gradient.m_data.radial.cx partially evaluated: m_data.radial.cx != gradient.m_data.radial.cx no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
841 | || m_data.radial.cy != gradient.m_data.radial.cy partially evaluated: m_data.radial.cy != gradient.m_data.radial.cy no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
842 | || m_data.radial.fx != gradient.m_data.radial.fx partially evaluated: m_data.radial.fx != gradient.m_data.radial.fx no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
843 | || m_data.radial.fy != gradient.m_data.radial.fy partially evaluated: m_data.radial.fy != gradient.m_data.radial.fy no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
844 | || m_data.radial.cradius != gradient.m_data.radial.cradius) partially evaluated: m_data.radial.cradius != gradient.m_data.radial.cradius no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
845 | return false; never executed: return false; | 0 |
846 | } else { executed: } Execution Count:3 | 3 |
847 | if (m_data.conical.cx != gradient.m_data.conical.cx partially evaluated: m_data.conical.cx != gradient.m_data.conical.cx no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
848 | || m_data.conical.cy != gradient.m_data.conical.cy partially evaluated: m_data.conical.cy != gradient.m_data.conical.cy no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
849 | || m_data.conical.angle != gradient.m_data.conical.angle) partially evaluated: m_data.conical.angle != gradient.m_data.conical.angle no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
850 | return false; never executed: return false; | 0 |
851 | } executed: } Execution Count:3 | 3 |
852 | | - |
853 | return stops() == gradient.stops(); executed: return stops() == gradient.stops(); Execution Count:18 | 18 |
854 | } | - |
855 | QLinearGradient::QLinearGradient() | - |
856 | { | - |
857 | m_type = LinearGradient; | - |
858 | m_spread = PadSpread; | - |
859 | m_data.linear.x1 = 0; | - |
860 | m_data.linear.y1 = 0; | - |
861 | m_data.linear.x2 = 1; | - |
862 | m_data.linear.y2 = 1; | - |
863 | } executed: } Execution Count:16019 | 16019 |
864 | QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop) | - |
865 | { | - |
866 | m_type = LinearGradient; | - |
867 | m_spread = PadSpread; | - |
868 | m_data.linear.x1 = start.x(); | - |
869 | m_data.linear.y1 = start.y(); | - |
870 | m_data.linear.x2 = finalStop.x(); | - |
871 | m_data.linear.y2 = finalStop.y(); | - |
872 | } executed: } Execution Count:88 | 88 |
873 | QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop) | - |
874 | { | - |
875 | m_type = LinearGradient; | - |
876 | m_spread = PadSpread; | - |
877 | m_data.linear.x1 = xStart; | - |
878 | m_data.linear.y1 = yStart; | - |
879 | m_data.linear.x2 = xFinalStop; | - |
880 | m_data.linear.y2 = yFinalStop; | - |
881 | } executed: } Execution Count:505 | 505 |
882 | QPointF QLinearGradient::start() const | - |
883 | { | - |
884 | qt_noop(); | - |
885 | return QPointF(m_data.linear.x1, m_data.linear.y1); executed: return QPointF(m_data.linear.x1, m_data.linear.y1); Execution Count:33425 | 33425 |
886 | } | - |
887 | void QLinearGradient::setStart(const QPointF &start) | - |
888 | { | - |
889 | qt_noop(); | - |
890 | m_data.linear.x1 = start.x(); | - |
891 | m_data.linear.y1 = start.y(); | - |
892 | } executed: } Execution Count:4 | 4 |
893 | QPointF QLinearGradient::finalStop() const | - |
894 | { | - |
895 | qt_noop(); | - |
896 | return QPointF(m_data.linear.x2, m_data.linear.y2); executed: return QPointF(m_data.linear.x2, m_data.linear.y2); Execution Count:33422 | 33422 |
897 | } | - |
898 | void QLinearGradient::setFinalStop(const QPointF &stop) | - |
899 | { | - |
900 | qt_noop(); | - |
901 | m_data.linear.x2 = stop.x(); | - |
902 | m_data.linear.y2 = stop.y(); | - |
903 | } executed: } Execution Count:4 | 4 |
904 | static QPointF qt_radial_gradient_adapt_focal_point(const QPointF ¢er, | - |
905 | qreal radius, | - |
906 | const QPointF &focalPoint) | - |
907 | { | - |
908 | | - |
909 | | - |
910 | | - |
911 | const qreal compensated_radius = radius - radius * qreal(0.001); | - |
912 | QLineF line(center, focalPoint); | - |
913 | if (line.length() > (compensated_radius)) partially evaluated: line.length() > (compensated_radius) no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
914 | line.setLength(compensated_radius); never executed: line.setLength(compensated_radius); | 0 |
915 | return line.p2(); executed: return line.p2(); Execution Count:10 | 10 |
916 | } | - |
917 | QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius, const QPointF &focalPoint) | - |
918 | { | - |
919 | m_type = RadialGradient; | - |
920 | m_spread = PadSpread; | - |
921 | m_data.radial.cx = center.x(); | - |
922 | m_data.radial.cy = center.y(); | - |
923 | m_data.radial.cradius = radius; | - |
924 | | - |
925 | QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(center, radius, focalPoint); | - |
926 | m_data.radial.fx = adapted_focal.x(); | - |
927 | m_data.radial.fy = adapted_focal.y(); | - |
928 | } executed: } Execution Count:3 | 3 |
929 | | - |
930 | | - |
931 | | - |
932 | | - |
933 | | - |
934 | | - |
935 | | - |
936 | QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius) | - |
937 | { | - |
938 | m_type = RadialGradient; | - |
939 | m_spread = PadSpread; | - |
940 | m_data.radial.cx = center.x(); | - |
941 | m_data.radial.cy = center.y(); | - |
942 | m_data.radial.cradius = radius; | - |
943 | m_data.radial.fx = center.x(); | - |
944 | m_data.radial.fy = center.y(); | - |
945 | } executed: } Execution Count:250 | 250 |
946 | QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy) | - |
947 | { | - |
948 | m_type = RadialGradient; | - |
949 | m_spread = PadSpread; | - |
950 | m_data.radial.cx = cx; | - |
951 | m_data.radial.cy = cy; | - |
952 | m_data.radial.cradius = radius; | - |
953 | | - |
954 | QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy), | - |
955 | radius, | - |
956 | QPointF(fx, fy)); | - |
957 | | - |
958 | m_data.radial.fx = adapted_focal.x(); | - |
959 | m_data.radial.fy = adapted_focal.y(); | - |
960 | } executed: } Execution Count:7 | 7 |
961 | | - |
962 | | - |
963 | | - |
964 | | - |
965 | | - |
966 | | - |
967 | | - |
968 | QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius) | - |
969 | { | - |
970 | m_type = RadialGradient; | - |
971 | m_spread = PadSpread; | - |
972 | m_data.radial.cx = cx; | - |
973 | m_data.radial.cy = cy; | - |
974 | m_data.radial.cradius = radius; | - |
975 | m_data.radial.fx = cx; | - |
976 | m_data.radial.fy = cy; | - |
977 | } executed: } Execution Count:3 | 3 |
978 | | - |
979 | | - |
980 | | - |
981 | | - |
982 | | - |
983 | | - |
984 | QRadialGradient::QRadialGradient() | - |
985 | { | - |
986 | m_type = RadialGradient; | - |
987 | m_spread = PadSpread; | - |
988 | m_data.radial.cx = 0; | - |
989 | m_data.radial.cy = 0; | - |
990 | m_data.radial.cradius = 1; | - |
991 | m_data.radial.fx = 0; | - |
992 | m_data.radial.fy = 0; | - |
993 | } executed: } Execution Count:1 | 1 |
994 | | - |
995 | | - |
996 | | - |
997 | | - |
998 | | - |
999 | | - |
1000 | | - |
1001 | QRadialGradient::QRadialGradient(const QPointF ¢er, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius) | - |
1002 | { | - |
1003 | m_type = RadialGradient; | - |
1004 | m_spread = PadSpread; | - |
1005 | m_data.radial.cx = center.x(); | - |
1006 | m_data.radial.cy = center.y(); | - |
1007 | m_data.radial.cradius = centerRadius; | - |
1008 | | - |
1009 | m_data.radial.fx = focalPoint.x(); | - |
1010 | m_data.radial.fy = focalPoint.y(); | - |
1011 | setFocalRadius(focalRadius); | - |
1012 | } | 0 |
1013 | QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius) | - |
1014 | { | - |
1015 | m_type = RadialGradient; | - |
1016 | m_spread = PadSpread; | - |
1017 | m_data.radial.cx = cx; | - |
1018 | m_data.radial.cy = cy; | - |
1019 | m_data.radial.cradius = centerRadius; | - |
1020 | | - |
1021 | m_data.radial.fx = fx; | - |
1022 | m_data.radial.fy = fy; | - |
1023 | setFocalRadius(focalRadius); | - |
1024 | } | 0 |
1025 | | - |
1026 | | - |
1027 | | - |
1028 | | - |
1029 | | - |
1030 | | - |
1031 | | - |
1032 | QPointF QRadialGradient::center() const | - |
1033 | { | - |
1034 | qt_noop(); | - |
1035 | return QPointF(m_data.radial.cx, m_data.radial.cy); executed: return QPointF(m_data.radial.cx, m_data.radial.cy); Execution Count:1025 | 1025 |
1036 | } | - |
1037 | void QRadialGradient::setCenter(const QPointF ¢er) | - |
1038 | { | - |
1039 | qt_noop(); | - |
1040 | m_data.radial.cx = center.x(); | - |
1041 | m_data.radial.cy = center.y(); | - |
1042 | } executed: } Execution Count:2 | 2 |
1043 | qreal QRadialGradient::radius() const | - |
1044 | { | - |
1045 | qt_noop(); | - |
1046 | return m_data.radial.cradius; executed: return m_data.radial.cradius; Execution Count:1024 | 1024 |
1047 | } | - |
1048 | void QRadialGradient::setRadius(qreal radius) | - |
1049 | { | - |
1050 | qt_noop(); | - |
1051 | m_data.radial.cradius = radius; | - |
1052 | } executed: } Execution Count:1 | 1 |
1053 | qreal QRadialGradient::centerRadius() const | - |
1054 | { | - |
1055 | qt_noop(); | - |
1056 | return m_data.radial.cradius; executed: return m_data.radial.cradius; Execution Count:506 | 506 |
1057 | } | - |
1058 | | - |
1059 | | - |
1060 | | - |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | | - |
1065 | void QRadialGradient::setCenterRadius(qreal radius) | - |
1066 | { | - |
1067 | qt_noop(); | - |
1068 | m_data.radial.cradius = radius; | - |
1069 | } | 0 |
1070 | qreal QRadialGradient::focalRadius() const | - |
1071 | { | - |
1072 | qt_noop(); | - |
1073 | union {void *p; uint i;}; p = dummy; | - |
1074 | | - |
1075 | | - |
1076 | union { float f; quint32 i; } u; | - |
1077 | u.i = i & ~0x07; | - |
1078 | return u.f; executed: return u.f; Execution Count:1012 | 1012 |
1079 | } | - |
1080 | | - |
1081 | | - |
1082 | | - |
1083 | | - |
1084 | | - |
1085 | | - |
1086 | | - |
1087 | void QRadialGradient::setFocalRadius(qreal radius) | - |
1088 | { | - |
1089 | qt_noop(); | - |
1090 | union {void *p; uint i;}; p = dummy; | - |
1091 | | - |
1092 | | - |
1093 | | - |
1094 | | - |
1095 | | - |
1096 | union { float f; quint32 i; } u; | - |
1097 | u.f = float(radius); | - |
1098 | | - |
1099 | i |= (u.i + 0x04) & ~0x07; | - |
1100 | dummy = p; | - |
1101 | } | 0 |
1102 | QPointF QRadialGradient::focalPoint() const | - |
1103 | { | - |
1104 | qt_noop(); | - |
1105 | return QPointF(m_data.radial.fx, m_data.radial.fy); executed: return QPointF(m_data.radial.fx, m_data.radial.fy); Execution Count:1025 | 1025 |
1106 | } | - |
1107 | void QRadialGradient::setFocalPoint(const QPointF &focalPoint) | - |
1108 | { | - |
1109 | qt_noop(); | - |
1110 | m_data.radial.fx = focalPoint.x(); | - |
1111 | m_data.radial.fy = focalPoint.y(); | - |
1112 | } executed: } Execution Count:2 | 2 |
1113 | QConicalGradient::QConicalGradient(const QPointF ¢er, qreal angle) | - |
1114 | { | - |
1115 | m_type = ConicalGradient; | - |
1116 | m_spread = PadSpread; | - |
1117 | m_data.conical.cx = center.x(); | - |
1118 | m_data.conical.cy = center.y(); | - |
1119 | m_data.conical.angle = angle; | - |
1120 | } executed: } Execution Count:3 | 3 |
1121 | QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle) | - |
1122 | { | - |
1123 | m_type = ConicalGradient; | - |
1124 | m_spread = PadSpread; | - |
1125 | m_data.conical.cx = cx; | - |
1126 | m_data.conical.cy = cy; | - |
1127 | m_data.conical.angle = angle; | - |
1128 | } executed: } Execution Count:4 | 4 |
1129 | QConicalGradient::QConicalGradient() | - |
1130 | { | - |
1131 | m_type = ConicalGradient; | - |
1132 | m_spread = PadSpread; | - |
1133 | m_data.conical.cx = 0; | - |
1134 | m_data.conical.cy = 0; | - |
1135 | m_data.conical.angle = 0; | - |
1136 | } executed: } Execution Count:1 | 1 |
1137 | QPointF QConicalGradient::center() const | - |
1138 | { | - |
1139 | qt_noop(); | - |
1140 | return QPointF(m_data.conical.cx, m_data.conical.cy); executed: return QPointF(m_data.conical.cx, m_data.conical.cy); Execution Count:13 | 13 |
1141 | } | - |
1142 | void QConicalGradient::setCenter(const QPointF ¢er) | - |
1143 | { | - |
1144 | qt_noop(); | - |
1145 | m_data.conical.cx = center.x(); | - |
1146 | m_data.conical.cy = center.y(); | - |
1147 | } executed: } Execution Count:2 | 2 |
1148 | qreal QConicalGradient::angle() const | - |
1149 | { | - |
1150 | qt_noop(); | - |
1151 | return m_data.conical.angle; executed: return m_data.conical.angle; Execution Count:12 | 12 |
1152 | } | - |
1153 | void QConicalGradient::setAngle(qreal angle) | - |
1154 | { | - |
1155 | qt_noop(); | - |
1156 | m_data.conical.angle = angle; | - |
1157 | } executed: } Execution Count:1 | 1 |
1158 | | - |
1159 | | - |
| | |