summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/transforms
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-18 13:36:51 +0100
committerSteve Block <steveblock@google.com>2011-05-24 15:38:28 +0100
commit2fc2651226baac27029e38c9d6ef883fa32084db (patch)
treee396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/platform/graphics/transforms
parentb3725cedeb43722b3b175aaeff70552e562d2c94 (diff)
downloadexternal_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/platform/graphics/transforms')
-rw-r--r--Source/WebCore/platform/graphics/transforms/AffineTransform.cpp14
-rw-r--r--Source/WebCore/platform/graphics/transforms/AffineTransform.h6
-rw-r--r--Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h2
-rw-r--r--Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h2
-rw-r--r--Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp25
-rw-r--r--Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h14
-rw-r--r--Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp48
-rw-r--r--Source/WebCore/platform/graphics/transforms/TransformationMatrix.h18
8 files changed, 63 insertions, 66 deletions
diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp
index 3f88140..a1ffa30 100644
--- a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp
+++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp
@@ -222,14 +222,6 @@ AffineTransform& AffineTransform::translate(double tx, double ty)
return *this;
}
-// *this = translation * *this
-AffineTransform& AffineTransform::translateRight(double tx, double ty)
-{
- m_transform[4] += tx;
- m_transform[5] += ty;
- return *this;
-}
-
AffineTransform& AffineTransform::scaleNonUniform(double sx, double sy)
{
return scale(sx, sy);
@@ -324,9 +316,9 @@ FloatRect AffineTransform::mapRect(const FloatRect& rect) const
FloatQuad result;
result.setP1(mapPoint(rect.location()));
- result.setP2(mapPoint(FloatPoint(rect.right(), rect.y())));
- result.setP3(mapPoint(FloatPoint(rect.right(), rect.bottom())));
- result.setP4(mapPoint(FloatPoint(rect.x(), rect.bottom())));
+ result.setP2(mapPoint(FloatPoint(rect.maxX(), rect.y())));
+ result.setP3(mapPoint(FloatPoint(rect.maxX(), rect.maxY())));
+ result.setP4(mapPoint(FloatPoint(rect.x(), rect.maxY())));
return result.boundingBox();
}
diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.h b/Source/WebCore/platform/graphics/transforms/AffineTransform.h
index 50d0655..3e3995f 100644
--- a/Source/WebCore/platform/graphics/transforms/AffineTransform.h
+++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.h
@@ -103,7 +103,6 @@ public:
AffineTransform& rotate(double d);
AffineTransform& rotateFromVector(double x, double y);
AffineTransform& translate(double tx, double ty);
- AffineTransform& translateRight(double tx, double ty);
AffineTransform& shear(double sx, double sy);
AffineTransform& flipX();
AffineTransform& flipY();
@@ -172,6 +171,11 @@ public:
operator wxGraphicsMatrix() const;
#endif
+ static AffineTransform translation(double x, double y)
+ {
+ return AffineTransform(1, 0, 0, 1, x, y);
+ }
+
private:
void setMatrix(const Transform m)
{
diff --git a/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h b/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h
index 0a0aaf0..dd5dae2 100644
--- a/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h
+++ b/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h
@@ -55,7 +55,7 @@ private:
virtual bool apply(TransformationMatrix& transform, const IntSize&) const
{
- transform.multLeft(TransformationMatrix(m_matrix));
+ transform.multiply(TransformationMatrix(m_matrix));
return false;
}
diff --git a/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h b/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
index fd9b27e..6f4e725 100644
--- a/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
+++ b/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
@@ -62,7 +62,7 @@ private:
virtual bool apply(TransformationMatrix& transform, const IntSize&) const
{
TransformationMatrix matrix(m_a, m_b, m_c, m_d, m_e, m_f);
- transform.multLeft(TransformationMatrix(matrix));
+ transform.multiply(matrix);
return false;
}
diff --git a/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp b/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp
index 9fd03a1..18bfe37 100644
--- a/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp
+++ b/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "PerspectiveTransformOperation.h"
-#include <algorithm>
+#include <wtf/MathExtras.h>
using namespace std;
@@ -37,22 +37,29 @@ PassRefPtr<TransformOperation> PerspectiveTransformOperation::blend(const Transf
if (from && !from->isSameType(*this))
return this;
- if (blendToIdentity)
- return PerspectiveTransformOperation::create(m_p + (1. - m_p) * progress);
+ if (blendToIdentity) {
+ double p = m_p.calcFloatValue(1);
+ p = p + (1. - p) * progress; // FIXME: this seems wrong. https://bugs.webkit.org/show_bug.cgi?id=52700
+ return PerspectiveTransformOperation::create(Length(clampToPositiveInteger(p), Fixed));
+ }
const PerspectiveTransformOperation* fromOp = static_cast<const PerspectiveTransformOperation*>(from);
- double fromP = fromOp ? fromOp->m_p : 0;
- double toP = m_p;
+ Length fromP = fromOp ? fromOp->m_p : Length(m_p.type());
+ Length toP = m_p;
TransformationMatrix fromT;
TransformationMatrix toT;
- fromT.applyPerspective(fromP);
- toT.applyPerspective(toP);
+ fromT.applyPerspective(fromP.calcFloatValue(1));
+ toT.applyPerspective(toP.calcFloatValue(1));
toT.blend(fromT, progress);
TransformationMatrix::DecomposedType decomp;
toT.decompose(decomp);
-
- return PerspectiveTransformOperation::create(decomp.perspectiveZ ? -1.0 / decomp.perspectiveZ : 0.0);
+
+ if (decomp.perspectiveZ) {
+ double val = -1.0 / decomp.perspectiveZ;
+ return PerspectiveTransformOperation::create(Length(clampToPositiveInteger(val), Fixed));
+ }
+ return PerspectiveTransformOperation::create(Length(0, Fixed));
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h b/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h
index 834cc83..886d3dc 100644
--- a/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h
+++ b/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h
@@ -26,21 +26,22 @@
#ifndef PerspectiveTransformOperation_h
#define PerspectiveTransformOperation_h
+#include "Length.h"
#include "TransformOperation.h"
namespace WebCore {
class PerspectiveTransformOperation : public TransformOperation {
public:
- static PassRefPtr<PerspectiveTransformOperation> create(double p)
+ static PassRefPtr<PerspectiveTransformOperation> create(const Length& p)
{
return adoptRef(new PerspectiveTransformOperation(p));
}
- double perspective() const { return m_p; }
+ Length perspective() const { return m_p; }
private:
- virtual bool isIdentity() const { return m_p == 0; }
+ virtual bool isIdentity() const { return m_p.calcFloatValue(1) == 0; }
virtual OperationType getOperationType() const { return PERSPECTIVE; }
virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == PERSPECTIVE; }
@@ -54,18 +55,19 @@ private:
virtual bool apply(TransformationMatrix& transform, const IntSize&) const
{
- transform.applyPerspective(m_p);
+ transform.applyPerspective(m_p.calcFloatValue(1));
return false;
}
virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
- PerspectiveTransformOperation(double p)
+ PerspectiveTransformOperation(const Length& p)
: m_p(p)
{
+ ASSERT(p.isFixed());
}
- double m_p;
+ Length m_p;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
index 357a140..c7283a5 100644
--- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
+++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
@@ -55,21 +55,17 @@ namespace WebCore {
// webmasters - are to be held responsible. Basically, don't be a jerk, and remember that anything free comes
// with no guarantee.
-// A Note About row-major vs. column major matrixes
+// A clarification about the storage of matrix elements
//
-// The clients of this class (CSSMatrix and SVGMatrix) assume a column-major ordering.
-// That means that when the matrix is initialized with 16 values, the first 4 values
-// go in the 4 rows of the first column, etc. And in the dereferencing calls, the first
-// digit is the column (e.g., m23() is column 2 row 3). Because C++ uses row-major arrays
-// the internal matrix is stored in row-major order, so m[2][0] means row 2, column 0. This
-// has no bearing on how the matrix is viewed on the outside, since all access is done
-// with function calls. But it does help make the code more clear if you know that.
+// This class uses a 2 dimensional array internally to store the elements of the matrix. The first index into
+// the array refers to the column that the element lies in; the second index refers to the row.
//
-// FIXME: Multiply calls are named for what they do in the internal, row-major world.
-// multLeft is actually a multRight in a column-major world, and multiply is a multLeft
-// in a column-major world. For now I've left it that way to avoid too many confusing
-// changes to the code. In particular AffineTransform uses these same terms for the
-// opposite operations. So we have to be VERY careful when we change them.
+// In other words, this is the layout of the matrix:
+//
+// | m_matrix[0][0] m_matrix[1][0] m_matrix[2][0] m_matrix[3][0] |
+// | m_matrix[0][1] m_matrix[1][1] m_matrix[2][1] m_matrix[3][1] |
+// | m_matrix[0][2] m_matrix[1][2] m_matrix[2][2] m_matrix[3][2] |
+// | m_matrix[0][3] m_matrix[1][3] m_matrix[2][3] m_matrix[3][3] |
typedef double Vector4[4];
typedef double Vector3[3];
@@ -634,7 +630,7 @@ TransformationMatrix& TransformationMatrix::scaleNonUniform(double sx, double sy
mat.m_matrix[0][0] = sx;
mat.m_matrix[1][1] = sy;
- multLeft(mat);
+ multiply(mat);
return *this;
}
@@ -645,7 +641,7 @@ TransformationMatrix& TransformationMatrix::scale3d(double sx, double sy, double
mat.m_matrix[1][1] = sy;
mat.m_matrix[2][2] = sz;
- multLeft(mat);
+ multiply(mat);
return *this;
}
@@ -732,7 +728,7 @@ TransformationMatrix& TransformationMatrix::rotate3d(double x, double y, double
mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
mat.m_matrix[3][3] = 1.0f;
}
- multLeft(mat);
+ multiply(mat);
return *this;
}
@@ -783,7 +779,7 @@ TransformationMatrix& TransformationMatrix::rotate3d(double rx, double ry, doubl
mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
mat.m_matrix[3][3] = 1.0f;
- rmat.multLeft(mat);
+ rmat.multiply(mat);
rx /= 2.0f;
sinA = sin(rx);
@@ -803,9 +799,9 @@ TransformationMatrix& TransformationMatrix::rotate3d(double rx, double ry, doubl
mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
mat.m_matrix[3][3] = 1.0f;
- rmat.multLeft(mat);
+ rmat.multiply(mat);
- multLeft(rmat);
+ multiply(rmat);
return *this;
}
@@ -869,7 +865,7 @@ TransformationMatrix& TransformationMatrix::skew(double sx, double sy)
mat.m_matrix[0][1] = tan(sy); // note that the y shear goes in the first row
mat.m_matrix[1][0] = tan(sx); // and the x shear in the second row
- multLeft(mat);
+ multiply(mat);
return *this;
}
@@ -879,7 +875,7 @@ TransformationMatrix& TransformationMatrix::applyPerspective(double p)
if (p != 0)
mat.m_matrix[2][3] = -1/p;
- multLeft(mat);
+ multiply(mat);
return *this;
}
@@ -896,7 +892,7 @@ TransformationMatrix TransformationMatrix::rectToRect(const FloatRect& from, con
//
// *this = mat * *this
//
-TransformationMatrix& TransformationMatrix::multLeft(const TransformationMatrix& mat)
+TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix& mat)
{
Matrix4 tmp;
@@ -1105,25 +1101,25 @@ void TransformationMatrix::recompose(const DecomposedType& decomp)
2 * (xz - yw), 2 * (yz + xw), 1 - 2 * (xx + yy), 0,
0, 0, 0, 1);
- multLeft(rotationMatrix);
+ multiply(rotationMatrix);
// now apply skew
if (decomp.skewYZ) {
TransformationMatrix tmp;
tmp.setM32((float) decomp.skewYZ);
- multLeft(tmp);
+ multiply(tmp);
}
if (decomp.skewXZ) {
TransformationMatrix tmp;
tmp.setM31((float) decomp.skewXZ);
- multLeft(tmp);
+ multiply(tmp);
}
if (decomp.skewXY) {
TransformationMatrix tmp;
tmp.setM21((float) decomp.skewXY);
- multLeft(tmp);
+ multiply(tmp);
}
// finally, apply scale
diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
index c883675..fa27c0e 100644
--- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
+++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
@@ -208,11 +208,8 @@ public:
void setF(double f) { m_matrix[3][1] = f; }
// this = this * mat
- TransformationMatrix& multiply(const TransformationMatrix& t) { return *this *= t; }
+ TransformationMatrix& multiply(const TransformationMatrix&);
- // this = mat * this
- TransformationMatrix& multLeft(const TransformationMatrix& mat);
-
TransformationMatrix& scale(double);
TransformationMatrix& scaleNonUniform(double sx, double sy);
TransformationMatrix& scale3d(double sx, double sy, double sz);
@@ -296,19 +293,18 @@ public:
}
bool operator!=(const TransformationMatrix& other) const { return !(*this == other); }
-
- // *this = *this * t (i.e., a multRight)
+
+ // *this = *this * t
TransformationMatrix& operator*=(const TransformationMatrix& t)
{
- *this = *this * t;
- return *this;
+ return multiply(t);
}
- // result = *this * t (i.e., a multRight)
+ // result = *this * t
TransformationMatrix operator*(const TransformationMatrix& t) const
{
- TransformationMatrix result = t;
- result.multLeft(*this);
+ TransformationMatrix result = *this;
+ result.multiply(t);
return result;
}