[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:39:00 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit ac756a8c1385d8dd781c8be0d96fa05c1e704ccf
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Aug 26 17:52:00 2010 +0000
2010-08-25 Kenneth Russell <kbr at google.com>
Reviewed by Dimitri Glazkov.
Expose Vector3 and associated operations
https://bugs.webkit.org/show_bug.cgi?id=44666
No new tests; ran several 3D CSS demos and did full layout test
run. New code paths have also been tested by new calling code
which will be checked in soon.
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::decompose):
* platform/graphics/transforms/TransformationMatrix.h:
(WebCore::Vector3::Vector3):
(WebCore::Vector3::x):
(WebCore::Vector3::y):
(WebCore::Vector3::z):
(WebCore::Vector3::setX):
(WebCore::Vector3::setY):
(WebCore::Vector3::setZ):
(WebCore::Vector3::set):
(WebCore::Vector3::operator =):
(WebCore::Vector3::operator +):
(WebCore::Vector3::operator -):
(WebCore::Vector3::operator[]):
(WebCore::Vector3::length):
(WebCore::Vector3::lengthSquared):
(WebCore::Vector3::scaleTo):
(WebCore::Vector3::normalize):
(WebCore::Vector3::dot):
(WebCore::Vector3::combine):
(WebCore::Vector3::cross):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0c34171..a0b816f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2010-08-25 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Dimitri Glazkov.
+
+ Expose Vector3 and associated operations
+ https://bugs.webkit.org/show_bug.cgi?id=44666
+
+ No new tests; ran several 3D CSS demos and did full layout test
+ run. New code paths have also been tested by new calling code
+ which will be checked in soon.
+
+ * platform/graphics/transforms/TransformationMatrix.cpp:
+ (WebCore::decompose):
+ * platform/graphics/transforms/TransformationMatrix.h:
+ (WebCore::Vector3::Vector3):
+ (WebCore::Vector3::x):
+ (WebCore::Vector3::y):
+ (WebCore::Vector3::z):
+ (WebCore::Vector3::setX):
+ (WebCore::Vector3::setY):
+ (WebCore::Vector3::setZ):
+ (WebCore::Vector3::set):
+ (WebCore::Vector3::operator =):
+ (WebCore::Vector3::operator +):
+ (WebCore::Vector3::operator -):
+ (WebCore::Vector3::operator[]):
+ (WebCore::Vector3::length):
+ (WebCore::Vector3::lengthSquared):
+ (WebCore::Vector3::scaleTo):
+ (WebCore::Vector3::normalize):
+ (WebCore::Vector3::dot):
+ (WebCore::Vector3::combine):
+ (WebCore::Vector3::cross):
+
2010-08-26 Mikhail Naganov <mnaganov at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
index 10c7f70..685db8c 100644
--- a/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
@@ -71,7 +71,6 @@ 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;
@@ -254,44 +253,6 @@ 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;
@@ -369,35 +330,35 @@ static bool decompose(const TransformationMatrix::Matrix4& mat, TransformationMa
}
// Compute X scale factor and normalize first row.
- result.scaleX = v3Length(row[0]);
- v3Scale(row[0], 1.0);
+ result.scaleX = row[0].length();
+ row[0].scaleTo(1.0);
// Compute XY shear factor and make 2nd row orthogonal to 1st.
- result.skewXY = v3Dot(row[0], row[1]);
- v3Combine(row[1], row[0], row[1], 1.0, -result.skewXY);
+ result.skewXY = row[0].dot(row[1]);
+ row[1].combine(row[1], row[0], 1.0, -result.skewXY);
// Now, compute Y scale and normalize 2nd row.
- result.scaleY = v3Length(row[1]);
- v3Scale(row[1], 1.0);
+ result.scaleY = row[1].length();
+ row[1].scaleTo(1.0);
result.skewXY /= result.scaleY;
// Compute XZ and YZ shears, orthogonalize 3rd row.
- 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);
+ 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);
// Next, get Z scale and normalize 3rd row.
- result.scaleZ = v3Length(row[2]);
- v3Scale(row[2], 1.0);
+ result.scaleZ = row[2].length();
+ row[2].scaleTo(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.
- v3Cross(row[1], row[2], pdum3);
- if (v3Dot(row[0], pdum3) < 0) {
+ pdum3.cross(row[1], row[2]);
+ if (row[0].dot(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 96b4baa..374f91d 100644
--- a/WebCore/platform/graphics/transforms/TransformationMatrix.h
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.h
@@ -62,6 +62,130 @@ 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