From 2f8141dc3c922619bbe577902c2ef8a9e2195d70 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 5 Mar 2010 11:52:10 +1000 Subject: Image drawing in OpenVG was off by 0.5 of a pixel Path transforms need to be adjusted by 0.5 for the difference in OpenVG and Qt co-ordinate systems. Image transforms do not need to be adjusted because OpenVG implicitly adjusts by 0.5. Task-number: QT-2999 Reviewed-by: Sarah Smith --- src/openvg/qpaintengine_vg.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index c46bc27..4a97a6f 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -516,14 +516,11 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev) 0.0f, -1.0f, 0.0f, 0.5f, devh + 0.5f, 1.0f); - // The image transform is always the full transformation, - // because it can be projective. - imageTransform = transform * viewport; - - // Determine if the transformation is projective. - bool projective = (imageTransform.m13() != 0.0f || - imageTransform.m23() != 0.0f || - imageTransform.m33() != 1.0f); + // Compute the path transform and determine if it is projective. + pathTransform = transform * viewport; + bool projective = (pathTransform.m13() != 0.0f || + pathTransform.m23() != 0.0f || + pathTransform.m33() != 1.0f); if (projective) { // The engine cannot do projective path transforms for us, // so we will have to convert the co-ordinates ourselves. @@ -531,11 +528,19 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev) pathTransform = viewport; simpleTransform = false; } else { - pathTransform = imageTransform; simpleTransform = true; } pathTransformSet = false; + // The image transform is always the full transformation, + // because it can be projective. It also does not need the + // (0.5, -0.5) translation because vgDrawImage() implicitly + // adds 0.5 to each co-ordinate. + QTransform viewport2(1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, devh, 1.0f); + imageTransform = transform * viewport2; + // Calculate the scaling factor to use for turning cosmetic pens // into ordinary non-cosmetic pens. qt_scaleForTransform(transform, &penScale); -- cgit v0.12