Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4318)

Unified Diff: cc/animation/transform_operations_unittest.cc

Issue 15972006: TransformOperations should be able to blend outside the range [0, 1] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/transform_operations.cc ('k') | ui/gfx/transform.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/transform_operations_unittest.cc
diff --git a/cc/animation/transform_operations_unittest.cc b/cc/animation/transform_operations_unittest.cc
index 7e344c706d42aea03249de075aec090b3448d780..8fc9b949d7421d38cb48ca26c50087c55f066cb1 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
« no previous file with comments | « cc/animation/transform_operations.cc ('k') | ui/gfx/transform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698