qbrush.cpp

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

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