effects/qgraphicseffect.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent) -
7 : QObject(dd, parent) -
8{}
executed: }
Execution Count:28
28
9 -
10 -
11 -
12 -
13QGraphicsEffectSource::~QGraphicsEffectSource() -
14{} -
15 -
16 -
17 -
18 -
19 -
20 -
21QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const -
22{ -
23 return d_func()->boundingRect(system);
executed: return d_func()->boundingRect(system);
Execution Count:30
30
24} -
25QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const -
26{ -
27 const QGraphicsEffectPrivate * const d = d_func(); -
28 if (d->source)
never evaluated: d->source
0
29 return d->source->boundingRect(system);
never executed: return d->source->boundingRect(system);
0
30 return QRectF();
never executed: return QRectF();
0
31} -
32 -
33 -
34 -
35 -
36 -
37 -
38 -
39const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const -
40{ -
41 return d_func()->graphicsItem();
executed: return d_func()->graphicsItem();
Execution Count:33
33
42} -
43 -
44 -
45 -
46 -
47 -
48 -
49 -
50const QWidget *QGraphicsEffectSource::widget() const -
51{ -
52 return d_func()->widget();
never executed: return d_func()->widget();
0
53} -
54 -
55 -
56 -
57 -
58 -
59 -
60 -
61const QStyleOption *QGraphicsEffectSource::styleOption() const -
62{ -
63 return d_func()->styleOption();
executed: return d_func()->styleOption();
Execution Count:11
11
64} -
65void QGraphicsEffectSource::draw(QPainter *painter) -
66{ -
67 const QGraphicsEffectSourcePrivate * const d = d_func(); -
68 -
69 QPixmap pm; -
70 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
71 QTransform restoreTransform; -
72 if (d->m_cachedSystem == Qt::DeviceCoordinates) {
partially evaluated: d->m_cachedSystem == Qt::DeviceCoordinates
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
73 restoreTransform = painter->worldTransform(); -
74 painter->setWorldTransform(QTransform()); -
75 }
executed: }
Execution Count:4
4
76 -
77 painter->drawPixmap(d->m_cachedOffset, pm); -
78 -
79 if (d->m_cachedSystem == Qt::DeviceCoordinates)
partially evaluated: d->m_cachedSystem == Qt::DeviceCoordinates
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
80 painter->setWorldTransform(restoreTransform);
executed: painter->setWorldTransform(restoreTransform);
Execution Count:4
4
81 } else {
executed: }
Execution Count:4
4
82 d_func()->draw(painter); -
83 }
executed: }
Execution Count:14
14
84} -
85void QGraphicsEffect::drawSource(QPainter *painter) -
86{ -
87 const QGraphicsEffectPrivate * const d = d_func(); -
88 if (d->source)
partially evaluated: d->source
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
89 d->source->draw(painter);
executed: d->source->draw(painter);
Execution Count:10
10
90}
executed: }
Execution Count:10
10
91void QGraphicsEffectSource::update() -
92{ -
93 d_func()->update(); -
94}
executed: }
Execution Count:8
8
95bool QGraphicsEffectSource::isPixmap() const -
96{ -
97 return d_func()->isPixmap();
executed: return d_func()->isPixmap();
Execution Count:3
3
98} -
99bool QGraphicsEffect::sourceIsPixmap() const -
100{ -
101 return source() ? source()->isPixmap() : false;
never executed: return source() ? source()->isPixmap() : false;
0
102} -
103QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const -
104{ -
105 const QGraphicsEffectSourcePrivate * const d = d_func(); -
106 -
107 -
108 const QGraphicsItem *item = graphicsItem(); -
109 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
110 const QGraphicsPixmapItem *pixmapItem = static_cast<const QGraphicsPixmapItem *>(item); -
111 if (offset)
partially evaluated: offset
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
112 *offset = pixmapItem->offset().toPoint();
executed: *offset = pixmapItem->offset().toPoint();
Execution Count:1
1
113 return pixmapItem->pixmap();
executed: return pixmapItem->pixmap();
Execution Count:1
1
114 } -
115 -
116 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
117 && !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
118 QMessageLogger("effects/qgraphicseffect.cpp", 325, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); -
119 return QPixmap();
executed: return QPixmap();
Execution Count:1
1
120 } -
121 -
122 QPixmap pm; -
123 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
124 QPixmapCache::find(d->m_cacheKey, &pm);
executed: QPixmapCache::find(d->m_cacheKey, &pm);
Execution Count:10
10
125 -
126 if (pm.isNull()) {
evaluated: pm.isNull()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:5
5-20
127 pm = d->pixmap(system, &d->m_cachedOffset, mode); -
128 d->m_cachedSystem = system; -
129 d->m_cachedMode = mode; -
130 -
131 d->invalidateCache(); -
132 d->m_cacheKey = QPixmapCache::insert(pm); -
133 }
executed: }
Execution Count:20
20
134 -
135 if (offset)
evaluated: offset
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:10
10-15
136 *offset = d->m_cachedOffset;
executed: *offset = d->m_cachedOffset;
Execution Count:15
15
137 -
138 return pm;
executed: return pm;
Execution Count:25
25
139} -
140QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const -
141{ -
142 const QGraphicsEffectPrivate * const d = d_func(); -
143 if (d->source)
partially evaluated: d->source
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
144 return d->source->pixmap(system, offset, mode);
executed: return d->source->pixmap(system, offset, mode);
Execution Count:14
14
145 return QPixmap();
never executed: return QPixmap();
0
146} -
147 -
148QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() -
149{ -
150 invalidateCache(); -
151}
executed: }
Execution Count:21
21
152 -
153void QGraphicsEffectSourcePrivate::setCachedOffset(const QPoint &offset) -
154{ -
155 m_cachedOffset = offset; -
156}
executed: }
Execution Count:9
9
157 -
158void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) const -
159{ -
160 if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
evaluated: m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:28
28-117
161 && (reason == EffectRectChanged
evaluated: reason == EffectRectChanged
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:115
2-115
162 || (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
163 return;
executed: return;
Execution Count:2
2
164 } -
165 -
166 QPixmapCache::remove(m_cacheKey); -
167}
executed: }
Execution Count:143
143
168 -
169 -
170 -
171 -
172 -
173QGraphicsEffect::QGraphicsEffect(QObject *parent) -
174 : QObject(*new QGraphicsEffectPrivate, parent) -
175{ -
176}
executed: }
Execution Count:21
21
177 -
178 -
179 -
180 -
181QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent) -
182 : QObject(dd, parent) -
183{ -
184}
executed: }
Execution Count:8
8
185 -
186 -
187 -
188 -
189QGraphicsEffect::~QGraphicsEffect() -
190{ -
191 QGraphicsEffectPrivate * const d = d_func(); -
192 d->setGraphicsEffectSource(0); -
193}
executed: }
Execution Count:22
22
194QRectF QGraphicsEffect::boundingRect() const -
195{ -
196 const QGraphicsEffectPrivate * const d = d_func(); -
197 if (d->source)
evaluated: d->source
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
1-16
198 return boundingRectFor(d->source->boundingRect());
executed: return boundingRectFor(d->source->boundingRect());
Execution Count:16
16
199 return QRectF();
executed: return QRectF();
Execution Count:1
1
200} -
201QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const -
202{ -
203 return rect;
never executed: return rect;
0
204} -
205bool QGraphicsEffect::isEnabled() const -
206{ -
207 const QGraphicsEffectPrivate * const d = d_func(); -
208 return d->isEnabled;
executed: return d->isEnabled;
Execution Count:170
170
209} -
210 -
211void QGraphicsEffect::setEnabled(bool enable) -
212{ -
213 QGraphicsEffectPrivate * const d = d_func(); -
214 if (d->isEnabled == enable)
evaluated: d->isEnabled == enable
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
215 return;
executed: return;
Execution Count:1
1
216 -
217 d->isEnabled = enable; -
218 if (d->source) {
evaluated: d->source
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
219 d->source->d_func()->effectBoundingRectChanged(); -
220 d->source->d_func()->invalidateCache(); -
221 }
executed: }
Execution Count:6
6
222 enabledChanged(enable); -
223}
executed: }
Execution Count:7
7
224void QGraphicsEffect::update() -
225{ -
226 QGraphicsEffectPrivate * const d = d_func(); -
227 if (d->source)
partially evaluated: d->source
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
228 d->source->update();
executed: d->source->update();
Execution Count:3
3
229}
executed: }
Execution Count:3
3
230QGraphicsEffectSource *QGraphicsEffect::source() const -
231{ -
232 const QGraphicsEffectPrivate * const d = d_func(); -
233 return d->source;
executed: return d->source;
Execution Count:113
113
234} -
235void QGraphicsEffect::updateBoundingRect() -
236{ -
237 QGraphicsEffectPrivate * const d = d_func(); -
238 if (d->source) {
evaluated: d->source
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
239 d->source->d_func()->effectBoundingRectChanged(); -
240 d->source->d_func()->invalidateCache(QGraphicsEffectSourcePrivate::EffectRectChanged); -
241 }
executed: }
Execution Count:2
2
242}
executed: }
Execution Count:3
3
243void QGraphicsEffect::sourceChanged(ChangeFlags flags) -
244{ -
245 (void)flags;; -
246}
executed: }
Execution Count:48
48
247QGraphicsColorizeEffect::QGraphicsColorizeEffect(QObject *parent) -
248 : QGraphicsEffect(*new QGraphicsColorizeEffectPrivate, parent) -
249{ -
250}
never executed: }
0
251 -
252 -
253 -
254 -
255QGraphicsColorizeEffect::~QGraphicsColorizeEffect() -
256{ -
257} -
258 -
259 -
260 -
261 -
262 -
263 -
264 -
265QColor QGraphicsColorizeEffect::color() const -
266{ -
267 const QGraphicsColorizeEffectPrivate * const d = d_func(); -
268 return d->filter->color();
never executed: return d->filter->color();
0
269} -
270 -
271void QGraphicsColorizeEffect::setColor(const QColor &color) -
272{ -
273 QGraphicsColorizeEffectPrivate * const d = d_func(); -
274 if (d->filter->color() == color)
never evaluated: d->filter->color() == color
0
275 return;
never executed: return;
0
276 -
277 d->filter->setColor(color); -
278 update(); -
279 colorChanged(color); -
280}
never executed: }
0
281qreal QGraphicsColorizeEffect::strength() const -
282{ -
283 const QGraphicsColorizeEffectPrivate * const d = d_func(); -
284 return d->filter->strength();
never executed: return d->filter->strength();
0
285} -
286 -
287void QGraphicsColorizeEffect::setStrength(qreal strength) -
288{ -
289 QGraphicsColorizeEffectPrivate * const d = d_func(); -
290 if (qFuzzyCompare(d->filter->strength(), strength))
never evaluated: qFuzzyCompare(d->filter->strength(), strength)
0
291 return;
never executed: return;
0
292 -
293 d->filter->setStrength(strength); -
294 d->opaque = !qFuzzyIsNull(strength); -
295 update(); -
296 strengthChanged(strength); -
297}
never executed: }
0
298void QGraphicsColorizeEffect::draw(QPainter *painter) -
299{ -
300 QGraphicsColorizeEffectPrivate * const d = d_func(); -
301 -
302 if (!d->opaque) {
never evaluated: !d->opaque
0
303 drawSource(painter); -
304 return;
never executed: return;
0
305 } -
306 -
307 QPoint offset; -
308 if (sourceIsPixmap()) {
never evaluated: sourceIsPixmap()
0
309 -
310 const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad); -
311 if (!pixmap.isNull())
never evaluated: !pixmap.isNull()
0
312 d->filter->draw(painter, offset, pixmap);
never executed: d->filter->draw(painter, offset, pixmap);
0
313 -
314 return;
never executed: return;
0
315 } -
316 -
317 -
318 const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); -
319 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
320 return;
never executed: return;
0
321 -
322 QTransform restoreTransform = painter->worldTransform(); -
323 painter->setWorldTransform(QTransform()); -
324 d->filter->draw(painter, offset, pixmap); -
325 painter->setWorldTransform(restoreTransform); -
326}
never executed: }
0
327QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) -
328 : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) -
329{ -
330 QGraphicsBlurEffectPrivate * const d = d_func(); -
331 d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint); -
332}
executed: }
Execution Count:4
4
333 -
334 -
335 -
336 -
337QGraphicsBlurEffect::~QGraphicsBlurEffect() -
338{ -
339} -
340qreal QGraphicsBlurEffect::blurRadius() const -
341{ -
342 const QGraphicsBlurEffectPrivate * const d = d_func(); -
343 return d->filter->radius();
never executed: return d->filter->radius();
0
344} -
345 -
346void QGraphicsBlurEffect::setBlurRadius(qreal radius) -
347{ -
348 QGraphicsBlurEffectPrivate * const d = d_func(); -
349 if (qFuzzyCompare(d->filter->radius(), radius))
never evaluated: qFuzzyCompare(d->filter->radius(), radius)
0
350 return;
never executed: return;
0
351 -
352 d->filter->setRadius(radius); -
353 updateBoundingRect(); -
354 blurRadiusChanged(radius); -
355}
never executed: }
0
356QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const -
357{ -
358 const QGraphicsBlurEffectPrivate * const d = d_func(); -
359 return d->filter->blurHints();
never executed: return d->filter->blurHints();
0
360} -
361 -
362void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints) -
363{ -
364 QGraphicsBlurEffectPrivate * const d = d_func(); -
365 if (d->filter->blurHints() == hints)
never evaluated: d->filter->blurHints() == hints
0
366 return;
never executed: return;
0
367 -
368 d->filter->setBlurHints(hints); -
369 blurHintsChanged(hints); -
370}
never executed: }
0
371QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const -
372{ -
373 const QGraphicsBlurEffectPrivate * const d = d_func(); -
374 return d->filter->boundingRectFor(rect);
never executed: return d->filter->boundingRectFor(rect);
0
375} -
376 -
377 -
378 -
379 -
380void QGraphicsBlurEffect::draw(QPainter *painter) -
381{ -
382 QGraphicsBlurEffectPrivate * const d = d_func(); -
383 if (d->filter->radius() < 1) {
never evaluated: d->filter->radius() < 1
0
384 drawSource(painter); -
385 return;
never executed: return;
0
386 } -
387 -
388 PixmapPadMode mode = PadToEffectiveBoundingRect; -
389 if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
never evaluated: painter->paintEngine()->type() == QPaintEngine::OpenGL2
0
390 mode = NoPad;
never executed: mode = NoPad;
0
391 -
392 QPoint offset; -
393 QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode); -
394 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
395 return;
never executed: return;
0
396 -
397 d->filter->draw(painter, offset, pixmap); -
398}
never executed: }
0
399QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent) -
400 : QGraphicsEffect(*new QGraphicsDropShadowEffectPrivate, parent) -
401{ -
402}
executed: }
Execution Count:4
4
403 -
404 -
405 -
406 -
407QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() -
408{ -
409} -
410QPointF QGraphicsDropShadowEffect::offset() const -
411{ -
412 const QGraphicsDropShadowEffectPrivate * const d = d_func(); -
413 return d->filter->offset();
never executed: return d->filter->offset();
0
414} -
415 -
416void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) -
417{ -
418 QGraphicsDropShadowEffectPrivate * const d = d_func(); -
419 if (d->filter->offset() == offset)
never evaluated: d->filter->offset() == offset
0
420 return;
never executed: return;
0
421 -
422 d->filter->setOffset(offset); -
423 updateBoundingRect(); -
424 offsetChanged(offset); -
425}
never executed: }
0
426qreal QGraphicsDropShadowEffect::blurRadius() const -
427{ -
428 const QGraphicsDropShadowEffectPrivate * const d = d_func(); -
429 return d->filter->blurRadius();
never executed: return d->filter->blurRadius();
0
430} -
431 -
432void QGraphicsDropShadowEffect::setBlurRadius(qreal blurRadius) -
433{ -
434 QGraphicsDropShadowEffectPrivate * const d = d_func(); -
435 if (qFuzzyCompare(d->filter->blurRadius(), blurRadius))
never evaluated: qFuzzyCompare(d->filter->blurRadius(), blurRadius)
0
436 return;
never executed: return;
0
437 -
438 d->filter->setBlurRadius(blurRadius); -
439 updateBoundingRect(); -
440 blurRadiusChanged(blurRadius); -
441}
never executed: }
0
442QColor QGraphicsDropShadowEffect::color() const -
443{ -
444 const QGraphicsDropShadowEffectPrivate * const d = d_func(); -
445 return d->filter->color();
never executed: return d->filter->color();
0
446} -
447 -
448void QGraphicsDropShadowEffect::setColor(const QColor &color) -
449{ -
450 QGraphicsDropShadowEffectPrivate * const d = d_func(); -
451 if (d->filter->color() == color)
never evaluated: d->filter->color() == color
0
452 return;
never executed: return;
0
453 -
454 d->filter->setColor(color); -
455 update(); -
456 colorChanged(color); -
457}
never executed: }
0
458QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const -
459{ -
460 const QGraphicsDropShadowEffectPrivate * const d = d_func(); -
461 return d->filter->boundingRectFor(rect);
executed: return d->filter->boundingRectFor(rect);
Execution Count:32
32
462} -
463 -
464 -
465 -
466 -
467void QGraphicsDropShadowEffect::draw(QPainter *painter) -
468{ -
469 QGraphicsDropShadowEffectPrivate * const d = d_func(); -
470 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
471 drawSource(painter); -
472 return;
never executed: return;
0
473 } -
474 -
475 PixmapPadMode mode = PadToEffectiveBoundingRect; -
476 if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
partially evaluated: painter->paintEngine()->type() == QPaintEngine::OpenGL2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
477 mode = NoPad;
never executed: mode = NoPad;
0
478 -
479 -
480 QPoint offset; -
481 const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); -
482 if (pixmap.isNull())
partially evaluated: pixmap.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
483 return;
never executed: return;
0
484 -
485 QTransform restoreTransform = painter->worldTransform(); -
486 painter->setWorldTransform(QTransform()); -
487 d->filter->draw(painter, offset, pixmap); -
488 painter->setWorldTransform(restoreTransform); -
489}
executed: }
Execution Count:7
7
490QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent) -
491 : QGraphicsEffect(*new QGraphicsOpacityEffectPrivate, parent) -
492{ -
493}
never executed: }
0
494 -
495 -
496 -
497 -
498QGraphicsOpacityEffect::~QGraphicsOpacityEffect() -
499{ -
500} -
501qreal QGraphicsOpacityEffect::opacity() const -
502{ -
503 const QGraphicsOpacityEffectPrivate * const d = d_func(); -
504 return d->opacity;
never executed: return d->opacity;
0
505} -
506 -
507void QGraphicsOpacityEffect::setOpacity(qreal opacity) -
508{ -
509 QGraphicsOpacityEffectPrivate * const d = d_func(); -
510 opacity = qBound(qreal(0.0), opacity, qreal(1.0)); -
511 -
512 if (qFuzzyCompare(d->opacity, opacity))
never evaluated: qFuzzyCompare(d->opacity, opacity)
0
513 return;
never executed: return;
0
514 -
515 d->opacity = opacity; -
516 if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity)))
never evaluated: (d->isFullyTransparent = qFuzzyIsNull(d->opacity))
0
517 d->isFullyOpaque = 0;
never executed: d->isFullyOpaque = 0;
0
518 else -
519 d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
never executed: d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
0
520 update(); -
521 opacityChanged(opacity); -
522}
never executed: }
0
523QBrush QGraphicsOpacityEffect::opacityMask() const -
524{ -
525 const QGraphicsOpacityEffectPrivate * const d = d_func(); -
526 return d->opacityMask;
never executed: return d->opacityMask;
0
527} -
528 -
529void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) -
530{ -
531 QGraphicsOpacityEffectPrivate * const d = d_func(); -
532 if (d->opacityMask == mask)
never evaluated: d->opacityMask == mask
0
533 return;
never executed: return;
0
534 -
535 d->opacityMask = mask; -
536 d->hasOpacityMask = (mask.style() != Qt::NoBrush); -
537 update(); -
538 -
539 opacityMaskChanged(mask); -
540}
never executed: }
0
541void QGraphicsOpacityEffect::draw(QPainter *painter) -
542{ -
543 QGraphicsOpacityEffectPrivate * const d = d_func(); -
544 -
545 -
546 if (d->isFullyTransparent)
never evaluated: d->isFullyTransparent
0
547 return;
never executed: return;
0
548 -
549 -
550 if (d->isFullyOpaque && !d->hasOpacityMask) {
never evaluated: d->isFullyOpaque
never evaluated: !d->hasOpacityMask
0
551 drawSource(painter); -
552 return;
never executed: return;
0
553 } -
554 -
555 QPoint offset; -
556 Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
never evaluated: sourceIsPixmap()
0
557 QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad); -
558 if (pixmap.isNull())
never evaluated: pixmap.isNull()
0
559 return;
never executed: return;
0
560 -
561 painter->save(); -
562 painter->setOpacity(d->opacity); -
563 -
564 if (d->hasOpacityMask) {
never evaluated: d->hasOpacityMask
0
565 QPainter pixmapPainter(&pixmap); -
566 pixmapPainter.setRenderHints(painter->renderHints()); -
567 pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); -
568 if (system == Qt::DeviceCoordinates) {
never evaluated: system == Qt::DeviceCoordinates
0
569 QTransform worldTransform = painter->worldTransform(); -
570 worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y()); -
571 pixmapPainter.setWorldTransform(worldTransform); -
572 pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask); -
573 } else {
never executed: }
0
574 pixmapPainter.translate(-offset); -
575 pixmapPainter.fillRect(pixmap.rect(), d->opacityMask); -
576 }
never executed: }
0
577 } -
578 -
579 if (system == Qt::DeviceCoordinates)
never evaluated: system == Qt::DeviceCoordinates
0
580 painter->setWorldTransform(QTransform());
never executed: painter->setWorldTransform(QTransform());
0
581 -
582 painter->drawPixmap(offset, pixmap); -
583 painter->restore(); -
584}
never executed: }
0
585 -
586 -
587 -
588 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial