Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qbrush.h" | - |
43 | #include "qpixmap.h" | - |
44 | #include "qbitmap.h" | - |
45 | #include "qpixmapcache.h" | - |
46 | #include "qdatastream.h" | - |
47 | #include "qvariant.h" | - |
48 | #include "qline.h" | - |
49 | #include "qdebug.h" | - |
50 | #include <QtCore/qcoreapplication.h> | - |
51 | #include "private/qhexstring_p.h" | - |
52 | #include <QtCore/qnumeric.h> | - |
53 | | - |
54 | QT_BEGIN_NAMESPACE | - |
55 | | - |
56 | const uchar *qt_patternForBrush(int brushStyle, bool invert) | - |
57 | { | - |
58 | Q_ASSERT(brushStyle > Qt::SolidPattern && brushStyle < Qt::LinearGradientPattern); executed (the execution status of this line is deduced): qt_noop(); | - |
59 | if(invert) { evaluated: invert yes Evaluation Count:715 | yes Evaluation Count:715 |
| 715 |
60 | static const uchar dense1_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff }; | - |
61 | static const uchar dense2_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff }; | - |
62 | static const uchar dense3_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee }; | - |
63 | static const uchar dense4_pat[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }; | - |
64 | static const uchar dense5_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 }; | - |
65 | static const uchar dense6_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }; | - |
66 | static const uchar dense7_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 }; | - |
67 | static const uchar hor_pat[] = { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }; | - |
68 | static const uchar ver_pat[] = { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }; | - |
69 | static const uchar cross_pat[] = { 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10 }; | - |
70 | static const uchar bdiag_pat[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; | - |
71 | static const uchar fdiag_pat[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; | - |
72 | static const uchar dcross_pat[] = { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }; | - |
73 | static const uchar *const pat_tbl[] = { | - |
74 | dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat, | - |
75 | dense6_pat, dense7_pat, | - |
76 | hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat }; | - |
77 | return pat_tbl[brushStyle - Qt::Dense1Pattern]; executed: return pat_tbl[brushStyle - Qt::Dense1Pattern]; Execution Count:715 | 715 |
78 | } | - |
79 | static const uchar dense1_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 }; | - |
80 | static const uchar dense2_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }; | - |
81 | static const uchar dense3_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 }; | - |
82 | static const uchar dense4_pat[] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }; | - |
83 | static const uchar dense5_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee }; | - |
84 | static const uchar dense6_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff }; | - |
85 | static const uchar dense7_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff }; | - |
86 | static const uchar hor_pat[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff }; | - |
87 | static const uchar ver_pat[] = { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef }; | - |
88 | static const uchar cross_pat[] = { 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef, 0xef }; | - |
89 | static const uchar bdiag_pat[] = { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe }; | - |
90 | static const uchar fdiag_pat[] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f }; | - |
91 | static const uchar dcross_pat[] = { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e }; | - |
92 | static const uchar *const pat_tbl[] = { | - |
93 | dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat, | - |
94 | dense6_pat, dense7_pat, | - |
95 | hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat }; | - |
96 | return pat_tbl[brushStyle - Qt::Dense1Pattern]; executed: return pat_tbl[brushStyle - Qt::Dense1Pattern]; Execution Count:715 | 715 |
97 | } | - |
98 | | - |
99 | QPixmap qt_pixmapForBrush(int brushStyle, bool invert) | - |
100 | { | - |
101 | | - |
102 | QPixmap pm; never executed (the execution status of this line is deduced): QPixmap pm; | - |
103 | QString key = QLatin1String("$qt-brush$") never executed (the execution status of this line is deduced): QString key = QLatin1String("$qt-brush$") | - |
104 | % HexString<uint>(brushStyle) never executed (the execution status of this line is deduced): % HexString<uint>(brushStyle) | - |
105 | % QLatin1Char(invert ? '1' : '0'); never executed (the execution status of this line is deduced): % QLatin1Char(invert ? '1' : '0'); | - |
106 | if (!QPixmapCache::find(key, pm)) { never evaluated: !QPixmapCache::find(key, pm) | 0 |
107 | pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert), never executed (the execution status of this line is deduced): pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert), | - |
108 | QImage::Format_MonoLSB); never executed (the execution status of this line is deduced): QImage::Format_MonoLSB); | - |
109 | QPixmapCache::insert(key, pm); never executed (the execution status of this line is deduced): QPixmapCache::insert(key, pm); | - |
110 | } | 0 |
111 | | - |
112 | return pm; never executed: return pm; | 0 |
113 | } | - |
114 | | - |
115 | static void qt_cleanup_brush_pattern_image_cache(); | - |
116 | class QBrushPatternImageCache | - |
117 | { | - |
118 | public: | - |
119 | QBrushPatternImageCache() | - |
120 | : m_initialized(false) | - |
121 | { | - |
122 | init(); executed (the execution status of this line is deduced): init(); | - |
123 | } executed: } Execution Count:55 | 55 |
124 | | - |
125 | void init() | - |
126 | { | - |
127 | qAddPostRoutine(qt_cleanup_brush_pattern_image_cache); executed (the execution status of this line is deduced): qAddPostRoutine(qt_cleanup_brush_pattern_image_cache); | - |
128 | for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) { evaluated: style <= Qt::DiagCrossPattern yes Evaluation Count:715 | yes Evaluation Count:55 |
| 55-715 |
129 | int i = style - Qt::Dense1Pattern; executed (the execution status of this line is deduced): int i = style - Qt::Dense1Pattern; | - |
130 | m_images[i][0] = QImage(qt_patternForBrush(style, 0), 8, 8, 1, QImage::Format_MonoLSB); executed (the execution status of this line is deduced): m_images[i][0] = QImage(qt_patternForBrush(style, 0), 8, 8, 1, QImage::Format_MonoLSB); | - |
131 | m_images[i][1] = QImage(qt_patternForBrush(style, 1), 8, 8, 1, QImage::Format_MonoLSB); executed (the execution status of this line is deduced): m_images[i][1] = QImage(qt_patternForBrush(style, 1), 8, 8, 1, QImage::Format_MonoLSB); | - |
132 | } executed: } Execution Count:715 | 715 |
133 | m_initialized = true; executed (the execution status of this line is deduced): m_initialized = true; | - |
134 | } executed: } Execution Count:55 | 55 |
135 | | - |
136 | QImage getImage(int brushStyle, bool invert) const | - |
137 | { | - |
138 | Q_ASSERT(brushStyle >= Qt::Dense1Pattern && brushStyle <= Qt::DiagCrossPattern); executed (the execution status of this line is deduced): qt_noop(); | - |
139 | if (!m_initialized) partially evaluated: !m_initialized no Evaluation Count:0 | yes Evaluation Count:9554 |
| 0-9554 |
140 | const_cast<QBrushPatternImageCache*>(this)->init(); never executed: const_cast<QBrushPatternImageCache*>(this)->init(); | 0 |
141 | return m_images[brushStyle - Qt::Dense1Pattern][invert]; executed: return m_images[brushStyle - Qt::Dense1Pattern][invert]; Execution Count:9554 | 9554 |
142 | } | - |
143 | | - |
144 | void cleanup() { | - |
145 | for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) { evaluated: style <= Qt::DiagCrossPattern yes Evaluation Count:715 | yes Evaluation Count:55 |
| 55-715 |
146 | int i = style - Qt::Dense1Pattern; executed (the execution status of this line is deduced): int i = style - Qt::Dense1Pattern; | - |
147 | m_images[i][0] = QImage(); executed (the execution status of this line is deduced): m_images[i][0] = QImage(); | - |
148 | m_images[i][1] = QImage(); executed (the execution status of this line is deduced): m_images[i][1] = QImage(); | - |
149 | } executed: } Execution Count:715 | 715 |
150 | m_initialized = false; executed (the execution status of this line is deduced): m_initialized = false; | - |
151 | } executed: } Execution Count:55 | 55 |
152 | | - |
153 | private: | - |
154 | QImage m_images[Qt::DiagCrossPattern - Qt::Dense1Pattern + 1][2]; | - |
155 | bool m_initialized; | - |
156 | }; | - |
157 | | - |
158 | Q_GLOBAL_STATIC(QBrushPatternImageCache, qt_brushPatternImageCache) 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 |
159 | | - |
160 | static void qt_cleanup_brush_pattern_image_cache() | - |
161 | { | - |
162 | qt_brushPatternImageCache()->cleanup(); executed (the execution status of this line is deduced): qt_brushPatternImageCache()->cleanup(); | - |
163 | } executed: } Execution Count:55 | 55 |
164 | | - |
165 | Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert) | - |
166 | { | - |
167 | return qt_brushPatternImageCache()->getImage(brushStyle, invert); executed: return qt_brushPatternImageCache()->getImage(brushStyle, invert); Execution Count:9554 | 9554 |
168 | } | - |
169 | | - |
170 | struct QTexturedBrushData : public QBrushData | - |
171 | { | - |
172 | QTexturedBrushData() { | - |
173 | m_has_pixmap_texture = false; executed (the execution status of this line is deduced): m_has_pixmap_texture = false; | - |
174 | m_pixmap = 0; executed (the execution status of this line is deduced): m_pixmap = 0; | - |
175 | } executed: } Execution Count:89 | 89 |
176 | ~QTexturedBrushData() { | - |
177 | delete m_pixmap; executed (the execution status of this line is deduced): delete m_pixmap; | - |
178 | } executed: } Execution Count:89 | 89 |
179 | | - |
180 | void setPixmap(const QPixmap &pm) { | - |
181 | delete m_pixmap; executed (the execution status of this line is deduced): delete m_pixmap; | - |
182 | | - |
183 | if (pm.isNull()) { partially evaluated: pm.isNull() no Evaluation Count:0 | yes Evaluation Count:60 |
| 0-60 |
184 | m_pixmap = 0; never executed (the execution status of this line is deduced): m_pixmap = 0; | - |
185 | m_has_pixmap_texture = false; never executed (the execution status of this line is deduced): m_has_pixmap_texture = false; | - |
186 | } else { | 0 |
187 | m_pixmap = new QPixmap(pm); executed (the execution status of this line is deduced): m_pixmap = new QPixmap(pm); | - |
188 | m_has_pixmap_texture = true; executed (the execution status of this line is deduced): m_has_pixmap_texture = true; | - |
189 | } executed: } Execution Count:60 | 60 |
190 | | - |
191 | m_image = QImage(); executed (the execution status of this line is deduced): m_image = QImage(); | - |
192 | } executed: } Execution Count:60 | 60 |
193 | | - |
194 | void setImage(const QImage &image) { | - |
195 | m_image = image; executed (the execution status of this line is deduced): m_image = image; | - |
196 | delete m_pixmap; executed (the execution status of this line is deduced): delete m_pixmap; | - |
197 | m_pixmap = 0; executed (the execution status of this line is deduced): m_pixmap = 0; | - |
198 | m_has_pixmap_texture = false; executed (the execution status of this line is deduced): m_has_pixmap_texture = false; | - |
199 | } executed: } Execution Count:29 | 29 |
200 | | - |
201 | QPixmap &pixmap() { | - |
202 | if (!m_pixmap) { evaluated: !m_pixmap yes Evaluation Count:4 | yes Evaluation Count:100 |
| 4-100 |
203 | m_pixmap = new QPixmap(QPixmap::fromImage(m_image)); executed (the execution status of this line is deduced): m_pixmap = new QPixmap(QPixmap::fromImage(m_image)); | - |
204 | } executed: } Execution Count:4 | 4 |
205 | return *m_pixmap; executed: return *m_pixmap; Execution Count:104 | 104 |
206 | } | - |
207 | | - |
208 | QImage &image() { | - |
209 | 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 |
210 | m_image = m_pixmap->toImage(); executed: m_image = m_pixmap->toImage(); Execution Count:3 | 3 |
211 | return m_image; executed: return m_image; Execution Count:203 | 203 |
212 | } | - |
213 | | - |
214 | QPixmap *m_pixmap; | - |
215 | QImage m_image; | - |
216 | bool m_has_pixmap_texture; | - |
217 | }; | - |
218 | | - |
219 | // returns true if the brush has a pixmap (or bitmap) set as the | - |
220 | // brush texture, false otherwise | - |
221 | bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush) | - |
222 | { | - |
223 | if (brush.style() != Qt::TexturePattern) partially evaluated: brush.style() != Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:200 |
| 0-200 |
224 | return false; never executed: return false; | 0 |
225 | QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data()); executed (the execution status of this line is deduced): QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data()); | - |
226 | return tx_data->m_has_pixmap_texture; executed: return tx_data->m_has_pixmap_texture; Execution Count:200 | 200 |
227 | } | - |
228 | | - |
229 | struct QGradientBrushData : public QBrushData | - |
230 | { | - |
231 | QGradient gradient; | - |
232 | }; | - |
233 | | - |
234 | struct QBrushDataPointerDeleter | - |
235 | { | - |
236 | static inline void deleteData(QBrushData *d) | - |
237 | { | - |
238 | switch (d->style) { | - |
239 | case Qt::TexturePattern: | - |
240 | delete static_cast<QTexturedBrushData*>(d); executed (the execution status of this line is deduced): delete static_cast<QTexturedBrushData*>(d); | - |
241 | break; executed: break; Execution Count:89 | 89 |
242 | case Qt::LinearGradientPattern: | - |
243 | case Qt::RadialGradientPattern: | - |
244 | case Qt::ConicalGradientPattern: | - |
245 | delete static_cast<QGradientBrushData*>(d); executed (the execution status of this line is deduced): delete static_cast<QGradientBrushData*>(d); | - |
246 | break; executed: break; Execution Count:16966 | 16966 |
247 | default: | - |
248 | delete d; executed (the execution status of this line is deduced): delete d; | - |
249 | } executed: } Execution Count:370595 | 370595 |
250 | } executed: } Execution Count:387650 | 387650 |
251 | | - |
252 | static inline void cleanup(QBrushData *d) | - |
253 | { | - |
254 | 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 |
255 | deleteData(d); executed (the execution status of this line is deduced): deleteData(d); | - |
256 | } executed: } Execution Count:387651 | 387651 |
257 | } executed: } Execution Count:11204524 | 11204524 |
258 | }; | - |
259 | | - |
260 | /*! | - |
261 | \class QBrush | - |
262 | \ingroup painting | - |
263 | \ingroup shared | - |
264 | \inmodule QtGui | - |
265 | | - |
266 | \brief The QBrush class defines the fill pattern of shapes drawn | - |
267 | by QPainter. | - |
268 | | - |
269 | A brush has a style, a color, a gradient and a texture. | - |
270 | | - |
271 | The brush style() defines the fill pattern using the | - |
272 | Qt::BrushStyle enum. The default brush style is Qt::NoBrush | - |
273 | (depending on how you construct a brush). This style tells the | - |
274 | painter to not fill shapes. The standard style for filling is | - |
275 | Qt::SolidPattern. The style can be set when the brush is created | - |
276 | using the appropriate constructor, and in addition the setStyle() | - |
277 | function provides means for altering the style once the brush is | - |
278 | constructed. | - |
279 | | - |
280 | \image brush-styles.png Brush Styles | - |
281 | | - |
282 | The brush color() defines the color of the fill pattern. The color | - |
283 | can either be one of Qt's predefined colors, Qt::GlobalColor, or | - |
284 | any other custom QColor. The currently set color can be retrieved | - |
285 | and altered using the color() and setColor() functions, | - |
286 | respectively. | - |
287 | | - |
288 | The gradient() defines the gradient fill used when the current | - |
289 | style is either Qt::LinearGradientPattern, | - |
290 | Qt::RadialGradientPattern or Qt::ConicalGradientPattern. Gradient | - |
291 | brushes are created by giving a QGradient as a constructor | - |
292 | argument when creating the QBrush. Qt provides three different | - |
293 | gradients: QLinearGradient, QConicalGradient, and QRadialGradient | - |
294 | - all of which inherit QGradient. | - |
295 | | - |
296 | \snippet brush/gradientcreationsnippet.cpp 0 | - |
297 | | - |
298 | The texture() defines the pixmap used when the current style is | - |
299 | Qt::TexturePattern. You can create a brush with a texture by | - |
300 | providing the pixmap when the brush is created or by using | - |
301 | setTexture(). | - |
302 | | - |
303 | Note that applying setTexture() makes style() == | - |
304 | Qt::TexturePattern, regardless of previous style | - |
305 | settings. Also, calling setColor() will not make a difference if | - |
306 | the style is a gradient. The same is the case if the style is | - |
307 | Qt::TexturePattern style unless the current texture is a QBitmap. | - |
308 | | - |
309 | The isOpaque() function returns true if the brush is fully opaque | - |
310 | otherwise false. A brush is considered opaque if: | - |
311 | | - |
312 | \list | - |
313 | \li The alpha component of the color() is 255. | - |
314 | \li Its texture() does not have an alpha channel and is not a QBitmap. | - |
315 | \li The colors in the gradient() all have an alpha component that is 255. | - |
316 | \endlist | - |
317 | | - |
318 | \table 100% | - |
319 | \row | - |
320 | \li \inlineimage brush-outline.png Outlines | - |
321 | \li | - |
322 | | - |
323 | To specify the style and color of lines and outlines, use the | - |
324 | QPainter's \l {QPen}{pen} combined with Qt::PenStyle and | - |
325 | Qt::GlobalColor: | - |
326 | | - |
327 | \snippet code/src_gui_painting_qbrush.cpp 0 | - |
328 | | - |
329 | Note that, by default, QPainter renders the outline (using the | - |
330 | currently set pen) when drawing shapes. Use \l {Qt::NoPen}{\c | - |
331 | painter.setPen(Qt::NoPen)} to disable this behavior. | - |
332 | | - |
333 | \endtable | - |
334 | | - |
335 | For more information about painting in general, see the \l{Paint | - |
336 | System}. | - |
337 | | - |
338 | \sa Qt::BrushStyle, QPainter, QColor | - |
339 | */ | - |
340 | | - |
341 | class QNullBrushData | - |
342 | { | - |
343 | public: | - |
344 | QBrushData *brush; | - |
345 | QNullBrushData() : brush(new QBrushData) | - |
346 | { | - |
347 | brush->ref.store(1); executed (the execution status of this line is deduced): brush->ref.store(1); | - |
348 | brush->style = Qt::BrushStyle(0); executed (the execution status of this line is deduced): brush->style = Qt::BrushStyle(0); | - |
349 | brush->color = Qt::black; executed (the execution status of this line is deduced): brush->color = Qt::black; | - |
350 | } executed: } Execution Count:151 | 151 |
351 | ~QNullBrushData() | - |
352 | { | - |
353 | if (!brush->ref.deref()) evaluated: !brush->ref.deref() yes Evaluation Count:125 | yes Evaluation Count:26 |
| 26-125 |
354 | delete brush; executed: delete brush; Execution Count:125 | 125 |
355 | brush = 0; executed (the execution status of this line is deduced): brush = 0; | - |
356 | } executed: } Execution Count:151 | 151 |
357 | }; | - |
358 | | - |
359 | Q_GLOBAL_STATIC(QNullBrushData, nullBrushInstance_holder) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:5099993 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 |
| 0-5099993 |
360 | static QBrushData *nullBrushInstance() | - |
361 | { | - |
362 | return nullBrushInstance_holder()->brush; executed: return nullBrushInstance_holder()->brush; Execution Count:5099993 | 5099993 |
363 | } | - |
364 | | - |
365 | static bool qbrush_check_type(Qt::BrushStyle style) { | - |
366 | switch (style) { | - |
367 | case Qt::TexturePattern: | - |
368 | qWarning("QBrush: Incorrect use of TexturePattern"); executed (the execution status of this line is deduced): QMessageLogger("painting/qbrush.cpp", 368, __PRETTY_FUNCTION__).warning("QBrush: Incorrect use of TexturePattern"); | - |
369 | break; executed: break; Execution Count:4 | 4 |
370 | case Qt::LinearGradientPattern: | - |
371 | case Qt::RadialGradientPattern: | - |
372 | case Qt::ConicalGradientPattern: | - |
373 | qWarning("QBrush: Wrong use of a gradient pattern"); executed (the execution status of this line is deduced): QMessageLogger("painting/qbrush.cpp", 373, __PRETTY_FUNCTION__).warning("QBrush: Wrong use of a gradient pattern"); | - |
374 | break; executed: break; Execution Count:12 | 12 |
375 | default: | - |
376 | return true; executed: return true; Execution Count:375302 | 375302 |
377 | } | - |
378 | return false; executed: return false; Execution Count:16 | 16 |
379 | } | - |
380 | | - |
381 | /*! | - |
382 | \internal | - |
383 | Initializes the brush. | - |
384 | */ | - |
385 | | - |
386 | void QBrush::init(const QColor &color, Qt::BrushStyle style) | - |
387 | { | - |
388 | switch(style) { | - |
389 | case Qt::NoBrush: | - |
390 | d.reset(nullBrushInstance()); executed (the execution status of this line is deduced): d.reset(nullBrushInstance()); | - |
391 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
392 | if (d->color != color) setColor(color); executed: setColor(color); Execution Count:27 evaluated: d->color != color yes Evaluation Count:27 | yes Evaluation Count:4117 |
| 27-4117 |
393 | return; executed: return; Execution Count:4144 | 4144 |
394 | case Qt::TexturePattern: | - |
395 | d.reset(new QTexturedBrushData); executed (the execution status of this line is deduced): d.reset(new QTexturedBrushData); | - |
396 | break; executed: break; Execution Count:85 | 85 |
397 | case Qt::LinearGradientPattern: | - |
398 | case Qt::RadialGradientPattern: | - |
399 | case Qt::ConicalGradientPattern: | - |
400 | d.reset(new QGradientBrushData); executed (the execution status of this line is deduced): d.reset(new QGradientBrushData); | - |
401 | break; executed: break; Execution Count:16967 | 16967 |
402 | default: | - |
403 | d.reset(new QBrushData); executed (the execution status of this line is deduced): d.reset(new QBrushData); | - |
404 | break; executed: break; Execution Count:371158 | 371158 |
405 | } | - |
406 | d->ref.store(1); executed (the execution status of this line is deduced): d->ref.store(1); | - |
407 | d->style = style; executed (the execution status of this line is deduced): d->style = style; | - |
408 | d->color = color; executed (the execution status of this line is deduced): d->color = color; | - |
409 | } executed: } Execution Count:388209 | 388209 |
410 | | - |
411 | /*! | - |
412 | Constructs a default black brush with the style Qt::NoBrush | - |
413 | (i.e. this brush will not fill shapes). | - |
414 | */ | - |
415 | | - |
416 | QBrush::QBrush() | - |
417 | : d(nullBrushInstance()) | - |
418 | { | - |
419 | Q_ASSERT(d); executed (the execution status of this line is deduced): qt_noop(); | - |
420 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
421 | } executed: } Execution Count:5095837 | 5095837 |
422 | | - |
423 | /*! | - |
424 | Constructs a brush with a black color and a texture set to the | - |
425 | given \a pixmap. The style is set to Qt::TexturePattern. | - |
426 | | - |
427 | \sa setTexture() | - |
428 | */ | - |
429 | | - |
430 | QBrush::QBrush(const QPixmap &pixmap) | - |
431 | { | - |
432 | init(Qt::black, Qt::TexturePattern); executed (the execution status of this line is deduced): init(Qt::black, Qt::TexturePattern); | - |
433 | setTexture(pixmap); executed (the execution status of this line is deduced): setTexture(pixmap); | - |
434 | } executed: } Execution Count:58 | 58 |
435 | | - |
436 | | - |
437 | /*! | - |
438 | Constructs a brush with a black color and a texture set to the | - |
439 | given \a image. The style is set to Qt::TexturePattern. | - |
440 | | - |
441 | \sa setTextureImage() | - |
442 | */ | - |
443 | | - |
444 | QBrush::QBrush(const QImage &image) | - |
445 | { | - |
446 | init(Qt::black, Qt::TexturePattern); executed (the execution status of this line is deduced): init(Qt::black, Qt::TexturePattern); | - |
447 | setTextureImage(image); executed (the execution status of this line is deduced): setTextureImage(image); | - |
448 | } executed: } Execution Count:27 | 27 |
449 | | - |
450 | /*! | - |
451 | Constructs a black brush with the given \a style. | - |
452 | | - |
453 | \sa setStyle() | - |
454 | */ | - |
455 | | - |
456 | QBrush::QBrush(Qt::BrushStyle style) | - |
457 | { | - |
458 | if (qbrush_check_type(style)) evaluated: qbrush_check_type(style) yes Evaluation Count:3776 | yes Evaluation Count:4 |
| 4-3776 |
459 | init(Qt::black, style); executed: init(Qt::black, style); Execution Count:3776 | 3776 |
460 | else { | - |
461 | d.reset(nullBrushInstance()); executed (the execution status of this line is deduced): d.reset(nullBrushInstance()); | - |
462 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
463 | } executed: } Execution Count:4 | 4 |
464 | } | - |
465 | | - |
466 | /*! | - |
467 | Constructs a brush with the given \a color and \a style. | - |
468 | | - |
469 | \sa setColor(), setStyle() | - |
470 | */ | - |
471 | | - |
472 | QBrush::QBrush(const QColor &color, Qt::BrushStyle style) | - |
473 | { | - |
474 | if (qbrush_check_type(style)) evaluated: qbrush_check_type(style) yes Evaluation Count:213038 | yes Evaluation Count:4 |
| 4-213038 |
475 | init(color, style); executed: init(color, style); Execution Count:213038 | 213038 |
476 | else { | - |
477 | d.reset(nullBrushInstance()); executed (the execution status of this line is deduced): d.reset(nullBrushInstance()); | - |
478 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
479 | } executed: } Execution Count:4 | 4 |
480 | } | - |
481 | | - |
482 | /*! | - |
483 | \fn QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style) | - |
484 | | - |
485 | Constructs a brush with the given \a color and \a style. | - |
486 | | - |
487 | \sa setColor(), setStyle() | - |
488 | */ | - |
489 | QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style) | - |
490 | { | - |
491 | if (qbrush_check_type(style)) evaluated: qbrush_check_type(style) yes Evaluation Count:158488 | yes Evaluation Count:4 |
| 4-158488 |
492 | init(color, style); executed: init(color, style); Execution Count:158488 | 158488 |
493 | else { | - |
494 | d.reset(nullBrushInstance()); executed (the execution status of this line is deduced): d.reset(nullBrushInstance()); | - |
495 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
496 | } executed: } Execution Count:4 | 4 |
497 | } | - |
498 | | - |
499 | /*! | - |
500 | Constructs a brush with the given \a color and the custom pattern | - |
501 | stored in \a pixmap. | - |
502 | | - |
503 | The style is set to Qt::TexturePattern. The color will only have | - |
504 | an effect for QBitmaps. | - |
505 | | - |
506 | \sa setColor(), setPixmap() | - |
507 | */ | - |
508 | | - |
509 | QBrush::QBrush(const QColor &color, const QPixmap &pixmap) | - |
510 | { | - |
511 | init(color, Qt::TexturePattern); never executed (the execution status of this line is deduced): init(color, Qt::TexturePattern); | - |
512 | setTexture(pixmap); never executed (the execution status of this line is deduced): setTexture(pixmap); | - |
513 | } | 0 |
514 | | - |
515 | /*! | - |
516 | | - |
517 | Constructs a brush with the given \a color and the custom pattern | - |
518 | stored in \a pixmap. | - |
519 | | - |
520 | The style is set to Qt::TexturePattern. The color will only have | - |
521 | an effect for QBitmaps. | - |
522 | | - |
523 | \sa setColor(), setPixmap() | - |
524 | */ | - |
525 | QBrush::QBrush(Qt::GlobalColor color, const QPixmap &pixmap) | - |
526 | { | - |
527 | init(color, Qt::TexturePattern); never executed (the execution status of this line is deduced): init(color, Qt::TexturePattern); | - |
528 | setTexture(pixmap); never executed (the execution status of this line is deduced): setTexture(pixmap); | - |
529 | } | 0 |
530 | | - |
531 | /*! | - |
532 | Constructs a copy of \a other. | - |
533 | */ | - |
534 | | - |
535 | QBrush::QBrush(const QBrush &other) | - |
536 | : d(other.d.data()) | - |
537 | { | - |
538 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
539 | } executed: } Execution Count:778119 | 778119 |
540 | | - |
541 | /*! | - |
542 | Constructs a brush based on the given \a gradient. | - |
543 | | - |
544 | The brush style is set to the corresponding gradient style (either | - |
545 | Qt::LinearGradientPattern, Qt::RadialGradientPattern or | - |
546 | Qt::ConicalGradientPattern). | - |
547 | */ | - |
548 | QBrush::QBrush(const QGradient &gradient) | - |
549 | { | - |
550 | Q_ASSERT_X(gradient.type() != QGradient::NoGradient, "QBrush::QBrush", executed (the execution status of this line is deduced): qt_noop(); | - |
551 | "QGradient should not be used directly, use the linear, radial\n" | - |
552 | "or conical gradients instead"); | - |
553 | | - |
554 | const Qt::BrushStyle enum_table[] = { executed (the execution status of this line is deduced): const Qt::BrushStyle enum_table[] = { | - |
555 | Qt::LinearGradientPattern, executed (the execution status of this line is deduced): Qt::LinearGradientPattern, | - |
556 | Qt::RadialGradientPattern, executed (the execution status of this line is deduced): Qt::RadialGradientPattern, | - |
557 | Qt::ConicalGradientPattern executed (the execution status of this line is deduced): Qt::ConicalGradientPattern | - |
558 | }; executed (the execution status of this line is deduced): }; | - |
559 | | - |
560 | init(QColor(), enum_table[gradient.type()]); executed (the execution status of this line is deduced): init(QColor(), enum_table[gradient.type()]); | - |
561 | QGradientBrushData *grad = static_cast<QGradientBrushData *>(d.data()); executed (the execution status of this line is deduced): QGradientBrushData *grad = static_cast<QGradientBrushData *>(d.data()); | - |
562 | grad->gradient = gradient; executed (the execution status of this line is deduced): grad->gradient = gradient; | - |
563 | } executed: } Execution Count:16967 | 16967 |
564 | | - |
565 | /*! | - |
566 | Destroys the brush. | - |
567 | */ | - |
568 | | - |
569 | QBrush::~QBrush() | - |
570 | { | - |
571 | } | - |
572 | | - |
573 | void QBrush::cleanUp(QBrushData *x) | - |
574 | { | - |
575 | QBrushDataPointerDeleter::deleteData(x); never executed (the execution status of this line is deduced): QBrushDataPointerDeleter::deleteData(x); | - |
576 | } | 0 |
577 | | - |
578 | | - |
579 | void QBrush::detach(Qt::BrushStyle newStyle) | - |
580 | { | - |
581 | 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 |
582 | return; executed: return; Execution Count:821 | 821 |
583 | | - |
584 | QScopedPointer<QBrushData> x; executed (the execution status of this line is deduced): QScopedPointer<QBrushData> x; | - |
585 | switch(newStyle) { | - |
586 | case Qt::TexturePattern: { | - |
587 | QTexturedBrushData *tbd = new QTexturedBrushData; executed (the execution status of this line is deduced): QTexturedBrushData *tbd = new QTexturedBrushData; | - |
588 | if (d->style == Qt::TexturePattern) { partially evaluated: d->style == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
589 | QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); never executed (the execution status of this line is deduced): QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); | - |
590 | if (data->m_has_pixmap_texture) never evaluated: data->m_has_pixmap_texture | 0 |
591 | tbd->setPixmap(data->pixmap()); never executed: tbd->setPixmap(data->pixmap()); | 0 |
592 | else | - |
593 | tbd->setImage(data->image()); never executed: tbd->setImage(data->image()); | 0 |
594 | } | - |
595 | x.reset(tbd); executed (the execution status of this line is deduced): x.reset(tbd); | - |
596 | break; executed: break; Execution Count:4 | 4 |
597 | } | - |
598 | case Qt::LinearGradientPattern: | - |
599 | case Qt::RadialGradientPattern: | - |
600 | case Qt::ConicalGradientPattern: | - |
601 | x.reset(new QGradientBrushData); executed (the execution status of this line is deduced): x.reset(new QGradientBrushData); | - |
602 | static_cast<QGradientBrushData *>(x.data())->gradient = executed (the execution status of this line is deduced): static_cast<QGradientBrushData *>(x.data())->gradient = | - |
603 | static_cast<QGradientBrushData *>(d.data())->gradient; executed (the execution status of this line is deduced): static_cast<QGradientBrushData *>(d.data())->gradient; | - |
604 | break; executed: break; Execution Count:4 | 4 |
605 | default: | - |
606 | x.reset(new QBrushData); executed (the execution status of this line is deduced): x.reset(new QBrushData); | - |
607 | break; executed: break; Execution Count:37 | 37 |
608 | } | - |
609 | x->ref.store(1); executed (the execution status of this line is deduced): x->ref.store(1); | - |
610 | x->style = newStyle; executed (the execution status of this line is deduced): x->style = newStyle; | - |
611 | x->color = d->color; executed (the execution status of this line is deduced): x->color = d->color; | - |
612 | x->transform = d->transform; executed (the execution status of this line is deduced): x->transform = d->transform; | - |
613 | d.reset(x.take()); executed (the execution status of this line is deduced): d.reset(x.take()); | - |
614 | } executed: } Execution Count:45 | 45 |
615 | | - |
616 | | - |
617 | /*! | - |
618 | \fn QBrush &QBrush::operator=(const QBrush &brush) | - |
619 | | - |
620 | Assigns the given \a brush to \e this brush and returns a | - |
621 | reference to \e this brush. | - |
622 | */ | - |
623 | | - |
624 | QBrush &QBrush::operator=(const QBrush &b) | - |
625 | { | - |
626 | if (d == b.d) evaluated: d == b.d yes Evaluation Count:456054 | yes Evaluation Count:4547676 |
| 456054-4547676 |
627 | return *this; executed: return *this; Execution Count:456054 | 456054 |
628 | | - |
629 | b.d->ref.ref(); executed (the execution status of this line is deduced): b.d->ref.ref(); | - |
630 | d.reset(b.d.data()); executed (the execution status of this line is deduced): d.reset(b.d.data()); | - |
631 | return *this; executed: return *this; Execution Count:4547690 | 4547690 |
632 | } | - |
633 | | - |
634 | | - |
635 | /*! | - |
636 | \fn void QBrush::swap(QBrush &other) | - |
637 | \since 4.8 | - |
638 | | - |
639 | Swaps brush \a other with this brush. This operation is very | - |
640 | fast and never fails. | - |
641 | */ | - |
642 | | - |
643 | /*! | - |
644 | Returns the brush as a QVariant | - |
645 | */ | - |
646 | QBrush::operator QVariant() const | - |
647 | { | - |
648 | return QVariant(QVariant::Brush, this); executed: return QVariant(QVariant::Brush, this); Execution Count:33550 | 33550 |
649 | } | - |
650 | | - |
651 | /*! | - |
652 | \fn Qt::BrushStyle QBrush::style() const | - |
653 | | - |
654 | Returns the brush style. | - |
655 | | - |
656 | \sa setStyle() | - |
657 | */ | - |
658 | | - |
659 | /*! | - |
660 | Sets the brush style to \a style. | - |
661 | | - |
662 | \sa style() | - |
663 | */ | - |
664 | | - |
665 | void QBrush::setStyle(Qt::BrushStyle style) | - |
666 | { | - |
667 | if (d->style == style) partially evaluated: d->style == style no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
668 | return; | 0 |
669 | | - |
670 | if (qbrush_check_type(style)) { partially evaluated: qbrush_check_type(style) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
671 | detach(style); never executed (the execution status of this line is deduced): detach(style); | - |
672 | d->style = style; never executed (the execution status of this line is deduced): d->style = style; | - |
673 | } | 0 |
674 | } executed: } Execution Count:4 | 4 |
675 | | - |
676 | | - |
677 | /*! | - |
678 | \fn const QColor &QBrush::color() const | - |
679 | | - |
680 | Returns the brush color. | - |
681 | | - |
682 | \sa setColor() | - |
683 | */ | - |
684 | | - |
685 | /*! | - |
686 | \fn void QBrush::setColor(const QColor &color) | - |
687 | | - |
688 | Sets the brush color to the given \a color. | - |
689 | | - |
690 | Note that calling setColor() will not make a difference if the | - |
691 | style is a gradient. The same is the case if the style is | - |
692 | Qt::TexturePattern style unless the current texture is a QBitmap. | - |
693 | | - |
694 | \sa color() | - |
695 | */ | - |
696 | | - |
697 | void QBrush::setColor(const QColor &c) | - |
698 | { | - |
699 | detach(d->style); executed (the execution status of this line is deduced): detach(d->style); | - |
700 | d->color = c; executed (the execution status of this line is deduced): d->color = c; | - |
701 | } executed: } Execution Count:27 | 27 |
702 | | - |
703 | /*! | - |
704 | \fn void QBrush::setColor(Qt::GlobalColor color) | - |
705 | \overload | - |
706 | | - |
707 | Sets the brush color to the given \a color. | - |
708 | */ | - |
709 | | - |
710 | /*! | - |
711 | \fn QPixmap QBrush::texture() const | - |
712 | | - |
713 | Returns the custom brush pattern, or a null pixmap if no custom brush pattern | - |
714 | has been set. | - |
715 | | - |
716 | \sa setTexture() | - |
717 | */ | - |
718 | QPixmap QBrush::texture() const | - |
719 | { | - |
720 | return d->style == Qt::TexturePattern executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap(); Execution Count:6574 | 6574 |
721 | ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap(); Execution Count:6574 | 6574 |
722 | : QPixmap(); executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap(); Execution Count:6574 | 6574 |
723 | } | - |
724 | | - |
725 | /*! | - |
726 | Sets the brush pixmap to \a pixmap. The style is set to | - |
727 | Qt::TexturePattern. | - |
728 | | - |
729 | The current brush color will only have an effect for monochrome | - |
730 | pixmaps, i.e. for QPixmap::depth() == 1 (\l {QBitmap}{QBitmaps}). | - |
731 | | - |
732 | \sa texture() | - |
733 | */ | - |
734 | | - |
735 | void QBrush::setTexture(const QPixmap &pixmap) | - |
736 | { | - |
737 | if (!pixmap.isNull()) { partially evaluated: !pixmap.isNull() yes Evaluation Count:60 | no Evaluation Count:0 |
| 0-60 |
738 | detach(Qt::TexturePattern); executed (the execution status of this line is deduced): detach(Qt::TexturePattern); | - |
739 | QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); executed (the execution status of this line is deduced): QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); | - |
740 | data->setPixmap(pixmap); executed (the execution status of this line is deduced): data->setPixmap(pixmap); | - |
741 | } else { executed: } Execution Count:60 | 60 |
742 | detach(Qt::NoBrush); never executed (the execution status of this line is deduced): detach(Qt::NoBrush); | - |
743 | } | 0 |
744 | } | - |
745 | | - |
746 | | - |
747 | /*! | - |
748 | \since 4.2 | - |
749 | | - |
750 | Returns the custom brush pattern, or a null image if no custom | - |
751 | brush pattern has been set. | - |
752 | | - |
753 | If the texture was set as a QPixmap it will be converted to a | - |
754 | QImage. | - |
755 | | - |
756 | \sa setTextureImage() | - |
757 | */ | - |
758 | | - |
759 | QImage QBrush::textureImage() const | - |
760 | { | - |
761 | return d->style == Qt::TexturePattern executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage(); Execution Count:203 | 203 |
762 | ? (static_cast<QTexturedBrushData *>(d.data()))->image() executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage(); Execution Count:203 | 203 |
763 | : QImage(); executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage(); Execution Count:203 | 203 |
764 | } | - |
765 | | - |
766 | | - |
767 | /*! | - |
768 | \since 4.2 | - |
769 | | - |
770 | Sets the brush image to \a image. The style is set to | - |
771 | Qt::TexturePattern. | - |
772 | | - |
773 | Note the current brush color will \e not have any affect on | - |
774 | monochrome images, as opposed to calling setTexture() with a | - |
775 | QBitmap. If you want to change the color of monochrome image | - |
776 | brushes, either convert the image to QBitmap with \c | - |
777 | QBitmap::fromImage() and set the resulting QBitmap as a texture, | - |
778 | or change the entries in the color table for the image. | - |
779 | | - |
780 | \sa textureImage(), setTexture() | - |
781 | */ | - |
782 | | - |
783 | void QBrush::setTextureImage(const QImage &image) | - |
784 | { | - |
785 | if (!image.isNull()) { partially evaluated: !image.isNull() yes Evaluation Count:29 | no Evaluation Count:0 |
| 0-29 |
786 | detach(Qt::TexturePattern); executed (the execution status of this line is deduced): detach(Qt::TexturePattern); | - |
787 | QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); executed (the execution status of this line is deduced): QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data()); | - |
788 | data->setImage(image); executed (the execution status of this line is deduced): data->setImage(image); | - |
789 | } else { executed: } Execution Count:29 | 29 |
790 | detach(Qt::NoBrush); never executed (the execution status of this line is deduced): detach(Qt::NoBrush); | - |
791 | } | 0 |
792 | } | - |
793 | | - |
794 | | - |
795 | /*! | - |
796 | Returns the gradient describing this brush. | - |
797 | */ | - |
798 | const QGradient *QBrush::gradient() const | - |
799 | { | - |
800 | if (d->style == Qt::LinearGradientPattern evaluated: d->style == Qt::LinearGradientPattern yes Evaluation Count:50416 | yes Evaluation Count:275458 |
| 50416-275458 |
801 | || d->style == Qt::RadialGradientPattern evaluated: d->style == Qt::RadialGradientPattern yes Evaluation Count:2051 | yes Evaluation Count:273407 |
| 2051-273407 |
802 | || d->style == Qt::ConicalGradientPattern) { evaluated: d->style == Qt::ConicalGradientPattern yes Evaluation Count:22 | yes Evaluation Count:273385 |
| 22-273385 |
803 | return &static_cast<const QGradientBrushData *>(d.data())->gradient; executed: return &static_cast<const QGradientBrushData *>(d.data())->gradient; Execution Count:52488 | 52488 |
804 | } | - |
805 | return 0; executed: return 0; Execution Count:273385 | 273385 |
806 | } | - |
807 | | - |
808 | Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush) | - |
809 | { | - |
810 | if (brush.style() == Qt::RadialGradientPattern) { evaluated: brush.style() == Qt::RadialGradientPattern yes Evaluation Count:506 | yes Evaluation Count:16716 |
| 506-16716 |
811 | const QGradient *g = brush.gradient(); executed (the execution status of this line is deduced): const QGradient *g = brush.gradient(); | - |
812 | const QRadialGradient *rg = static_cast<const QRadialGradient *>(g); executed (the execution status of this line is deduced): const QRadialGradient *rg = static_cast<const QRadialGradient *>(g); | - |
813 | | - |
814 | if (!qFuzzyIsNull(rg->focalRadius())) partially evaluated: !qFuzzyIsNull(rg->focalRadius()) no Evaluation Count:0 | yes Evaluation Count:506 |
| 0-506 |
815 | return true; never executed: return true; | 0 |
816 | | - |
817 | QPointF delta = rg->focalPoint() - rg->center(); executed (the execution status of this line is deduced): QPointF delta = rg->focalPoint() - rg->center(); | - |
818 | 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 |
819 | return true; never executed: return true; | 0 |
820 | } executed: } Execution Count:506 | 506 |
821 | | - |
822 | return false; executed: return false; Execution Count:17220 | 17220 |
823 | } | - |
824 | | - |
825 | /*! | - |
826 | Returns true if the brush is fully opaque otherwise false. A brush | - |
827 | is considered opaque if: | - |
828 | | - |
829 | \list | - |
830 | \li The alpha component of the color() is 255. | - |
831 | \li Its texture() does not have an alpha channel and is not a QBitmap. | - |
832 | \li The colors in the gradient() all have an alpha component that is 255. | - |
833 | \li It is an extended radial gradient. | - |
834 | \endlist | - |
835 | */ | - |
836 | | - |
837 | bool QBrush::isOpaque() const | - |
838 | { | - |
839 | bool opaqueColor = d->color.alpha() == 255; executed (the execution status of this line is deduced): bool opaqueColor = d->color.alpha() == 255; | - |
840 | | - |
841 | // Test awfully simple case first | - |
842 | if (d->style == Qt::SolidPattern) evaluated: d->style == Qt::SolidPattern yes Evaluation Count:34168 | yes Evaluation Count:17219 |
| 17219-34168 |
843 | return opaqueColor; executed: return opaqueColor; Execution Count:34168 | 34168 |
844 | | - |
845 | if (qt_isExtendedRadialGradient(*this)) partially evaluated: qt_isExtendedRadialGradient(*this) no Evaluation Count:0 | yes Evaluation Count:17219 |
| 0-17219 |
846 | return false; never executed: return false; | 0 |
847 | | - |
848 | if (d->style == Qt::LinearGradientPattern evaluated: d->style == Qt::LinearGradientPattern yes Evaluation Count:16705 | yes Evaluation Count:513 |
| 513-16705 |
849 | || d->style == Qt::RadialGradientPattern evaluated: d->style == Qt::RadialGradientPattern yes Evaluation Count:506 | yes Evaluation Count:7 |
| 7-506 |
850 | || d->style == Qt::ConicalGradientPattern) { partially evaluated: d->style == Qt::ConicalGradientPattern no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
851 | QGradientStops stops = gradient()->stops(); executed (the execution status of this line is deduced): QGradientStops stops = gradient()->stops(); | - |
852 | for (int i=0; i<stops.size(); ++i) evaluated: i<stops.size() yes Evaluation Count:34216 | yes Evaluation Count:16712 |
| 16712-34216 |
853 | if (stops.at(i).second.alpha() != 255) evaluated: stops.at(i).second.alpha() != 255 yes Evaluation Count:506 | yes Evaluation Count:33716 |
| 506-33716 |
854 | return false; executed: return false; Execution Count:506 | 506 |
855 | return true; executed: return true; Execution Count:16712 | 16712 |
856 | } else if (d->style == Qt::TexturePattern) { evaluated: d->style == Qt::TexturePattern yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
857 | return qHasPixmapTexture(*this) executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel(); Execution Count:5 | 5 |
858 | ? !texture().hasAlphaChannel() && !texture().isQBitmap() executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel(); Execution Count:5 | 5 |
859 | : !textureImage().hasAlphaChannel(); executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel(); Execution Count:5 | 5 |
860 | } | - |
861 | | - |
862 | return false; executed: return false; Execution Count:2 | 2 |
863 | } | - |
864 | | - |
865 | | - |
866 | /*! | - |
867 | \since 4.2 | - |
868 | | - |
869 | Sets \a matrix as an explicit transformation matrix on the | - |
870 | current brush. The brush transformation matrix is merged with | - |
871 | QPainter transformation matrix to produce the final result. | - |
872 | | - |
873 | \sa matrix() | - |
874 | */ | - |
875 | void QBrush::setMatrix(const QMatrix &matrix) | - |
876 | { | - |
877 | setTransform(QTransform(matrix)); never executed (the execution status of this line is deduced): setTransform(QTransform(matrix)); | - |
878 | } | 0 |
879 | | - |
880 | /*! | - |
881 | \since 4.3 | - |
882 | | - |
883 | Sets \a matrix as an explicit transformation matrix on the | - |
884 | current brush. The brush transformation matrix is merged with | - |
885 | QPainter transformation matrix to produce the final result. | - |
886 | | - |
887 | \sa transform() | - |
888 | */ | - |
889 | void QBrush::setTransform(const QTransform &matrix) | - |
890 | { | - |
891 | detach(d->style); executed (the execution status of this line is deduced): detach(d->style); | - |
892 | d->transform = matrix; executed (the execution status of this line is deduced): d->transform = matrix; | - |
893 | } executed: } Execution Count:750 | 750 |
894 | | - |
895 | | - |
896 | /*! | - |
897 | \fn void QBrush::matrix() const | - |
898 | \since 4.2 | - |
899 | | - |
900 | Returns the current transformation matrix for the brush. | - |
901 | | - |
902 | \sa setMatrix() | - |
903 | */ | - |
904 | | - |
905 | /*! | - |
906 | \fn bool QBrush::operator!=(const QBrush &brush) const | - |
907 | | - |
908 | Returns true if the brush is different from the given \a brush; | - |
909 | otherwise returns false. | - |
910 | | - |
911 | Two brushes are different if they have different styles, colors or | - |
912 | transforms or different pixmaps or gradients depending on the style. | - |
913 | | - |
914 | \sa operator==() | - |
915 | */ | - |
916 | | - |
917 | /*! | - |
918 | \fn bool QBrush::operator==(const QBrush &brush) const | - |
919 | | - |
920 | Returns true if the brush is equal to the given \a brush; | - |
921 | otherwise returns false. | - |
922 | | - |
923 | Two brushes are equal if they have equal styles, colors and | - |
924 | transforms and equal pixmaps or gradients depending on the style. | - |
925 | | - |
926 | \sa operator!=() | - |
927 | */ | - |
928 | | - |
929 | bool QBrush::operator==(const QBrush &b) const | - |
930 | { | - |
931 | if (b.d == d) evaluated: b.d == d yes Evaluation Count:300544 | yes Evaluation Count:103770 |
| 103770-300544 |
932 | return true; executed: return true; Execution Count:300544 | 300544 |
933 | 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 |
934 | return false; executed: return false; Execution Count:81400 | 81400 |
935 | switch (d->style) { | - |
936 | case Qt::TexturePattern: | - |
937 | { | - |
938 | const QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap(); executed (the execution status of this line is deduced): const QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap(); | - |
939 | const QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap(); executed (the execution status of this line is deduced): const QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap(); | - |
940 | return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); executed: return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey()); Execution Count:21 | 21 |
941 | } | - |
942 | case Qt::LinearGradientPattern: | - |
943 | case Qt::RadialGradientPattern: | - |
944 | case Qt::ConicalGradientPattern: | - |
945 | { | - |
946 | const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data()); executed (the execution status of this line is deduced): const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data()); | - |
947 | const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data()); executed (the execution status of this line is deduced): const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data()); | - |
948 | return d1->gradient == d2->gradient; executed: return d1->gradient == d2->gradient; Execution Count:19 | 19 |
949 | } | - |
950 | default: | - |
951 | return true; executed: return true; Execution Count:22330 | 22330 |
952 | } | - |
953 | } | 0 |
954 | | - |
955 | #ifndef QT_NO_DEBUG_STREAM | - |
956 | /*! | - |
957 | \internal | - |
958 | */ | - |
959 | QDebug operator<<(QDebug dbg, const QBrush &b) | - |
960 | { | - |
961 | static const char *BRUSH_STYLES[] = { | - |
962 | "NoBrush", | - |
963 | "SolidPattern", | - |
964 | "Dense1Pattern", | - |
965 | "Dense2Pattern", | - |
966 | "Dense3Pattern", | - |
967 | "Dense4Pattern", | - |
968 | "Dense5Pattern", | - |
969 | "Dense6Pattern", | - |
970 | "Dense7Pattern", | - |
971 | "HorPattern", | - |
972 | "VerPattern", | - |
973 | "CrossPattern", | - |
974 | "BDiagPattern", | - |
975 | "FDiagPattern", | - |
976 | "DiagCrossPattern", | - |
977 | "LinearGradientPattern", | - |
978 | "RadialGradientPattern", | - |
979 | "ConicalGradientPattern", | - |
980 | 0, 0, 0, 0, 0, 0, | - |
981 | "TexturePattern" // 24 | - |
982 | }; | - |
983 | | - |
984 | dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; executed (the execution status of this line is deduced): dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; | - |
985 | return dbg.space(); executed: return dbg.space(); Execution Count:3 | 3 |
986 | } | - |
987 | #endif | - |
988 | | - |
989 | /***************************************************************************** | - |
990 | QBrush stream functions | - |
991 | *****************************************************************************/ | - |
992 | #ifndef QT_NO_DATASTREAM | - |
993 | /*! | - |
994 | \fn QDataStream &operator<<(QDataStream &stream, const QBrush &brush) | - |
995 | \relates QBrush | - |
996 | | - |
997 | Writes the given \a brush to the given \a stream and returns a | - |
998 | reference to the \a stream. | - |
999 | | - |
1000 | \sa {Serializing Qt Data Types} | - |
1001 | */ | - |
1002 | | - |
1003 | QDataStream &operator<<(QDataStream &s, const QBrush &b) | - |
1004 | { | - |
1005 | quint8 style = (quint8) b.style(); executed (the execution status of this line is deduced): quint8 style = (quint8) b.style(); | - |
1006 | bool gradient_style = false; executed (the execution status of this line is deduced): bool gradient_style = false; | - |
1007 | | - |
1008 | 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 |
1009 | || style == Qt::ConicalGradientPattern) evaluated: style == Qt::ConicalGradientPattern yes Evaluation Count:2 | yes Evaluation Count:1533 |
| 2-1533 |
1010 | gradient_style = true; executed: gradient_style = true; Execution Count:20 | 20 |
1011 | | - |
1012 | 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 |
1013 | style = Qt::NoBrush; executed: style = Qt::NoBrush; Execution Count:8 | 8 |
1014 | | - |
1015 | s << style << b.color(); executed (the execution status of this line is deduced): s << style << b.color(); | - |
1016 | if (b.style() == Qt::TexturePattern) { partially evaluated: b.style() == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:1553 |
| 0-1553 |
1017 | s << b.texture(); never executed (the execution status of this line is deduced): s << b.texture(); | - |
1018 | } else if (s.version() >= QDataStream::Qt_4_0 && gradient_style) { never executed: } 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 |
1019 | const QGradient *gradient = b.gradient(); executed (the execution status of this line is deduced): const QGradient *gradient = b.gradient(); | - |
1020 | int type_as_int = int(gradient->type()); executed (the execution status of this line is deduced): int type_as_int = int(gradient->type()); | - |
1021 | s << type_as_int; executed (the execution status of this line is deduced): s << type_as_int; | - |
1022 | if (s.version() >= QDataStream::Qt_4_3) { evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:10 | yes Evaluation Count:2 |
| 2-10 |
1023 | s << int(gradient->spread()); executed (the execution status of this line is deduced): s << int(gradient->spread()); | - |
1024 | s << int(gradient->coordinateMode()); executed (the execution status of this line is deduced): s << int(gradient->coordinateMode()); | - |
1025 | } executed: } Execution Count:10 | 10 |
1026 | | - |
1027 | if (s.version() >= QDataStream::Qt_4_5) evaluated: s.version() >= QDataStream::Qt_4_5 yes Evaluation Count:10 | yes Evaluation Count:2 |
| 2-10 |
1028 | s << int(gradient->interpolationMode()); executed: s << int(gradient->interpolationMode()); Execution Count:10 | 10 |
1029 | | - |
1030 | if (sizeof(qreal) == sizeof(double)) { partially evaluated: sizeof(qreal) == sizeof(double) yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
1031 | s << gradient->stops(); executed (the execution status of this line is deduced): s << gradient->stops(); | - |
1032 | } else { executed: } Execution Count:12 | 12 |
1033 | // ensure that we write doubles here instead of streaming the stops | - |
1034 | // directly; otherwise, platforms that redefine qreal might generate | - |
1035 | // data that cannot be read on other platforms. | - |
1036 | QVector<QGradientStop> stops = gradient->stops(); never executed (the execution status of this line is deduced): QVector<QGradientStop> stops = gradient->stops(); | - |
1037 | s << quint32(stops.size()); never executed (the execution status of this line is deduced): s << quint32(stops.size()); | - |
1038 | for (int i = 0; i < stops.size(); ++i) { never evaluated: i < stops.size() | 0 |
1039 | const QGradientStop &stop = stops.at(i); never executed (the execution status of this line is deduced): const QGradientStop &stop = stops.at(i); | - |
1040 | s << QPair<double, QColor>(double(stop.first), stop.second); never executed (the execution status of this line is deduced): s << QPair<double, QColor>(double(stop.first), stop.second); | - |
1041 | } | 0 |
1042 | } | 0 |
1043 | | - |
1044 | if (gradient->type() == QGradient::LinearGradient) { evaluated: gradient->type() == QGradient::LinearGradient yes Evaluation Count:8 | yes Evaluation Count:4 |
| 4-8 |
1045 | s << static_cast<const QLinearGradient *>(gradient)->start(); executed (the execution status of this line is deduced): s << static_cast<const QLinearGradient *>(gradient)->start(); | - |
1046 | s << static_cast<const QLinearGradient *>(gradient)->finalStop(); executed (the execution status of this line is deduced): s << static_cast<const QLinearGradient *>(gradient)->finalStop(); | - |
1047 | } 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 |
1048 | s << static_cast<const QRadialGradient *>(gradient)->center(); executed (the execution status of this line is deduced): s << static_cast<const QRadialGradient *>(gradient)->center(); | - |
1049 | s << static_cast<const QRadialGradient *>(gradient)->focalPoint(); executed (the execution status of this line is deduced): s << static_cast<const QRadialGradient *>(gradient)->focalPoint(); | - |
1050 | s << (double) static_cast<const QRadialGradient *>(gradient)->radius(); executed (the execution status of this line is deduced): s << (double) static_cast<const QRadialGradient *>(gradient)->radius(); | - |
1051 | } else { // type == Conical executed: } Execution Count:2 | 2 |
1052 | s << static_cast<const QConicalGradient *>(gradient)->center(); executed (the execution status of this line is deduced): s << static_cast<const QConicalGradient *>(gradient)->center(); | - |
1053 | s << (double) static_cast<const QConicalGradient *>(gradient)->angle(); executed (the execution status of this line is deduced): s << (double) static_cast<const QConicalGradient *>(gradient)->angle(); | - |
1054 | } executed: } Execution Count:2 | 2 |
1055 | } | - |
1056 | if (s.version() >= QDataStream::Qt_4_3) evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:777 | yes Evaluation Count:776 |
| 776-777 |
1057 | s << b.transform(); executed: s << b.transform(); Execution Count:777 | 777 |
1058 | return s; executed: return s; Execution Count:1553 | 1553 |
1059 | } | - |
1060 | | - |
1061 | /*! | - |
1062 | \fn QDataStream &operator>>(QDataStream &stream, QBrush &brush) | - |
1063 | \relates QBrush | - |
1064 | | - |
1065 | Reads the given \a brush from the given \a stream and returns a | - |
1066 | reference to the \a stream. | - |
1067 | | - |
1068 | \sa {Serializing Qt Data Types} | - |
1069 | */ | - |
1070 | | - |
1071 | QDataStream &operator>>(QDataStream &s, QBrush &b) | - |
1072 | { | - |
1073 | quint8 style; executed (the execution status of this line is deduced): quint8 style; | - |
1074 | QColor color; executed (the execution status of this line is deduced): QColor color; | - |
1075 | s >> style; executed (the execution status of this line is deduced): s >> style; | - |
1076 | s >> color; executed (the execution status of this line is deduced): s >> color; | - |
1077 | if (style == Qt::TexturePattern) { partially evaluated: style == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:1524 |
| 0-1524 |
1078 | QPixmap pm; never executed (the execution status of this line is deduced): QPixmap pm; | - |
1079 | s >> pm; never executed (the execution status of this line is deduced): s >> pm; | - |
1080 | b = QBrush(color, pm); never executed (the execution status of this line is deduced): b = QBrush(color, pm); | - |
1081 | } else if (style == Qt::LinearGradientPattern never executed: } evaluated: style == Qt::LinearGradientPattern yes Evaluation Count:8 | yes Evaluation Count:1516 |
| 0-1516 |
1082 | || style == Qt::RadialGradientPattern evaluated: style == Qt::RadialGradientPattern yes Evaluation Count:3 | yes Evaluation Count:1513 |
| 3-1513 |
1083 | || style == Qt::ConicalGradientPattern) { evaluated: style == Qt::ConicalGradientPattern yes Evaluation Count:3 | yes Evaluation Count:1510 |
| 3-1510 |
1084 | | - |
1085 | int type_as_int; executed (the execution status of this line is deduced): int type_as_int; | - |
1086 | QGradient::Type type; executed (the execution status of this line is deduced): QGradient::Type type; | - |
1087 | QGradientStops stops; executed (the execution status of this line is deduced): QGradientStops stops; | - |
1088 | QGradient::CoordinateMode cmode = QGradient::LogicalMode; executed (the execution status of this line is deduced): QGradient::CoordinateMode cmode = QGradient::LogicalMode; | - |
1089 | QGradient::Spread spread = QGradient::PadSpread; executed (the execution status of this line is deduced): QGradient::Spread spread = QGradient::PadSpread; | - |
1090 | QGradient::InterpolationMode imode = QGradient::ColorInterpolation; executed (the execution status of this line is deduced): QGradient::InterpolationMode imode = QGradient::ColorInterpolation; | - |
1091 | | - |
1092 | s >> type_as_int; executed (the execution status of this line is deduced): s >> type_as_int; | - |
1093 | type = QGradient::Type(type_as_int); executed (the execution status of this line is deduced): type = QGradient::Type(type_as_int); | - |
1094 | if (s.version() >= QDataStream::Qt_4_3) { evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:10 | yes Evaluation Count:4 |
| 4-10 |
1095 | s >> type_as_int; executed (the execution status of this line is deduced): s >> type_as_int; | - |
1096 | spread = QGradient::Spread(type_as_int); executed (the execution status of this line is deduced): spread = QGradient::Spread(type_as_int); | - |
1097 | s >> type_as_int; executed (the execution status of this line is deduced): s >> type_as_int; | - |
1098 | cmode = QGradient::CoordinateMode(type_as_int); executed (the execution status of this line is deduced): cmode = QGradient::CoordinateMode(type_as_int); | - |
1099 | } executed: } Execution Count:10 | 10 |
1100 | | - |
1101 | if (s.version() >= QDataStream::Qt_4_5) { evaluated: s.version() >= QDataStream::Qt_4_5 yes Evaluation Count:10 | yes Evaluation Count:4 |
| 4-10 |
1102 | s >> type_as_int; executed (the execution status of this line is deduced): s >> type_as_int; | - |
1103 | imode = QGradient::InterpolationMode(type_as_int); executed (the execution status of this line is deduced): imode = QGradient::InterpolationMode(type_as_int); | - |
1104 | } executed: } Execution Count:10 | 10 |
1105 | | - |
1106 | if (sizeof(qreal) == sizeof(double)) { partially evaluated: sizeof(qreal) == sizeof(double) yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
1107 | s >> stops; executed (the execution status of this line is deduced): s >> stops; | - |
1108 | } else { executed: } Execution Count:14 | 14 |
1109 | quint32 numStops; never executed (the execution status of this line is deduced): quint32 numStops; | - |
1110 | double n; never executed (the execution status of this line is deduced): double n; | - |
1111 | QColor c; never executed (the execution status of this line is deduced): QColor c; | - |
1112 | | - |
1113 | s >> numStops; never executed (the execution status of this line is deduced): s >> numStops; | - |
1114 | for (quint32 i = 0; i < numStops; ++i) { never evaluated: i < numStops | 0 |
1115 | s >> n >> c; never executed (the execution status of this line is deduced): s >> n >> c; | - |
1116 | stops << QPair<qreal, QColor>(n, c); never executed (the execution status of this line is deduced): stops << QPair<qreal, QColor>(n, c); | - |
1117 | } | 0 |
1118 | } | 0 |
1119 | | - |
1120 | if (type == QGradient::LinearGradient) { evaluated: type == QGradient::LinearGradient yes Evaluation Count:8 | yes Evaluation Count:6 |
| 6-8 |
1121 | QPointF p1, p2; executed (the execution status of this line is deduced): QPointF p1, p2; | - |
1122 | s >> p1; executed (the execution status of this line is deduced): s >> p1; | - |
1123 | s >> p2; executed (the execution status of this line is deduced): s >> p2; | - |
1124 | QLinearGradient lg(p1, p2); executed (the execution status of this line is deduced): QLinearGradient lg(p1, p2); | - |
1125 | lg.setStops(stops); executed (the execution status of this line is deduced): lg.setStops(stops); | - |
1126 | lg.setSpread(spread); executed (the execution status of this line is deduced): lg.setSpread(spread); | - |
1127 | lg.setCoordinateMode(cmode); executed (the execution status of this line is deduced): lg.setCoordinateMode(cmode); | - |
1128 | lg.setInterpolationMode(imode); executed (the execution status of this line is deduced): lg.setInterpolationMode(imode); | - |
1129 | b = QBrush(lg); executed (the execution status of this line is deduced): b = QBrush(lg); | - |
1130 | } else if (type == QGradient::RadialGradient) { executed: } Execution Count:8 evaluated: type == QGradient::RadialGradient yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-8 |
1131 | QPointF center, focal; executed (the execution status of this line is deduced): QPointF center, focal; | - |
1132 | double radius; executed (the execution status of this line is deduced): double radius; | - |
1133 | s >> center; executed (the execution status of this line is deduced): s >> center; | - |
1134 | s >> focal; executed (the execution status of this line is deduced): s >> focal; | - |
1135 | s >> radius; executed (the execution status of this line is deduced): s >> radius; | - |
1136 | QRadialGradient rg(center, radius, focal); executed (the execution status of this line is deduced): QRadialGradient rg(center, radius, focal); | - |
1137 | rg.setStops(stops); executed (the execution status of this line is deduced): rg.setStops(stops); | - |
1138 | rg.setSpread(spread); executed (the execution status of this line is deduced): rg.setSpread(spread); | - |
1139 | rg.setCoordinateMode(cmode); executed (the execution status of this line is deduced): rg.setCoordinateMode(cmode); | - |
1140 | rg.setInterpolationMode(imode); executed (the execution status of this line is deduced): rg.setInterpolationMode(imode); | - |
1141 | b = QBrush(rg); executed (the execution status of this line is deduced): b = QBrush(rg); | - |
1142 | } else { // type == QGradient::ConicalGradient executed: } Execution Count:3 | 3 |
1143 | QPointF center; executed (the execution status of this line is deduced): QPointF center; | - |
1144 | double angle; executed (the execution status of this line is deduced): double angle; | - |
1145 | s >> center; executed (the execution status of this line is deduced): s >> center; | - |
1146 | s >> angle; executed (the execution status of this line is deduced): s >> angle; | - |
1147 | QConicalGradient cg(center, angle); executed (the execution status of this line is deduced): QConicalGradient cg(center, angle); | - |
1148 | cg.setStops(stops); executed (the execution status of this line is deduced): cg.setStops(stops); | - |
1149 | cg.setSpread(spread); executed (the execution status of this line is deduced): cg.setSpread(spread); | - |
1150 | cg.setCoordinateMode(cmode); executed (the execution status of this line is deduced): cg.setCoordinateMode(cmode); | - |
1151 | cg.setInterpolationMode(imode); executed (the execution status of this line is deduced): cg.setInterpolationMode(imode); | - |
1152 | b = QBrush(cg); executed (the execution status of this line is deduced): b = QBrush(cg); | - |
1153 | } executed: } Execution Count:3 | 3 |
1154 | } else { | - |
1155 | b = QBrush(color, (Qt::BrushStyle)style); executed (the execution status of this line is deduced): b = QBrush(color, (Qt::BrushStyle)style); | - |
1156 | } executed: } Execution Count:1510 | 1510 |
1157 | if (s.version() >= QDataStream::Qt_4_3) { evaluated: s.version() >= QDataStream::Qt_4_3 yes Evaluation Count:745 | yes Evaluation Count:779 |
| 745-779 |
1158 | QTransform transform; executed (the execution status of this line is deduced): QTransform transform; | - |
1159 | s >> transform; executed (the execution status of this line is deduced): s >> transform; | - |
1160 | b.setTransform(transform); executed (the execution status of this line is deduced): b.setTransform(transform); | - |
1161 | } executed: } Execution Count:745 | 745 |
1162 | return s; executed: return s; Execution Count:1524 | 1524 |
1163 | } | - |
1164 | #endif // QT_NO_DATASTREAM | - |
1165 | | - |
1166 | /******************************************************************************* | - |
1167 | * QGradient implementations | - |
1168 | */ | - |
1169 | | - |
1170 | | - |
1171 | /*! | - |
1172 | \class QGradient | - |
1173 | \ingroup painting | - |
1174 | \ingroup shared | - |
1175 | \inmodule QtGui | - |
1176 | | - |
1177 | \brief The QGradient class is used in combination with QBrush to | - |
1178 | specify gradient fills. | - |
1179 | | - |
1180 | Qt currently supports three types of gradient fills: | - |
1181 | | - |
1182 | \list | - |
1183 | \li \e Linear gradients interpolate colors between start and end points. | - |
1184 | \li \e Simple radial gradients interpolate colors between a focal point | - |
1185 | and end points on a circle surrounding it. | - |
1186 | \li \e Extended radial gradients interpolate colors between a center and | - |
1187 | a focal circle. | - |
1188 | \li \e Conical gradients interpolate colors around a center point. | - |
1189 | \endlist | - |
1190 | | - |
1191 | A gradient's type can be retrieved using the type() function. | - |
1192 | Each of the types is represented by a subclass of QGradient: | - |
1193 | | - |
1194 | \table | - |
1195 | \header | - |
1196 | \li QLinearGradient | - |
1197 | \li QRadialGradient | - |
1198 | \li QConicalGradient | - |
1199 | \row | - |
1200 | \li \inlineimage qgradient-linear.png | - |
1201 | \li \inlineimage qgradient-radial.png | - |
1202 | \li \inlineimage qgradient-conical.png | - |
1203 | \endtable | - |
1204 | | - |
1205 | The colors in a gradient are defined using stop points of the | - |
1206 | QGradientStop type; i.e., a position and a color. Use the setColorAt() | - |
1207 | function to define a single stop point. Alternatively, use the | - |
1208 | setStops() function to define several stop points in one go. Note that | - |
1209 | the latter function \e replaces the current set of stop points. | - |
1210 | | - |
1211 | It is the gradient's complete set of stop points (accessible | - |
1212 | through the stops() function) that describes how the gradient area | - |
1213 | should be filled. If no stop points have been specified, a gradient | - |
1214 | of black at 0 to white at 1 is used. | - |
1215 | | - |
1216 | A diagonal linear gradient from black at (100, 100) to white at | - |
1217 | (200, 200) could be specified like this: | - |
1218 | | - |
1219 | \snippet brush/brush.cpp 0 | - |
1220 | | - |
1221 | A gradient can have an arbitrary number of stop points. The | - |
1222 | following would create a radial gradient starting with | - |
1223 | red in the center, blue and then green on the edges: | - |
1224 | | - |
1225 | \snippet brush/brush.cpp 1 | - |
1226 | | - |
1227 | It is possible to repeat or reflect the gradient outside its area | - |
1228 | by specifiying the \l {QGradient::Spread}{spread method} using the | - |
1229 | setSpread() function. The default is to pad the outside area with | - |
1230 | the color at the closest stop point. The currently set \l | - |
1231 | {QGradient::Spread}{spread method} can be retrieved using the | - |
1232 | spread() function. The QGradient::Spread enum defines three | - |
1233 | different methods: | - |
1234 | | - |
1235 | \table | - |
1236 | \row | - |
1237 | \li \inlineimage qradialgradient-pad.png | - |
1238 | \li \inlineimage qradialgradient-repeat.png | - |
1239 | \li \inlineimage qradialgradient-reflect.png | - |
1240 | \row | - |
1241 | \li \l {QGradient::PadSpread}{PadSpread} | - |
1242 | \li \l {QGradient::RepeatSpread}{RepeatSpread} | - |
1243 | \li \l {QGradient::ReflectSpread}{ReflectSpread} | - |
1244 | \endtable | - |
1245 | | - |
1246 | Note that the setSpread() function only has effect for linear and | - |
1247 | radial gradients. The reason is that the conical gradient is | - |
1248 | closed by definition, i.e. the \e conical gradient fills the | - |
1249 | entire circle from 0 - 360 degrees, while the boundary of a radial | - |
1250 | or a linear gradient can be specified through its radius or final | - |
1251 | stop points, respectively. | - |
1252 | | - |
1253 | The gradient coordinates can be specified in logical coordinates, | - |
1254 | relative to device coordinates, or relative to object bounding box coordinates. | - |
1255 | The \l {QGradient::CoordinateMode}{coordinate mode} can be set using the | - |
1256 | setCoordinateMode() function. The default is LogicalMode, where the | - |
1257 | gradient coordinates are specified in the same way as the object | - |
1258 | coordinates. To retrieve the currently set \l {QGradient::CoordinateMode} | - |
1259 | {coordinate mode} use coordinateMode(). | - |
1260 | | - |
1261 | | - |
1262 | \sa {painting/gradients}{The Gradients Example}, QBrush | - |
1263 | */ | - |
1264 | | - |
1265 | /*! | - |
1266 | \internal | - |
1267 | */ | - |
1268 | QGradient::QGradient() | - |
1269 | : m_type(NoGradient), dummy(0) | - |
1270 | { | - |
1271 | } executed: } Execution Count:33850 | 33850 |
1272 | | - |
1273 | | - |
1274 | /*! | - |
1275 | \enum QGradient::Type | - |
1276 | | - |
1277 | Specifies the type of gradient. | - |
1278 | | - |
1279 | \value LinearGradient Interpolates colors between start and end points | - |
1280 | (QLinearGradient). | - |
1281 | | - |
1282 | \value RadialGradient Interpolate colors between a focal point and end | - |
1283 | points on a circle surrounding it (QRadialGradient). | - |
1284 | | - |
1285 | \value ConicalGradient Interpolate colors around a center point (QConicalGradient). | - |
1286 | \value NoGradient No gradient is used. | - |
1287 | | - |
1288 | \sa type() | - |
1289 | */ | - |
1290 | | - |
1291 | /*! | - |
1292 | \enum QGradient::Spread | - |
1293 | | - |
1294 | Specifies how the area outside the gradient area should be | - |
1295 | filled. | - |
1296 | | - |
1297 | \value PadSpread The area is filled with the closest stop | - |
1298 | color. This is the default. | - |
1299 | | - |
1300 | \value RepeatSpread The gradient is repeated outside the gradient | - |
1301 | area. | - |
1302 | | - |
1303 | \value ReflectSpread The gradient is reflected outside the | - |
1304 | gradient area. | - |
1305 | | - |
1306 | \sa spread(), setSpread() | - |
1307 | */ | - |
1308 | | - |
1309 | /*! | - |
1310 | \fn void QGradient::setSpread(Spread method) | - |
1311 | | - |
1312 | Specifies the spread \a method that should be used for this | - |
1313 | gradient. | - |
1314 | | - |
1315 | Note that this function only has effect for linear and radial | - |
1316 | gradients. | - |
1317 | | - |
1318 | \sa spread() | - |
1319 | */ | - |
1320 | | - |
1321 | /*! | - |
1322 | \fn QGradient::Spread QGradient::spread() const | - |
1323 | | - |
1324 | Returns the spread method use by this gradient. The default is | - |
1325 | PadSpread. | - |
1326 | | - |
1327 | \sa setSpread() | - |
1328 | */ | - |
1329 | | - |
1330 | /*! | - |
1331 | \fn QGradient::Type QGradient::type() const | - |
1332 | | - |
1333 | Returns the type of gradient. | - |
1334 | */ | - |
1335 | | - |
1336 | /*! | - |
1337 | \fn void QGradient::setColorAt(qreal position, const QColor &color) | - |
1338 | | - |
1339 | Creates a stop point at the given \a position with the given \a | - |
1340 | color. The given \a position must be in the range 0 to 1. | - |
1341 | | - |
1342 | \sa setStops(), stops() | - |
1343 | */ | - |
1344 | | - |
1345 | void QGradient::setColorAt(qreal pos, const QColor &color) | - |
1346 | { | - |
1347 | 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 |
1348 | qWarning("QGradient::setColorAt: Color position must be specified in the range 0 to 1"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qbrush.cpp", 1348, __PRETTY_FUNCTION__).warning("QGradient::setColorAt: Color position must be specified in the range 0 to 1"); | - |
1349 | return; | 0 |
1350 | } | - |
1351 | | - |
1352 | int index = 0; executed (the execution status of this line is deduced): int index = 0; | - |
1353 | if (!qIsNaN(pos)) evaluated: !qIsNaN(pos) yes Evaluation Count:34156 | yes Evaluation Count:1 |
| 1-34156 |
1354 | 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 |
1355 | | - |
1356 | 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 |
1357 | m_stops[index].second = color; executed: m_stops[index].second = color; Execution Count:2 | 2 |
1358 | else | - |
1359 | m_stops.insert(index, QGradientStop(pos, color)); executed: m_stops.insert(index, QGradientStop(pos, color)); Execution Count:34151 | 34151 |
1360 | } | - |
1361 | | - |
1362 | /*! | - |
1363 | \fn void QGradient::setStops(const QGradientStops &stopPoints) | - |
1364 | | - |
1365 | Replaces the current set of stop points with the given \a | - |
1366 | stopPoints. The positions of the points must be in the range 0 to | - |
1367 | 1, and must be sorted with the lowest point first. | - |
1368 | | - |
1369 | \sa setColorAt(), stops() | - |
1370 | */ | - |
1371 | void QGradient::setStops(const QGradientStops &stops) | - |
1372 | { | - |
1373 | m_stops.clear(); executed (the execution status of this line is deduced): m_stops.clear(); | - |
1374 | for (int i=0; i<stops.size(); ++i) evaluated: i<stops.size() yes Evaluation Count:54 | yes Evaluation Count:21 |
| 21-54 |
1375 | setColorAt(stops.at(i).first, stops.at(i).second); executed: setColorAt(stops.at(i).first, stops.at(i).second); Execution Count:54 | 54 |
1376 | } executed: } Execution Count:21 | 21 |
1377 | | - |
1378 | | - |
1379 | /*! | - |
1380 | Returns the stop points for this gradient. | - |
1381 | | - |
1382 | If no stop points have been specified, a gradient of black at 0 to white | - |
1383 | at 1 is used. | - |
1384 | | - |
1385 | \sa setStops(), setColorAt() | - |
1386 | */ | - |
1387 | QGradientStops QGradient::stops() const | - |
1388 | { | - |
1389 | if (m_stops.isEmpty()) { evaluated: m_stops.isEmpty() yes Evaluation Count:33 | yes Evaluation Count:59049 |
| 33-59049 |
1390 | QGradientStops tmp; executed (the execution status of this line is deduced): QGradientStops tmp; | - |
1391 | tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white); executed (the execution status of this line is deduced): tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white); | - |
1392 | return tmp; executed: return tmp; Execution Count:33 | 33 |
1393 | } | - |
1394 | return m_stops; executed: return m_stops; Execution Count:59028 | 59028 |
1395 | } | - |
1396 | | - |
1397 | #define Q_DUMMY_ACCESSOR union {void *p; uint i;}; p = dummy; | - |
1398 | | - |
1399 | /*! | - |
1400 | \enum QGradient::CoordinateMode | - |
1401 | \since 4.4 | - |
1402 | | - |
1403 | This enum specifies how gradient coordinates map to the paint | - |
1404 | device on which the gradient is used. | - |
1405 | | - |
1406 | \value LogicalMode This is the default mode. The gradient coordinates | - |
1407 | are specified logical space just like the object coordinates. | - |
1408 | \value StretchToDeviceMode In this mode the gradient coordinates | - |
1409 | are relative to the bounding rectangle of the paint device, | - |
1410 | with (0,0) in the top left corner, and (1,1) in the bottom right | - |
1411 | corner of the paint device. | - |
1412 | \value ObjectBoundingMode In this mode the gradient coordinates are | - |
1413 | relative to the bounding rectangle of the object being drawn, with | - |
1414 | (0,0) in the top left corner, and (1,1) in the bottom right corner | - |
1415 | of the object's bounding rectangle. | - |
1416 | */ | - |
1417 | | - |
1418 | /*! | - |
1419 | \since 4.4 | - |
1420 | | - |
1421 | Returns the coordinate mode of this gradient. The default mode is | - |
1422 | LogicalMode. | - |
1423 | */ | - |
1424 | QGradient::CoordinateMode QGradient::coordinateMode() const | - |
1425 | { | - |
1426 | Q_DUMMY_ACCESSOR executed (the execution status of this line is deduced): union {void *p; uint i;}; p = dummy; | - |
1427 | return CoordinateMode(i & 0x03); executed: return CoordinateMode(i & 0x03); Execution Count:17529 | 17529 |
1428 | } | - |
1429 | | - |
1430 | /*! | - |
1431 | \since 4.4 | - |
1432 | | - |
1433 | Sets the coordinate mode of this gradient to \a mode. The default | - |
1434 | mode is LogicalMode. | - |
1435 | */ | - |
1436 | void QGradient::setCoordinateMode(CoordinateMode mode) | - |
1437 | { | - |
1438 | Q_DUMMY_ACCESSOR executed (the execution status of this line is deduced): union {void *p; uint i;}; p = dummy; | - |
1439 | i &= ~0x03; executed (the execution status of this line is deduced): i &= ~0x03; | - |
1440 | i |= uint(mode); executed (the execution status of this line is deduced): i |= uint(mode); | - |
1441 | dummy = p; executed (the execution status of this line is deduced): dummy = p; | - |
1442 | } executed: } Execution Count:28 | 28 |
1443 | | - |
1444 | /*! | - |
1445 | \enum QGradient::InterpolationMode | - |
1446 | \since 4.5 | - |
1447 | \internal | - |
1448 | | - |
1449 | \value ComponentInterpolation The color components and the alpha component are | - |
1450 | independently linearly interpolated. | - |
1451 | \value ColorInterpolation The colors are linearly interpolated in | - |
1452 | premultiplied color space. | - |
1453 | */ | - |
1454 | | - |
1455 | /*! | - |
1456 | \since 4.5 | - |
1457 | \internal | - |
1458 | | - |
1459 | Returns the interpolation mode of this gradient. The default mode is | - |
1460 | ColorInterpolation. | - |
1461 | */ | - |
1462 | QGradient::InterpolationMode QGradient::interpolationMode() const | - |
1463 | { | - |
1464 | Q_DUMMY_ACCESSOR executed (the execution status of this line is deduced): union {void *p; uint i;}; p = dummy; | - |
1465 | return InterpolationMode((i >> 2) & 0x01); executed: return InterpolationMode((i >> 2) & 0x01); Execution Count:29580 | 29580 |
1466 | } | - |
1467 | | - |
1468 | /*! | - |
1469 | \since 4.5 | - |
1470 | \internal | - |
1471 | | - |
1472 | Sets the interpolation mode of this gradient to \a mode. The default | - |
1473 | mode is ColorInterpolation. | - |
1474 | */ | - |
1475 | void QGradient::setInterpolationMode(InterpolationMode mode) | - |
1476 | { | - |
1477 | Q_DUMMY_ACCESSOR executed (the execution status of this line is deduced): union {void *p; uint i;}; p = dummy; | - |
1478 | i &= ~(1 << 2); executed (the execution status of this line is deduced): i &= ~(1 << 2); | - |
1479 | i |= (uint(mode) << 2); executed (the execution status of this line is deduced): i |= (uint(mode) << 2); | - |
1480 | dummy = p; executed (the execution status of this line is deduced): dummy = p; | - |
1481 | } executed: } Execution Count:27 | 27 |
1482 | | - |
1483 | /*! | - |
1484 | \fn bool QGradient::operator!=(const QGradient &gradient) const | - |
1485 | \since 4.2 | - |
1486 | | - |
1487 | Returns true if the gradient is the same as the other \a gradient | - |
1488 | specified; otherwise returns false. | - |
1489 | | - |
1490 | \sa operator==() | - |
1491 | */ | - |
1492 | | - |
1493 | /*! | - |
1494 | Returns true if the gradient is the same as the other \a gradient | - |
1495 | specified; otherwise returns false. | - |
1496 | | - |
1497 | \sa operator!=() | - |
1498 | */ | - |
1499 | bool QGradient::operator==(const QGradient &gradient) const | - |
1500 | { | - |
1501 | if (gradient.m_type != m_type partially evaluated: gradient.m_type != m_type no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
1502 | || gradient.m_spread != m_spread partially evaluated: gradient.m_spread != m_spread no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
1503 | || gradient.dummy != dummy) return false; never executed: return false; partially evaluated: gradient.dummy != dummy no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
1504 | | - |
1505 | if (m_type == LinearGradient) { evaluated: m_type == LinearGradient yes Evaluation Count:13 | yes Evaluation Count:6 |
| 6-13 |
1506 | 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 |
1507 | || 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 |
1508 | || 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 |
1509 | || 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 |
1510 | return false; executed: return false; Execution Count:1 | 1 |
1511 | } else if (m_type == RadialGradient) { executed: } Execution Count:12 evaluated: m_type == RadialGradient yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-12 |
1512 | 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 |
1513 | || 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 |
1514 | || 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 |
1515 | || 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 |
1516 | || 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 |
1517 | return false; never executed: return false; | 0 |
1518 | } else { // m_type == ConicalGradient executed: } Execution Count:3 | 3 |
1519 | 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 |
1520 | || 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 |
1521 | || 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 |
1522 | return false; never executed: return false; | 0 |
1523 | } executed: } Execution Count:3 | 3 |
1524 | | - |
1525 | return stops() == gradient.stops(); executed: return stops() == gradient.stops(); Execution Count:18 | 18 |
1526 | } | - |
1527 | | - |
1528 | /*! | - |
1529 | \class QLinearGradient | - |
1530 | \ingroup painting | - |
1531 | \inmodule QtGui | - |
1532 | | - |
1533 | \brief The QLinearGradient class is used in combination with QBrush to | - |
1534 | specify a linear gradient brush. | - |
1535 | | - |
1536 | Linear gradients interpolate colors between start and end | - |
1537 | points. Outside these points the gradient is either padded, | - |
1538 | reflected or repeated depending on the currently set \l | - |
1539 | {QGradient::Spread}{spread} method: | - |
1540 | | - |
1541 | \table | - |
1542 | \row | - |
1543 | \li \inlineimage qlineargradient-pad.png | - |
1544 | \li \inlineimage qlineargradient-reflect.png | - |
1545 | \li \inlineimage qlineargradient-repeat.png | - |
1546 | \row | - |
1547 | \li \l {QGradient::PadSpread}{PadSpread} (default) | - |
1548 | \li \l {QGradient::ReflectSpread}{ReflectSpread} | - |
1549 | \li \l {QGradient::RepeatSpread}{RepeatSpread} | - |
1550 | \endtable | - |
1551 | | - |
1552 | The colors in a gradient is defined using stop points of the | - |
1553 | QGradientStop type, i.e. a position and a color. Use the | - |
1554 | QGradient::setColorAt() or the QGradient::setStops() function to | - |
1555 | define the stop points. It is the gradient's complete set of stop | - |
1556 | points that describes how the gradient area should be filled. If | - |
1557 | no stop points have been specified, a gradient of black at 0 to | - |
1558 | white at 1 is used. | - |
1559 | | - |
1560 | In addition to the functions inherited from QGradient, the | - |
1561 | QLinearGradient class provides the finalStop() function which | - |
1562 | returns the final stop point of the gradient, and the start() | - |
1563 | function returning the start point of the gradient. | - |
1564 | | - |
1565 | \sa QRadialGradient, QConicalGradient, {painting/gradients}{The | - |
1566 | Gradients Example} | - |
1567 | */ | - |
1568 | | - |
1569 | | - |
1570 | /*! | - |
1571 | Constructs a default linear gradient with interpolation area | - |
1572 | between (0, 0) and (1, 1). | - |
1573 | | - |
1574 | \sa QGradient::setColorAt(), setStart(), setFinalStop() | - |
1575 | */ | - |
1576 | | - |
1577 | QLinearGradient::QLinearGradient() | - |
1578 | { | - |
1579 | m_type = LinearGradient; executed (the execution status of this line is deduced): m_type = LinearGradient; | - |
1580 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1581 | m_data.linear.x1 = 0; executed (the execution status of this line is deduced): m_data.linear.x1 = 0; | - |
1582 | m_data.linear.y1 = 0; executed (the execution status of this line is deduced): m_data.linear.y1 = 0; | - |
1583 | m_data.linear.x2 = 1; executed (the execution status of this line is deduced): m_data.linear.x2 = 1; | - |
1584 | m_data.linear.y2 = 1; executed (the execution status of this line is deduced): m_data.linear.y2 = 1; | - |
1585 | } executed: } Execution Count:16019 | 16019 |
1586 | | - |
1587 | | - |
1588 | /*! | - |
1589 | Constructs a linear gradient with interpolation area between the | - |
1590 | given \a start point and \a finalStop. | - |
1591 | | - |
1592 | \note The expected parameter values are in pixels. | - |
1593 | | - |
1594 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
1595 | */ | - |
1596 | QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop) | - |
1597 | { | - |
1598 | m_type = LinearGradient; executed (the execution status of this line is deduced): m_type = LinearGradient; | - |
1599 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1600 | m_data.linear.x1 = start.x(); executed (the execution status of this line is deduced): m_data.linear.x1 = start.x(); | - |
1601 | m_data.linear.y1 = start.y(); executed (the execution status of this line is deduced): m_data.linear.y1 = start.y(); | - |
1602 | m_data.linear.x2 = finalStop.x(); executed (the execution status of this line is deduced): m_data.linear.x2 = finalStop.x(); | - |
1603 | m_data.linear.y2 = finalStop.y(); executed (the execution status of this line is deduced): m_data.linear.y2 = finalStop.y(); | - |
1604 | } executed: } Execution Count:88 | 88 |
1605 | | - |
1606 | /*! | - |
1607 | \fn QLinearGradient::QLinearGradient(qreal x1, qreal y1, qreal x2, qreal y2) | - |
1608 | | - |
1609 | Constructs a linear gradient with interpolation area between (\a | - |
1610 | x1, \a y1) and (\a x2, \a y2). | - |
1611 | | - |
1612 | \note The expected parameter values are in pixels. | - |
1613 | | - |
1614 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
1615 | */ | - |
1616 | QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop) | - |
1617 | { | - |
1618 | m_type = LinearGradient; executed (the execution status of this line is deduced): m_type = LinearGradient; | - |
1619 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1620 | m_data.linear.x1 = xStart; executed (the execution status of this line is deduced): m_data.linear.x1 = xStart; | - |
1621 | m_data.linear.y1 = yStart; executed (the execution status of this line is deduced): m_data.linear.y1 = yStart; | - |
1622 | m_data.linear.x2 = xFinalStop; executed (the execution status of this line is deduced): m_data.linear.x2 = xFinalStop; | - |
1623 | m_data.linear.y2 = yFinalStop; executed (the execution status of this line is deduced): m_data.linear.y2 = yFinalStop; | - |
1624 | } executed: } Execution Count:505 | 505 |
1625 | | - |
1626 | | - |
1627 | /*! | - |
1628 | Returns the start point of this linear gradient in logical coordinates. | - |
1629 | | - |
1630 | \sa QGradient::stops() | - |
1631 | */ | - |
1632 | | - |
1633 | QPointF QLinearGradient::start() const | - |
1634 | { | - |
1635 | Q_ASSERT(m_type == LinearGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1636 | 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 |
1637 | } | - |
1638 | | - |
1639 | /*! | - |
1640 | \fn void QLinearGradient::setStart(qreal x, qreal y) | - |
1641 | \overload | - |
1642 | \since 4.2 | - |
1643 | | - |
1644 | Sets the start point of this linear gradient in logical | - |
1645 | coordinates to \a x, \a y. | - |
1646 | | - |
1647 | \sa start() | - |
1648 | */ | - |
1649 | | - |
1650 | /*! | - |
1651 | \since 4.2 | - |
1652 | | - |
1653 | Sets the start point of this linear gradient in logical | - |
1654 | coordinates to \a start. | - |
1655 | | - |
1656 | \sa start() | - |
1657 | */ | - |
1658 | | - |
1659 | void QLinearGradient::setStart(const QPointF &start) | - |
1660 | { | - |
1661 | Q_ASSERT(m_type == LinearGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1662 | m_data.linear.x1 = start.x(); executed (the execution status of this line is deduced): m_data.linear.x1 = start.x(); | - |
1663 | m_data.linear.y1 = start.y(); executed (the execution status of this line is deduced): m_data.linear.y1 = start.y(); | - |
1664 | } executed: } Execution Count:4 | 4 |
1665 | | - |
1666 | | - |
1667 | /*! | - |
1668 | \fn void QLinearGradient::setFinalStop(qreal x, qreal y) | - |
1669 | \overload | - |
1670 | \since 4.2 | - |
1671 | | - |
1672 | Sets the final stop point of this linear gradient in logical | - |
1673 | coordinates to \a x, \a y. | - |
1674 | | - |
1675 | \sa start() | - |
1676 | */ | - |
1677 | | - |
1678 | /*! | - |
1679 | Returns the final stop point of this linear gradient in logical coordinates. | - |
1680 | | - |
1681 | \sa QGradient::stops() | - |
1682 | */ | - |
1683 | | - |
1684 | QPointF QLinearGradient::finalStop() const | - |
1685 | { | - |
1686 | Q_ASSERT(m_type == LinearGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1687 | 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 |
1688 | } | - |
1689 | | - |
1690 | | - |
1691 | /*! | - |
1692 | \since 4.2 | - |
1693 | | - |
1694 | Sets the final stop point of this linear gradient in logical | - |
1695 | coordinates to \a stop. | - |
1696 | | - |
1697 | \sa finalStop() | - |
1698 | */ | - |
1699 | | - |
1700 | void QLinearGradient::setFinalStop(const QPointF &stop) | - |
1701 | { | - |
1702 | Q_ASSERT(m_type == LinearGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1703 | m_data.linear.x2 = stop.x(); executed (the execution status of this line is deduced): m_data.linear.x2 = stop.x(); | - |
1704 | m_data.linear.y2 = stop.y(); executed (the execution status of this line is deduced): m_data.linear.y2 = stop.y(); | - |
1705 | } executed: } Execution Count:4 | 4 |
1706 | | - |
1707 | | - |
1708 | /*! | - |
1709 | \class QRadialGradient | - |
1710 | \ingroup painting | - |
1711 | \inmodule QtGui | - |
1712 | | - |
1713 | \brief The QRadialGradient class is used in combination with QBrush to | - |
1714 | specify a radial gradient brush. | - |
1715 | | - |
1716 | Qt supports both simple and extended radial gradients. | - |
1717 | | - |
1718 | Simple radial gradients interpolate colors between a focal point and end | - |
1719 | points on a circle surrounding it. Extended radial gradients interpolate | - |
1720 | colors between a focal circle and a center circle. Points outside the cone | - |
1721 | defined by the two circles will be transparent. For simple radial gradients | - |
1722 | the focal point is adjusted to lie inside the center circle, whereas the | - |
1723 | focal point can have any position in an extended radial gradient. | - |
1724 | | - |
1725 | Outside the end points the gradient is either padded, reflected or repeated | - |
1726 | depending on the currently set \l {QGradient::Spread}{spread} method: | - |
1727 | | - |
1728 | \table | - |
1729 | \row | - |
1730 | \li \inlineimage qradialgradient-pad.png | - |
1731 | \li \inlineimage qradialgradient-reflect.png | - |
1732 | \li \inlineimage qradialgradient-repeat.png | - |
1733 | \row | - |
1734 | \li \l {QGradient::PadSpread}{PadSpread} (default) | - |
1735 | \li \l {QGradient::ReflectSpread}{ReflectSpread} | - |
1736 | \li \l {QGradient::RepeatSpread}{RepeatSpread} | - |
1737 | \endtable | - |
1738 | | - |
1739 | The colors in a gradient is defined using stop points of the | - |
1740 | QGradientStop type, i.e. a position and a color. Use the | - |
1741 | QGradient::setColorAt() or the QGradient::setStops() function to | - |
1742 | define the stop points. It is the gradient's complete set of stop | - |
1743 | points that describes how the gradient area should be filled. If | - |
1744 | no stop points have been specified, a gradient of black at 0 to | - |
1745 | white at 1 is used. | - |
1746 | | - |
1747 | In addition to the functions inherited from QGradient, the | - |
1748 | QRadialGradient class provides the center(), focalPoint() and | - |
1749 | radius() functions returning the gradient's center, focal point | - |
1750 | and radius respectively. | - |
1751 | | - |
1752 | \sa QLinearGradient, QConicalGradient, {painting/gradients}{The | - |
1753 | Gradients Example} | - |
1754 | */ | - |
1755 | | - |
1756 | static QPointF qt_radial_gradient_adapt_focal_point(const QPointF ¢er, | - |
1757 | qreal radius, | - |
1758 | const QPointF &focalPoint) | - |
1759 | { | - |
1760 | // We have a one pixel buffer zone to avoid numerical instability on the | - |
1761 | // circle border | - |
1762 | //### this is hacky because technically we should adjust based on current matrix | - |
1763 | const qreal compensated_radius = radius - radius * qreal(0.001); executed (the execution status of this line is deduced): const qreal compensated_radius = radius - radius * qreal(0.001); | - |
1764 | QLineF line(center, focalPoint); executed (the execution status of this line is deduced): QLineF line(center, focalPoint); | - |
1765 | if (line.length() > (compensated_radius)) partially evaluated: line.length() > (compensated_radius) no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1766 | line.setLength(compensated_radius); never executed: line.setLength(compensated_radius); | 0 |
1767 | return line.p2(); executed: return line.p2(); Execution Count:10 | 10 |
1768 | } | - |
1769 | | - |
1770 | /*! | - |
1771 | Constructs a simple radial gradient with the given \a center, \a | - |
1772 | radius and \a focalPoint. | - |
1773 | | - |
1774 | \note If the given focal point is outside the circle defined by the | - |
1775 | \a center point and \a radius, it will be re-adjusted to lie at a point on | - |
1776 | the circle where it intersects with the line from \a center to | - |
1777 | \a focalPoint. | - |
1778 | | - |
1779 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
1780 | */ | - |
1781 | | - |
1782 | QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius, const QPointF &focalPoint) | - |
1783 | { | - |
1784 | m_type = RadialGradient; executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1785 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1786 | m_data.radial.cx = center.x(); executed (the execution status of this line is deduced): m_data.radial.cx = center.x(); | - |
1787 | m_data.radial.cy = center.y(); executed (the execution status of this line is deduced): m_data.radial.cy = center.y(); | - |
1788 | m_data.radial.cradius = radius; executed (the execution status of this line is deduced): m_data.radial.cradius = radius; | - |
1789 | | - |
1790 | QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(center, radius, focalPoint); executed (the execution status of this line is deduced): QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(center, radius, focalPoint); | - |
1791 | m_data.radial.fx = adapted_focal.x(); executed (the execution status of this line is deduced): m_data.radial.fx = adapted_focal.x(); | - |
1792 | m_data.radial.fy = adapted_focal.y(); executed (the execution status of this line is deduced): m_data.radial.fy = adapted_focal.y(); | - |
1793 | } executed: } Execution Count:3 | 3 |
1794 | | - |
1795 | /*! | - |
1796 | Constructs a simple radial gradient with the given \a center, \a | - |
1797 | radius and the focal point in the circle center. | - |
1798 | | - |
1799 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
1800 | */ | - |
1801 | QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius) | - |
1802 | { | - |
1803 | m_type = RadialGradient; executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1804 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1805 | m_data.radial.cx = center.x(); executed (the execution status of this line is deduced): m_data.radial.cx = center.x(); | - |
1806 | m_data.radial.cy = center.y(); executed (the execution status of this line is deduced): m_data.radial.cy = center.y(); | - |
1807 | m_data.radial.cradius = radius; executed (the execution status of this line is deduced): m_data.radial.cradius = radius; | - |
1808 | m_data.radial.fx = center.x(); executed (the execution status of this line is deduced): m_data.radial.fx = center.x(); | - |
1809 | m_data.radial.fy = center.y(); executed (the execution status of this line is deduced): m_data.radial.fy = center.y(); | - |
1810 | } executed: } Execution Count:250 | 250 |
1811 | | - |
1812 | | - |
1813 | /*! | - |
1814 | Constructs a simple radial gradient with the given center (\a cx, \a cy), | - |
1815 | \a radius and focal point (\a fx, \a fy). | - |
1816 | | - |
1817 | \note If the given focal point is outside the circle defined by the | - |
1818 | center (\a cx, \a cy) and the \a radius it will be re-adjusted to | - |
1819 | the intersection between the line from the center to the focal point | - |
1820 | and the circle. | - |
1821 | | - |
1822 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
1823 | */ | - |
1824 | | - |
1825 | QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy) | - |
1826 | { | - |
1827 | m_type = RadialGradient; executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1828 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1829 | m_data.radial.cx = cx; executed (the execution status of this line is deduced): m_data.radial.cx = cx; | - |
1830 | m_data.radial.cy = cy; executed (the execution status of this line is deduced): m_data.radial.cy = cy; | - |
1831 | m_data.radial.cradius = radius; executed (the execution status of this line is deduced): m_data.radial.cradius = radius; | - |
1832 | | - |
1833 | QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy), executed (the execution status of this line is deduced): QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy), | - |
1834 | radius, executed (the execution status of this line is deduced): radius, | - |
1835 | QPointF(fx, fy)); executed (the execution status of this line is deduced): QPointF(fx, fy)); | - |
1836 | | - |
1837 | m_data.radial.fx = adapted_focal.x(); executed (the execution status of this line is deduced): m_data.radial.fx = adapted_focal.x(); | - |
1838 | m_data.radial.fy = adapted_focal.y(); executed (the execution status of this line is deduced): m_data.radial.fy = adapted_focal.y(); | - |
1839 | } executed: } Execution Count:7 | 7 |
1840 | | - |
1841 | /*! | - |
1842 | Constructs a simple radial gradient with the center at (\a cx, \a cy) and the | - |
1843 | specified \a radius. The focal point lies at the center of the circle. | - |
1844 | | - |
1845 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
1846 | */ | - |
1847 | QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius) | - |
1848 | { | - |
1849 | m_type = RadialGradient; executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1850 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1851 | m_data.radial.cx = cx; executed (the execution status of this line is deduced): m_data.radial.cx = cx; | - |
1852 | m_data.radial.cy = cy; executed (the execution status of this line is deduced): m_data.radial.cy = cy; | - |
1853 | m_data.radial.cradius = radius; executed (the execution status of this line is deduced): m_data.radial.cradius = radius; | - |
1854 | m_data.radial.fx = cx; executed (the execution status of this line is deduced): m_data.radial.fx = cx; | - |
1855 | m_data.radial.fy = cy; executed (the execution status of this line is deduced): m_data.radial.fy = cy; | - |
1856 | } executed: } Execution Count:3 | 3 |
1857 | | - |
1858 | | - |
1859 | /*! | - |
1860 | Constructs a simple radial gradient with the center and focal point at | - |
1861 | (0, 0) with a radius of 1. | - |
1862 | */ | - |
1863 | QRadialGradient::QRadialGradient() | - |
1864 | { | - |
1865 | m_type = RadialGradient; executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1866 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1867 | m_data.radial.cx = 0; executed (the execution status of this line is deduced): m_data.radial.cx = 0; | - |
1868 | m_data.radial.cy = 0; executed (the execution status of this line is deduced): m_data.radial.cy = 0; | - |
1869 | m_data.radial.cradius = 1; executed (the execution status of this line is deduced): m_data.radial.cradius = 1; | - |
1870 | m_data.radial.fx = 0; executed (the execution status of this line is deduced): m_data.radial.fx = 0; | - |
1871 | m_data.radial.fy = 0; executed (the execution status of this line is deduced): m_data.radial.fy = 0; | - |
1872 | } executed: } Execution Count:1 | 1 |
1873 | | - |
1874 | /*! | - |
1875 | \since 4.8 | - |
1876 | | - |
1877 | Constructs an extended radial gradient with the given \a center, \a | - |
1878 | centerRadius, \a focalPoint, and \a focalRadius. | - |
1879 | */ | - |
1880 | QRadialGradient::QRadialGradient(const QPointF ¢er, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius) | - |
1881 | { | - |
1882 | m_type = RadialGradient; never executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1883 | m_spread = PadSpread; never executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1884 | m_data.radial.cx = center.x(); never executed (the execution status of this line is deduced): m_data.radial.cx = center.x(); | - |
1885 | m_data.radial.cy = center.y(); never executed (the execution status of this line is deduced): m_data.radial.cy = center.y(); | - |
1886 | m_data.radial.cradius = centerRadius; never executed (the execution status of this line is deduced): m_data.radial.cradius = centerRadius; | - |
1887 | | - |
1888 | m_data.radial.fx = focalPoint.x(); never executed (the execution status of this line is deduced): m_data.radial.fx = focalPoint.x(); | - |
1889 | m_data.radial.fy = focalPoint.y(); never executed (the execution status of this line is deduced): m_data.radial.fy = focalPoint.y(); | - |
1890 | setFocalRadius(focalRadius); never executed (the execution status of this line is deduced): setFocalRadius(focalRadius); | - |
1891 | } | 0 |
1892 | | - |
1893 | /*! | - |
1894 | \since 4.8 | - |
1895 | | - |
1896 | Constructs an extended radial gradient with the given center | - |
1897 | (\a cx, \a cy), center radius, \a centerRadius, focal point, (\a fx, \a fy), | - |
1898 | and focal radius \a focalRadius. | - |
1899 | */ | - |
1900 | QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius) | - |
1901 | { | - |
1902 | m_type = RadialGradient; never executed (the execution status of this line is deduced): m_type = RadialGradient; | - |
1903 | m_spread = PadSpread; never executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
1904 | m_data.radial.cx = cx; never executed (the execution status of this line is deduced): m_data.radial.cx = cx; | - |
1905 | m_data.radial.cy = cy; never executed (the execution status of this line is deduced): m_data.radial.cy = cy; | - |
1906 | m_data.radial.cradius = centerRadius; never executed (the execution status of this line is deduced): m_data.radial.cradius = centerRadius; | - |
1907 | | - |
1908 | m_data.radial.fx = fx; never executed (the execution status of this line is deduced): m_data.radial.fx = fx; | - |
1909 | m_data.radial.fy = fy; never executed (the execution status of this line is deduced): m_data.radial.fy = fy; | - |
1910 | setFocalRadius(focalRadius); never executed (the execution status of this line is deduced): setFocalRadius(focalRadius); | - |
1911 | } | 0 |
1912 | | - |
1913 | /*! | - |
1914 | Returns the center of this radial gradient in logical coordinates. | - |
1915 | | - |
1916 | \sa QGradient::stops() | - |
1917 | */ | - |
1918 | | - |
1919 | QPointF QRadialGradient::center() const | - |
1920 | { | - |
1921 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1922 | 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 |
1923 | } | - |
1924 | | - |
1925 | /*! | - |
1926 | \fn void QRadialGradient::setCenter(qreal x, qreal y) | - |
1927 | \overload | - |
1928 | \since 4.2 | - |
1929 | | - |
1930 | Sets the center of this radial gradient in logical coordinates | - |
1931 | to (\a x, \a y). | - |
1932 | | - |
1933 | \sa center() | - |
1934 | */ | - |
1935 | | - |
1936 | /*! | - |
1937 | \since 4.2 | - |
1938 | | - |
1939 | Sets the center of this radial gradient in logical coordinates | - |
1940 | to \a center. | - |
1941 | | - |
1942 | \sa center() | - |
1943 | */ | - |
1944 | | - |
1945 | void QRadialGradient::setCenter(const QPointF ¢er) | - |
1946 | { | - |
1947 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1948 | m_data.radial.cx = center.x(); executed (the execution status of this line is deduced): m_data.radial.cx = center.x(); | - |
1949 | m_data.radial.cy = center.y(); executed (the execution status of this line is deduced): m_data.radial.cy = center.y(); | - |
1950 | } executed: } Execution Count:2 | 2 |
1951 | | - |
1952 | | - |
1953 | /*! | - |
1954 | Returns the radius of this radial gradient in logical coordinates. | - |
1955 | | - |
1956 | Equivalent to centerRadius() | - |
1957 | | - |
1958 | \sa QGradient::stops() | - |
1959 | */ | - |
1960 | | - |
1961 | qreal QRadialGradient::radius() const | - |
1962 | { | - |
1963 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1964 | return m_data.radial.cradius; executed: return m_data.radial.cradius; Execution Count:1024 | 1024 |
1965 | } | - |
1966 | | - |
1967 | | - |
1968 | /*! | - |
1969 | \since 4.2 | - |
1970 | | - |
1971 | Sets the radius of this radial gradient in logical coordinates | - |
1972 | to \a radius | - |
1973 | | - |
1974 | Equivalent to setCenterRadius() | - |
1975 | */ | - |
1976 | void QRadialGradient::setRadius(qreal radius) | - |
1977 | { | - |
1978 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1979 | m_data.radial.cradius = radius; executed (the execution status of this line is deduced): m_data.radial.cradius = radius; | - |
1980 | } executed: } Execution Count:1 | 1 |
1981 | | - |
1982 | /*! | - |
1983 | \since 4.8 | - |
1984 | | - |
1985 | Returns the center radius of this radial gradient in logical | - |
1986 | coordinates. | - |
1987 | | - |
1988 | \sa QGradient::stops() | - |
1989 | */ | - |
1990 | qreal QRadialGradient::centerRadius() const | - |
1991 | { | - |
1992 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
1993 | return m_data.radial.cradius; executed: return m_data.radial.cradius; Execution Count:506 | 506 |
1994 | } | - |
1995 | | - |
1996 | /*! | - |
1997 | \since 4.8 | - |
1998 | | - |
1999 | Sets the center radius of this radial gradient in logical coordinates | - |
2000 | to \a radius | - |
2001 | */ | - |
2002 | void QRadialGradient::setCenterRadius(qreal radius) | - |
2003 | { | - |
2004 | Q_ASSERT(m_type == RadialGradient); never executed (the execution status of this line is deduced): qt_noop(); | - |
2005 | m_data.radial.cradius = radius; never executed (the execution status of this line is deduced): m_data.radial.cradius = radius; | - |
2006 | } | 0 |
2007 | | - |
2008 | /*! | - |
2009 | \since 4.8 | - |
2010 | | - |
2011 | Returns the focal radius of this radial gradient in logical | - |
2012 | coordinates. | - |
2013 | | - |
2014 | \sa QGradient::stops() | - |
2015 | */ | - |
2016 | qreal QRadialGradient::focalRadius() const | - |
2017 | { | - |
2018 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2019 | Q_DUMMY_ACCESSOR executed (the execution status of this line is deduced): union {void *p; uint i;}; p = dummy; | - |
2020 | | - |
2021 | // mask away low three bits | - |
2022 | union { float f; quint32 i; } u; executed (the execution status of this line is deduced): union { float f; quint32 i; } u; | - |
2023 | u.i = i & ~0x07; executed (the execution status of this line is deduced): u.i = i & ~0x07; | - |
2024 | return u.f; executed: return u.f; Execution Count:1012 | 1012 |
2025 | } | - |
2026 | | - |
2027 | /*! | - |
2028 | \since 4.8 | - |
2029 | | - |
2030 | Sets the focal radius of this radial gradient in logical coordinates | - |
2031 | to \a radius | - |
2032 | */ | - |
2033 | void QRadialGradient::setFocalRadius(qreal radius) | - |
2034 | { | - |
2035 | Q_ASSERT(m_type == RadialGradient); never executed (the execution status of this line is deduced): qt_noop(); | - |
2036 | Q_DUMMY_ACCESSOR never executed (the execution status of this line is deduced): union {void *p; uint i;}; p = dummy; | - |
2037 | | - |
2038 | // Since there's no QGradientData, we only have the dummy void * to | - |
2039 | // store additional data in. The three lowest bits are already | - |
2040 | // taken, thus we cut the three lowest bits from the significand | - |
2041 | // and store the radius as a float. | - |
2042 | union { float f; quint32 i; } u; never executed (the execution status of this line is deduced): union { float f; quint32 i; } u; | - |
2043 | u.f = float(radius); never executed (the execution status of this line is deduced): u.f = float(radius); | - |
2044 | // add 0x04 to round up when we drop the three lowest bits | - |
2045 | i |= (u.i + 0x04) & ~0x07; never executed (the execution status of this line is deduced): i |= (u.i + 0x04) & ~0x07; | - |
2046 | dummy = p; never executed (the execution status of this line is deduced): dummy = p; | - |
2047 | } | 0 |
2048 | | - |
2049 | /*! | - |
2050 | Returns the focal point of this radial gradient in logical | - |
2051 | coordinates. | - |
2052 | | - |
2053 | \sa QGradient::stops() | - |
2054 | */ | - |
2055 | | - |
2056 | QPointF QRadialGradient::focalPoint() const | - |
2057 | { | - |
2058 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2059 | 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 |
2060 | } | - |
2061 | | - |
2062 | /*! | - |
2063 | \fn void QRadialGradient::setFocalPoint(qreal x, qreal y) | - |
2064 | \overload | - |
2065 | \since 4.2 | - |
2066 | | - |
2067 | Sets the focal point of this radial gradient in logical | - |
2068 | coordinates to (\a x, \a y). | - |
2069 | | - |
2070 | \sa focalPoint() | - |
2071 | */ | - |
2072 | | - |
2073 | /*! | - |
2074 | \since 4.2 | - |
2075 | | - |
2076 | Sets the focal point of this radial gradient in logical | - |
2077 | coordinates to \a focalPoint. | - |
2078 | | - |
2079 | \sa focalPoint() | - |
2080 | */ | - |
2081 | | - |
2082 | void QRadialGradient::setFocalPoint(const QPointF &focalPoint) | - |
2083 | { | - |
2084 | Q_ASSERT(m_type == RadialGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2085 | m_data.radial.fx = focalPoint.x(); executed (the execution status of this line is deduced): m_data.radial.fx = focalPoint.x(); | - |
2086 | m_data.radial.fy = focalPoint.y(); executed (the execution status of this line is deduced): m_data.radial.fy = focalPoint.y(); | - |
2087 | } executed: } Execution Count:2 | 2 |
2088 | | - |
2089 | | - |
2090 | | - |
2091 | /*! | - |
2092 | \class QConicalGradient | - |
2093 | \ingroup painting | - |
2094 | \inmodule QtGui | - |
2095 | | - |
2096 | \brief The QConicalGradient class is used in combination with QBrush to | - |
2097 | specify a conical gradient brush. | - |
2098 | | - |
2099 | Conical gradients interpolate interpolate colors counter-clockwise | - |
2100 | around a center point. | - |
2101 | | - |
2102 | \image qconicalgradient.png | - |
2103 | | - |
2104 | The colors in a gradient is defined using stop points of the | - |
2105 | QGradientStop type, i.e. a position and a color. Use the | - |
2106 | QGradient::setColorAt() or the QGradient::setStops() function to | - |
2107 | define the stop points. It is the gradient's complete set of stop | - |
2108 | points that describes how the gradient area should be filled. If | - |
2109 | no stop points have been specified, a gradient of black at 0 to | - |
2110 | white at 1 is used. | - |
2111 | | - |
2112 | In addition to the functions inherited from QGradient, the | - |
2113 | QConicalGradient class provides the angle() and center() functions | - |
2114 | returning the start angle and center of the gradient. | - |
2115 | | - |
2116 | Note that the setSpread() function has no effect for conical | - |
2117 | gradients. The reason is that the conical gradient is closed by | - |
2118 | definition, i.e. the conical gradient fills the entire circle from | - |
2119 | 0 - 360 degrees, while the boundary of a radial or a linear | - |
2120 | gradient can be specified through its radius or final stop points, | - |
2121 | respectively. | - |
2122 | | - |
2123 | \sa QLinearGradient, QRadialGradient, {painting/gradients}{The | - |
2124 | Gradients Example} | - |
2125 | */ | - |
2126 | | - |
2127 | | - |
2128 | /*! | - |
2129 | Constructs a conical gradient with the given \a center, starting | - |
2130 | the interpolation at the given \a angle. The \a angle must be | - |
2131 | specified in degrees between 0 and 360. | - |
2132 | | - |
2133 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
2134 | */ | - |
2135 | | - |
2136 | QConicalGradient::QConicalGradient(const QPointF ¢er, qreal angle) | - |
2137 | { | - |
2138 | m_type = ConicalGradient; executed (the execution status of this line is deduced): m_type = ConicalGradient; | - |
2139 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
2140 | m_data.conical.cx = center.x(); executed (the execution status of this line is deduced): m_data.conical.cx = center.x(); | - |
2141 | m_data.conical.cy = center.y(); executed (the execution status of this line is deduced): m_data.conical.cy = center.y(); | - |
2142 | m_data.conical.angle = angle; executed (the execution status of this line is deduced): m_data.conical.angle = angle; | - |
2143 | } executed: } Execution Count:3 | 3 |
2144 | | - |
2145 | | - |
2146 | /*! | - |
2147 | Constructs a conical gradient with the given center (\a cx, \a | - |
2148 | cy), starting the interpolation at the given \a angle. The angle | - |
2149 | must be specified in degrees between 0 and 360. | - |
2150 | | - |
2151 | \sa QGradient::setColorAt(), QGradient::setStops() | - |
2152 | */ | - |
2153 | | - |
2154 | QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle) | - |
2155 | { | - |
2156 | m_type = ConicalGradient; executed (the execution status of this line is deduced): m_type = ConicalGradient; | - |
2157 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
2158 | m_data.conical.cx = cx; executed (the execution status of this line is deduced): m_data.conical.cx = cx; | - |
2159 | m_data.conical.cy = cy; executed (the execution status of this line is deduced): m_data.conical.cy = cy; | - |
2160 | m_data.conical.angle = angle; executed (the execution status of this line is deduced): m_data.conical.angle = angle; | - |
2161 | } executed: } Execution Count:4 | 4 |
2162 | | - |
2163 | | - |
2164 | /*! | - |
2165 | Constructs a conical with center at (0, 0) starting the | - |
2166 | interpolation at angle 0. | - |
2167 | | - |
2168 | \sa QGradient::setColorAt(), setCenter(), setAngle() | - |
2169 | */ | - |
2170 | | - |
2171 | QConicalGradient::QConicalGradient() | - |
2172 | { | - |
2173 | m_type = ConicalGradient; executed (the execution status of this line is deduced): m_type = ConicalGradient; | - |
2174 | m_spread = PadSpread; executed (the execution status of this line is deduced): m_spread = PadSpread; | - |
2175 | m_data.conical.cx = 0; executed (the execution status of this line is deduced): m_data.conical.cx = 0; | - |
2176 | m_data.conical.cy = 0; executed (the execution status of this line is deduced): m_data.conical.cy = 0; | - |
2177 | m_data.conical.angle = 0; executed (the execution status of this line is deduced): m_data.conical.angle = 0; | - |
2178 | } executed: } Execution Count:1 | 1 |
2179 | | - |
2180 | | - |
2181 | /*! | - |
2182 | Returns the center of the conical gradient in logical | - |
2183 | coordinates. | - |
2184 | | - |
2185 | \sa stops() | - |
2186 | */ | - |
2187 | | - |
2188 | QPointF QConicalGradient::center() const | - |
2189 | { | - |
2190 | Q_ASSERT(m_type == ConicalGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2191 | 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 |
2192 | } | - |
2193 | | - |
2194 | | - |
2195 | /*! | - |
2196 | \fn void QConicalGradient::setCenter(qreal x, qreal y) | - |
2197 | | - |
2198 | \overload | - |
2199 | | - |
2200 | Sets the center of this conical gradient in logical coordinates to | - |
2201 | (\a x, \a y). | - |
2202 | | - |
2203 | \sa center() | - |
2204 | */ | - |
2205 | | - |
2206 | /*! | - |
2207 | Sets the center of this conical gradient in logical coordinates to | - |
2208 | \a center. | - |
2209 | | - |
2210 | \sa center() | - |
2211 | */ | - |
2212 | | - |
2213 | void QConicalGradient::setCenter(const QPointF ¢er) | - |
2214 | { | - |
2215 | Q_ASSERT(m_type == ConicalGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2216 | m_data.conical.cx = center.x(); executed (the execution status of this line is deduced): m_data.conical.cx = center.x(); | - |
2217 | m_data.conical.cy = center.y(); executed (the execution status of this line is deduced): m_data.conical.cy = center.y(); | - |
2218 | } executed: } Execution Count:2 | 2 |
2219 | | - |
2220 | /*! | - |
2221 | Returns the start angle of the conical gradient in logical | - |
2222 | coordinates. | - |
2223 | | - |
2224 | \sa stops() | - |
2225 | */ | - |
2226 | | - |
2227 | qreal QConicalGradient::angle() const | - |
2228 | { | - |
2229 | Q_ASSERT(m_type == ConicalGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2230 | return m_data.conical.angle; executed: return m_data.conical.angle; Execution Count:12 | 12 |
2231 | } | - |
2232 | | - |
2233 | | - |
2234 | /*! | - |
2235 | \since 4.2 | - |
2236 | | - |
2237 | Sets \a angle to be the start angle for this conical gradient in | - |
2238 | logical coordinates. | - |
2239 | | - |
2240 | \sa angle() | - |
2241 | */ | - |
2242 | | - |
2243 | void QConicalGradient::setAngle(qreal angle) | - |
2244 | { | - |
2245 | Q_ASSERT(m_type == ConicalGradient); executed (the execution status of this line is deduced): qt_noop(); | - |
2246 | m_data.conical.angle = angle; executed (the execution status of this line is deduced): m_data.conical.angle = angle; | - |
2247 | } executed: } Execution Count:1 | 1 |
2248 | | - |
2249 | /*! | - |
2250 | \typedef QGradientStop | - |
2251 | \relates QGradient | - |
2252 | | - |
2253 | Typedef for QPair<\l qreal, QColor>. | - |
2254 | */ | - |
2255 | | - |
2256 | /*! | - |
2257 | \typedef QGradientStops | - |
2258 | \relates QGradient | - |
2259 | | - |
2260 | Typedef for QVector<QGradientStop>. | - |
2261 | */ | - |
2262 | | - |
2263 | /*! | - |
2264 | \typedef QBrush::DataPtr | - |
2265 | \internal | - |
2266 | */ | - |
2267 | | - |
2268 | /*! | - |
2269 | \fn DataPtr &QBrush::data_ptr() | - |
2270 | \internal | - |
2271 | */ | - |
2272 | | - |
2273 | | - |
2274 | /*! | - |
2275 | \fn bool QBrush::isDetached() const | - |
2276 | \internal | - |
2277 | */ | - |
2278 | | - |
2279 | /*! | - |
2280 | \fn QTransform QBrush::transform() const | - |
2281 | \since 4.3 | - |
2282 | | - |
2283 | Returns the current transformation matrix for the brush. | - |
2284 | | - |
2285 | \sa setTransform() | - |
2286 | */ | - |
2287 | | - |
2288 | #undef Q_DUMMY_ACCESSOR | - |
2289 | | - |
2290 | QT_END_NAMESPACE | - |
2291 | | - |
| | |