summaryrefslogtreecommitdiffstats
path: root/src/gui/effects
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-10-30 12:37:05 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-11-02 11:57:54 (GMT)
commit85e41590732f15cec16909bf1121d944ae684373 (patch)
tree66d88bfcc51803f92749a8d5bcd0017857a7cbd5 /src/gui/effects
parent17cda5c55273813cbedcced3a511f1c222978182 (diff)
downloadQt-85e41590732f15cec16909bf1121d944ae684373.zip
Qt-85e41590732f15cec16909bf1121d944ae684373.tar.gz
Qt-85e41590732f15cec16909bf1121d944ae684373.tar.bz2
Optimized graphics effects to not needlessly invalidate cache.
When the effect rect changes we only need to invalidate the cache if the mode is ExpandToEffectRectPadMode. Reviewed-by: Gunnar Sletta
Diffstat (limited to 'src/gui/effects')
-rw-r--r--src/gui/effects/qgraphicseffect.cpp9
-rw-r--r--src/gui/effects/qgraphicseffect_p.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 3a6bab5..c8e39da 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -279,6 +279,13 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse
return pm;
}
+void QGraphicsEffectSourcePrivate::invalidateCache(bool effectRectChanged) const
+{
+ if (effectRectChanged && m_cachedMode != QGraphicsEffectSource::ExpandToEffectRectPadMode)
+ return;
+ QPixmapCache::remove(m_cacheKey);
+}
+
/*!
Constructs a new QGraphicsEffect instance having the
specified \a parent.
@@ -418,7 +425,7 @@ void QGraphicsEffect::updateBoundingRect()
Q_D(QGraphicsEffect);
if (d->source) {
d->source->d_func()->effectBoundingRectChanged();
- d->source->d_func()->invalidateCache();
+ d->source->d_func()->invalidateCache(true);
}
}
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h
index 1ed7103..0ff5794 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/gui/effects/qgraphicseffect_p.h
@@ -85,7 +85,7 @@ public:
virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0,
QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode) const = 0;
virtual void effectBoundingRectChanged() = 0;
- void invalidateCache() const { QPixmapCache::remove(m_cacheKey); }
+ void invalidateCache(bool effectRectChanged = false) const;
friend class QGraphicsScenePrivate;
friend class QGraphicsItem;