summaryrefslogtreecommitdiffstats
path: root/src/gui/effects/qgraphicseffect.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-10-16 07:55:28 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-10-22 16:44:05 (GMT)
commit5de213210ef4f14e698c3fd970cf7e6c5b27c72d (patch)
treeda5d692ff2dec2ed835cc698ee7770d93351830d /src/gui/effects/qgraphicseffect.cpp
parenta392366b164081fe3b75c806dbf2030e64754eaf (diff)
downloadQt-5de213210ef4f14e698c3fd970cf7e6c5b27c72d.zip
Qt-5de213210ef4f14e698c3fd970cf7e6c5b27c72d.tar.gz
Qt-5de213210ef4f14e698c3fd970cf7e6c5b27c72d.tar.bz2
Added caching of graphics effect source pixmaps to speed up effects.
If an effect is applied repeatedly on the same source, just with varying parameters, we can save a lot by caching the source pixmaps. Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'src/gui/effects/qgraphicseffect.cpp')
-rw-r--r--src/gui/effects/qgraphicseffect.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 91641b0..96d35b0 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -253,7 +253,24 @@ bool QGraphicsEffectSource::isPixmap() const
*/
QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset) const
{
- return d_func()->pixmap(system, offset);
+ Q_D(const QGraphicsEffectSource);
+
+ QPixmap pm;
+ if (d->m_cachedSystem == system)
+ QPixmapCache::find(d->m_cacheKey, &pm);
+
+ if (pm.isNull()) {
+ pm = d->pixmap(system, &d->m_cachedOffset);
+ d->m_cachedSystem = system;
+
+ d->invalidateCache();
+ d->m_cacheKey = QPixmapCache::insert(pm);
+ }
+
+ if (offset)
+ *offset = d->m_cachedOffset;
+
+ return pm;
}
/*!