summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
authorJani Hautakangas <jani.hautakangas@nokia.com>2011-04-13 08:38:13 (GMT)
committerJani Hautakangas <jani.hautakangas@nokia.com>2011-04-13 09:10:08 (GMT)
commitcc526edbff1cc413532f7ab1b6c088adae76744d (patch)
tree25133a687eb79dceee8a5aee69aaf3d8ad67bff4 /src/openvg
parent1840a4383fd19bc64ef6d81c09c3f54aeb52d777 (diff)
downloadQt-cc526edbff1cc413532f7ab1b6c088adae76744d.zip
Qt-cc526edbff1cc413532f7ab1b6c088adae76744d.tar.gz
Qt-cc526edbff1cc413532f7ab1b6c088adae76744d.tar.bz2
Fix to 'QImage convertToFormat doesn't work correctly'
OpenVG paint engine tries to use vgWritePixels shortcut whenever possible to optimize rendering performance. The check 'canVgWritePixels' failed to map formats correctly and resulted to incorrect return value. Task-number: QTBUG-18682 Reviewed-by: Jason Barron
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 570adfd..ebdfa5f 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -1024,9 +1024,11 @@ static VGImage toVGImage
switch (img.format()) {
case QImage::Format_Mono:
img = image.convertToFormat(QImage::Format_MonoLSB, flags);
+ img.invertPixels();
format = VG_BW_1;
break;
case QImage::Format_MonoLSB:
+ img.invertPixels();
format = VG_BW_1;
break;
case QImage::Format_RGB32:
@@ -3189,6 +3191,19 @@ void qt_vg_drawVGImageStencil
bool QVGPaintEngine::canVgWritePixels(const QImage &image) const
{
Q_D(const QVGPaintEngine);
+
+ // qt_vg_image_to_vg_format returns VG_sARGB_8888 as
+ // fallback case if no matching VG format is found.
+ // If given image format is not Format_ARGB32 and returned
+ // format is VG_sARGB_8888, it means that no match was
+ // found. In that case vgWritePixels cannot be used.
+ // Also 1-bit formats cannot be used directly either.
+ if ((image.format() != QImage::Format_ARGB32
+ && qt_vg_image_to_vg_format(image.format()) == VG_sARGB_8888)
+ || image.depth() == 1) {
+ return false;
+ }
+
// vgWritePixels ignores masking, blending and xforms so we can only use it if
// ALL of the following conditions are true:
// - It is a simple translate, or a scale of -1 on the y-axis (inverted)