diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-16 01:46:41 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-16 03:05:02 (GMT) |
commit | 10e1d939d6bf08249304cb2c555be2f74c3a0f02 (patch) | |
tree | bfda461b0e49c138bc408aa0c799f15ce5907513 /src/openvg/qpaintengine_vg.cpp | |
parent | a4571547a38d68d6778bf0ebfa4dc26cc3d865a3 (diff) | |
download | Qt-10e1d939d6bf08249304cb2c555be2f74c3a0f02.zip Qt-10e1d939d6bf08249304cb2c555be2f74c3a0f02.tar.gz Qt-10e1d939d6bf08249304cb2c555be2f74c3a0f02.tar.bz2 |
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/qpaintengine_vg.cpp')
-rw-r--r-- | src/openvg/qpaintengine_vg.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 972f4a1..d87ac40 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) |