OSDN Git Service

Implement a GLUtils::toSkMatrix() function
authorNicolas Roard <nicolas@android.com>
Wed, 15 Dec 2010 21:31:34 +0000 (13:31 -0800)
committerNicolas Roard <nicolas@android.com>
Wed, 15 Dec 2010 23:50:44 +0000 (15:50 -0800)
This also fix the rotation in software rendering.

Change-Id: Iffe1ed3666c9501861ec6793294bf5cde89026d7

WebCore/platform/graphics/android/GLUtils.cpp
WebCore/platform/graphics/android/GLUtils.h
WebCore/platform/graphics/android/LayerAndroid.cpp

index 0923c54..739dafc 100644 (file)
@@ -46,22 +46,34 @@ using namespace android;
 /////////////////////////////////////////////////////////////////////////////////////////
 
 void GLUtils::toGLMatrix(GLfloat* flattened, const TransformationMatrix& m) {
-    flattened[0] = m.m11();
-    flattened[1] = m.m12();
+    flattened[0] = m.m11(); // scaleX
+    flattened[1] = m.m12(); // skewY
     flattened[2] = m.m13();
-    flattened[3] = m.m14();
-    flattened[4] = m.m21();
-    flattened[5] = m.m22();
+    flattened[3] = m.m14(); // persp0
+    flattened[4] = m.m21(); // skewX
+    flattened[5] = m.m22(); // scaleY
     flattened[6] = m.m23();
-    flattened[7] = m.m24();
+    flattened[7] = m.m24(); // persp1
     flattened[8] = m.m31();
     flattened[9] = m.m32();
     flattened[10] = m.m33();
     flattened[11] = m.m34();
-    flattened[12] = m.m41();
-    flattened[13] = m.m42();
+    flattened[12] = m.m41(); // transX
+    flattened[13] = m.m42(); // transY
     flattened[14] = m.m43();
-    flattened[15] = m.m44();
+    flattened[15] = m.m44(); // persp2
+}
+
+void GLUtils::toSkMatrix(SkMatrix& matrix, const TransformationMatrix& m) {
+    matrix[0] = m.m11(); // scaleX
+    matrix[1] = m.m21(); // skewX
+    matrix[2] = m.m41(); // transX
+    matrix[3] = m.m12(); // skewY
+    matrix[4] = m.m22(); // scaleY
+    matrix[5] = m.m42(); // transY
+    matrix[6] = m.m14(); // persp0
+    matrix[7] = m.m24(); // persp1
+    matrix[8] = m.m44(); // persp2
 }
 
 void GLUtils::setOrthographicMatrix(TransformationMatrix& ortho, float left, float top,
index 1886c04..1b2e823 100644 (file)
@@ -33,6 +33,7 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 #include "SkBitmap.h"
+#include "SkMatrix.h"
 #include "TransformationMatrix.h"
 
 namespace WebCore {
@@ -42,6 +43,7 @@ class GLUtils {
 public:
    // Matrix utilities
    static void toGLMatrix(GLfloat* flattened, const TransformationMatrix& matrix);
+   static void toSkMatrix(SkMatrix& skmatrix, const TransformationMatrix& matrix);
    static void setOrthographicMatrix(TransformationMatrix& ortho, float left, float top,
                                      float right, float bottom, float nearZ, float farZ);
 
index d91ac65..b71f525 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "AndroidAnimation.h"
 #include "DrawExtra.h"
+#include "GLUtils.h"
 #include "ParseCanvas.h"
 #include "SkBitmapRef.h"
 #include "SkBounder.h"
@@ -419,17 +420,8 @@ void LayerAndroid::updatePositions()
         //
         // TODO: this should happen in the caller, and we should remove these
         // fields from our subclass
-        TransformationMatrix::DecomposedType tDecomp;
-        m_transform.decompose(tDecomp);
         matrix.reset();
-        matrix.setScaleX(tDecomp.scaleX);
-        matrix.setScaleY(tDecomp.scaleY);
-        matrix.setSkewX(tDecomp.skewXZ);
-        matrix.setSkewY(tDecomp.skewYZ);
-        matrix.setTranslateX(tDecomp.translateX);
-        matrix.setTranslateY(tDecomp.translateY);
-        matrix.setPerspX(tDecomp.perspectiveX);
-        matrix.setPerspY(tDecomp.perspectiveY);
+        GLUtils::toSkMatrix(matrix, m_transform);
         this->setMatrix(matrix);
     }