2009-03-02 Kim Grönholm <kim.gronholm@nomovok.com>
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2009 14:42:32 +0000 (14:42 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2009 14:42:32 +0000 (14:42 +0000)
        Reviewed by Simon Hausmann.

        Improvement to 3d transformations rendering in QtWebKit. QTransform is used
        instead of QMatrix. This allows perspective transformations since QTransform is
        a true 3x3 matrix.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/qt/FontQt.cpp
WebCore/platform/graphics/qt/GraphicsContextQt.cpp
WebCore/platform/graphics/qt/ImageQt.cpp
WebCore/platform/graphics/qt/PathQt.cpp
WebCore/platform/graphics/qt/PatternQt.cpp
WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
WebCore/platform/graphics/transforms/TransformationMatrix.h

index 0153c15557f903eacb350e444d09a3007a633582..df22d4a97ffd10fc3e11dd6213369e868a940fb3 100644 (file)
@@ -1,3 +1,34 @@
+2009-03-02  Kim Grönholm  <kim.gronholm@nomovok.com>
+
+        Reviewed by Simon Hausmann.
+
+        Improvement to 3d transformations rendering in QtWebKit. QTransform is used
+        instead of QMatrix. This allows perspective transformations since QTransform is
+        a true 3x3 matrix.
+
+        * platform/graphics/qt/GraphicsContextQt.cpp: Use QTransform instead of QMatrix everywhere.
+        (WebCore::GraphicsContext::getCTM):
+        (WebCore::GraphicsContext::restorePlatformState):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::strokePath):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::translate):
+        (WebCore::GraphicsContext::rotate):
+        (WebCore::GraphicsContext::scale):
+        (WebCore::GraphicsContext::concatCTM):
+        * platform/graphics/qt/ImageQt.cpp:
+        (WebCore::Image::drawPattern):
+        * platform/graphics/qt/PathQt.cpp:
+        (WebCore::Path::translate):
+        (WebCore::Path::transform):
+        * platform/graphics/qt/PatternQt.cpp:
+        (WebCore::Pattern::createPlatformPattern):
+        * platform/graphics/qt/TransformationMatrixQt.cpp:
+        (WebCore::TransformationMatrix::operator QTransform): Replace the conversion operator
+        to QMatrix with one to QTransform.
+        * platform/graphics/transforms/TransformationMatrix.h:
+        * platform/graphics/qt/FontQt.cpp:
+
 2009-02-24  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Reviewed by Simon Hausmann.
index b96f9efa471b3dbfe658ce4d57537caf1fe47157..36638ddd13cc8fe3c6e39bfc076e8cc0f44f4889 100644 (file)
@@ -84,7 +84,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
     if (ctx->textDrawingMode() & cTextFill) {
         if (ctx->fillGradient()) {
             QBrush brush(*ctx->fillGradient()->platformGradient());
-            brush.setMatrix(ctx->fillGradient()->gradientSpaceTransform());
+            brush.setTransform(ctx->fillGradient()->gradientSpaceTransform());
             p->setPen(QPen(brush, 0));
         } else if (ctx->fillPattern()) {
             TransformationMatrix affine;
@@ -96,7 +96,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
     if (ctx->textDrawingMode() & cTextStroke) {
         if (ctx->strokeGradient()) {
             QBrush brush(*ctx->strokeGradient()->platformGradient());
-            brush.setMatrix(ctx->strokeGradient()->gradientSpaceTransform());
+            brush.setTransform(ctx->strokeGradient()->gradientSpaceTransform());
             p->setPen(QPen(brush, 0));
         } else if (ctx->strokePattern()) {
             TransformationMatrix affine;
index ff68adc3ce565d14bd88224547c42f746a264425..47f8e27d4d76a2580023708026433b532e486120 100644 (file)
@@ -266,8 +266,11 @@ PlatformGraphicsContext* GraphicsContext::platformContext() const
 
 TransformationMatrix GraphicsContext::getCTM() const
 {
-    QMatrix matrix(platformContext()->combinedMatrix());
-    return TransformationMatrix(matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), matrix.dx(), matrix.dy());
+    QTransform matrix(platformContext()->combinedTransform());
+    return TransformationMatrix(matrix.m11(), matrix.m12(), 0, matrix.m13(), 
+                                matrix.m21(), matrix.m22(), 0, matrix.m23(),
+                                           0,            0, 1,            0,
+                                matrix.m31(), matrix.m32(), 0, matrix.m33());
 }
 
 void GraphicsContext::savePlatformState()
@@ -280,7 +283,7 @@ void GraphicsContext::restorePlatformState()
     m_data->p()->restore();
 
     if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) {
-        QMatrix matrix = m_common->state.pathTransform;
+        QTransform matrix = m_common->state.pathTransform;
         m_data->currentPath = m_data->currentPath * matrix;
     }
 }
@@ -539,7 +542,7 @@ void GraphicsContext::fillPath()
     }
     case GradientColorSpace:
         QBrush brush(*m_common->state.fillGradient->platformGradient());
-        brush.setMatrix(m_common->state.fillGradient->gradientSpaceTransform());
+        brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
         p->fillPath(path, brush);
         break;
     }
@@ -569,7 +572,7 @@ void GraphicsContext::strokePath()
     }
     case GradientColorSpace: {
         QBrush brush(*m_common->state.strokeGradient->platformGradient());
-        brush.setMatrix(m_common->state.strokeGradient->gradientSpaceTransform());
+        brush.setTransform(m_common->state.strokeGradient->gradientSpaceTransform());
         pen.setBrush(brush);
         p->setPen(pen);
         p->strokePath(path, pen);
@@ -598,7 +601,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     }
     case GradientColorSpace:
         QBrush brush(*m_common->state.fillGradient->platformGradient());
-        brush.setMatrix(m_common->state.fillGradient->gradientSpaceTransform());
+        brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
         p->fillRect(rect, brush);
         break;
     }
@@ -923,7 +926,7 @@ void GraphicsContext::translate(float x, float y)
     m_data->p()->translate(x, y);
 
     if (!m_data->currentPath.isEmpty()) {
-        QMatrix matrix;
+        QTransform matrix;
         m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y);
         m_common->state.pathTransform.translate(x, y);
     }
@@ -945,7 +948,7 @@ void GraphicsContext::rotate(float radians)
     m_data->p()->rotate(180/M_PI*radians);
 
     if (!m_data->currentPath.isEmpty()) {
-        QMatrix matrix;
+        QTransform matrix;
         m_data->currentPath = m_data->currentPath * matrix.rotate(-180/M_PI*radians);
         m_common->state.pathTransform.rotate(radians);
     }
@@ -959,7 +962,7 @@ void GraphicsContext::scale(const FloatSize& s)
     m_data->p()->scale(s.width(), s.height());
 
     if (!m_data->currentPath.isEmpty()) {
-        QMatrix matrix;
+        QTransform matrix;
         m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height());
         m_common->state.pathTransform.scaleNonUniform(s.width(), s.height());
     }
@@ -1025,12 +1028,12 @@ void GraphicsContext::concatCTM(const TransformationMatrix& transform)
     if (paintingDisabled())
         return;
 
-    m_data->p()->setMatrix(transform, true);
+    m_data->p()->setWorldTransform(transform, true);
 
     // Transformations to the context shouldn't transform the currentPath. 
     // We have to undo every change made to the context from the currentPath to avoid wrong drawings.
     if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
-        QMatrix matrix = transform.inverse();
+        QTransform matrix = transform.inverse();
         m_data->currentPath = m_data->currentPath * matrix;
         m_common->state.pathTransform.multiply(transform);
     }
index 5898daa5aa15addcbcb4c9d75c92f8146eb95d8f..f3823915f7dd384cf83d812379f70d4f7c9320be 100644 (file)
@@ -108,7 +108,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
     }
 
     QBrush b(pixmap);
-    b.setMatrix(patternTransform);
+    b.setTransform(patternTransform);
     ctxt->save();
     ctxt->setCompositeOperation(op);
     QPainter* p = ctxt->platformContext();
index 99a297aaf5f3a1ca2a9aad903ab623b9731ffa53..a8a3ea2d051638b8b7fb520152169c7f917f211a 100644 (file)
@@ -37,7 +37,7 @@
 #include "PlatformString.h"
 #include "StrokeStyleApplier.h"
 #include <QPainterPath>
-#include <QMatrix>
+#include <QTransform>
 #include <QString>
 
 #define _USE_MATH_DEFINES
@@ -109,7 +109,7 @@ bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point)
 
 void Path::translate(const FloatSize& size)
 {
-    QMatrix matrix;
+    QTransform matrix;
     matrix.translate(size.width(), size.height());
     *m_path = (*m_path) * matrix;
 }
@@ -380,7 +380,7 @@ void Path::apply(void* info, PathApplierFunction function) const
 void Path::transform(const TransformationMatrix& transform)
 {
     if (m_path) {
-        QMatrix mat = transform;
+        QTransform mat = transform;
         QPainterPath temp = mat.map(*m_path);
         delete m_path;
         m_path = new QPainterPath(temp);
index 1931477b763428b7267b4713b4abe4d40c1f31a0..b2616130699dcbd8b61f7e805baedd4ccf8c02fa 100644 (file)
@@ -39,7 +39,7 @@ QBrush Pattern::createPlatformPattern(const TransformationMatrix&) const
 
     // Qt merges patter space and user space itself
     QBrush brush(*pixmap);
-    brush.setMatrix(m_patternSpaceTransformation);
+    brush.setTransform(m_patternSpaceTransformation);
 
     return brush;
 }
index 57ff526973e1d91404a6332b7050b1f131b614c7..15f0cc53948bf2c7733ac9906eed83d251ba6201 100644 (file)
@@ -31,9 +31,9 @@
 
 namespace WebCore {
 
-TransformationMatrix::operator QMatrix() const
-{
-    return QMatrix(a(), b(), c(), d(), e(), f());
+TransformationMatrix::operator QTransform() const
+{          
+    return QTransform(m11(), m12(), m14(), m21(), m22(), m24(), m41(), m42(), m44());
 }
 
 }
index 306a4ca5e94370501a00de1fc58fbb4e42320c5f..9d0c2ce91fac17aa0e628b50624fc6e970f354cb 100644 (file)
@@ -31,7 +31,7 @@
 #elif PLATFORM(CAIRO)
 #include <cairo.h>
 #elif PLATFORM(QT)
-#include <QMatrix>
+#include <QTransform>
 #elif PLATFORM(SKIA)
 #include <SkMatrix.h>
 #elif PLATFORM(WX) && USE(WXGC)
@@ -287,7 +287,7 @@ public:
 #elif PLATFORM(CAIRO)
     operator cairo_matrix_t() const;
 #elif PLATFORM(QT)
-    operator QMatrix() const;
+    operator QTransform() const;
 #elif PLATFORM(SKIA)
     operator SkMatrix() const;
 #elif PLATFORM(WX) && USE(WXGC)