diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-05-12 22:46:35 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-05-12 22:46:35 (GMT) |
commit | 13c3a19eff8dead535e0ef20f69a311c2925f663 (patch) | |
tree | 3dcaf3601f64826ed18620a97eb3a6c46e2052ee /src | |
parent | f474f0f900d48b41be1a3de1dffe48552ab23372 (diff) | |
download | Qt-13c3a19eff8dead535e0ef20f69a311c2925f663.zip Qt-13c3a19eff8dead535e0ef20f69a311c2925f663.tar.gz Qt-13c3a19eff8dead535e0ef20f69a311c2925f663.tar.bz2 |
OpenVG blending modes from VG_KHR_advanced_blending extension
This change introduces the extra blending modes that are
defined in the VG_KHR_advanced_blending extension. Patch
originally provided by contributor:
http://qt.gitorious.org/qt/qt/merge_requests/505
Reviewed-by: Julian de Bhal
Diffstat (limited to 'src')
-rw-r--r-- | src/openvg/qpaintengine_vg.cpp | 87 |
1 files changed, 83 insertions, 4 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index cabb41c..07f8415 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -120,6 +120,35 @@ private: class QVGPaintEnginePrivate : public QPaintEngineExPrivate { public: + // Extra blending modes from VG_KHR_advanced_blending extension. + // Use the QT_VG prefix to avoid conflicts with any definitions + // that may come in via <VG/vgext.h>. + enum AdvancedBlending { + QT_VG_BLEND_OVERLAY_KHR = 0x2010, + QT_VG_BLEND_HARDLIGHT_KHR = 0x2011, + QT_VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012, + QT_VG_BLEND_SOFTLIGHT_KHR = 0x2013, + QT_VG_BLEND_COLORDODGE_KHR = 0x2014, + QT_VG_BLEND_COLORBURN_KHR = 0x2015, + QT_VG_BLEND_DIFFERENCE_KHR = 0x2016, + QT_VG_BLEND_SUBTRACT_KHR = 0x2017, + QT_VG_BLEND_INVERT_KHR = 0x2018, + QT_VG_BLEND_EXCLUSION_KHR = 0x2019, + QT_VG_BLEND_LINEARDODGE_KHR = 0x201a, + QT_VG_BLEND_LINEARBURN_KHR = 0x201b, + QT_VG_BLEND_VIVIDLIGHT_KHR = 0x201c, + QT_VG_BLEND_LINEARLIGHT_KHR = 0x201d, + QT_VG_BLEND_PINLIGHT_KHR = 0x201e, + QT_VG_BLEND_HARDMIX_KHR = 0x201f, + QT_VG_BLEND_CLEAR_KHR = 0x2020, + QT_VG_BLEND_DST_KHR = 0x2021, + QT_VG_BLEND_SRC_OUT_KHR = 0x2022, + QT_VG_BLEND_DST_OUT_KHR = 0x2023, + QT_VG_BLEND_SRC_ATOP_KHR = 0x2024, + QT_VG_BLEND_DST_ATOP_KHR = 0x2025, + QT_VG_BLEND_XOR_KHR = 0x2026 + }; + QVGPaintEnginePrivate(); ~QVGPaintEnginePrivate(); @@ -217,6 +246,8 @@ public: QVGFontEngineCleaner *fontEngineCleaner; #endif + bool hasAdvancedBlending; + QScopedPointer<QPixmapFilter> convolutionFilter; QScopedPointer<QPixmapFilter> colorizeFilter; QScopedPointer<QPixmapFilter> dropShadowFilter; @@ -370,6 +401,8 @@ void QVGPaintEnginePrivate::init() fontEngineCleaner = 0; #endif + hasAdvancedBlending = false; + clearModes(); } @@ -446,6 +479,10 @@ void QVGPaintEnginePrivate::initObjects() VG_PATH_CAPABILITY_ALL); vgAppendPathData(linePath, 2, segments, coords); #endif + + const char *extensions = reinterpret_cast<const char *>(vgGetString(VG_EXTENSIONS)); + if (extensions) + hasAdvancedBlending = strstr(extensions, "VG_KHR_advanced_blending") != 0; } void QVGPaintEnginePrivate::destroy() @@ -2292,7 +2329,7 @@ void QVGPaintEngine::compositionModeChanged() Q_D(QVGPaintEngine); d->dirty |= QPaintEngine::DirtyCompositionMode; - VGBlendMode vgMode = VG_BLEND_SRC_OVER; + VGint vgMode = VG_BLEND_SRC_OVER; switch (state()->composition_mode) { case QPainter::CompositionMode_SourceOver: @@ -2326,11 +2363,53 @@ void QVGPaintEngine::compositionModeChanged() vgMode = VG_BLEND_LIGHTEN; break; default: - qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; - break; // Fall back to VG_BLEND_SRC_OVER. + if (d->hasAdvancedBlending) { + switch (state()->composition_mode) { + case QPainter::CompositionMode_Overlay: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_OVERLAY_KHR; + break; + case QPainter::CompositionMode_ColorDodge: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORDODGE_KHR; + break; + case QPainter::CompositionMode_ColorBurn: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORBURN_KHR; + break; + case QPainter::CompositionMode_HardLight: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_HARDLIGHT_KHR; + break; + case QPainter::CompositionMode_SoftLight: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SOFTLIGHT_KHR; + break; + case QPainter::CompositionMode_Difference: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DIFFERENCE_KHR; + break; + case QPainter::CompositionMode_Exclusion: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_EXCLUSION_KHR; + break; + case QPainter::CompositionMode_SourceOut: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_OUT_KHR; + break; + case QPainter::CompositionMode_DestinationOut: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_OUT_KHR; + break; + case QPainter::CompositionMode_SourceAtop: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_ATOP_KHR; + break; + case QPainter::CompositionMode_DestinationAtop: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_ATOP_KHR; + break; + case QPainter::CompositionMode_Xor: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_XOR_KHR; + break; + default: break; // Fall back to VG_BLEND_SRC_OVER. + } + } + if (vgMode == VG_BLEND_SRC_OVER) + qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; + break; } - d->setBlendMode(vgMode); + d->setBlendMode(VGBlendMode(vgMode)); } void QVGPaintEngine::renderHintsChanged() |