summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 22:56:44 +0000
committerajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 22:56:44 +0000
commit9797c9c2ab931d7cef0141738ef838b46dedf53e (patch)
tree159b9925d0b8b36fe55a47d3c6bb4084da353732
parent62cb5d905de209526a1c51e2c43bb0349c67e213 (diff)
downloadchromium_src-9797c9c2ab931d7cef0141738ef838b46dedf53e.zip
chromium_src-9797c9c2ab931d7cef0141738ef838b46dedf53e.tar.gz
chromium_src-9797c9c2ab931d7cef0141738ef838b46dedf53e.tar.bz2
Finish migrating cc/ from WebKit::WebTransformationMatrix to gfx::Transform
BUG=166640 Review URL: https://chromiumcodereview.appspot.com/12035029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178931 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/animation_curve.h4
-rw-r--r--cc/keyframed_animation_curve.cc4
-rw-r--r--cc/keyframed_animation_curve.h2
-rw-r--r--cc/keyframed_animation_curve_unittest.cc11
-rw-r--r--cc/layer_animation_controller.cc26
-rw-r--r--cc/test/animation_test_common.cc4
-rw-r--r--cc/test/animation_test_common.h2
-rw-r--r--cc/test/geometry_test_utils.cc22
-rw-r--r--cc/test/geometry_test_utils.h7
-rw-r--r--cc/transform_operation.cc39
-rw-r--r--cc/transform_operation.h6
-rw-r--r--cc/transform_operations.cc45
-rw-r--r--cc/transform_operations.h13
-rw-r--r--cc/transform_operations_unittest.cc176
-rw-r--r--ui/compositor/transform_animation_curve_adapter.cc36
-rw-r--r--ui/compositor/transform_animation_curve_adapter.h2
-rw-r--r--webkit/compositor_bindings/compositor_bindings.gyp2
-rw-r--r--webkit/compositor_bindings/web_layer_impl.cc33
-rw-r--r--webkit/compositor_bindings/web_transform_animation_curve_impl.cc3
-rw-r--r--webkit/compositor_bindings/web_transform_operations_impl.cc4
-rw-r--r--webkit/compositor_bindings/web_transformation_matrix_unittest.cc37
-rw-r--r--webkit/compositor_bindings/web_transformation_matrix_util.cc40
-rw-r--r--webkit/compositor_bindings/web_transformation_matrix_util.h24
23 files changed, 260 insertions, 282 deletions
diff --git a/cc/animation_curve.h b/cc/animation_curve.h
index e9ddfd9..a9419f0 100644
--- a/cc/animation_curve.h
+++ b/cc/animation_curve.h
@@ -7,7 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
+#include "ui/gfx/transform.h"
namespace cc {
@@ -45,7 +45,7 @@ class CC_EXPORT TransformAnimationCurve : public AnimationCurve {
public:
virtual ~TransformAnimationCurve() { }
- virtual WebKit::WebTransformationMatrix getValue(double t) const = 0;
+ virtual gfx::Transform getValue(double t) const = 0;
// Partial Animation implementation.
virtual Type type() const OVERRIDE;
diff --git a/cc/keyframed_animation_curve.cc b/cc/keyframed_animation_curve.cc
index 579d787..e913c9a 100644
--- a/cc/keyframed_animation_curve.cc
+++ b/cc/keyframed_animation_curve.cc
@@ -4,8 +4,6 @@
#include "cc/keyframed_animation_curve.h"
-using WebKit::WebTransformationMatrix;
-
namespace cc {
namespace {
@@ -196,7 +194,7 @@ scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::clone() const
return toReturn.PassAs<AnimationCurve>();
}
-WebTransformationMatrix KeyframedTransformAnimationCurve::getValue(double t) const
+gfx::Transform KeyframedTransformAnimationCurve::getValue(double t) const
{
if (t <= m_keyframes.front()->time())
return m_keyframes.front()->value().Apply();
diff --git a/cc/keyframed_animation_curve.h b/cc/keyframed_animation_curve.h
index cfd1915..70fcd66 100644
--- a/cc/keyframed_animation_curve.h
+++ b/cc/keyframed_animation_curve.h
@@ -99,7 +99,7 @@ public:
virtual scoped_ptr<AnimationCurve> clone() const OVERRIDE;
// TransformAnimationCurve implementation
- virtual WebKit::WebTransformationMatrix getValue(double t) const OVERRIDE;
+ virtual gfx::Transform getValue(double t) const OVERRIDE;
private:
KeyframedTransformAnimationCurve();
diff --git a/cc/keyframed_animation_curve_unittest.cc b/cc/keyframed_animation_curve_unittest.cc
index a08ada6..28091902 100644
--- a/cc/keyframed_animation_curve_unittest.cc
+++ b/cc/keyframed_animation_curve_unittest.cc
@@ -7,16 +7,13 @@
#include "cc/transform_operations.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
-
-using WebKit::WebTransformationMatrix;
namespace cc {
namespace {
-void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
+void expectTranslateX(double translateX, const gfx::Transform& transform)
{
- EXPECT_FLOAT_EQ(translateX, matrix.m41());
+ EXPECT_FLOAT_EQ(translateX, transform.matrix().getDouble(0, 3));
}
// Tests that a float animation with one keyframe works as expected.
@@ -161,8 +158,8 @@ TEST(KeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
expectTranslateX(4, curve->getValue(0.5));
// There is a discontinuity at 1. Any value between 4 and 6 is valid.
- WebTransformationMatrix value = curve->getValue(1);
- EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6);
+ gfx::Transform value = curve->getValue(1);
+ EXPECT_TRUE(value.matrix().getDouble(0, 3) >= 4 && value.matrix().getDouble(0, 3) <= 6);
expectTranslateX(6, curve->getValue(1.5));
expectTranslateX(6, curve->getValue(2));
diff --git a/cc/layer_animation_controller.cc b/cc/layer_animation_controller.cc
index d5ed278..8efcc4f 100644
--- a/cc/layer_animation_controller.cc
+++ b/cc/layer_animation_controller.cc
@@ -13,30 +13,6 @@
#include "cc/scoped_ptr_algorithm.h"
#include "ui/gfx/transform.h"
-namespace {
-gfx::Transform convertWebTransformationMatrixToTransform(const WebKit::WebTransformationMatrix& matrix)
-{
- gfx::Transform transform;
- transform.matrix().setDouble(0, 0, matrix.m11());
- transform.matrix().setDouble(0, 1, matrix.m21());
- transform.matrix().setDouble(0, 2, matrix.m31());
- transform.matrix().setDouble(0, 3, matrix.m41());
- transform.matrix().setDouble(1, 0, matrix.m12());
- transform.matrix().setDouble(1, 1, matrix.m22());
- transform.matrix().setDouble(1, 2, matrix.m32());
- transform.matrix().setDouble(1, 3, matrix.m42());
- transform.matrix().setDouble(2, 0, matrix.m13());
- transform.matrix().setDouble(2, 1, matrix.m23());
- transform.matrix().setDouble(2, 2, matrix.m33());
- transform.matrix().setDouble(2, 3, matrix.m43());
- transform.matrix().setDouble(3, 0, matrix.m14());
- transform.matrix().setDouble(3, 1, matrix.m24());
- transform.matrix().setDouble(3, 2, matrix.m34());
- transform.matrix().setDouble(3, 3, matrix.m44());
- return transform;
-}
-} // namespace
-
namespace cc {
LayerAnimationController::LayerAnimationController(int id)
@@ -443,7 +419,7 @@ void LayerAnimationController::tickAnimations(double monotonicTime)
case Animation::Transform: {
const TransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]->curve()->toTransformAnimationCurve();
- const gfx::Transform transform = convertWebTransformationMatrixToTransform(transformAnimationCurve->getValue(trimmed));
+ const gfx::Transform transform = transformAnimationCurve->getValue(trimmed);
if (m_activeAnimations[i]->isFinishedAt(monotonicTime))
m_activeAnimations[i]->setRunState(Animation::Finished, monotonicTime);
diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc
index 9cce327..3c80b17 100644
--- a/cc/test/animation_test_common.cc
+++ b/cc/test/animation_test_common.cc
@@ -111,9 +111,9 @@ double FakeTransformTransition::duration() const
return m_duration;
}
-WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) const
+gfx::Transform FakeTransformTransition::getValue(double time) const
{
- return WebKit::WebTransformationMatrix();
+ return gfx::Transform();
}
scoped_ptr<cc::AnimationCurve> FakeTransformTransition::clone() const
diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h
index 4f9c13b..95e42799 100644
--- a/cc/test/animation_test_common.h
+++ b/cc/test/animation_test_common.h
@@ -37,7 +37,7 @@ public:
virtual ~FakeTransformTransition();
virtual double duration() const OVERRIDE;
- virtual WebKit::WebTransformationMatrix getValue(double time) const OVERRIDE;
+ virtual gfx::Transform getValue(double time) const OVERRIDE;
virtual scoped_ptr<cc::AnimationCurve> clone() const OVERRIDE;
diff --git a/cc/test/geometry_test_utils.cc b/cc/test/geometry_test_utils.cc
index 385dbac..e02e072 100644
--- a/cc/test/geometry_test_utils.cc
+++ b/cc/test/geometry_test_utils.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
#include "ui/gfx/transform.h"
namespace cc {
@@ -15,27 +14,6 @@ namespace cc {
// for equality within single-precision error bounds because many transforms
// originate from single-precision data types such as quads/rects/etc.
-void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
- const WebKit::WebTransformationMatrix& actual)
-{
- EXPECT_FLOAT_EQ((expected).m11(), (actual).m11());
- EXPECT_FLOAT_EQ((expected).m12(), (actual).m12());
- EXPECT_FLOAT_EQ((expected).m13(), (actual).m13());
- EXPECT_FLOAT_EQ((expected).m14(), (actual).m14());
- EXPECT_FLOAT_EQ((expected).m21(), (actual).m21());
- EXPECT_FLOAT_EQ((expected).m22(), (actual).m22());
- EXPECT_FLOAT_EQ((expected).m23(), (actual).m23());
- EXPECT_FLOAT_EQ((expected).m24(), (actual).m24());
- EXPECT_FLOAT_EQ((expected).m31(), (actual).m31());
- EXPECT_FLOAT_EQ((expected).m32(), (actual).m32());
- EXPECT_FLOAT_EQ((expected).m33(), (actual).m33());
- EXPECT_FLOAT_EQ((expected).m34(), (actual).m34());
- EXPECT_FLOAT_EQ((expected).m41(), (actual).m41());
- EXPECT_FLOAT_EQ((expected).m42(), (actual).m42());
- EXPECT_FLOAT_EQ((expected).m43(), (actual).m43());
- EXPECT_FLOAT_EQ((expected).m44(), (actual).m44());
-}
-
void ExpectTransformationMatrixEq(const gfx::Transform& expected,
const gfx::Transform& actual)
{
diff --git a/cc/test/geometry_test_utils.h b/cc/test/geometry_test_utils.h
index 0bcb99e..b27e998 100644
--- a/cc/test/geometry_test_utils.h
+++ b/cc/test/geometry_test_utils.h
@@ -9,10 +9,6 @@ namespace gfx {
class Transform;
}
-namespace WebKit {
-class WebTransformationMatrix;
-}
-
namespace cc {
// These are macros instead of functions so that we get useful line numbers where a test failed.
@@ -64,9 +60,6 @@ do { \
void ExpectTransformationMatrixEq(const gfx::Transform& expected,
const gfx::Transform& actual);
-void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
- const WebKit::WebTransformationMatrix& actual);
-
#define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \
{ \
SCOPED_TRACE(""); \
diff --git a/cc/transform_operation.cc b/cc/transform_operation.cc
index 7ca81a3..2c3b632 100644
--- a/cc/transform_operation.cc
+++ b/cc/transform_operation.cc
@@ -6,8 +6,7 @@
#include <limits>
#include "cc/transform_operation.h"
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/vector3d_f.h"
namespace {
const double kAngleEpsilon = 1e-4;
@@ -16,7 +15,7 @@ const double kAngleEpsilon = 1e-4;
namespace cc {
bool TransformOperation::IsIdentity() const {
- return matrix.isIdentity();
+ return matrix.IsIdentity();
}
static bool IsOperationIdentity(const TransformOperation* operation) {
@@ -73,6 +72,12 @@ static bool ShareSameAxis(const TransformOperation* from,
}
static double BlendDoubles(double from, double to, double progress) {
+ if (progress <= 0.0)
+ return from;
+
+ if (progress >= 1.0)
+ return to;
+
return from * (1 - progress) + to * progress;
}
@@ -80,7 +85,7 @@ bool TransformOperation::BlendTransformOperations(
const TransformOperation* from,
const TransformOperation* to,
double progress,
- WebTransformationMatrix& result) {
+ gfx::Transform& result) {
if (IsOperationIdentity(from) && IsOperationIdentity(to))
return true;
@@ -99,7 +104,7 @@ bool TransformOperation::BlendTransformOperations(
double to_x = IsOperationIdentity(to) ? 0 : to->translate.x;
double to_y = IsOperationIdentity(to) ? 0 : to->translate.y;
double to_z = IsOperationIdentity(to) ? 0 : to->translate.z;
- result.translate3d(BlendDoubles(from_x, to_x, progress),
+ result.Translate3d(BlendDoubles(from_x, to_x, progress),
BlendDoubles(from_y, to_y, progress),
BlendDoubles(from_z, to_z, progress));
break;
@@ -111,17 +116,17 @@ bool TransformOperation::BlendTransformOperations(
double from_angle = 0;
double to_angle = IsOperationIdentity(to) ? 0 : to->rotate.angle;
if (ShareSameAxis(from, to, axis_x, axis_y, axis_z, from_angle))
- result.rotate3d(axis_x, axis_y, axis_z,
- BlendDoubles(from_angle, to_angle, progress));
+ result.RotateAbout(gfx::Vector3dF(axis_x, axis_y, axis_z),
+ BlendDoubles(from_angle, to_angle, progress));
else {
- WebTransformationMatrix to_matrix;
+ gfx::Transform to_matrix;
if (!IsOperationIdentity(to))
to_matrix = to->matrix;
- WebTransformationMatrix from_matrix;
+ gfx::Transform from_matrix;
if (!IsOperationIdentity(from))
from_matrix = from->matrix;
result = to_matrix;
- if (!result.blend(from_matrix, progress))
+ if (!result.Blend(from_matrix, progress))
return false;
}
break;
@@ -133,7 +138,7 @@ bool TransformOperation::BlendTransformOperations(
double to_x = IsOperationIdentity(to) ? 1 : to->scale.x;
double to_y = IsOperationIdentity(to) ? 1 : to->scale.y;
double to_z = IsOperationIdentity(to) ? 1 : to->scale.z;
- result.scale3d(BlendDoubles(from_x, to_x, progress),
+ result.Scale3d(BlendDoubles(from_x, to_x, progress),
BlendDoubles(from_y, to_y, progress),
BlendDoubles(from_z, to_z, progress));
break;
@@ -143,8 +148,8 @@ bool TransformOperation::BlendTransformOperations(
double from_y = IsOperationIdentity(from) ? 0 : from->skew.y;
double to_x = IsOperationIdentity(to) ? 0 : to->skew.x;
double to_y = IsOperationIdentity(to) ? 0 : to->skew.y;
- result.skewX(BlendDoubles(from_x, to_x, progress));
- result.skewY(BlendDoubles(from_y, to_y, progress));
+ result.SkewX(BlendDoubles(from_x, to_x, progress));
+ result.SkewY(BlendDoubles(from_y, to_y, progress));
break;
}
case TransformOperation::TransformOperationPerspective: {
@@ -152,19 +157,19 @@ bool TransformOperation::BlendTransformOperations(
std::numeric_limits<double>::max() : from->perspective_depth;
double to_perspective_depth = IsOperationIdentity(to) ?
std::numeric_limits<double>::max() : to->perspective_depth;
- result.applyPerspective(
+ result.ApplyPerspectiveDepth(
BlendDoubles(from_perspective_depth, to_perspective_depth, progress));
break;
}
case TransformOperation::TransformOperationMatrix: {
- WebTransformationMatrix to_matrix;
+ gfx::Transform to_matrix;
if (!IsOperationIdentity(to))
to_matrix = to->matrix;
- WebTransformationMatrix from_matrix;
+ gfx::Transform from_matrix;
if (!IsOperationIdentity(from))
from_matrix = from->matrix;
result = to_matrix;
- if (!result.blend(from_matrix, progress))
+ if (!result.Blend(from_matrix, progress))
return false;
break;
}
diff --git a/cc/transform_operation.h b/cc/transform_operation.h
index 3a74095..818914e 100644
--- a/cc/transform_operation.h
+++ b/cc/transform_operation.h
@@ -5,7 +5,7 @@
#ifndef CC_TRANSFORM_OPERATION_H_
#define CC_TRANSFORM_OPERATION_H
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
+#include "ui/gfx/transform.h"
namespace cc {
@@ -25,7 +25,7 @@ struct TransformOperation {
}
Type type;
- WebKit::WebTransformationMatrix matrix;
+ gfx::Transform matrix;
union {
double perspective_depth;
@@ -55,7 +55,7 @@ struct TransformOperation {
static bool BlendTransformOperations(const TransformOperation* from,
const TransformOperation* to,
double progress,
- WebKit::WebTransformationMatrix& result);
+ gfx::Transform& result);
};
} // namespace cc
diff --git a/cc/transform_operations.cc b/cc/transform_operations.cc
index de4fd4c..0f06639 100644
--- a/cc/transform_operations.cc
+++ b/cc/transform_operations.cc
@@ -3,8 +3,7 @@
// found in the LICENSE file.
#include "cc/transform_operations.h"
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/vector3d_f.h"
namespace cc {
@@ -18,17 +17,17 @@ TransformOperations::TransformOperations(const TransformOperations& other) {
TransformOperations::~TransformOperations() {
}
-WebTransformationMatrix TransformOperations::Apply() const {
- WebTransformationMatrix to_return;
+gfx::Transform TransformOperations::Apply() const {
+ gfx::Transform to_return;
for (size_t i = 0; i < operations_.size(); ++i)
- to_return.multiply(operations_[i].matrix);
+ to_return.PreconcatTransform(operations_[i].matrix);
return to_return;
}
-WebTransformationMatrix TransformOperations::Blend(
+gfx::Transform TransformOperations::Blend(
const TransformOperations& from, double progress) const {
- WebTransformationMatrix to_return;
- BlendInternal(from, progress, to_return);
+ gfx::Transform to_return;
+ BlendInternal(from, progress, &to_return);
return to_return;
}
@@ -51,13 +50,13 @@ bool TransformOperations::MatchesTypes(const TransformOperations& other) const {
bool TransformOperations::CanBlendWith(
const TransformOperations& other) const {
- WebTransformationMatrix dummy;
- return BlendInternal(other, 0.5, dummy);
+ gfx::Transform dummy;
+ return BlendInternal(other, 0.5, &dummy);
}
void TransformOperations::AppendTranslate(double x, double y, double z) {
TransformOperation to_add;
- to_add.matrix.translate3d(x, y, z);
+ to_add.matrix.Translate3d(x, y, z);
to_add.type = TransformOperation::TransformOperationTranslate;
to_add.translate.x = x;
to_add.translate.y = y;
@@ -68,7 +67,7 @@ void TransformOperations::AppendTranslate(double x, double y, double z) {
void TransformOperations::AppendRotate(double x, double y, double z,
double degrees) {
TransformOperation to_add;
- to_add.matrix.rotate3d(x, y, z, degrees);
+ to_add.matrix.RotateAbout(gfx::Vector3dF(x, y, z), degrees);
to_add.type = TransformOperation::TransformOperationRotate;
to_add.rotate.axis.x = x;
to_add.rotate.axis.y = y;
@@ -79,7 +78,7 @@ void TransformOperations::AppendRotate(double x, double y, double z,
void TransformOperations::AppendScale(double x, double y, double z) {
TransformOperation to_add;
- to_add.matrix.scale3d(x, y, z);
+ to_add.matrix.Scale3d(x, y, z);
to_add.type = TransformOperation::TransformOperationScale;
to_add.scale.x = x;
to_add.scale.y = y;
@@ -89,8 +88,8 @@ void TransformOperations::AppendScale(double x, double y, double z) {
void TransformOperations::AppendSkew(double x, double y) {
TransformOperation to_add;
- to_add.matrix.skewX(x);
- to_add.matrix.skewY(y);
+ to_add.matrix.SkewX(x);
+ to_add.matrix.SkewY(y);
to_add.type = TransformOperation::TransformOperationSkew;
to_add.skew.x = x;
to_add.skew.y = y;
@@ -99,13 +98,13 @@ void TransformOperations::AppendSkew(double x, double y) {
void TransformOperations::AppendPerspective(double depth) {
TransformOperation to_add;
- to_add.matrix.applyPerspective(depth);
+ to_add.matrix.ApplyPerspectiveDepth(depth);
to_add.type = TransformOperation::TransformOperationPerspective;
to_add.perspective_depth = depth;
operations_.push_back(to_add);
}
-void TransformOperations::AppendMatrix(const WebTransformationMatrix& matrix) {
+void TransformOperations::AppendMatrix(const gfx::Transform& matrix) {
TransformOperation to_add;
to_add.matrix = matrix;
to_add.type = TransformOperation::TransformOperationMatrix;
@@ -126,7 +125,7 @@ bool TransformOperations::IsIdentity() const {
bool TransformOperations::BlendInternal(const TransformOperations& from,
double progress,
- WebTransformationMatrix& result) const {
+ gfx::Transform* result) const {
bool from_identity = from.IsIdentity();
bool to_identity = IsIdentity();
if (from_identity && to_identity)
@@ -137,21 +136,21 @@ bool TransformOperations::BlendInternal(const TransformOperations& from,
std::max(from_identity ? 0 : from.operations_.size(),
to_identity ? 0 : operations_.size());
for (size_t i = 0; i < num_operations; ++i) {
- WebTransformationMatrix blended;
+ gfx::Transform blended;
if (!TransformOperation::BlendTransformOperations(
from_identity ? 0 : &from.operations_[i],
to_identity ? 0 : &operations_[i],
progress,
blended))
return false;
- result.multiply(blended);
+ result->PreconcatTransform(blended);
}
return true;
}
- result = Apply();
- WebTransformationMatrix from_transform = from.Apply();
- return result.blend(from_transform, progress);
+ *result = Apply();
+ gfx::Transform from_transform = from.Apply();
+ return result->Blend(from_transform, progress);
}
} // namespace cc
diff --git a/cc/transform_operations.h b/cc/transform_operations.h
index f3c5838..78c7fb5 100644
--- a/cc/transform_operations.h
+++ b/cc/transform_operations.h
@@ -10,12 +10,12 @@
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
#include "cc/transform_operation.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
+#include "ui/gfx/transform.h"
namespace cc {
// Transform operations are a decomposed transformation matrix. It can be
-// applied to obtain a WebTransformationMatrix at any time, and can be blended
+// applied to obtain a gfx::Transform at any time, and can be blended
// intelligently with other transform operations, so long as they represent the
// same decomposition. For example, if we have a transform that is made up of
// a rotation followed by skew, it can be blended intelligently with another
@@ -30,7 +30,7 @@ class CC_EXPORT TransformOperations {
~TransformOperations();
// Returns a transformation matrix representing these transform operations.
- WebKit::WebTransformationMatrix Apply() const;
+ gfx::Transform Apply() const;
// Given another set of transform operations and a progress in the range
// [0, 1], returns a transformation matrix representing the intermediate
@@ -39,8 +39,7 @@ class CC_EXPORT TransformOperations {
// transforms are baked to matrices (using apply), and the matrices are
// then decomposed and interpolated. For more information, see
// http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposition.
- WebKit::WebTransformationMatrix Blend(
- const TransformOperations& from, double progress) const;
+ gfx::Transform Blend(const TransformOperations& from, double progress) const;
// Returns true if this operation and its descendants have the same types
// as other and its descendants.
@@ -56,13 +55,13 @@ class CC_EXPORT TransformOperations {
void AppendScale(double x, double y, double z);
void AppendSkew(double x, double y);
void AppendPerspective(double depth);
- void AppendMatrix(const WebKit::WebTransformationMatrix& matrix);
+ void AppendMatrix(const gfx::Transform& matrix);
void AppendIdentity();
bool IsIdentity() const;
private:
bool BlendInternal(const TransformOperations& from, double progress,
- WebKit::WebTransformationMatrix& result) const;
+ gfx::Transform* result) const;
std::vector<TransformOperation> operations_;
};
diff --git a/cc/transform_operations_unittest.cc b/cc/transform_operations_unittest.cc
index 973565c..245777f 100644
--- a/cc/transform_operations_unittest.cc
+++ b/cc/transform_operations_unittest.cc
@@ -6,9 +6,7 @@
#include "cc/test/geometry_test_utils.h"
#include "cc/transform_operations.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/vector3d_f.h"
namespace cc {
namespace {
@@ -126,12 +124,12 @@ void GetIdentityOperations(ScopedVector<TransformOperations>* operations) {
operations->push_back(to_add);
to_add = new TransformOperations();
- to_add->AppendMatrix(WebTransformationMatrix());
+ to_add->AppendMatrix(gfx::Transform());
operations->push_back(to_add);
to_add = new TransformOperations();
- to_add->AppendMatrix(WebTransformationMatrix());
- to_add->AppendMatrix(WebTransformationMatrix());
+ to_add->AppendMatrix(gfx::Transform());
+ to_add->AppendMatrix(gfx::Transform());
operations->push_back(to_add);
}
@@ -151,8 +149,8 @@ TEST(TransformOperationTest, ApplyTranslate) {
double z = 3;
TransformOperations operations;
operations.AppendTranslate(x, y, z);
- WebTransformationMatrix expected;
- expected.translate3d(x, y, z);
+ gfx::Transform expected;
+ expected.Translate3d(x, y, z);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply());
}
@@ -163,8 +161,8 @@ TEST(TransformOperationTest, ApplyRotate) {
double degrees = 80;
TransformOperations operations;
operations.AppendRotate(x, y, z, degrees);
- WebTransformationMatrix expected;
- expected.rotate3d(x, y, z, degrees);
+ gfx::Transform expected;
+ expected.RotateAbout(gfx::Vector3dF(x, y, z), degrees);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply());
}
@@ -174,8 +172,8 @@ TEST(TransformOperationTest, ApplyScale) {
double z = 3;
TransformOperations operations;
operations.AppendScale(x, y, z);
- WebTransformationMatrix expected;
- expected.scale3d(x, y, z);
+ gfx::Transform expected;
+ expected.Scale3d(x, y, z);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply());
}
@@ -184,9 +182,9 @@ TEST(TransformOperationTest, ApplySkew) {
double y = 2;
TransformOperations operations;
operations.AppendSkew(x, y);
- WebTransformationMatrix expected;
- expected.skewX(x);
- expected.skewY(y);
+ gfx::Transform expected;
+ expected.SkewX(x);
+ expected.SkewY(y);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply());
}
@@ -194,8 +192,8 @@ TEST(TransformOperationTest, ApplyPerspective) {
double depth = 800;
TransformOperations operations;
operations.AppendPerspective(depth);
- WebTransformationMatrix expected;
- expected.applyPerspective(depth);
+ gfx::Transform expected;
+ expected.ApplyPerspectiveDepth(depth);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply());
}
@@ -203,8 +201,8 @@ TEST(TransformOperationTest, ApplyMatrix) {
double dx = 1;
double dy = 2;
double dz = 3;
- WebTransformationMatrix expected_matrix;
- expected_matrix.translate3d(dx, dy, dz);
+ gfx::Transform expected_matrix;
+ expected_matrix.Translate3d(dx, dy, dz);
TransformOperations matrix_transform;
matrix_transform.AppendMatrix(expected_matrix);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_matrix, matrix_transform.Apply());
@@ -223,14 +221,14 @@ TEST(TransformOperationTest, ApplyOrder) {
operations.AppendScale(sx, sy, sz);
operations.AppendTranslate(dx, dy, dz);
- WebTransformationMatrix expected_scale_matrix;
- expected_scale_matrix.scale3d(sx, sy, sz);
+ gfx::Transform expected_scale_matrix;
+ expected_scale_matrix.Scale3d(sx, sy, sz);
- WebTransformationMatrix expected_translate_matrix;
- expected_translate_matrix.translate3d(dx, dy, dz);
+ gfx::Transform expected_translate_matrix;
+ expected_translate_matrix.Translate3d(dx, dy, dz);
- WebTransformationMatrix expected_combined_matrix = expected_scale_matrix;
- expected_combined_matrix.multiply(expected_translate_matrix);
+ gfx::Transform expected_combined_matrix = expected_scale_matrix;
+ expected_combined_matrix.PreconcatTransform(expected_translate_matrix);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_combined_matrix, operations.Apply());
}
@@ -260,38 +258,38 @@ TEST(TransformOperationTest, BlendOrder) {
operations_to.AppendScale(sx2, sy2, sz2);
operations_to.AppendTranslate(dx2, dy2, dz2);
- WebTransformationMatrix scale_from;
- scale_from.scale3d(sx1, sy1, sz1);
- WebTransformationMatrix translate_from;
- translate_from.translate3d(dx1, dy1, dz1);
+ gfx::Transform scale_from;
+ scale_from.Scale3d(sx1, sy1, sz1);
+ gfx::Transform translate_from;
+ translate_from.Translate3d(dx1, dy1, dz1);
- WebTransformationMatrix scale_to;
- scale_to.scale3d(sx2, sy2, sz2);
- WebTransformationMatrix translate_to;
- translate_to.translate3d(dx2, dy2, dz2);
+ gfx::Transform scale_to;
+ scale_to.Scale3d(sx2, sy2, sz2);
+ gfx::Transform translate_to;
+ translate_to.Translate3d(dx2, dy2, dz2);
double progress = 0.25;
- WebTransformationMatrix blended_scale = scale_to;
- blended_scale.blend(scale_from, progress);
+ gfx::Transform blended_scale = scale_to;
+ blended_scale.Blend(scale_from, progress);
- WebTransformationMatrix blended_translate = translate_to;
- blended_translate.blend(translate_from, progress);
+ gfx::Transform blended_translate = translate_to;
+ blended_translate.Blend(translate_from, progress);
- WebTransformationMatrix expected = blended_scale;
- expected.multiply(blended_translate);
+ gfx::Transform expected = blended_scale;
+ expected.PreconcatTransform(blended_translate);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations_to.Blend(operations_from, progress));
}
static void CheckProgress(double progress,
- const WebTransformationMatrix& from_matrix,
- const WebTransformationMatrix& to_matrix,
+ const gfx::Transform& from_matrix,
+ const gfx::Transform& to_matrix,
const TransformOperations& from_transform,
const TransformOperations& to_transform) {
- WebTransformationMatrix expected_matrix = to_matrix;
- expected_matrix.blend(from_matrix, progress);
+ gfx::Transform expected_matrix = to_matrix;
+ expected_matrix.Blend(from_matrix, progress);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected_matrix, to_transform.Blend(from_transform, progress));
}
@@ -303,8 +301,8 @@ TEST(TransformOperationTest, BlendProgress) {
TransformOperations operations_from;
operations_from.AppendScale(sx, sy, sz);
- WebTransformationMatrix matrix_from;
- matrix_from.scale3d(sx, sy, sz);
+ gfx::Transform matrix_from;
+ matrix_from.Scale3d(sx, sy, sz);
sx = 4;
sy = 8;
@@ -312,8 +310,8 @@ TEST(TransformOperationTest, BlendProgress) {
TransformOperations operations_to;
operations_to.AppendScale(sx, sy, sz);
- WebTransformationMatrix matrix_to;
- matrix_to.scale3d(sx, sy, sz);
+ gfx::Transform matrix_to;
+ matrix_to.Scale3d(sx, sy, sz);
CheckProgress(-1, matrix_from, matrix_to, operations_from, operations_to);
CheckProgress(0, matrix_from, matrix_to, operations_from, operations_to);
@@ -348,18 +346,18 @@ TEST(TransformOperationTest, BlendWhenTypesDoNotMatch) {
operations_to.AppendTranslate(dx2, dy2, dz2);
operations_to.AppendScale(sx2, sy2, sz2);
- WebTransformationMatrix from;
- from.scale3d(sx1, sy1, sz1);
- from.translate3d(dx1, dy1, dz1);
+ gfx::Transform from;
+ from.Scale3d(sx1, sy1, sz1);
+ from.Translate3d(dx1, dy1, dz1);
- WebTransformationMatrix to;
- to.translate3d(dx2, dy2, dz2);
- to.scale3d(sx2, sy2, sz2);
+ gfx::Transform to;
+ to.Translate3d(dx2, dy2, dz2);
+ to.Scale3d(sx2, sy2, sz2);
double progress = 0.25;
- WebTransformationMatrix expected = to;
- expected.blend(from, progress);
+ gfx::Transform expected = to;
+ expected.Blend(from, progress);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations_to.Blend(operations_from, progress));
@@ -374,8 +372,8 @@ TEST(TransformOperationTest, LargeRotationsWithSameAxis) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.rotate3d(0, 0, 1, 180);
+ gfx::Transform expected;
+ expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations_to.Blend(operations_from, progress));
@@ -390,7 +388,7 @@ TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) {
double progress = 0.5;
- WebTransformationMatrix expected;
+ gfx::Transform expected;
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations_to.Blend(operations_from, progress));
@@ -398,20 +396,20 @@ TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) {
TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) {
TransformOperations operations_from;
- operations_from.AppendRotate(0, 0, 1, 180);
+ operations_from.AppendRotate(0, 0, 1, 175);
TransformOperations operations_to;
- operations_to.AppendRotate(0, 1, 0, 180);
+ operations_to.AppendRotate(0, 1, 0, 175);
double progress = 0.5;
- WebTransformationMatrix matrix_from;
- matrix_from.rotate3d(0, 0, 1, 180);
+ gfx::Transform matrix_from;
+ matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 175);
- WebTransformationMatrix matrix_to;
- matrix_to.rotate3d(0, 1, 0, 180);
+ gfx::Transform matrix_to;
+ matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175);
- WebTransformationMatrix expected = matrix_to;
- expected.blend(matrix_from, progress);
+ gfx::Transform expected = matrix_to;
+ expected.Blend(matrix_from, progress);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations_to.Blend(operations_from, progress));
@@ -427,8 +425,8 @@ TEST(TransformOperationTest, BlendRotationFromIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.rotate3d(0, 0, 1, 180);
+ gfx::Transform expected;
+ expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
@@ -445,8 +443,8 @@ TEST(TransformOperationTest, BlendTranslationFromIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.translate3d(1, 1, 1);
+ gfx::Transform expected;
+ expected.Translate3d(1, 1, 1);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
@@ -463,8 +461,8 @@ TEST(TransformOperationTest, BlendScaleFromIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.scale3d(2, 2, 2);
+ gfx::Transform expected;
+ expected.Scale3d(2, 2, 2);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
@@ -481,9 +479,9 @@ TEST(TransformOperationTest, BlendSkewFromIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.skewX(1);
- expected.skewY(1);
+ gfx::Transform expected;
+ expected.SkewX(1);
+ expected.SkewY(1);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
@@ -500,8 +498,9 @@ TEST(TransformOperationTest, BlendPerspectiveFromIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.applyPerspective(500 + 0.5 * std::numeric_limits<double>::max());
+ gfx::Transform expected;
+ expected.ApplyPerspectiveDepth(
+ 500 + 0.5 * std::numeric_limits<double>::max());
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
@@ -518,8 +517,8 @@ TEST(TransformOperationTest, BlendRotationToIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.rotate3d(0, 0, 1, 180);
+ gfx::Transform expected;
+ expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, identity_operations[i]->Blend(operations, progress));
@@ -536,8 +535,8 @@ TEST(TransformOperationTest, BlendTranslationToIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.translate3d(1, 1, 1);
+ gfx::Transform expected;
+ expected.Translate3d(1, 1, 1);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, identity_operations[i]->Blend(operations, progress));
@@ -554,8 +553,8 @@ TEST(TransformOperationTest, BlendScaleToIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.scale3d(2, 2, 2);
+ gfx::Transform expected;
+ expected.Scale3d(2, 2, 2);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, identity_operations[i]->Blend(operations, progress));
@@ -572,9 +571,9 @@ TEST(TransformOperationTest, BlendSkewToIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.skewX(1);
- expected.skewY(1);
+ gfx::Transform expected;
+ expected.SkewX(1);
+ expected.SkewY(1);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, identity_operations[i]->Blend(operations, progress));
@@ -591,8 +590,9 @@ TEST(TransformOperationTest, BlendPerspectiveToIdentity) {
double progress = 0.5;
- WebTransformationMatrix expected;
- expected.applyPerspective(500 + 0.5 * std::numeric_limits<double>::max());
+ gfx::Transform expected;
+ expected.ApplyPerspectiveDepth(
+ 500 + 0.5 * std::numeric_limits<double>::max());
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, identity_operations[i]->Blend(operations, progress));
diff --git a/ui/compositor/transform_animation_curve_adapter.cc b/ui/compositor/transform_animation_curve_adapter.cc
index 5700ffd..f7ad0f1 100644
--- a/ui/compositor/transform_animation_curve_adapter.cc
+++ b/ui/compositor/transform_animation_curve_adapter.cc
@@ -4,33 +4,6 @@
#include "ui/compositor/transform_animation_curve_adapter.h"
-using WebKit::WebTransformationMatrix;
-
-namespace {
-// TODO(ajuma): Remove this once the return type of
-// cc::TransformAnimationCurve::getValue is changed to gfx::Transform.
-WebTransformationMatrix convertTransformToWebTransformationMatrix(
- const gfx::Transform& transform) {
- return WebTransformationMatrix(transform.matrix().getDouble(0, 0),
- transform.matrix().getDouble(1, 0),
- transform.matrix().getDouble(2, 0),
- transform.matrix().getDouble(3, 0),
- transform.matrix().getDouble(0, 1),
- transform.matrix().getDouble(1, 1),
- transform.matrix().getDouble(2, 1),
- transform.matrix().getDouble(3, 1),
- transform.matrix().getDouble(0, 2),
- transform.matrix().getDouble(1, 2),
- transform.matrix().getDouble(2, 2),
- transform.matrix().getDouble(3, 2),
- transform.matrix().getDouble(0, 3),
- transform.matrix().getDouble(1, 3),
- transform.matrix().getDouble(2, 3),
- transform.matrix().getDouble(3, 3));
-
-}
-} // namespace
-
namespace ui {
TransformAnimationCurveAdapter::TransformAnimationCurveAdapter(
@@ -62,12 +35,12 @@ scoped_ptr<cc::AnimationCurve> TransformAnimationCurveAdapter::clone() const {
return to_return.PassAs<cc::AnimationCurve>();
}
-WebTransformationMatrix TransformAnimationCurveAdapter::getValue(
+gfx::Transform TransformAnimationCurveAdapter::getValue(
double t) const {
if (t >= duration_.InSecondsF())
- return convertTransformToWebTransformationMatrix(target_value_);
+ return target_value_;
if (t <= 0.0)
- return convertTransformToWebTransformationMatrix(initial_value_);
+ return initial_value_;
double progress = t / duration_.InSecondsF();
gfx::DecomposedTransform to_return;
@@ -75,8 +48,7 @@ WebTransformationMatrix TransformAnimationCurveAdapter::getValue(
decomposed_initial_value_,
decomposed_target_value_,
Tween::CalculateValue(tween_type_, progress));
- return convertTransformToWebTransformationMatrix(
- gfx::ComposeTransform(to_return));
+ return gfx::ComposeTransform(to_return);
}
} // namespace ui
diff --git a/ui/compositor/transform_animation_curve_adapter.h b/ui/compositor/transform_animation_curve_adapter.h
index 073cbfe..795de84 100644
--- a/ui/compositor/transform_animation_curve_adapter.h
+++ b/ui/compositor/transform_animation_curve_adapter.h
@@ -25,7 +25,7 @@ class TransformAnimationCurveAdapter :public cc::TransformAnimationCurve {
// TransformAnimationCurve implementation.
virtual double duration() const OVERRIDE;
virtual scoped_ptr<AnimationCurve> clone() const OVERRIDE;
- virtual WebKit::WebTransformationMatrix getValue(double t) const OVERRIDE;
+ virtual gfx::Transform getValue(double t) const OVERRIDE;
private:
Tween::Type tween_type_;
diff --git a/webkit/compositor_bindings/compositor_bindings.gyp b/webkit/compositor_bindings/compositor_bindings.gyp
index 3ab51a1..5d6f9cf 100644
--- a/webkit/compositor_bindings/compositor_bindings.gyp
+++ b/webkit/compositor_bindings/compositor_bindings.gyp
@@ -43,6 +43,8 @@
'web_solid_color_layer_impl.h',
'web_transform_operations_impl.cc',
'web_transform_operations_impl.h',
+ 'web_transformation_matrix_util.cc',
+ 'web_transformation_matrix_util.h',
'web_video_layer_impl.cc',
'web_video_layer_impl.h',
'web_transform_animation_curve_impl.cc',
diff --git a/webkit/compositor_bindings/web_layer_impl.cc b/webkit/compositor_bindings/web_layer_impl.cc
index 3e44860..db04332 100644
--- a/webkit/compositor_bindings/web_layer_impl.cc
+++ b/webkit/compositor_bindings/web_layer_impl.cc
@@ -14,36 +14,11 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
#include "third_party/skia/include/utils/SkMatrix44.h"
#include "webkit/compositor_bindings/web_animation_impl.h"
+#include "webkit/compositor_bindings/web_transformation_matrix_util.h"
using cc::Animation;
using cc::Layer;
-
-namespace {
-gfx::Transform convertWebTransformationMatrixToTransform(const WebKit::WebTransformationMatrix& matrix)
-{
- // TODO(jamesr): When gfx::Transform provides a constructor that does not
- // initialize the matrix, use that.
- gfx::Transform transform;
- transform.matrix().setDouble(0, 0, matrix.m11());
- transform.matrix().setDouble(0, 1, matrix.m21());
- transform.matrix().setDouble(0, 2, matrix.m31());
- transform.matrix().setDouble(0, 3, matrix.m41());
- transform.matrix().setDouble(1, 0, matrix.m12());
- transform.matrix().setDouble(1, 1, matrix.m22());
- transform.matrix().setDouble(1, 2, matrix.m32());
- transform.matrix().setDouble(1, 3, matrix.m42());
- transform.matrix().setDouble(2, 0, matrix.m13());
- transform.matrix().setDouble(2, 1, matrix.m23());
- transform.matrix().setDouble(2, 2, matrix.m33());
- transform.matrix().setDouble(2, 3, matrix.m43());
- transform.matrix().setDouble(3, 0, matrix.m14());
- transform.matrix().setDouble(3, 1, matrix.m24());
- transform.matrix().setDouble(3, 2, matrix.m34());
- transform.matrix().setDouble(3, 3, matrix.m44());
- return transform;
-}
-} // namespace
-
+using webkit::WebTransformationMatrixUtil;
namespace WebKit {
@@ -193,7 +168,7 @@ void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix)
void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix)
{
- m_layer->setSublayerTransform(convertWebTransformationMatrixToTransform(matrix));
+ m_layer->setSublayerTransform(WebTransformationMatrixUtil::ToTransform(matrix));
}
SkMatrix44 WebLayerImpl::sublayerTransform() const
@@ -210,7 +185,7 @@ void WebLayerImpl::setTransform(const SkMatrix44& matrix)
void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix)
{
- m_layer->setTransform(convertWebTransformationMatrixToTransform(matrix));
+ m_layer->setTransform(WebTransformationMatrixUtil::ToTransform(matrix));
}
SkMatrix44 WebLayerImpl::transform() const
diff --git a/webkit/compositor_bindings/web_transform_animation_curve_impl.cc b/webkit/compositor_bindings/web_transform_animation_curve_impl.cc
index 3affd5a..e8c1622 100644
--- a/webkit/compositor_bindings/web_transform_animation_curve_impl.cc
+++ b/webkit/compositor_bindings/web_transform_animation_curve_impl.cc
@@ -9,6 +9,7 @@
#include "cc/transform_operations.h"
#include "webkit/compositor_bindings/web_animation_curve_common.h"
#include "webkit/compositor_bindings/web_transform_operations_impl.h"
+#include "webkit/compositor_bindings/web_transformation_matrix_util.h"
namespace WebKit {
@@ -47,7 +48,7 @@ void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, d
WebTransformationMatrix WebTransformAnimationCurveImpl::getValue(double time) const
{
- return m_curve->getValue(time);
+ return webkit::WebTransformationMatrixUtil::ToWebTransformationMatrix(m_curve->getValue(time));
}
scoped_ptr<cc::AnimationCurve> WebTransformAnimationCurveImpl::cloneToAnimationCurve() const
diff --git a/webkit/compositor_bindings/web_transform_operations_impl.cc b/webkit/compositor_bindings/web_transform_operations_impl.cc
index fef43d0..c2f8ef0 100644
--- a/webkit/compositor_bindings/web_transform_operations_impl.cc
+++ b/webkit/compositor_bindings/web_transform_operations_impl.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "webkit/compositor_bindings/web_transform_operations_impl.h"
+#include "webkit/compositor_bindings/web_transformation_matrix_util.h"
namespace webkit {
@@ -44,7 +45,8 @@ void WebTransformOperationsImpl::appendPerspective(double depth) {
void WebTransformOperationsImpl::appendMatrix(
const WebKit::WebTransformationMatrix& matrix) {
- transform_operations_.AppendMatrix(matrix);
+ transform_operations_.AppendMatrix(
+ WebTransformationMatrixUtil::ToTransform(matrix));
}
void WebTransformOperationsImpl::appendIdentity() {
diff --git a/webkit/compositor_bindings/web_transformation_matrix_unittest.cc b/webkit/compositor_bindings/web_transformation_matrix_unittest.cc
index 2dc60d3..256c59a 100644
--- a/webkit/compositor_bindings/web_transformation_matrix_unittest.cc
+++ b/webkit/compositor_bindings/web_transformation_matrix_unittest.cc
@@ -5,7 +5,6 @@
#define _USE_MATH_DEFINES
#include <math.h>
-#include "cc/test/geometry_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
@@ -33,6 +32,24 @@
EXPECT_FLOAT_EQ((c), (matrix).m34()); \
EXPECT_FLOAT_EQ((d), (matrix).m44());
+#define EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(expected, actual) \
+ EXPECT_FLOAT_EQ((expected).m11(), (actual).m11()); \
+ EXPECT_FLOAT_EQ((expected).m12(), (actual).m12()); \
+ EXPECT_FLOAT_EQ((expected).m13(), (actual).m13()); \
+ EXPECT_FLOAT_EQ((expected).m14(), (actual).m14()); \
+ EXPECT_FLOAT_EQ((expected).m21(), (actual).m21()); \
+ EXPECT_FLOAT_EQ((expected).m22(), (actual).m22()); \
+ EXPECT_FLOAT_EQ((expected).m23(), (actual).m23()); \
+ EXPECT_FLOAT_EQ((expected).m24(), (actual).m24()); \
+ EXPECT_FLOAT_EQ((expected).m31(), (actual).m31()); \
+ EXPECT_FLOAT_EQ((expected).m32(), (actual).m32()); \
+ EXPECT_FLOAT_EQ((expected).m33(), (actual).m33()); \
+ EXPECT_FLOAT_EQ((expected).m34(), (actual).m34()); \
+ EXPECT_FLOAT_EQ((expected).m41(), (actual).m41()); \
+ EXPECT_FLOAT_EQ((expected).m42(), (actual).m42()); \
+ EXPECT_FLOAT_EQ((expected).m43(), (actual).m43()); \
+ EXPECT_FLOAT_EQ((expected).m44(), (actual).m44());
+
// Checking float values for equality close to zero is not robust using EXPECT_FLOAT_EQ
// (see gtest documentation). So, to verify rotation matrices, we must use a looser
// absolute error threshold in some places.
@@ -994,7 +1011,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForTranslation)
to.makeIdentity();
to.translate3d(200, 100, 300);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
to.makeIdentity();
to.translate3d(200, 100, 300);
@@ -1031,7 +1048,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForScale)
to.makeIdentity();
to.scale3d(200, 100, 300);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
to.makeIdentity();
to.scale3d(200, 100, 300);
@@ -1068,7 +1085,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForSkewX)
to.makeIdentity();
to.skewX(45);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
to.makeIdentity();
to.skewX(45);
@@ -1117,7 +1134,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForSkewY)
to.makeIdentity();
to.skewY(45);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
to.makeIdentity();
to.skewY(45);
@@ -1159,7 +1176,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutX)
to.makeIdentity();
to.rotate3d(1, 0, 0, 90);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
double expectedRotationAngle = 22.5 * M_PI / 180.0;
to.makeIdentity();
@@ -1198,7 +1215,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutY)
to.makeIdentity();
to.rotate3d(0, 1, 0, 90);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
double expectedRotationAngle = 22.5 * M_PI / 180.0;
to.makeIdentity();
@@ -1237,7 +1254,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutZ)
to.makeIdentity();
to.rotate3d(0, 0, 1, 90);
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
double expectedRotationAngle = 22.5 * M_PI / 180.0;
to.makeIdentity();
@@ -1290,7 +1307,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForCompositeTransform)
to = expectedEndOfAnimation;
to.blend(from, 0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(from, to);
to = expectedEndOfAnimation;
to.blend(from, 1);
@@ -1306,7 +1323,7 @@ TEST(WebTransformationMatrixTest, verifyBlendForCompositeTransform)
normalizationMatrix.setM44(1 / expectedEndOfAnimation.m44());
normalizedExpectedEndOfAnimation.multiply(normalizationMatrix);
- EXPECT_TRANSFORMATION_MATRIX_EQ(normalizedExpectedEndOfAnimation, to);
+ EXPECT_WEB_TRANSFORMATION_MATRIX_EQ(normalizedExpectedEndOfAnimation, to);
}
} // namespace
diff --git a/webkit/compositor_bindings/web_transformation_matrix_util.cc b/webkit/compositor_bindings/web_transformation_matrix_util.cc
new file mode 100644
index 0000000..d7c6211
--- /dev/null
+++ b/webkit/compositor_bindings/web_transformation_matrix_util.cc
@@ -0,0 +1,40 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/compositor_bindings/web_transformation_matrix_util.h"
+
+using WebKit::WebTransformationMatrix;
+
+namespace webkit {
+
+gfx::Transform WebTransformationMatrixUtil::ToTransform(
+ const WebTransformationMatrix& matrix) {
+ return gfx::Transform(matrix.m11(), matrix.m21(), matrix.m31(), matrix.m41(),
+ matrix.m12(), matrix.m22(), matrix.m32(), matrix.m42(),
+ matrix.m13(), matrix.m23(), matrix.m33(), matrix.m43(),
+ matrix.m14(), matrix.m24(), matrix.m34(), matrix.m44());
+}
+
+WebTransformationMatrix WebTransformationMatrixUtil::ToWebTransformationMatrix(
+ const gfx::Transform& transform) {
+ return WebTransformationMatrix(transform.matrix().getDouble(0, 0),
+ transform.matrix().getDouble(1, 0),
+ transform.matrix().getDouble(2, 0),
+ transform.matrix().getDouble(3, 0),
+ transform.matrix().getDouble(0, 1),
+ transform.matrix().getDouble(1, 1),
+ transform.matrix().getDouble(2, 1),
+ transform.matrix().getDouble(3, 1),
+ transform.matrix().getDouble(0, 2),
+ transform.matrix().getDouble(1, 2),
+ transform.matrix().getDouble(2, 2),
+ transform.matrix().getDouble(3, 2),
+ transform.matrix().getDouble(0, 3),
+ transform.matrix().getDouble(1, 3),
+ transform.matrix().getDouble(2, 3),
+ transform.matrix().getDouble(3, 3));
+
+}
+
+} // namespace webkit
diff --git a/webkit/compositor_bindings/web_transformation_matrix_util.h b/webkit/compositor_bindings/web_transformation_matrix_util.h
new file mode 100644
index 0000000..e65afe2
--- /dev/null
+++ b/webkit/compositor_bindings/web_transformation_matrix_util.h
@@ -0,0 +1,24 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_COMPOSITOR_BINDINGS_WEB_TRANSFORMATION_MATRIX_UTIL_H_
+#define WEBKIT_COMPOSITOR_BINDINGS_WEB_TRANSFORMATION_MATRIX_UTIL_H_
+
+#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
+#include "ui/gfx/transform.h"
+
+namespace webkit {
+
+class WebTransformationMatrixUtil {
+ public:
+ static gfx::Transform ToTransform(
+ const WebKit::WebTransformationMatrix& matrix);
+
+ static WebKit::WebTransformationMatrix ToWebTransformationMatrix(
+ const gfx::Transform& transform);
+};
+
+} // namespace webkit
+
+#endif // WEBKIT_COMPOSITOR_BINDINGS_WEB_TRANSFORMATION_MATRIX_UTIL_H_