summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget.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/kernel/qwidget.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/kernel/qwidget.cpp')
-rw-r--r--src/gui/kernel/qwidget.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index de08312..088197e 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -93,6 +93,7 @@
# include "qx11info_x11.h"
#endif
+#include <private/qgraphicseffect_p.h>
#include <private/qwindowsurface_p.h>
#include <private/qbackingstore_p.h>
#ifdef Q_WS_MAC
@@ -1806,12 +1807,29 @@ QRegion QWidgetPrivate::clipRegion() const
return r;
}
+void QWidgetPrivate::invalidateGraphicsEffectsRecursively()
+{
+ Q_Q(QWidget);
+ QWidget *w = q;
+ do {
+ if (w->graphicsEffect()) {
+ QWidgetEffectSourcePrivate *sourced =
+ static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func());
+ if (!sourced->updateDueToGraphicsEffect)
+ w->graphicsEffect()->source()->d_func()->invalidateCache();
+ }
+ w = w->parentWidget();
+ } while (w);
+}
+
void QWidgetPrivate::setDirtyOpaqueRegion()
{
Q_Q(QWidget);
dirtyOpaqueChildren = true;
+ invalidateGraphicsEffectsRecursively();
+
if (q->isWindow())
return;
@@ -5215,6 +5233,10 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
paintEngine->d_func()->systemClip = QRegion();
} else {
context.painter = sharedPainter;
+ if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
+ sourced->invalidateCache();
+ sourced->lastEffectTransform = sharedPainter->worldTransform();
+ }
sharedPainter->save();
sharedPainter->translate(offset);
graphicsEffect->draw(sharedPainter, source);