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

Unified Diff: cc/animation/transform_operations_unittest.cc

Issue 642983003: cc: Make PictureLayerImpl use a better choice for animated raster scale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: animationscale: onemorerename Created 6 years, 2 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
Index: cc/animation/transform_operations_unittest.cc
diff --git a/cc/animation/transform_operations_unittest.cc b/cc/animation/transform_operations_unittest.cc
index 87dd69df1220b48dd841dd92162fd8eff7c95d49..208f81a7a62f9ccc4043179714b97fefccb27a16 100644
--- a/cc/animation/transform_operations_unittest.cc
+++ b/cc/animation/transform_operations_unittest.cc
@@ -1402,131 +1402,83 @@ TEST(TransformOperationTest, IsTranslationWithMultipleOperations) {
EXPECT_TRUE(operations2.IsTranslation());
}
-TEST(TransformOperationTest, MaximumScale) {
- TransformOperations operations1;
- operations1.AppendScale(3.f, 2.f, 5.f);
- TransformOperations operations2;
- operations2.AppendScale(6.f, 5.f, 2.f);
-
- float max_scale = 0.f;
- EXPECT_TRUE(operations2.MaximumScale(operations1, 0.f, 1.f, &max_scale));
- // x at progress 1.f
- EXPECT_EQ(6.f, max_scale);
-
- EXPECT_TRUE(operations2.MaximumScale(operations1, -1.f, 1.f, &max_scale));
- // z at progress -1.f
- EXPECT_EQ(8.f, max_scale);
-
- EXPECT_TRUE(operations2.MaximumScale(operations1, 0.f, 2.f, &max_scale));
- // x at progress 2.f
- EXPECT_EQ(9.f, max_scale);
-
- TransformOperations operations3;
- operations3.AppendScale(1.f, 4.f, 1.f);
- TransformOperations operations4;
-
- EXPECT_TRUE(operations4.MaximumScale(operations3, 0.f, 1.f, &max_scale));
- // y at progress 0.f
- EXPECT_EQ(4.f, max_scale);
+TEST(TransformOperationTest, ScaleComponent) {
+ gfx::Vector3dF scale;
- EXPECT_TRUE(operations4.MaximumScale(operations3, -1.f, 1.f, &max_scale));
- // y at progress -1.f
- EXPECT_EQ(7.f, max_scale);
-
- EXPECT_TRUE(operations4.MaximumScale(operations3, 0.f, 2.f, &max_scale));
- // y at progress 0.f
- EXPECT_EQ(4.f, max_scale);
+ // Scale.
+ TransformOperations operations1;
+ operations1.AppendScale(-3.f, 2.f, 5.f);
+ EXPECT_TRUE(operations1.ScaleComponent(&scale));
+ EXPECT_EQ(gfx::Vector3dF(-3.f, 2.f, 5.f), scale);
+ // Translate + Scale.
TransformOperations operations5;
operations5.AppendTranslate(1.f, 2.f, 3.f);
- operations5.AppendScale(1.f, 1.f, 4.f);
+ operations5.AppendScale(2.f, 5.f, 4.f);
+ EXPECT_TRUE(operations5.ScaleComponent(&scale));
+ EXPECT_EQ(gfx::Vector3dF(2.f, 5.f, 4.f), scale);
+
+ // Translate + Scale + Matrix with translate.
gfx::Transform translation_transform;
translation_transform.Translate3d(1.f, 2.f, 3.f);
operations5.AppendMatrix(translation_transform);
- TransformOperations operations6;
- operations6.AppendTranslate(2.f, 3.f, 4.f);
- operations6.AppendScale(2.f, 5.f, 1.f);
- operations6.AppendMatrix(translation_transform);
-
- EXPECT_TRUE(operations6.MaximumScale(operations5, 0.f, 1.f, &max_scale));
- // y at progress 1.f
- EXPECT_EQ(5.f, max_scale);
-
- EXPECT_TRUE(operations6.MaximumScale(operations5, -1.f, 1.f, &max_scale));
- // z at progress -1.f
- EXPECT_EQ(7.f, max_scale);
-
- EXPECT_TRUE(operations6.MaximumScale(operations5, 0.f, 2.f, &max_scale));
- // y at progress 2.f
- EXPECT_EQ(9.f, max_scale);
+ EXPECT_TRUE(operations5.ScaleComponent(&scale));
+ EXPECT_EQ(gfx::Vector3dF(2.f, 5.f, 4.f), scale);
}
-TEST(TransformOperationTest, MaximumScaleCannotBeComputed) {
+TEST(TransformOperationTest, ScaleComponentCannotBeComputed) {
+ gfx::Vector3dF scale;
+
+ // Scale can.
TransformOperations operations1;
operations1.AppendScale(2.f, 2.f, 2.f);
+ EXPECT_TRUE(operations1.ScaleComponent(&scale));
+ EXPECT_EQ(gfx::Vector3dF(2.f, 2.f, 2.f), scale);
+
+ // Translate can.
TransformOperations operations2;
operations2.AppendTranslate(1.f, 2.f, 3.f);
+ EXPECT_TRUE(operations2.ScaleComponent(&scale));
+ EXPECT_EQ(gfx::Vector3dF(1.f, 1.f, 1.f), scale);
- float max_scale = 0.f;
-
- // Non-matching operations.
- EXPECT_FALSE(operations2.MaximumScale(operations1, 0.f, 1.f, &max_scale));
-
+ // Scale + translate can.
TransformOperations operations3;
- operations3.AppendScale(2.f, 2.f, 2.f);
+ operations3.AppendScale(2.f, 3.f, 2.f);
operations3.AppendTranslate(1.f, 2.f, 3.f);
- operations3.AppendScale(3.f, 3.f, 3.f);
- TransformOperations operations4;
- operations4.AppendScale(4.f, 4.f, 4.f);
- operations4.AppendTranslate(2.f, 3.f, 4.f);
- operations4.AppendScale(5.f, 5.f, 5.f);
+ EXPECT_TRUE(operations3.ScaleComponent(&scale));
+ EXPECT_EQ(gfx::Vector3dF(2.f, 3.f, 2.f), scale);
- // More that one scale operation in a sequence.
- EXPECT_FALSE(operations4.MaximumScale(operations3, 0.f, 1.f, &max_scale));
+ // Two Scales can't.
+ TransformOperations operations4;
+ operations4.AppendScale(2.f, 3.f, 2.f);
+ operations4.AppendScale(3.f, 2.f, 3.f);
+ EXPECT_FALSE(operations4.ScaleComponent(&scale));
+ // Matrix can't.
TransformOperations operations5;
operations5.AppendScale(2.f, 2.f, 2.f);
gfx::Transform scaling_transform;
scaling_transform.Scale(2.f, 2.f);
operations5.AppendMatrix(scaling_transform);
- TransformOperations operations6;
- operations6.AppendScale(3.f, 3.f, 3.f);
- gfx::Transform translation_transform;
- translation_transform.Translate3d(1.f, 2.f, 3.f);
- operations6.AppendMatrix(translation_transform);
-
- // Non-translation matrix operation.
- EXPECT_FALSE(operations6.MaximumScale(operations5, 0.f, 1.f, &max_scale));
+ EXPECT_FALSE(operations5.ScaleComponent(&scale));
+ // Scale + Rotate can't.
TransformOperations operations7;
operations7.AppendScale(2.f, 2.f, 2.f);
operations7.AppendRotate(1.f, 2.f, 3.f, 4.f);
- TransformOperations operations8;
- operations8.AppendScale(3.f, 3.f, 3.f);
- operations8.AppendRotate(3.f, 4.f, 5.f, 6.f);
-
- // Rotation operation.
- EXPECT_FALSE(operations8.MaximumScale(operations7, 0.f, 1.f, &max_scale));
+ EXPECT_FALSE(operations7.ScaleComponent(&scale));
+ // Scale + Skew can't.
TransformOperations operations9;
operations9.AppendScale(2.f, 2.f, 2.f);
operations9.AppendSkew(1.f, 2.f);
- TransformOperations operations10;
- operations10.AppendScale(3.f, 3.f, 3.f);
- operations10.AppendSkew(3.f, 4.f);
-
- // Skew operation.
- EXPECT_FALSE(operations10.MaximumScale(operations9, 0.f, 1.f, &max_scale));
+ EXPECT_FALSE(operations9.ScaleComponent(&scale));
+ // Scale + Perspective can't.
TransformOperations operations11;
operations11.AppendScale(2.f, 2.f, 2.f);
operations11.AppendPerspective(1.f);
- TransformOperations operations12;
- operations12.AppendScale(3.f, 3.f, 3.f);
- operations12.AppendPerspective(3.f);
-
- // Perspective operation.
- EXPECT_FALSE(operations12.MaximumScale(operations11, 0.f, 1.f, &max_scale));
+ EXPECT_FALSE(operations11.ScaleComponent(&scale));
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698