summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-09-16 11:46:41 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-09-16 13:05:02 +1000
commit10e1d939d6bf08249304cb2c555be2f74c3a0f02 (patch)
treebfda461b0e49c138bc408aa0c799f15ce5907513 /src/openvg
parenta4571547a38d68d6778bf0ebfa4dc26cc3d865a3 (diff)
Reduce overhead of paint engine-specific pixmap filters
Engine-specific pixmap filters were being created, used, and destroyed every time draw() was called on QPixmapColorizeFilter, QPixmapBlurFilter, and so on. This had a heavy performance penalty and made it difficult for the GL paint engine to cache shaders from one request to the next. A generic filter can request an engine-specific filter that matches its parameters. The engine can either create a new one or return a previously allocated filter object. Ownership of engine-specific pixmap filter objects is moved to the paint engine itself. Reviewed-by: Andrew den Exter Reviewed-by: Michael Brasser Reviewed-by: Michael Goddard Reviewed-by: Sarah Smith
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp38
-rw-r--r--src/openvg/qpaintengine_vg_p.h2
2 files changed, 28 insertions, 12 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 972f4a1e31..d87ac4009a 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -211,6 +211,11 @@ public:
QVGFontEngineCleaner *fontEngineCleaner;
#endif
+ QScopedPointer<QPixmapFilter> convolutionFilter;
+ QScopedPointer<QPixmapFilter> colorizeFilter;
+ QScopedPointer<QPixmapFilter> dropShadowFilter;
+ QScopedPointer<QPixmapFilter> blurFilter;
+
// Ensure that the path transform is properly set in the VG context
// before we perform a vgDrawPath() operation.
inline void ensurePathTransform()
@@ -3110,20 +3115,31 @@ void QVGPaintEngine::endNativePainting()
vgSetPaint(d->brushPaint, VG_FILL_PATH);
}
-QPixmapFilter *QVGPaintEngine::createPixmapFilter(int type) const
+QPixmapFilter *QVGPaintEngine::pixmapFilter(int type, const QPixmapFilter *prototype)
{
#if !defined(QT_SHIVAVG)
- if (type == QPixmapFilter::ConvolutionFilter)
- return new QVGPixmapConvolutionFilter;
- else if (type == QPixmapFilter::ColorizeFilter)
- return new QVGPixmapColorizeFilter;
- else if (type == QPixmapFilter::DropShadowFilter)
- return new QVGPixmapDropShadowFilter;
- else if (type == QPixmapFilter::BlurFilter)
- return new QVGPixmapBlurFilter;
- else
+ Q_D(QVGPaintEngine);
+ switch (type) {
+ case QPixmapFilter::ConvolutionFilter:
+ if (!d->convolutionFilter)
+ d->convolutionFilter.reset(new QVGPixmapConvolutionFilter);
+ return d->convolutionFilter.data();
+ case QPixmapFilter::ColorizeFilter:
+ if (!d->colorizeFilter)
+ d->colorizeFilter.reset(new QVGPixmapColorizeFilter);
+ return d->colorizeFilter.data();
+ case QPixmapFilter::DropShadowFilter:
+ if (!d->dropShadowFilter)
+ d->dropShadowFilter.reset(new QVGPixmapDropShadowFilter);
+ return d->dropShadowFilter.data();
+ case QPixmapFilter::BlurFilter:
+ if (!d->blurFilter)
+ d->blurFilter.reset(new QVGPixmapBlurFilter);
+ return d->blurFilter.data();
+ default: break;
+ }
#endif
- return QPaintEngineEx::createPixmapFilter(type);
+ return QPaintEngineEx::pixmapFilter(type, prototype);
}
void QVGPaintEngine::restoreState(QPaintEngine::DirtyFlags dirty)
diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h
index 4ae06bc567..5c0f525ab2 100644
--- a/src/openvg/qpaintengine_vg_p.h
+++ b/src/openvg/qpaintengine_vg_p.h
@@ -143,7 +143,7 @@ public:
void beginNativePainting();
void endNativePainting();
- QPixmapFilter *createPixmapFilter(int type) const;
+ QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype);
QVGPaintEnginePrivate *vgPrivate() { Q_D(QVGPaintEngine); return d; }