summaryrefslogtreecommitdiffstats
path: root/cc/animation
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 01:29:58 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 01:29:58 +0000
commit22a0fbd00117465e9d451cc4d1758e8050052661 (patch)
tree1125760f2c0cf4839239399f9757a5a6d8231e1b /cc/animation
parentfeacc37d3da5fdf5eec6d616835e2ede92d1bf13 (diff)
downloadchromium_src-22a0fbd00117465e9d451cc4d1758e8050052661.zip
chromium_src-22a0fbd00117465e9d451cc4d1758e8050052661.tar.gz
chromium_src-22a0fbd00117465e9d451cc4d1758e8050052661.tar.bz2
After http://crrev.com/202755, timing functions can now produce values outside the range [0, 1]. Unfortunately, these values are getting clamped when they are used for blending. This CL removes that extra clamping and adds unit tests for this extrapolation.
BUG=178299 R=ajuma@chromium.org Review URL: https://codereview.chromium.org/15972006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation')
-rw-r--r--cc/animation/transform_operation.cc6
-rw-r--r--cc/animation/transform_operations.cc10
-rw-r--r--cc/animation/transform_operations_unittest.cc106
3 files changed, 106 insertions, 16 deletions
diff --git a/cc/animation/transform_operation.cc b/cc/animation/transform_operation.cc
index e1468bf..854901d 100644
--- a/cc/animation/transform_operation.cc
+++ b/cc/animation/transform_operation.cc
@@ -74,12 +74,6 @@ 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;
}
diff --git a/cc/animation/transform_operations.cc b/cc/animation/transform_operations.cc
index 8826d29..d74f1a5 100644
--- a/cc/animation/transform_operations.cc
+++ b/cc/animation/transform_operations.cc
@@ -164,16 +164,6 @@ bool TransformOperations::BlendInternal(const TransformOperations& from,
return true;
}
- if (progress <= 0.0) {
- *result = from.Apply();
- return true;
- }
-
- if (progress >= 1.0) {
- *result = Apply();
- return true;
- }
-
if (!ComputeDecomposedTransform() || !from.ComputeDecomposedTransform())
return false;
diff --git a/cc/animation/transform_operations_unittest.cc b/cc/animation/transform_operations_unittest.cc
index 7e344c7..8fc9b94 100644
--- a/cc/animation/transform_operations_unittest.cc
+++ b/cc/animation/transform_operations_unittest.cc
@@ -432,6 +432,22 @@ TEST(TransformOperationTest, BlendRotationFromIdentity) {
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = -0.5;
+
+ expected.MakeIdentity();
+ expected.RotateAbout(gfx::Vector3dF(0, 0, 1), -180);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = 1.5;
+
+ expected.MakeIdentity();
+ expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 540);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
}
}
@@ -450,6 +466,22 @@ TEST(TransformOperationTest, BlendTranslationFromIdentity) {
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = -0.5;
+
+ expected.MakeIdentity();
+ expected.Translate3d(-1, -1, -1);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = 1.5;
+
+ expected.MakeIdentity();
+ expected.Translate3d(3, 3, 3);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
}
}
@@ -468,6 +500,22 @@ TEST(TransformOperationTest, BlendScaleFromIdentity) {
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = -0.5;
+
+ expected.MakeIdentity();
+ expected.Scale3d(0, 0, 0);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = 1.5;
+
+ expected.MakeIdentity();
+ expected.Scale3d(4, 4, 4);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
}
}
@@ -487,6 +535,24 @@ TEST(TransformOperationTest, BlendSkewFromIdentity) {
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = -0.5;
+
+ expected.MakeIdentity();
+ expected.SkewX(-1);
+ expected.SkewY(-1);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
+
+ progress = 1.5;
+
+ expected.MakeIdentity();
+ expected.SkewX(3);
+ expected.SkewY(3);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations.Blend(*identity_operations[i], progress));
}
}
@@ -601,5 +667,45 @@ TEST(TransformOperationTest, BlendPerspectiveToIdentity) {
}
}
+TEST(TransformOperationTest, ExtrapolatePerspectiveBlending) {
+ TransformOperations operations1;
+ operations1.AppendPerspective(1000);
+
+ TransformOperations operations2;
+ operations2.AppendPerspective(500);
+
+ gfx::Transform expected;
+ expected.ApplyPerspectiveDepth(250);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations1.Blend(operations2, -0.5));
+
+ expected.MakeIdentity();
+ expected.ApplyPerspectiveDepth(1250);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations1.Blend(operations2, 1.5));
+}
+
+TEST(TransformOperationTest, ExtrapolateMatrixBlending) {
+ gfx::Transform transform1;
+ transform1.Translate3d(1, 1, 1);
+ TransformOperations operations1;
+ operations1.AppendMatrix(transform1);
+
+ gfx::Transform transform2;
+ transform2.Translate3d(3, 3, 3);
+ TransformOperations operations2;
+ operations2.AppendMatrix(transform2);
+
+ gfx::Transform expected;
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations1.Blend(operations2, 1.5));
+
+ expected.Translate3d(4, 4, 4);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected, operations1.Blend(operations2, -0.5));
+}
+
} // namespace
} // namespace cc