diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-28 15:39:27 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-28 15:45:26 (GMT) |
commit | 15144fab1010194b078c34157e8d208cfb625e88 (patch) | |
tree | a4989e8be3685fa6c81239a7482891742e8631d3 /src/gui | |
parent | 78fdde630cb16086ef24d8e79adcf0f91a729ddb (diff) | |
download | Qt-15144fab1010194b078c34157e8d208cfb625e88.zip Qt-15144fab1010194b078c34157e8d208cfb625e88.tar.gz Qt-15144fab1010194b078c34157e8d208cfb625e88.tar.bz2 |
Don't call qFuzzyIsNull on every single frame in QGraphicsOpacityEffect.
We only have to do it when the opacity changes (in ::setOpacity).
Also, we cannot do the cut-off when the effect has an opacity mask set.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/effects/qgraphicseffect.cpp | 8 | ||||
-rw-r--r-- | src/gui/effects/qgraphicseffect_p.h | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 62ad44d..50644ff 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -1008,6 +1008,10 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) return; d->opacity = opacity; + if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity))) + d->isFullyOpaque = 0; + else + d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); emit opacityChanged(opacity); } @@ -1065,11 +1069,11 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour Q_D(QGraphicsOpacityEffect); // Transparent; nothing to draw. - if (qFuzzyIsNull(d->opacity)) + if (d->isFullyTransparent) return; // Opaque; draw directly without going through a pixmap. - if (qFuzzyIsNull(d->opacity - 1)) { + if (d->isFullyOpaque && !d->hasOpacityMask) { source->draw(painter); return; } diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index e0a77e7..c902b67 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -164,11 +164,14 @@ class QGraphicsOpacityEffectPrivate : public QGraphicsEffectPrivate { Q_DECLARE_PUBLIC(QGraphicsOpacityEffect) public: - QGraphicsOpacityEffectPrivate() : opacity(qreal(0.7)), hasOpacityMask(0) {} + QGraphicsOpacityEffectPrivate() + : opacity(qreal(0.7)), isFullyTransparent(0), isFullyOpaque(0), hasOpacityMask(0) {} ~QGraphicsOpacityEffectPrivate() {} qreal opacity; QBrush opacityMask; + uint isFullyTransparent : 1; + uint isFullyOpaque : 1; uint hasOpacityMask : 1; }; |