OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "cc/animation/transform_operations.h" | 9 #include "cc/animation/transform_operations.h" |
10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 TransformOperations operations_to; | 1212 TransformOperations operations_to; |
1213 operations_to.AppendSkew(skews[i].to_x, skews[i].to_y); | 1213 operations_to.AppendSkew(skews[i].to_x, skews[i].to_y); |
1214 EmpiricallyTestBoundsEquality(operations_from, | 1214 EmpiricallyTestBoundsEquality(operations_from, |
1215 operations_to, | 1215 operations_to, |
1216 progress[j].min_progress, | 1216 progress[j].min_progress, |
1217 progress[j].max_progress); | 1217 progress[j].max_progress); |
1218 } | 1218 } |
1219 } | 1219 } |
1220 } | 1220 } |
1221 | 1221 |
| 1222 TEST(TransformOperationTest, NonCommutativeRotations) { |
| 1223 TransformOperations operations_from; |
| 1224 operations_from.AppendRotate(1.0, 0.0, 0.0, 0.0); |
| 1225 operations_from.AppendRotate(0.0, 1.0, 0.0, 0.0); |
| 1226 TransformOperations operations_to; |
| 1227 operations_to.AppendRotate(1.0, 0.0, 0.0, 45.0); |
| 1228 operations_to.AppendRotate(0.0, 1.0, 0.0, 135.0); |
| 1229 |
| 1230 gfx::BoxF box(0, 0, 0, 1, 1, 1); |
| 1231 gfx::BoxF bounds; |
| 1232 |
| 1233 SkMScalar min_progress = 0.0f; |
| 1234 SkMScalar max_progress = 1.0f; |
| 1235 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 1236 box, operations_from, min_progress, max_progress, &bounds)); |
| 1237 gfx::Transform blended_transform = |
| 1238 operations_to.Blend(operations_from, max_progress); |
| 1239 gfx::Point3F blended_point(0.9f, 0.9f, 0.0f); |
| 1240 blended_transform.TransformPoint(&blended_point); |
| 1241 gfx::BoxF expanded_bounds = bounds; |
| 1242 expanded_bounds.ExpandTo(blended_point); |
| 1243 EXPECT_EQ(bounds.ToString(), expanded_bounds.ToString()); |
| 1244 } |
| 1245 |
1222 TEST(TransformOperationTest, BlendedBoundsForSequence) { | 1246 TEST(TransformOperationTest, BlendedBoundsForSequence) { |
1223 TransformOperations operations_from; | 1247 TransformOperations operations_from; |
| 1248 operations_from.AppendTranslate(1.0, -5.0, 1.0); |
| 1249 operations_from.AppendScale(-1.0, 2.0, 3.0); |
1224 operations_from.AppendTranslate(2.0, 4.0, -1.0); | 1250 operations_from.AppendTranslate(2.0, 4.0, -1.0); |
1225 operations_from.AppendScale(-1.0, 2.0, 3.0); | |
1226 operations_from.AppendTranslate(1.0, -5.0, 1.0); | |
1227 TransformOperations operations_to; | 1251 TransformOperations operations_to; |
| 1252 operations_to.AppendTranslate(13.0, -1.0, 5.0); |
| 1253 operations_to.AppendScale(-3.0, -2.0, 5.0); |
1228 operations_to.AppendTranslate(6.0, -2.0, 3.0); | 1254 operations_to.AppendTranslate(6.0, -2.0, 3.0); |
1229 operations_to.AppendScale(-3.0, -2.0, 5.0); | |
1230 operations_to.AppendTranslate(13.0, -1.0, 5.0); | |
1231 | 1255 |
1232 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); | 1256 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); |
1233 gfx::BoxF bounds; | 1257 gfx::BoxF bounds; |
1234 | 1258 |
1235 SkMScalar min_progress = -0.5f; | 1259 SkMScalar min_progress = -0.5f; |
1236 SkMScalar max_progress = 1.5f; | 1260 SkMScalar max_progress = 1.5f; |
1237 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 1261 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
1238 box, operations_from, min_progress, max_progress, &bounds)); | 1262 box, operations_from, min_progress, max_progress, &bounds)); |
1239 EXPECT_EQ(gfx::BoxF(-57.f, -59.f, -1.f, 76.f, 112.f, 80.f).ToString(), | 1263 EXPECT_EQ(gfx::BoxF(-57.f, -59.f, -1.f, 76.f, 112.f, 80.f).ToString(), |
1240 bounds.ToString()); | 1264 bounds.ToString()); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 TransformOperations operations12; | 1524 TransformOperations operations12; |
1501 operations12.AppendScale(3.f, 3.f, 3.f); | 1525 operations12.AppendScale(3.f, 3.f, 3.f); |
1502 operations12.AppendPerspective(3.f); | 1526 operations12.AppendPerspective(3.f); |
1503 | 1527 |
1504 // Perspective operation. | 1528 // Perspective operation. |
1505 EXPECT_FALSE(operations12.MaximumScale(operations11, 0.f, 1.f, &max_scale)); | 1529 EXPECT_FALSE(operations12.MaximumScale(operations11, 0.f, 1.f, &max_scale)); |
1506 } | 1530 } |
1507 | 1531 |
1508 } // namespace | 1532 } // namespace |
1509 } // namespace cc | 1533 } // namespace cc |
OLD | NEW |