summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-05-12 22:46:35 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-05-12 22:46:35 (GMT)
commit13c3a19eff8dead535e0ef20f69a311c2925f663 (patch)
tree3dcaf3601f64826ed18620a97eb3a6c46e2052ee
parentf474f0f900d48b41be1a3de1dffe48552ab23372 (diff)
downloadQt-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
-rw-r--r--doc/src/howtos/openvg.qdoc21
-rw-r--r--doc/src/platforms/emb-openvg.qdocinc21
-rw-r--r--src/openvg/qpaintengine_vg.cpp87
3 files changed, 121 insertions, 8 deletions
diff --git a/doc/src/howtos/openvg.qdoc b/doc/src/howtos/openvg.qdoc
index f70ed54..e448d9c 100644
--- a/doc/src/howtos/openvg.qdoc
+++ b/doc/src/howtos/openvg.qdoc
@@ -172,8 +172,25 @@
\endlist
The other members of QPainter::CompositionMode are not supported
- because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode
- enumeration. Any attempt to set an unsupported mode will result in
+ unless the \c{VG_KHR_advanced_blending} extension is present,
+ in which case the following additional modes are supported:
+
+ \list
+ \o QPainter::CompositionMode_Overlay
+ \o QPainter::CompositionMode_ColorDodge
+ \o QPainter::CompositionMode_ColorBurn
+ \o QPainter::CompositionMode_HardLight
+ \o QPainter::CompositionMode_SoftLight
+ \o QPainter::CompositionMode_Difference
+ \o QPainter::CompositionMode_Exclusion
+ \o QPainter::CompositionMode_SourceOut
+ \o QPainter::CompositionMode_DestinationOut
+ \o QPainter::CompositionMode_SourceAtop
+ \o QPainter::CompositionMode_DestinationAtop
+ \o QPainter::CompositionMode_Xor
+ \endlist
+
+ Any attempt to set an unsupported mode will result in
the actual mode being set to QPainter::CompositionMode_SourceOver.
Client applications should avoid using unsupported modes.
diff --git a/doc/src/platforms/emb-openvg.qdocinc b/doc/src/platforms/emb-openvg.qdocinc
index 2f9cc21..579af67 100644
--- a/doc/src/platforms/emb-openvg.qdocinc
+++ b/doc/src/platforms/emb-openvg.qdocinc
@@ -135,8 +135,25 @@ transformations for non-image elements in performance critical code.
\endlist
The other members of QPainter::CompositionMode are not supported
-because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode
-enumeration. Any attempt to set an unsupported mode will result in
+unless the \c{VG_KHR_advanced_blending} extension is present,
+in which case the following additional modes are supported:
+
+\list
+\o QPainter::CompositionMode_Overlay
+\o QPainter::CompositionMode_ColorDodge
+\o QPainter::CompositionMode_ColorBurn
+\o QPainter::CompositionMode_HardLight
+\o QPainter::CompositionMode_SoftLight
+\o QPainter::CompositionMode_Difference
+\o QPainter::CompositionMode_Exclusion
+\o QPainter::CompositionMode_SourceOut
+\o QPainter::CompositionMode_DestinationOut
+\o QPainter::CompositionMode_SourceAtop
+\o QPainter::CompositionMode_DestinationAtop
+\o QPainter::CompositionMode_Xor
+\endlist
+
+Any attempt to set an unsupported mode will result in
the actual mode being set to QPainter::CompositionMode_SourceOver.
Client applications should avoid using unsupported modes.
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()