effects/qgraphicseffect.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
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/*! -
43 \class QGraphicsEffect -
44 \brief The QGraphicsEffect class is the base class for all graphics -
45 effects. -
46 \since 4.6 -
47 \ingroup multimedia -
48 \ingroup graphicsview-api -
49 \inmodule QtWidgets -
50 -
51 Effects alter the appearance of elements by hooking into the rendering -
52 pipeline and operating between the source (e.g., a QGraphicsPixmapItem) -
53 and the destination device (e.g., QGraphicsView's viewport). Effects can be -
54 disabled by calling setEnabled(false). If effects are disabled, the source -
55 is rendered directly. -
56 -
57 To add a visual effect to a QGraphicsItem, for example, you can use one of -
58 the standard effects, or alternately, create your own effect by creating a -
59 subclass of QGraphicsEffect. The effect can then be installed on the item -
60 using QGraphicsItem::setGraphicsEffect(). -
61 -
62 Qt provides the following standard effects: -
63 -
64 \list -
65 \li QGraphicsBlurEffect - blurs the item by a given radius -
66 \li QGraphicsDropShadowEffect - renders a dropshadow behind the item -
67 \li QGraphicsColorizeEffect - renders the item in shades of any given color -
68 \li QGraphicsOpacityEffect - renders the item with an opacity -
69 \endlist -
70 -
71 \table -
72 \row -
73 \li{2,1} \image graphicseffect-plain.png -
74 \row -
75 \li \image graphicseffect-blur.png -
76 \li \image graphicseffect-colorize.png -
77 \row -
78 \li \image graphicseffect-opacity.png -
79 \li \image graphicseffect-drop-shadow.png -
80 \endtable -
81 -
82 \image graphicseffect-widget.png -
83 -
84 For more information on how to use each effect, refer to the specific -
85 effect's documentation. -
86 -
87 To create your own custom effect, create a subclass of QGraphicsEffect (or -
88 any other existing effects) and reimplement the virtual function draw(). -
89 This function is called whenever the effect needs to redraw. The draw() -
90 function takes the painter with which to draw as an argument. For more -
91 information, refer to the documenation for draw(). In the draw() function -
92 you can call sourcePixmap() to get a pixmap of the graphics effect source -
93 which you can then process. -
94 -
95 If your effect changes, use update() to request for a redraw. If your -
96 custom effect changes the bounding rectangle of the source, e.g., a radial -
97 glow effect may need to apply an extra margin, you can reimplement the -
98 virtual boundingRectFor() function, and call updateBoundingRect() -
99 to notify the framework whenever this rectangle changes. The virtual -
100 sourceChanged() function is called to notify the effects that -
101 the source has changed in some way - e.g., if the source is a -
102 QGraphicsRectItem and its rectangle parameters have changed. -
103 -
104 \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect() -
105*/ -
106 -
107#include "qgraphicseffect_p.h" -
108#include "private/qgraphicsitem_p.h" -
109 -
110#include <QtWidgets/qgraphicsitem.h> -
111 -
112#include <QtGui/qimage.h> -
113#include <QtGui/qpainter.h> -
114#include <QtGui/qpaintengine.h> -
115#include <QtCore/qrect.h> -
116#include <QtCore/qdebug.h> -
117#include <private/qdrawhelper_p.h> -
118 -
119#ifndef QT_NO_GRAPHICSEFFECT -
120QT_BEGIN_NAMESPACE -
121 -
122/*! -
123 \internal -
124 \class QGraphicsEffectSource -
125 \brief The QGraphicsEffectSource class represents the source on which a -
126 QGraphicsEffect is installed on. -
127 -
128 When a QGraphicsEffect is installed on a QGraphicsItem, for example, this -
129 class will act as a wrapper around QGraphicsItem. Then, calling update() is -
130 effectively the same as calling QGraphicsItem::update(). -
131 -
132 QGraphicsEffectSource also provides a pixmap() function which creates a -
133 pixmap with the source painted into it. -
134 -
135 \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect() -
136*/ -
137 -
138/*! -
139 \internal -
140*/ -
141QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent) -
142 : QObject(dd, parent) -
143{}
executed: }
Execution Count:28
28
144 -
145/*! -
146 Destroys the effect source. -
147*/ -
148QGraphicsEffectSource::~QGraphicsEffectSource() -
149{} -
150 -
151/*! -
152 Returns the bounding rectangle of the source mapped to the given \a system. -
153 -
154 \sa draw() -
155*/ -
156QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const -
157{ -
158 return d_func()->boundingRect(system);
executed: return d_func()->boundingRect(system);
Execution Count:30
30
159} -
160 -
161/*! -
162 Returns the bounding rectangle of the source mapped to the given \a system. -
163 -
164 Calling this function with Qt::DeviceCoordinates outside of -
165 QGraphicsEffect::draw() will give undefined results, as there is no device -
166 context available. -
167 -
168 \sa draw() -
169*/ -
170QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const -
171{ -
172 Q_D(const QGraphicsEffect);
never executed (the execution status of this line is deduced): const QGraphicsEffectPrivate * const d = d_func();
-
173 if (d->source)
never evaluated: d->source
0
174 return d->source->boundingRect(system);
never executed: return d->source->boundingRect(system);
0
175 return QRectF();
never executed: return QRectF();
0
176} -
177 -
178/*! -
179 Returns a pointer to the item if this source is a QGraphicsItem; otherwise -
180 returns 0. -
181 -
182 \sa widget() -
183*/ -
184const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const -
185{ -
186 return d_func()->graphicsItem();
executed: return d_func()->graphicsItem();
Execution Count:33
33
187} -
188 -
189/*! -
190 Returns a pointer to the widget if this source is a QWidget; otherwise -
191 returns 0. -
192 -
193 \sa graphicsItem() -
194*/ -
195const QWidget *QGraphicsEffectSource::widget() const -
196{ -
197 return d_func()->widget();
never executed: return d_func()->widget();
0
198} -
199 -
200/*! -
201 Returns a pointer to the style options (used when drawing the source) if -
202 available; otherwise returns 0. -
203 -
204 \sa graphicsItem(), widget() -
205*/ -
206const QStyleOption *QGraphicsEffectSource::styleOption() const -
207{ -
208 return d_func()->styleOption();
executed: return d_func()->styleOption();
Execution Count:11
11
209} -
210 -
211/*! -
212 Draws the source using the given \a painter. -
213 -
214 This function should only be called from QGraphicsEffect::draw(). -
215 -
216 \sa QGraphicsEffect::draw() -
217*/ -
218void QGraphicsEffectSource::draw(QPainter *painter) -
219{ -
220 Q_D(const QGraphicsEffectSource);
executed (the execution status of this line is deduced): const QGraphicsEffectSourcePrivate * const d = d_func();
-
221 -
222 QPixmap pm;
executed (the execution status of this line is deduced): QPixmap pm;
-
223 if (QPixmapCache::find(d->m_cacheKey, &pm)) {
evaluated: QPixmapCache::find(d->m_cacheKey, &pm)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:14
4-14
224 QTransform restoreTransform;
executed (the execution status of this line is deduced): QTransform restoreTransform;
-
225 if (d->m_cachedSystem == Qt::DeviceCoordinates) {
partially evaluated: d->m_cachedSystem == Qt::DeviceCoordinates
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
226 restoreTransform = painter->worldTransform();
executed (the execution status of this line is deduced): restoreTransform = painter->worldTransform();
-
227 painter->setWorldTransform(QTransform());
executed (the execution status of this line is deduced): painter->setWorldTransform(QTransform());
-
228 }
executed: }
Execution Count:4
4
229 -
230 painter->drawPixmap(d->m_cachedOffset, pm);
executed (the execution status of this line is deduced): painter->drawPixmap(d->m_cachedOffset, pm);
-
231 -
232 if (d->m_cachedSystem == Qt::DeviceCoordinates)
partially evaluated: d->m_cachedSystem == Qt::DeviceCoordinates
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
233 painter->setWorldTransform(restoreTransform);
executed: painter->setWorldTransform(restoreTransform);
Execution Count:4
4
234 } else {
executed: }
Execution Count:4
4
235 d_func()->draw(painter);
executed (the execution status of this line is deduced): d_func()->draw(painter);
-
236 }
executed: }
Execution Count:14
14
237} -
238 -
239/*! -
240 Draws the source directly using the given \a painter. -
241 -
242 This function should only be called from QGraphicsEffect::draw(). -
243 -
244 For example: -
245 -
246 \snippet code/src_gui_effects_qgraphicseffect.cpp 0 -
247 -
248 \sa QGraphicsEffect::draw() -
249*/ -
250void QGraphicsEffect::drawSource(QPainter *painter) -
251{ -
252 Q_D(const QGraphicsEffect);
executed (the execution status of this line is deduced): const QGraphicsEffectPrivate * const d = d_func();
-
253 if (d->source)
partially evaluated: d->source
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
254 d->source->draw(painter);
executed: d->source->draw(painter);
Execution Count:10
10
255}
executed: }
Execution Count:10
10
256 -
257/*! -
258 Schedules a redraw of the source. Call this function whenever the source -
259 needs to be redrawn. -
260 -
261 \sa QGraphicsEffect::updateBoundingRect(), QWidget::update(), -
262 QGraphicsItem::update(), -
263*/ -
264void QGraphicsEffectSource::update() -
265{ -
266 d_func()->update();
executed (the execution status of this line is deduced): d_func()->update();
-
267}
executed: }
Execution Count:8
8
268 -
269/*! -
270 Returns true if the source effectively is a pixmap, e.g., a -
271 QGraphicsPixmapItem. -
272 -
273 This function is useful for optimization purposes. For instance, there's no -
274 point in drawing the source in device coordinates to avoid pixmap scaling -
275 if this function returns true - the source pixmap will be scaled anyways. -
276*/ -
277bool QGraphicsEffectSource::isPixmap() const -
278{ -
279 return d_func()->isPixmap();
executed: return d_func()->isPixmap();
Execution Count:3
3
280} -
281 -
282/*! -
283 Returns true if the source effectively is a pixmap, e.g., a -
284 QGraphicsPixmapItem. -
285 -
286 This function is useful for optimization purposes. For instance, there's no -
287 point in drawing the source in device coordinates to avoid pixmap scaling -
288 if this function returns true - the source pixmap will be scaled anyways. -
289*/ -
290bool QGraphicsEffect::sourceIsPixmap() const -
291{ -
292 return source() ? source()->isPixmap() : false;
never executed: return source() ? source()->isPixmap() : false;
0
293} -
294 -
295/*! -
296 Returns a pixmap with the source painted into it. -
297 -
298 The \a system specifies which coordinate system to be used for the source. -
299 The optional \a offset parameter returns the offset where the pixmap should -
300 be painted at using the current painter. -
301 -
302 The \a mode determines how much of the effect the pixmap will contain. -
303 By default, the pixmap will contain the whole effect. -
304 -
305 The returned pixmap is bound to the current painter's device rectangle when -
306 \a system is Qt::DeviceCoordinates. -
307 -
308 \sa QGraphicsEffect::draw(), boundingRect() -
309*/ -
310QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const -
311{ -
312 Q_D(const QGraphicsEffectSource);
executed (the execution status of this line is deduced): const QGraphicsEffectSourcePrivate * const d = d_func();
-
313 -
314 // Shortcut, no cache for childless pixmap items... -
315 const QGraphicsItem *item = graphicsItem();
executed (the execution status of this line is deduced): const QGraphicsItem *item = graphicsItem();
-
316 if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) {
evaluated: system == Qt::LogicalCoordinates
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:20
evaluated: mode == QGraphicsEffect::NoPad
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: isPixmap()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-20
317 const QGraphicsPixmapItem *pixmapItem = static_cast<const QGraphicsPixmapItem *>(item);
executed (the execution status of this line is deduced): const QGraphicsPixmapItem *pixmapItem = static_cast<const QGraphicsPixmapItem *>(item);
-
318 if (offset)
partially evaluated: offset
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
319 *offset = pixmapItem->offset().toPoint();
executed: *offset = pixmapItem->offset().toPoint();
Execution Count:1
1
320 return pixmapItem->pixmap();
executed: return pixmapItem->pixmap();
Execution Count:1
1
321 } -
322 -
323 if (system == Qt::DeviceCoordinates && item
evaluated: system == Qt::DeviceCoordinates
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:6
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
324 && !static_cast<const QGraphicsItemEffectSourcePrivate *>(d_func())->info) {
evaluated: !static_cast<const QGraphicsItemEffectSourcePrivate *>(d_func())->info
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
325 qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
executed (the execution status of this line is deduced): QMessageLogger("effects/qgraphicseffect.cpp", 325, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
-
326 return QPixmap();
executed: return QPixmap();
Execution Count:1
1
327 } -
328 -
329 QPixmap pm;
executed (the execution status of this line is deduced): QPixmap pm;
-
330 if (item && d->m_cachedSystem == system && d->m_cachedMode == mode)
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
evaluated: d->m_cachedSystem == system
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:7
evaluated: d->m_cachedMode == mode
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:8
0-25
331 QPixmapCache::find(d->m_cacheKey, &pm);
executed: QPixmapCache::find(d->m_cacheKey, &pm);
Execution Count:10
10
332 -
333 if (pm.isNull()) {
evaluated: pm.isNull()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:5
5-20
334 pm = d->pixmap(system, &d->m_cachedOffset, mode);
executed (the execution status of this line is deduced): pm = d->pixmap(system, &d->m_cachedOffset, mode);
-
335 d->m_cachedSystem = system;
executed (the execution status of this line is deduced): d->m_cachedSystem = system;
-
336 d->m_cachedMode = mode;
executed (the execution status of this line is deduced): d->m_cachedMode = mode;
-
337 -
338 d->invalidateCache();
executed (the execution status of this line is deduced): d->invalidateCache();
-
339 d->m_cacheKey = QPixmapCache::insert(pm);
executed (the execution status of this line is deduced): d->m_cacheKey = QPixmapCache::insert(pm);
-
340 }
executed: }
Execution Count:20
20
341 -
342 if (offset)
evaluated: offset
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:10
10-15
343 *offset = d->m_cachedOffset;
executed: *offset = d->m_cachedOffset;
Execution Count:15
15
344 -
345 return pm;
executed: return pm;
Execution Count:25
25
346} -
347 -
348/*! -
349 Returns a pixmap with the source painted into it. -
350 -
351 The \a system specifies which coordinate system to be used for the source. -
352 The optional \a offset parameter returns the offset where the pixmap should -
353 be painted at using the current painter. For control on how the pixmap is -
354 padded use the \a mode parameter. -
355 -
356 The returned pixmap is clipped to the current painter's device rectangle when -
357 \a system is Qt::DeviceCoordinates. -
358 -
359 Calling this function with Qt::DeviceCoordinates outside of -
360 QGraphicsEffect::draw() will give undefined results, as there is no device -
361 context available. -
362 -
363 \sa draw(), boundingRect() -
364*/ -
365QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const -
366{ -
367 Q_D(const QGraphicsEffect);
executed (the execution status of this line is deduced): const QGraphicsEffectPrivate * const d = d_func();
-
368 if (d->source)
partially evaluated: d->source
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
369 return d->source->pixmap(system, offset, mode);
executed: return d->source->pixmap(system, offset, mode);
Execution Count:14
14
370 return QPixmap();
never executed: return QPixmap();
0
371} -
372 -
373QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() -
374{ -
375 invalidateCache();
executed (the execution status of this line is deduced): invalidateCache();
-
376}
executed: }
Execution Count:21
21
377 -
378void QGraphicsEffectSourcePrivate::setCachedOffset(const QPoint &offset) -
379{ -
380 m_cachedOffset = offset;
executed (the execution status of this line is deduced): m_cachedOffset = offset;
-
381}
executed: }
Execution Count:9
9
382 -
383void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) const -
384{ -
385 if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
evaluated: m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:28
28-117
386 && (reason == EffectRectChanged
evaluated: reason == EffectRectChanged
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:115
2-115
387 || (reason == TransformChanged && m_cachedSystem == Qt::LogicalCoordinates))) {
evaluated: reason == TransformChanged
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:109
partially evaluated: m_cachedSystem == Qt::LogicalCoordinates
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-109
388 return;
executed: return;
Execution Count:2
2
389 } -
390 -
391 QPixmapCache::remove(m_cacheKey);
executed (the execution status of this line is deduced): QPixmapCache::remove(m_cacheKey);
-
392}
executed: }
Execution Count:143
143
393 -
394/*! -
395 Constructs a new QGraphicsEffect instance having the -
396 specified \a parent. -
397*/ -
398QGraphicsEffect::QGraphicsEffect(QObject *parent) -
399 : QObject(*new QGraphicsEffectPrivate, parent) -
400{ -
401}
executed: }
Execution Count:21
21
402 -
403/*! -
404 \internal -
405*/ -
406QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent) -
407 : QObject(dd, parent) -
408{ -
409}
executed: }
Execution Count:8
8
410 -
411/*! -
412 Removes the effect from the source, and destroys the graphics effect. -
413*/ -
414QGraphicsEffect::~QGraphicsEffect() -
415{ -
416 Q_D(QGraphicsEffect);
executed (the execution status of this line is deduced): QGraphicsEffectPrivate * const d = d_func();
-
417 d->setGraphicsEffectSource(0);
executed (the execution status of this line is deduced): d->setGraphicsEffectSource(0);
-
418}
executed: }
Execution Count:22
22
419 -
420/*! -
421 Returns the effective bounding rectangle for this effect, i.e., the -
422 bounding rectangle of the source in device coordinates, adjusted by -
423 any margins applied by the effect itself. -
424 -
425 \sa boundingRectFor(), updateBoundingRect() -
426*/ -
427QRectF QGraphicsEffect::boundingRect() const -
428{ -
429 Q_D(const QGraphicsEffect);
executed (the execution status of this line is deduced): const QGraphicsEffectPrivate * const d = d_func();
-
430 if (d->source)
evaluated: d->source
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
1-16
431 return boundingRectFor(d->source->boundingRect());
executed: return boundingRectFor(d->source->boundingRect());
Execution Count:16
16
432 return QRectF();
executed: return QRectF();
Execution Count:1
1
433} -
434 -
435/*! -
436 Returns the effective bounding rectangle for this effect, given the -
437 provided \a rect in the device coordinates. When writing -
438 you own custom effect, you must call updateBoundingRect() whenever any -
439 parameters are changed that may cause this this function to return a -
440 different value. -
441 -
442 \sa sourceBoundingRect() -
443*/ -
444QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const -
445{ -
446 return rect;
never executed: return rect;
0
447} -
448 -
449/*! -
450 \property QGraphicsEffect::enabled -
451 \brief whether the effect is enabled or not. -
452 -
453 If an effect is disabled, the source will be rendered with as normal, with -
454 no interference from the effect. If the effect is enabled, the source will -
455 be rendered with the effect applied. -
456 -
457 This property is enabled by default. -
458 -
459 Using this property, you can disable certain effects on slow platforms, in -
460 order to ensure that the user interface is responsive. -
461*/ -
462bool QGraphicsEffect::isEnabled() const -
463{ -
464 Q_D(const QGraphicsEffect);
executed (the execution status of this line is deduced): const QGraphicsEffectPrivate * const d = d_func();
-
465 return d->isEnabled;
executed: return d->isEnabled;
Execution Count:170
170
466} -
467 -
468void QGraphicsEffect::setEnabled(bool enable) -
469{ -
470 Q_D(QGraphicsEffect);
executed (the execution status of this line is deduced): QGraphicsEffectPrivate * const d = d_func();
-
471 if (d->isEnabled == enable)
evaluated: d->isEnabled == enable
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
472 return;
executed: return;
Execution Count:1
1
473 -
474 d->isEnabled = enable;
executed (the execution status of this line is deduced): d->isEnabled = enable;
-
475 if (d->source) {
evaluated: d->source
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
476 d->source->d_func()->effectBoundingRectChanged();
executed (the execution status of this line is deduced): d->source->d_func()->effectBoundingRectChanged();
-
477 d->source->d_func()->invalidateCache();
executed (the execution status of this line is deduced): d->source->d_func()->invalidateCache();
-
478 }
executed: }
Execution Count:6
6
479 emit enabledChanged(enable);
executed (the execution status of this line is deduced): enabledChanged(enable);
-
480}
executed: }
Execution Count:7
7
481 -
482/*! -
483 \fn void QGraphicsEffect::enabledChanged(bool enabled) -
484 -
485 This signal is emitted whenever the effect is enabled or disabled. -
486 The \a enabled parameter holds the effects's new enabled state. -
487 -
488 \sa isEnabled() -
489*/ -
490 -
491/*! -
492 Schedules a redraw of the effect. Call this function whenever the effect -
493 needs to be redrawn. This function does not trigger a redraw of the source. -
494 -
495 \sa updateBoundingRect() -
496*/ -
497void QGraphicsEffect::update() -
498{ -
499 Q_D(QGraphicsEffect);
executed (the execution status of this line is deduced): QGraphicsEffectPrivate * const d = d_func();
-
500 if (d->source)
partially evaluated: d->source
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
501 d->source->update();
executed: d->source->update();
Execution Count:3
3
502}
executed: }
Execution Count:3
3
503 -
504/*! -
505 \internal -
506 -
507 Returns a pointer to the source, which provides extra context information -
508 that can be useful for the effect. -
509 -
510 \sa draw() -
511*/ -
512QGraphicsEffectSource *QGraphicsEffect::source() const -
513{ -
514 Q_D(const QGraphicsEffect);
executed (the execution status of this line is deduced): const QGraphicsEffectPrivate * const d = d_func();
-
515 return d->source;
executed: return d->source;
Execution Count:113
113
516} -
517 -
518/*! -
519 This function notifies the effect framework when the effect's bounding -
520 rectangle has changed. As a custom effect author, you must call this -
521 function whenever you change any parameters that will cause the virtual -
522 boundingRectFor() function to return a different value. -
523 -
524 This function will call update() if this is necessary. -
525 -
526 \sa boundingRectFor(), boundingRect(), sourceBoundingRect() -
527*/ -
528void QGraphicsEffect::updateBoundingRect() -
529{ -
530 Q_D(QGraphicsEffect);
executed (the execution status of this line is deduced): QGraphicsEffectPrivate * const d = d_func();
-
531 if (d->source) {
evaluated: d->source
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
532 d->source->d_func()->effectBoundingRectChanged();
executed (the execution status of this line is deduced): d->source->d_func()->effectBoundingRectChanged();
-
533 d->source->d_func()->invalidateCache(QGraphicsEffectSourcePrivate::EffectRectChanged);
executed (the execution status of this line is deduced): d->source->d_func()->invalidateCache(QGraphicsEffectSourcePrivate::EffectRectChanged);
-
534 }
executed: }
Execution Count:2
2
535}
executed: }
Execution Count:3
3
536 -
537/*! -
538 \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0 -
539 -
540 This pure virtual function draws the effect and is called whenever the -
541 source needs to be drawn. -
542 -
543 Reimplement this function in a QGraphicsEffect subclass to provide the -
544 effect's drawing implementation, using \a painter. -
545 -
546 For example: -
547 -
548 \snippet code/src_gui_effects_qgraphicseffect.cpp 1 -
549 -
550 This function should not be called explicitly by the user, since it is -
551 meant for reimplementation purposes only. -
552*/ -
553 -
554/*! -
555 \enum QGraphicsEffect::ChangeFlag -
556 -
557 This enum describes what has changed in QGraphicsEffectSource. -
558 -
559 \value SourceAttached The effect is installed on a source. -
560 \value SourceDetached The effect is uninstalled on a source. -
561 \value SourceBoundingRectChanged The bounding rect of the source has -
562 changed. -
563 \value SourceInvalidated The visual appearance of the source has changed. -
564*/ -
565 -
566/*! -
567 \enum QGraphicsEffect::PixmapPadMode -
568 -
569 This enum describes how the pixmap returned from sourcePixmap should be -
570 padded. -
571 -
572 \value NoPad The pixmap should not receive any additional -
573 padding. -
574 \value PadToTransparentBorder The pixmap should be padded -
575 to ensure it has a completely transparent border. -
576 \value PadToEffectiveBoundingRect The pixmap should be padded to -
577 match the effective bounding rectangle of the effect. -
578*/ -
579 -
580/*! -
581 This virtual function is called by QGraphicsEffect to notify the effect -
582 that the source has changed. If the effect applies any cache, then this -
583 cache must be purged in order to reflect the new appearance of the source. -
584 -
585 The \a flags describes what has changed. -
586*/ -
587void QGraphicsEffect::sourceChanged(ChangeFlags flags) -
588{ -
589 Q_UNUSED(flags);
executed (the execution status of this line is deduced): (void)flags;;
-
590}
executed: }
Execution Count:48
48
591 -
592/*! -
593 \class QGraphicsColorizeEffect -
594 \brief The QGraphicsColorizeEffect class provides a colorize effect. -
595 \since 4.6 -
596 \inmodule QtWidgets -
597 -
598 A colorize effect renders the source with a tint of its color(). The color -
599 can be modified using the setColor() function. -
600 -
601 By default, the color is light blue (QColor(0, 0, 192)). -
602 -
603 \image graphicseffect-colorize.png -
604 -
605 \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsOpacityEffect -
606*/ -
607 -
608/*! -
609 Constructs a new QGraphicsColorizeEffect instance. -
610 The \a parent parameter is passed to QGraphicsEffect's constructor. -
611*/ -
612QGraphicsColorizeEffect::QGraphicsColorizeEffect(QObject *parent) -
613 : QGraphicsEffect(*new QGraphicsColorizeEffectPrivate, parent) -
614{ -
615}
never executed: }
0
616 -
617/*! -
618 Destroys the effect. -
619*/ -
620QGraphicsColorizeEffect::~QGraphicsColorizeEffect() -
621{ -
622} -
623 -
624/*! -
625 \property QGraphicsColorizeEffect::color -
626 \brief the color of the effect. -
627 -
628 By default, the color is light blue (QColor(0, 0, 192)). -
629*/ -
630QColor QGraphicsColorizeEffect::color() const -
631{ -
632 Q_D(const QGraphicsColorizeEffect);
never executed (the execution status of this line is deduced): const QGraphicsColorizeEffectPrivate * const d = d_func();
-
633 return d->filter->color();
never executed: return d->filter->color();
0
634} -
635 -
636void QGraphicsColorizeEffect::setColor(const QColor &color) -
637{ -
638 Q_D(QGraphicsColorizeEffect);
never executed (the execution status of this line is deduced): QGraphicsColorizeEffectPrivate * const d = d_func();
-
639 if (d->filter->color() == color)
never evaluated: d->filter->color() == color
0
640 return;
never executed: return;
0
641 -
642 d->filter->setColor(color);
never executed (the execution status of this line is deduced): d->filter->setColor(color);
-
643 update();
never executed (the execution status of this line is deduced): update();
-
644 emit colorChanged(color);
never executed (the execution status of this line is deduced): colorChanged(color);
-
645}
never executed: }
0
646 -
647/*! -
648 \property QGraphicsColorizeEffect::strength -
649 \brief the strength of the effect. -
650 -
651 By default, the strength is 1.0. -
652 A strength 0.0 equals to no effect, while 1.0 means full colorization. -
653*/ -
654qreal QGraphicsColorizeEffect::strength() const -
655{ -
656 Q_D(const QGraphicsColorizeEffect);
never executed (the execution status of this line is deduced): const QGraphicsColorizeEffectPrivate * const d = d_func();
-
657 return d->filter->strength();
never executed: return d->filter->strength();
0
658} -
659 -
660void QGraphicsColorizeEffect::setStrength(qreal strength) -
661{ -
662 Q_D(QGraphicsColorizeEffect);
never executed (the execution status of this line is deduced): QGraphicsColorizeEffectPrivate * const d = d_func();
-
663 if (qFuzzyCompare(d->filter->strength(), strength))
never evaluated: qFuzzyCompare(d->filter->strength(), strength)
0
664 return;
never executed: return;
0
665 -
666 d->filter->setStrength(strength);
never executed (the execution status of this line is deduced): d->filter->setStrength(strength);
-
667 d->opaque = !qFuzzyIsNull(strength);
never executed (the execution status of this line is deduced): d->opaque = !qFuzzyIsNull(strength);
-
668 update();
never executed (the execution status of this line is deduced): update();
-
669 emit strengthChanged(strength);
never executed (the execution status of this line is deduced): strengthChanged(strength);
-
670}
never executed: }
0
671 -
672/*! \fn void QGraphicsColorizeEffect::strengthChanged(qreal strength) -
673 This signal is emitted whenever setStrength() changes the colorize -
674 strength property. \a strength contains the new strength value of -
675 the colorize effect. -
676 */ -
677 -
678/*! -
679 \fn void QGraphicsColorizeEffect::colorChanged(const QColor &color) -
680 -
681 This signal is emitted whenever the effect's color changes. -
682 The \a color parameter holds the effect's new color. -
683*/ -
684 -
685/*! -
686 \reimp -
687*/ -
688void QGraphicsColorizeEffect::draw(QPainter *painter) -
689{ -
690 Q_D(QGraphicsColorizeEffect);
never executed (the execution status of this line is deduced): QGraphicsColorizeEffectPrivate * const d = d_func();
-
691 -
692 if (!d->opaque) {
never evaluated: !d->opaque
0
693 drawSource(painter);
never executed (the execution status of this line is deduced): drawSource(painter);
-
694 return;
never executed: return;
0
695 } -
696 -
697 QPoint offset;
never executed (the execution status of this line is deduced): QPoint offset;
-
698 if (sourceIsPixmap()) {
never evaluated: sourceIsPixmap()
0
699 // No point in drawing in device coordinates (pixmap will be scaled anyways). -
700 const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad);
never executed (the execution status of this line is deduced): const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad);
-
701 if (!pixmap.isNull())
never evaluated: !pixmap.isNull()
0
702 d->filter->draw(painter, offset, pixmap);
never executed: d->filter->draw(painter, offset, pixmap);
0
703 -
704 return;
never executed: return;
0
705 } -
706 -
707 // Draw pixmap in deviceCoordinates to avoid pixmap scaling. -
708 const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
never executed (the execution status of this line is deduced): const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
-
709 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
710 return;
never executed: return;
0
711 -
712 QTransform restoreTransform = painter->worldTransform();
never executed (the execution status of this line is deduced): QTransform restoreTransform = painter->worldTransform();
-
713 painter->setWorldTransform(QTransform());
never executed (the execution status of this line is deduced): painter->setWorldTransform(QTransform());
-
714 d->filter->draw(painter, offset, pixmap);
never executed (the execution status of this line is deduced): d->filter->draw(painter, offset, pixmap);
-
715 painter->setWorldTransform(restoreTransform);
never executed (the execution status of this line is deduced): painter->setWorldTransform(restoreTransform);
-
716}
never executed: }
0
717 -
718/*! -
719 \class QGraphicsBlurEffect -
720 \brief The QGraphicsBlurEffect class provides a blur effect. -
721 \since 4.6 -
722 \inmodule QtWidgets -
723 -
724 A blur effect blurs the source. This effect is useful for reducing details, -
725 such as when the source loses focus and you want to draw attention to other -
726 elements. The level of detail can be modified using the setBlurRadius() -
727 function. Use setBlurHints() to choose the blur hints. -
728 -
729 By default, the blur radius is 5 pixels. The blur radius is specified in -
730 device coordinates. -
731 -
732 \image graphicseffect-blur.png -
733 -
734 \sa QGraphicsDropShadowEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect -
735*/ -
736 -
737/*! -
738 \enum QGraphicsBlurEffect::BlurHint -
739 \since 4.6 -
740 -
741 This enum describes the possible hints that can be used to control how -
742 blur effects are applied. The hints might not have an effect in all the -
743 paint engines. -
744 -
745 \value PerformanceHint Indicates that rendering performance is the most important factor, -
746 at the potential cost of lower quality. -
747 -
748 \value QualityHint Indicates that rendering quality is the most important factor, -
749 at the potential cost of lower performance. -
750 -
751 \value AnimationHint Indicates that the blur radius is going to be animated, hinting -
752 that the implementation can keep a cache of blurred verisons of the source. -
753 Do not use this hint if the source is going to be dynamically changing. -
754 -
755 \sa blurHints(), setBlurHints() -
756*/ -
757 -
758 -
759/*! -
760 Constructs a new QGraphicsBlurEffect instance. -
761 The \a parent parameter is passed to QGraphicsEffect's constructor. -
762*/ -
763QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) -
764 : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) -
765{ -
766 Q_D(QGraphicsBlurEffect);
executed (the execution status of this line is deduced): QGraphicsBlurEffectPrivate * const d = d_func();
-
767 d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint);
executed (the execution status of this line is deduced): d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint);
-
768}
executed: }
Execution Count:4
4
769 -
770/*! -
771 Destroys the effect. -
772*/ -
773QGraphicsBlurEffect::~QGraphicsBlurEffect() -
774{ -
775} -
776 -
777/*! -
778 \property QGraphicsBlurEffect::blurRadius -
779 \brief the blur radius of the effect. -
780 -
781 Using a smaller radius results in a sharper appearance, whereas a bigger -
782 radius results in a more blurred appearance. -
783 -
784 By default, the blur radius is 5 pixels. -
785 -
786 The radius is given in device coordinates, meaning it is -
787 unaffected by scale. -
788*/ -
789qreal QGraphicsBlurEffect::blurRadius() const -
790{ -
791 Q_D(const QGraphicsBlurEffect);
never executed (the execution status of this line is deduced): const QGraphicsBlurEffectPrivate * const d = d_func();
-
792 return d->filter->radius();
never executed: return d->filter->radius();
0
793} -
794 -
795void QGraphicsBlurEffect::setBlurRadius(qreal radius) -
796{ -
797 Q_D(QGraphicsBlurEffect);
never executed (the execution status of this line is deduced): QGraphicsBlurEffectPrivate * const d = d_func();
-
798 if (qFuzzyCompare(d->filter->radius(), radius))
never evaluated: qFuzzyCompare(d->filter->radius(), radius)
0
799 return;
never executed: return;
0
800 -
801 d->filter->setRadius(radius);
never executed (the execution status of this line is deduced): d->filter->setRadius(radius);
-
802 updateBoundingRect();
never executed (the execution status of this line is deduced): updateBoundingRect();
-
803 emit blurRadiusChanged(radius);
never executed (the execution status of this line is deduced): blurRadiusChanged(radius);
-
804}
never executed: }
0
805 -
806/*! -
807 \fn void QGraphicsBlurEffect::blurRadiusChanged(qreal radius) -
808 -
809 This signal is emitted whenever the effect's blur radius changes. -
810 The \a radius parameter holds the effect's new blur radius. -
811*/ -
812 -
813/*! -
814 \property QGraphicsBlurEffect::blurHints -
815 \brief the blur hint of the effect. -
816 -
817 Use the PerformanceHint hint to say that you want a faster blur, -
818 the QualityHint hint to say that you prefer a higher quality blur, -
819 or the AnimationHint when you want to animate the blur radius. -
820 -
821 By default, the blur hint is PerformanceHint. -
822*/ -
823QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const -
824{ -
825 Q_D(const QGraphicsBlurEffect);
never executed (the execution status of this line is deduced): const QGraphicsBlurEffectPrivate * const d = d_func();
-
826 return d->filter->blurHints();
never executed: return d->filter->blurHints();
0
827} -
828 -
829void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints) -
830{ -
831 Q_D(QGraphicsBlurEffect);
never executed (the execution status of this line is deduced): QGraphicsBlurEffectPrivate * const d = d_func();
-
832 if (d->filter->blurHints() == hints)
never evaluated: d->filter->blurHints() == hints
0
833 return;
never executed: return;
0
834 -
835 d->filter->setBlurHints(hints);
never executed (the execution status of this line is deduced): d->filter->setBlurHints(hints);
-
836 emit blurHintsChanged(hints);
never executed (the execution status of this line is deduced): blurHintsChanged(hints);
-
837}
never executed: }
0
838 -
839/*! -
840 \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints) -
841 -
842 This signal is emitted whenever the effect's blur hints changes. -
843 The \a hints parameter holds the effect's new blur hints. -
844*/ -
845 -
846/*! -
847 \reimp -
848*/ -
849QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const -
850{ -
851 Q_D(const QGraphicsBlurEffect);
never executed (the execution status of this line is deduced): const QGraphicsBlurEffectPrivate * const d = d_func();
-
852 return d->filter->boundingRectFor(rect);
never executed: return d->filter->boundingRectFor(rect);
0
853} -
854 -
855/*! -
856 \reimp -
857*/ -
858void QGraphicsBlurEffect::draw(QPainter *painter) -
859{ -
860 Q_D(QGraphicsBlurEffect);
never executed (the execution status of this line is deduced): QGraphicsBlurEffectPrivate * const d = d_func();
-
861 if (d->filter->radius() < 1) {
never evaluated: d->filter->radius() < 1
0
862 drawSource(painter);
never executed (the execution status of this line is deduced): drawSource(painter);
-
863 return;
never executed: return;
0
864 } -
865 -
866 PixmapPadMode mode = PadToEffectiveBoundingRect;
never executed (the execution status of this line is deduced): PixmapPadMode mode = PadToEffectiveBoundingRect;
-
867 if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
never evaluated: painter->paintEngine()->type() == QPaintEngine::OpenGL2
0
868 mode = NoPad;
never executed: mode = NoPad;
0
869 -
870 QPoint offset;
never executed (the execution status of this line is deduced): QPoint offset;
-
871 QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode);
never executed (the execution status of this line is deduced): QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode);
-
872 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
873 return;
never executed: return;
0
874 -
875 d->filter->draw(painter, offset, pixmap);
never executed (the execution status of this line is deduced): d->filter->draw(painter, offset, pixmap);
-
876}
never executed: }
0
877 -
878/*! -
879 \class QGraphicsDropShadowEffect -
880 \brief The QGraphicsDropShadowEffect class provides a drop shadow effect. -
881 \since 4.6 -
882 \inmodule QtWidgets -
883 -
884 A drop shadow effect renders the source with a drop shadow. The color of -
885 the drop shadow can be modified using the setColor() function. The drop -
886 shadow offset can be modified using the setOffset() function and the blur -
887 radius of the drop shadow can be changed with the setBlurRadius() -
888 function. -
889 -
890 By default, the drop shadow is a semi-transparent dark gray -
891 (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset -
892 of 8 pixels towards the lower right. The drop shadow offset is specified -
893 in device coordinates. -
894 -
895 \image graphicseffect-drop-shadow.png -
896 -
897 \sa QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect -
898*/ -
899 -
900/*! -
901 Constructs a new QGraphicsDropShadowEffect instance. -
902 The \a parent parameter is passed to QGraphicsEffect's constructor. -
903*/ -
904QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent) -
905 : QGraphicsEffect(*new QGraphicsDropShadowEffectPrivate, parent) -
906{ -
907}
executed: }
Execution Count:4
4
908 -
909/*! -
910 Destroys the effect. -
911*/ -
912QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() -
913{ -
914} -
915 -
916/*! -
917 \property QGraphicsDropShadowEffect::offset -
918 \brief the shadow offset in pixels. -
919 -
920 By default, the offset is 8 pixels towards the lower right. -
921 -
922 The offset is given in device coordinates, which means it is -
923 unaffected by scale. -
924 -
925 \sa xOffset(), yOffset(), blurRadius(), color() -
926*/ -
927QPointF QGraphicsDropShadowEffect::offset() const -
928{ -
929 Q_D(const QGraphicsDropShadowEffect);
never executed (the execution status of this line is deduced): const QGraphicsDropShadowEffectPrivate * const d = d_func();
-
930 return d->filter->offset();
never executed: return d->filter->offset();
0
931} -
932 -
933void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) -
934{ -
935 Q_D(QGraphicsDropShadowEffect);
never executed (the execution status of this line is deduced): QGraphicsDropShadowEffectPrivate * const d = d_func();
-
936 if (d->filter->offset() == offset)
never evaluated: d->filter->offset() == offset
0
937 return;
never executed: return;
0
938 -
939 d->filter->setOffset(offset);
never executed (the execution status of this line is deduced): d->filter->setOffset(offset);
-
940 updateBoundingRect();
never executed (the execution status of this line is deduced): updateBoundingRect();
-
941 emit offsetChanged(offset);
never executed (the execution status of this line is deduced): offsetChanged(offset);
-
942}
never executed: }
0
943 -
944/*! -
945 \property QGraphicsDropShadowEffect::xOffset -
946 \brief the horizontal shadow offset in pixels. -
947 -
948 By default, the horizontal shadow offset is 8 pixels. -
949 -
950 -
951 -
952 \sa yOffset(), offset() -
953*/ -
954 -
955/*! -
956 \property QGraphicsDropShadowEffect::yOffset -
957 \brief the vertical shadow offset in pixels. -
958 -
959 By default, the vertical shadow offset is 8 pixels. -
960 -
961 \sa xOffset(), offset() -
962*/ -
963 -
964/*! -
965 \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset) -
966 -
967 This signal is emitted whenever the effect's shadow offset changes. -
968 The \a offset parameter holds the effect's new shadow offset. -
969*/ -
970 -
971/*! -
972 \property QGraphicsDropShadowEffect::blurRadius -
973 \brief the blur radius in pixels of the drop shadow. -
974 -
975 Using a smaller radius results in a sharper shadow, whereas using a bigger -
976 radius results in a more blurred shadow. -
977 -
978 By default, the blur radius is 1 pixel. -
979 -
980 \sa color(), offset() -
981*/ -
982qreal QGraphicsDropShadowEffect::blurRadius() const -
983{ -
984 Q_D(const QGraphicsDropShadowEffect);
never executed (the execution status of this line is deduced): const QGraphicsDropShadowEffectPrivate * const d = d_func();
-
985 return d->filter->blurRadius();
never executed: return d->filter->blurRadius();
0
986} -
987 -
988void QGraphicsDropShadowEffect::setBlurRadius(qreal blurRadius) -
989{ -
990 Q_D(QGraphicsDropShadowEffect);
never executed (the execution status of this line is deduced): QGraphicsDropShadowEffectPrivate * const d = d_func();
-
991 if (qFuzzyCompare(d->filter->blurRadius(), blurRadius))
never evaluated: qFuzzyCompare(d->filter->blurRadius(), blurRadius)
0
992 return;
never executed: return;
0
993 -
994 d->filter->setBlurRadius(blurRadius);
never executed (the execution status of this line is deduced): d->filter->setBlurRadius(blurRadius);
-
995 updateBoundingRect();
never executed (the execution status of this line is deduced): updateBoundingRect();
-
996 emit blurRadiusChanged(blurRadius);
never executed (the execution status of this line is deduced): blurRadiusChanged(blurRadius);
-
997}
never executed: }
0
998 -
999/*! -
1000 \fn void QGraphicsDropShadowEffect::blurRadiusChanged(qreal blurRadius) -
1001 -
1002 This signal is emitted whenever the effect's blur radius changes. -
1003 The \a blurRadius parameter holds the effect's new blur radius. -
1004*/ -
1005 -
1006/*! -
1007 \property QGraphicsDropShadowEffect::color -
1008 \brief the color of the drop shadow. -
1009 -
1010 By default, the drop color is a semi-transparent dark gray -
1011 (QColor(63, 63, 63, 180)). -
1012 -
1013 \sa offset(), blurRadius() -
1014*/ -
1015QColor QGraphicsDropShadowEffect::color() const -
1016{ -
1017 Q_D(const QGraphicsDropShadowEffect);
never executed (the execution status of this line is deduced): const QGraphicsDropShadowEffectPrivate * const d = d_func();
-
1018 return d->filter->color();
never executed: return d->filter->color();
0
1019} -
1020 -
1021void QGraphicsDropShadowEffect::setColor(const QColor &color) -
1022{ -
1023 Q_D(QGraphicsDropShadowEffect);
never executed (the execution status of this line is deduced): QGraphicsDropShadowEffectPrivate * const d = d_func();
-
1024 if (d->filter->color() == color)
never evaluated: d->filter->color() == color
0
1025 return;
never executed: return;
0
1026 -
1027 d->filter->setColor(color);
never executed (the execution status of this line is deduced): d->filter->setColor(color);
-
1028 update();
never executed (the execution status of this line is deduced): update();
-
1029 emit colorChanged(color);
never executed (the execution status of this line is deduced): colorChanged(color);
-
1030}
never executed: }
0
1031 -
1032/*! -
1033 \fn void QGraphicsDropShadowEffect::colorChanged(const QColor &color) -
1034 -
1035 This signal is emitted whenever the effect's color changes. -
1036 The \a color parameter holds the effect's new color. -
1037*/ -
1038 -
1039/*! -
1040 \reimp -
1041*/ -
1042QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const -
1043{ -
1044 Q_D(const QGraphicsDropShadowEffect);
executed (the execution status of this line is deduced): const QGraphicsDropShadowEffectPrivate * const d = d_func();
-
1045 return d->filter->boundingRectFor(rect);
executed: return d->filter->boundingRectFor(rect);
Execution Count:32
32
1046} -
1047 -
1048/*! -
1049 \reimp -
1050*/ -
1051void QGraphicsDropShadowEffect::draw(QPainter *painter) -
1052{ -
1053 Q_D(QGraphicsDropShadowEffect);
executed (the execution status of this line is deduced): QGraphicsDropShadowEffectPrivate * const d = d_func();
-
1054 if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) {
partially evaluated: d->filter->blurRadius() <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
never evaluated: d->filter->offset().isNull()
0-7
1055 drawSource(painter);
never executed (the execution status of this line is deduced): drawSource(painter);
-
1056 return;
never executed: return;
0
1057 } -
1058 -
1059 PixmapPadMode mode = PadToEffectiveBoundingRect;
executed (the execution status of this line is deduced): PixmapPadMode mode = PadToEffectiveBoundingRect;
-
1060 if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
partially evaluated: painter->paintEngine()->type() == QPaintEngine::OpenGL2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1061 mode = NoPad;
never executed: mode = NoPad;
0
1062 -
1063 // Draw pixmap in device coordinates to avoid pixmap scaling. -
1064 QPoint offset;
executed (the execution status of this line is deduced): QPoint offset;
-
1065 const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
executed (the execution status of this line is deduced): const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
-
1066 if (pixmap.isNull())
partially evaluated: pixmap.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1067 return;
never executed: return;
0
1068 -
1069 QTransform restoreTransform = painter->worldTransform();
executed (the execution status of this line is deduced): QTransform restoreTransform = painter->worldTransform();
-
1070 painter->setWorldTransform(QTransform());
executed (the execution status of this line is deduced): painter->setWorldTransform(QTransform());
-
1071 d->filter->draw(painter, offset, pixmap);
executed (the execution status of this line is deduced): d->filter->draw(painter, offset, pixmap);
-
1072 painter->setWorldTransform(restoreTransform);
executed (the execution status of this line is deduced): painter->setWorldTransform(restoreTransform);
-
1073}
executed: }
Execution Count:7
7
1074 -
1075/*! -
1076 \class QGraphicsOpacityEffect -
1077 \brief The QGraphicsOpacityEffect class provides an opacity effect. -
1078 \since 4.6 -
1079 \inmodule QtWidgets -
1080 -
1081 An opacity effect renders the source with an opacity. This effect is useful -
1082 for making the source semi-transparent, similar to a fade-in/fade-out -
1083 sequence. The opacity can be modified using the setOpacity() function. -
1084 -
1085 By default, the opacity is 0.7. -
1086 -
1087 \image graphicseffect-opacity.png -
1088 -
1089 \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsColorizeEffect -
1090*/ -
1091 -
1092/*! -
1093 Constructs a new QGraphicsOpacityEffect instance. -
1094 The \a parent parameter is passed to QGraphicsEffect's constructor. -
1095*/ -
1096QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent) -
1097 : QGraphicsEffect(*new QGraphicsOpacityEffectPrivate, parent) -
1098{ -
1099}
never executed: }
0
1100 -
1101/*! -
1102 Destroys the effect. -
1103*/ -
1104QGraphicsOpacityEffect::~QGraphicsOpacityEffect() -
1105{ -
1106} -
1107 -
1108/*! -
1109 \property QGraphicsOpacityEffect::opacity -
1110 \brief the opacity of the effect. -
1111 -
1112 The value should be in the range of 0.0 to 1.0, where 0.0 is -
1113 fully transparent and 1.0 is fully opaque. -
1114 -
1115 By default, the opacity is 0.7. -
1116 -
1117 \sa setOpacityMask() -
1118*/ -
1119qreal QGraphicsOpacityEffect::opacity() const -
1120{ -
1121 Q_D(const QGraphicsOpacityEffect);
never executed (the execution status of this line is deduced): const QGraphicsOpacityEffectPrivate * const d = d_func();
-
1122 return d->opacity;
never executed: return d->opacity;
0
1123} -
1124 -
1125void QGraphicsOpacityEffect::setOpacity(qreal opacity) -
1126{ -
1127 Q_D(QGraphicsOpacityEffect);
never executed (the execution status of this line is deduced): QGraphicsOpacityEffectPrivate * const d = d_func();
-
1128 opacity = qBound(qreal(0.0), opacity, qreal(1.0));
never executed (the execution status of this line is deduced): opacity = qBound(qreal(0.0), opacity, qreal(1.0));
-
1129 -
1130 if (qFuzzyCompare(d->opacity, opacity))
never evaluated: qFuzzyCompare(d->opacity, opacity)
0
1131 return;
never executed: return;
0
1132 -
1133 d->opacity = opacity;
never executed (the execution status of this line is deduced): d->opacity = opacity;
-
1134 if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity)))
never evaluated: (d->isFullyTransparent = qFuzzyIsNull(d->opacity))
0
1135 d->isFullyOpaque = 0;
never executed: d->isFullyOpaque = 0;
0
1136 else -
1137 d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
never executed: d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
0
1138 update();
never executed (the execution status of this line is deduced): update();
-
1139 emit opacityChanged(opacity);
never executed (the execution status of this line is deduced): opacityChanged(opacity);
-
1140}
never executed: }
0
1141 -
1142/*! -
1143 \fn void QGraphicsOpacityEffect::opacityChanged(qreal opacity) -
1144 -
1145 This signal is emitted whenever the effect's opacity changes. -
1146 The \a opacity parameter holds the effect's new opacity. -
1147*/ -
1148 -
1149/*! -
1150 \property QGraphicsOpacityEffect::opacityMask -
1151 \brief the opacity mask of the effect. -
1152 -
1153 An opacity mask allows you apply opacity to portions of an element. -
1154 -
1155 For example: -
1156 -
1157 \snippet code/src_gui_effects_qgraphicseffect.cpp 2 -
1158 -
1159 There is no opacity mask by default. -
1160 -
1161 \sa setOpacity() -
1162*/ -
1163QBrush QGraphicsOpacityEffect::opacityMask() const -
1164{ -
1165 Q_D(const QGraphicsOpacityEffect);
never executed (the execution status of this line is deduced): const QGraphicsOpacityEffectPrivate * const d = d_func();
-
1166 return d->opacityMask;
never executed: return d->opacityMask;
0
1167} -
1168 -
1169void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) -
1170{ -
1171 Q_D(QGraphicsOpacityEffect);
never executed (the execution status of this line is deduced): QGraphicsOpacityEffectPrivate * const d = d_func();
-
1172 if (d->opacityMask == mask)
never evaluated: d->opacityMask == mask
0
1173 return;
never executed: return;
0
1174 -
1175 d->opacityMask = mask;
never executed (the execution status of this line is deduced): d->opacityMask = mask;
-
1176 d->hasOpacityMask = (mask.style() != Qt::NoBrush);
never executed (the execution status of this line is deduced): d->hasOpacityMask = (mask.style() != Qt::NoBrush);
-
1177 update();
never executed (the execution status of this line is deduced): update();
-
1178 -
1179 emit opacityMaskChanged(mask);
never executed (the execution status of this line is deduced): opacityMaskChanged(mask);
-
1180}
never executed: }
0
1181 -
1182/*! -
1183 \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask) -
1184 -
1185 This signal is emitted whenever the effect's opacity mask changes. -
1186 The \a mask parameter holds the effect's new opacity mask. -
1187*/ -
1188 -
1189/*! -
1190 \reimp -
1191*/ -
1192void QGraphicsOpacityEffect::draw(QPainter *painter) -
1193{ -
1194 Q_D(QGraphicsOpacityEffect);
never executed (the execution status of this line is deduced): QGraphicsOpacityEffectPrivate * const d = d_func();
-
1195 -
1196 // Transparent; nothing to draw. -
1197 if (d->isFullyTransparent)
never evaluated: d->isFullyTransparent
0
1198 return;
never executed: return;
0
1199 -
1200 // Opaque; draw directly without going through a pixmap. -
1201 if (d->isFullyOpaque && !d->hasOpacityMask) {
never evaluated: d->isFullyOpaque
never evaluated: !d->hasOpacityMask
0
1202 drawSource(painter);
never executed (the execution status of this line is deduced): drawSource(painter);
-
1203 return;
never executed: return;
0
1204 } -
1205 -
1206 QPoint offset;
never executed (the execution status of this line is deduced): QPoint offset;
-
1207 Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
never evaluated: sourceIsPixmap()
0
1208 QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad);
never executed (the execution status of this line is deduced): QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad);
-
1209 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
1210 return;
never executed: return;
0
1211 -
1212 painter->save();
never executed (the execution status of this line is deduced): painter->save();
-
1213 painter->setOpacity(d->opacity);
never executed (the execution status of this line is deduced): painter->setOpacity(d->opacity);
-
1214 -
1215 if (d->hasOpacityMask) {
never evaluated: d->hasOpacityMask
0
1216 QPainter pixmapPainter(&pixmap);
never executed (the execution status of this line is deduced): QPainter pixmapPainter(&pixmap);
-
1217 pixmapPainter.setRenderHints(painter->renderHints());
never executed (the execution status of this line is deduced): pixmapPainter.setRenderHints(painter->renderHints());
-
1218 pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
never executed (the execution status of this line is deduced): pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
-
1219 if (system == Qt::DeviceCoordinates) {
never evaluated: system == Qt::DeviceCoordinates
0
1220 QTransform worldTransform = painter->worldTransform();
never executed (the execution status of this line is deduced): QTransform worldTransform = painter->worldTransform();
-
1221 worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y());
never executed (the execution status of this line is deduced): worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y());
-
1222 pixmapPainter.setWorldTransform(worldTransform);
never executed (the execution status of this line is deduced): pixmapPainter.setWorldTransform(worldTransform);
-
1223 pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask);
never executed (the execution status of this line is deduced): pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask);
-
1224 } else {
never executed: }
0
1225 pixmapPainter.translate(-offset);
never executed (the execution status of this line is deduced): pixmapPainter.translate(-offset);
-
1226 pixmapPainter.fillRect(pixmap.rect(), d->opacityMask);
never executed (the execution status of this line is deduced): pixmapPainter.fillRect(pixmap.rect(), d->opacityMask);
-
1227 }
never executed: }
0
1228 } -
1229 -
1230 if (system == Qt::DeviceCoordinates)
never evaluated: system == Qt::DeviceCoordinates
0
1231 painter->setWorldTransform(QTransform());
never executed: painter->setWorldTransform(QTransform());
0
1232 -
1233 painter->drawPixmap(offset, pixmap);
never executed (the execution status of this line is deduced): painter->drawPixmap(offset, pixmap);
-
1234 painter->restore();
never executed (the execution status of this line is deduced): painter->restore();
-
1235}
never executed: }
0
1236 -
1237 -
1238QT_END_NAMESPACE -
1239 -
1240#endif //QT_NO_GRAPHICSEFFECT -
1241 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial