[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kbr at google.com kbr at google.com
Wed Dec 22 12:48:31 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a98233e1dfb045583f6b6dac3fb8a0fbbee29af2
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Aug 30 22:28:04 2010 +0000

    2010-08-30  Kenneth Russell  <kbr at google.com>
    
            Reviewed by Chris Marrin.
    
            Expose Vector3 and associated operations
            https://bugs.webkit.org/show_bug.cgi?id=44666
    
            Rolling out earlier patch exposing Vector3 class in
            TransformationMatrix.h. A different approach will be taken under
            another bug.
    
            * platform/graphics/transforms/TransformationMatrix.cpp:
            (WebCore::v3Length):
            (WebCore::v3Scale):
            (WebCore::v3Dot):
            (WebCore::v3Combine):
            (WebCore::v3Cross):
            (WebCore::decompose):
            * platform/graphics/transforms/TransformationMatrix.ha:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ff64457..95fb56c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-08-30  Kenneth Russell  <kbr at google.com>
+
+        Reviewed by Chris Marrin.
+
+        Expose Vector3 and associated operations
+        https://bugs.webkit.org/show_bug.cgi?id=44666
+
+        Rolling out earlier patch exposing Vector3 class in
+        TransformationMatrix.h. A different approach will be taken under
+        another bug.
+
+        * platform/graphics/transforms/TransformationMatrix.cpp:
+        (WebCore::v3Length):
+        (WebCore::v3Scale):
+        (WebCore::v3Dot):
+        (WebCore::v3Combine):
+        (WebCore::v3Cross):
+        (WebCore::decompose):
+        * platform/graphics/transforms/TransformationMatrix.ha:
+
 2010-08-30  Jer Noble  <jer.noble at apple.com>
 
         Build fix; Unreviewed.
diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
index 685db8c..10c7f70 100644
--- a/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
@@ -71,6 +71,7 @@ namespace WebCore {
 // opposite operations. So we have to be VERY careful when we change them.
 
 typedef double Vector4[4];
+typedef double Vector3[3];
 
 const double SMALL_NUMBER = 1.e-8;
 
@@ -253,6 +254,44 @@ static void v4MulPointByMatrix(const Vector4 p, const TransformationMatrix::Matr
                 (p[2] * m[2][3]) + (p[3] * m[3][3]);
 }
 
+static double v3Length(Vector3 a)
+{
+    return sqrt((a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2]));
+}
+
+static void v3Scale(Vector3 v, double desiredLength) 
+{
+    double len = v3Length(v);
+    if (len != 0) {
+        double l = desiredLength / len;
+        v[0] *= l;
+        v[1] *= l;
+        v[2] *= l;
+    }
+}
+
+static double v3Dot(const Vector3 a, const Vector3 b) 
+{
+    return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);
+}
+
+// Make a linear combination of two vectors and return the result.
+// result = (a * ascl) + (b * bscl)
+static void v3Combine(const Vector3 a, const Vector3 b, Vector3 result, double ascl, double bscl)
+{
+    result[0] = (ascl * a[0]) + (bscl * b[0]);
+    result[1] = (ascl * a[1]) + (bscl * b[1]);
+    result[2] = (ascl * a[2]) + (bscl * b[2]);
+}
+
+// Return the cross product result = a cross b */
+static void v3Cross(const Vector3 a, const Vector3 b, Vector3 result)
+{
+    result[0] = (a[1] * b[2]) - (a[2] * b[1]);
+    result[1] = (a[2] * b[0]) - (a[0] * b[2]);
+    result[2] = (a[0] * b[1]) - (a[1] * b[0]);
+}
+
 static bool decompose(const TransformationMatrix::Matrix4& mat, TransformationMatrix::DecomposedType& result)
 {
     TransformationMatrix::Matrix4 localMatrix;
@@ -330,35 +369,35 @@ static bool decompose(const TransformationMatrix::Matrix4& mat, TransformationMa
     }
 
     // Compute X scale factor and normalize first row.
-    result.scaleX = row[0].length();
-    row[0].scaleTo(1.0);
+    result.scaleX = v3Length(row[0]);
+    v3Scale(row[0], 1.0);
 
     // Compute XY shear factor and make 2nd row orthogonal to 1st.
-    result.skewXY = row[0].dot(row[1]);
-    row[1].combine(row[1], row[0], 1.0, -result.skewXY);
+    result.skewXY = v3Dot(row[0], row[1]);
+    v3Combine(row[1], row[0], row[1], 1.0, -result.skewXY);
 
     // Now, compute Y scale and normalize 2nd row.
-    result.scaleY = row[1].length();
-    row[1].scaleTo(1.0);
+    result.scaleY = v3Length(row[1]);
+    v3Scale(row[1], 1.0);
     result.skewXY /= result.scaleY;
 
     // Compute XZ and YZ shears, orthogonalize 3rd row.
-    result.skewXZ = row[0].dot(row[2]);
-    row[2].combine(row[2], row[0], 1.0, -result.skewXZ);
-    result.skewYZ = row[1].dot(row[2]);
-    row[2].combine(row[2], row[1], 1.0, -result.skewYZ);
+    result.skewXZ = v3Dot(row[0], row[2]);
+    v3Combine(row[2], row[0], row[2], 1.0, -result.skewXZ);
+    result.skewYZ = v3Dot(row[1], row[2]);
+    v3Combine(row[2], row[1], row[2], 1.0, -result.skewYZ);
 
     // Next, get Z scale and normalize 3rd row.
-    result.scaleZ = row[2].length();
-    row[2].scaleTo(1.0);
+    result.scaleZ = v3Length(row[2]);
+    v3Scale(row[2], 1.0);
     result.skewXZ /= result.scaleZ;
     result.skewYZ /= result.scaleZ;
  
     // At this point, the matrix (in rows[]) is orthonormal.
     // Check for a coordinate system flip.  If the determinant
     // is -1, then negate the matrix and the scaling factors.
-    pdum3.cross(row[1], row[2]);
-    if (row[0].dot(pdum3) < 0) {
+    v3Cross(row[1], row[2], pdum3);
+    if (v3Dot(row[0], pdum3) < 0) {
         for (i = 0; i < 3; i++) {
             result.scaleX *= -1;
             row[i][0] *= -1;
diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.h b/WebCore/platform/graphics/transforms/TransformationMatrix.h
index 374f91d..96b4baa 100644
--- a/WebCore/platform/graphics/transforms/TransformationMatrix.h
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.h
@@ -62,130 +62,6 @@ class FloatPoint3D;
 class FloatRect;
 class FloatQuad;
 
-class Vector3 : public FastAllocBase {
-public:
-    Vector3() { set(0, 0, 0); }
-    Vector3(const Vector3& v) { *this = v; }
-    Vector3(double x, double y, double z) { set(x, y, z); }
-
-    double x() const { return m_vector[0]; }
-    double y() const { return m_vector[1]; }
-    double z() const { return m_vector[2]; }
-    void setX(double x) { m_vector[0] = x; }
-    void setY(double y) { m_vector[1] = y; }
-    void setZ(double z) { m_vector[2] = z; }
-
-    void set(double x, double y, double z)
-    {
-        m_vector[0] = x;
-        m_vector[1] = y;
-        m_vector[2] = z;
-    }
-
-    void set(const Vector3& v)
-    {
-        if (m_vector != v.m_vector)
-            memcpy(m_vector, v.m_vector, sizeof(m_vector));
-    }
-
-    Vector3& operator =(const Vector3& v)
-    {
-        set(v);
-        return *this;
-    }
-
-    Vector3 operator +(const Vector3& v) const
-    {
-        return Vector3(m_vector[0] + v[0],
-                       m_vector[1] + v[1],
-                       m_vector[2] + v[2]);
-    }
-
-    Vector3 operator -(const Vector3& v) const
-    {
-        return Vector3(m_vector[0] - v[0],
-                       m_vector[1] - v[1],
-                       m_vector[2] - v[2]);
-    }
-
-    double& operator[](int index)
-    {
-        ASSERT(index >= 0 && index <= 2);
-        return m_vector[index];
-    }
-
-    const double& operator[](int index) const
-    {
-        ASSERT(index >= 0 && index <= 2);
-        return m_vector[index];
-    }
-
-    double length() const
-    {
-        return sqrt(lengthSquared());
-    }
-
-    double lengthSquared() const
-    {
-        return (m_vector[0] * m_vector[0]) + (m_vector[1] * m_vector[1]) + (m_vector[2] * m_vector[2]);
-    }
-
-    void scaleTo(double desiredLength)
-    {
-        double len = length();
-        if (len) {
-            double scaleFactor = desiredLength / len;
-            m_vector[0] *= scaleFactor;
-            m_vector[1] *= scaleFactor;
-            m_vector[2] *= scaleFactor;
-        }
-    }
-
-    void normalize()
-    {
-        scaleTo(1.0);
-    }
-
-    double dot(const Vector3& v) const
-    {
-        return m_vector[0] * v[0] + m_vector[1] * v[1] + m_vector[2] * v[2];
-    }
-
-    // Sets this to a linear combination of two vectors.
-    // this = (a * ascl) + (b * bscl).
-    // It is safe for "this" to be either a or b.
-    void combine(const Vector3& a, const Vector3& b, double ascl, double bscl)
-    {
-        m_vector[0] = (ascl * a[0]) + (bscl * b[0]);
-        m_vector[1] = (ascl * a[1]) + (bscl * b[1]);
-        m_vector[2] = (ascl * a[2]) + (bscl * b[2]);
-    }
-
-    // Sets this to the cross product of a and b.
-    // It is safe for "this" to be either a or b.
-    void cross(const Vector3& a, const Vector3& b)
-    {
-        double x = (a[1] * b[2]) - (a[2] * b[1]);
-        double y = (a[2] * b[0]) - (a[0] * b[2]);
-        double z = (a[0] * b[1]) - (a[1] * b[0]);
-        m_vector[0] = x;
-        m_vector[1] = y;
-        m_vector[2] = z;
-    }
-
-    // Convenience routine which returns the result of "this cross v"
-    // as a new Vector3.
-    Vector3 cross(const Vector3& v) const
-    {
-        Vector3 result;
-        result.cross(*this, v);
-        return result;
-    }
-
-private:
-    double m_vector[3];
-};
-
 class TransformationMatrix : public FastAllocBase {
 public:
     typedef double Matrix4[4][4];

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list