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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 gfx::Transform matrix_to; | 434 gfx::Transform matrix_to; |
435 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175); | 435 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175); |
436 | 436 |
437 gfx::Transform expected = matrix_to; | 437 gfx::Transform expected = matrix_to; |
438 expected.Blend(matrix_from, progress); | 438 expected.Blend(matrix_from, progress); |
439 | 439 |
440 EXPECT_TRANSFORMATION_MATRIX_EQ( | 440 EXPECT_TRANSFORMATION_MATRIX_EQ( |
441 expected, operations_to.Blend(operations_from, progress)); | 441 expected, operations_to.Blend(operations_from, progress)); |
442 } | 442 } |
443 | 443 |
| 444 TEST(TransformOperationTest, RotationWithSlerpFromZeroDeg) { |
| 445 TransformOperations operations_from; |
| 446 operations_from.AppendRotate(0, 0, 1, 0); |
| 447 |
| 448 TransformOperations operations_to; |
| 449 operations_to.AppendRotate(0, 1, 0, 450); |
| 450 |
| 451 SkMScalar progress = 0.5f; |
| 452 gfx::Transform matrix_from; |
| 453 matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 0); |
| 454 |
| 455 gfx::Transform matrix_to; |
| 456 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 90); |
| 457 |
| 458 gfx::Transform expected = matrix_to; |
| 459 expected.Blend(matrix_from, progress); |
| 460 |
| 461 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 462 expected, operations_to.Blend(operations_from, progress)); |
| 463 } |
| 464 |
| 465 TEST(TransformOperationTest, RotationWithoutSlerpFromZeroDeg) { |
| 466 TransformOperations operations_from; |
| 467 operations_from.AppendRotate(0, 0, 1, 0); |
| 468 |
| 469 TransformOperations operations_to; |
| 470 operations_to.AppendRotate(0, 0, 1, 450); |
| 471 |
| 472 SkMScalar progress = 0.5f; |
| 473 gfx::Transform expected; |
| 474 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); |
| 475 |
| 476 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 477 expected, operations_to.Blend(operations_from, progress)); |
| 478 } |
| 479 |
444 TEST(TransformOperationTest, BlendRotationFromIdentity) { | 480 TEST(TransformOperationTest, BlendRotationFromIdentity) { |
445 ScopedVector<TransformOperations> identity_operations; | 481 ScopedVector<TransformOperations> identity_operations; |
446 GetIdentityOperations(&identity_operations); | 482 GetIdentityOperations(&identity_operations); |
447 | 483 |
448 for (size_t i = 0; i < identity_operations.size(); ++i) { | 484 for (size_t i = 0; i < identity_operations.size(); ++i) { |
449 TransformOperations operations; | 485 TransformOperations operations; |
450 operations.AppendRotate(0, 0, 1, 90); | 486 operations.AppendRotate(0, 0, 1, 90); |
451 | 487 |
452 SkMScalar progress = 0.5f; | 488 SkMScalar progress = 0.5f; |
453 | 489 |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 | 1504 |
1469 // Scale + Perspective can't. | 1505 // Scale + Perspective can't. |
1470 TransformOperations operations11; | 1506 TransformOperations operations11; |
1471 operations11.AppendScale(2.f, 2.f, 2.f); | 1507 operations11.AppendScale(2.f, 2.f, 2.f); |
1472 operations11.AppendPerspective(1.f); | 1508 operations11.AppendPerspective(1.f); |
1473 EXPECT_FALSE(operations11.ScaleComponent(&scale)); | 1509 EXPECT_FALSE(operations11.ScaleComponent(&scale)); |
1474 } | 1510 } |
1475 | 1511 |
1476 } // namespace | 1512 } // namespace |
1477 } // namespace cc | 1513 } // namespace cc |
OLD | NEW |