| 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 "cc/animation/transform_operations.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 | 8 |
| 7 #include <limits> | 9 #include <limits> |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "cc/animation/transform_operations.h" | 12 #include "base/memory/ptr_util.h" |
| 11 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gfx/animation/tween.h" | 15 #include "ui/gfx/animation/tween.h" |
| 14 #include "ui/gfx/geometry/box_f.h" | 16 #include "ui/gfx/geometry/box_f.h" |
| 15 #include "ui/gfx/geometry/rect_conversions.h" | 17 #include "ui/gfx/geometry/rect_conversions.h" |
| 16 #include "ui/gfx/geometry/vector3d_f.h" | 18 #include "ui/gfx/geometry/vector3d_f.h" |
| 17 | 19 |
| 18 namespace cc { | 20 namespace cc { |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 TEST(TransformOperationTest, TransformTypesAreUnique) { | 23 TEST(TransformOperationTest, TransformTypesAreUnique) { |
| 22 std::vector<scoped_ptr<TransformOperations>> transforms; | 24 std::vector<std::unique_ptr<TransformOperations>> transforms; |
| 23 | 25 |
| 24 scoped_ptr<TransformOperations> to_add( | 26 std::unique_ptr<TransformOperations> to_add( |
| 25 make_scoped_ptr(new TransformOperations())); | 27 base::WrapUnique(new TransformOperations())); |
| 26 to_add->AppendTranslate(1, 0, 0); | 28 to_add->AppendTranslate(1, 0, 0); |
| 27 transforms.push_back(std::move(to_add)); | 29 transforms.push_back(std::move(to_add)); |
| 28 | 30 |
| 29 to_add = make_scoped_ptr(new TransformOperations()); | 31 to_add = base::WrapUnique(new TransformOperations()); |
| 30 to_add->AppendRotate(0, 0, 1, 2); | 32 to_add->AppendRotate(0, 0, 1, 2); |
| 31 transforms.push_back(std::move(to_add)); | 33 transforms.push_back(std::move(to_add)); |
| 32 | 34 |
| 33 to_add = make_scoped_ptr(new TransformOperations()); | 35 to_add = base::WrapUnique(new TransformOperations()); |
| 34 to_add->AppendScale(2, 2, 2); | 36 to_add->AppendScale(2, 2, 2); |
| 35 transforms.push_back(std::move(to_add)); | 37 transforms.push_back(std::move(to_add)); |
| 36 | 38 |
| 37 to_add = make_scoped_ptr(new TransformOperations()); | 39 to_add = base::WrapUnique(new TransformOperations()); |
| 38 to_add->AppendSkew(1, 0); | 40 to_add->AppendSkew(1, 0); |
| 39 transforms.push_back(std::move(to_add)); | 41 transforms.push_back(std::move(to_add)); |
| 40 | 42 |
| 41 to_add = make_scoped_ptr(new TransformOperations()); | 43 to_add = base::WrapUnique(new TransformOperations()); |
| 42 to_add->AppendPerspective(800); | 44 to_add->AppendPerspective(800); |
| 43 transforms.push_back(std::move(to_add)); | 45 transforms.push_back(std::move(to_add)); |
| 44 | 46 |
| 45 for (size_t i = 0; i < transforms.size(); ++i) { | 47 for (size_t i = 0; i < transforms.size(); ++i) { |
| 46 for (size_t j = 0; j < transforms.size(); ++j) { | 48 for (size_t j = 0; j < transforms.size(); ++j) { |
| 47 bool matches_type = transforms[i]->MatchesTypes(*transforms[j]); | 49 bool matches_type = transforms[i]->MatchesTypes(*transforms[j]); |
| 48 EXPECT_TRUE((i == j && matches_type) || !matches_type); | 50 EXPECT_TRUE((i == j && matches_type) || !matches_type); |
| 49 } | 51 } |
| 50 } | 52 } |
| 51 } | 53 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 skews.AppendSkew(2, 0); | 86 skews.AppendSkew(2, 0); |
| 85 | 87 |
| 86 TransformOperations translates2; | 88 TransformOperations translates2; |
| 87 translates2.AppendTranslate(0, 2, 0); | 89 translates2.AppendTranslate(0, 2, 0); |
| 88 translates2.AppendTranslate(0, 2, 0); | 90 translates2.AppendTranslate(0, 2, 0); |
| 89 | 91 |
| 90 EXPECT_FALSE(translates.MatchesTypes(skews)); | 92 EXPECT_FALSE(translates.MatchesTypes(skews)); |
| 91 EXPECT_FALSE(translates.MatchesTypes(translates2)); | 93 EXPECT_FALSE(translates.MatchesTypes(translates2)); |
| 92 } | 94 } |
| 93 | 95 |
| 94 std::vector<scoped_ptr<TransformOperations>> GetIdentityOperations() { | 96 std::vector<std::unique_ptr<TransformOperations>> GetIdentityOperations() { |
| 95 std::vector<scoped_ptr<TransformOperations>> operations; | 97 std::vector<std::unique_ptr<TransformOperations>> operations; |
| 96 scoped_ptr<TransformOperations> to_add( | 98 std::unique_ptr<TransformOperations> to_add( |
| 97 make_scoped_ptr(new TransformOperations())); | 99 base::WrapUnique(new TransformOperations())); |
| 98 operations.push_back(std::move(to_add)); | 100 operations.push_back(std::move(to_add)); |
| 99 | 101 |
| 100 to_add = make_scoped_ptr(new TransformOperations()); | 102 to_add = base::WrapUnique(new TransformOperations()); |
| 101 to_add->AppendTranslate(0, 0, 0); | 103 to_add->AppendTranslate(0, 0, 0); |
| 102 operations.push_back(std::move(to_add)); | 104 operations.push_back(std::move(to_add)); |
| 103 | 105 |
| 104 to_add = make_scoped_ptr(new TransformOperations()); | 106 to_add = base::WrapUnique(new TransformOperations()); |
| 105 to_add->AppendTranslate(0, 0, 0); | 107 to_add->AppendTranslate(0, 0, 0); |
| 106 to_add->AppendTranslate(0, 0, 0); | 108 to_add->AppendTranslate(0, 0, 0); |
| 107 operations.push_back(std::move(to_add)); | 109 operations.push_back(std::move(to_add)); |
| 108 | 110 |
| 109 to_add = make_scoped_ptr(new TransformOperations()); | 111 to_add = base::WrapUnique(new TransformOperations()); |
| 110 to_add->AppendScale(1, 1, 1); | 112 to_add->AppendScale(1, 1, 1); |
| 111 operations.push_back(std::move(to_add)); | 113 operations.push_back(std::move(to_add)); |
| 112 | 114 |
| 113 to_add = make_scoped_ptr(new TransformOperations()); | 115 to_add = base::WrapUnique(new TransformOperations()); |
| 114 to_add->AppendScale(1, 1, 1); | 116 to_add->AppendScale(1, 1, 1); |
| 115 to_add->AppendScale(1, 1, 1); | 117 to_add->AppendScale(1, 1, 1); |
| 116 operations.push_back(std::move(to_add)); | 118 operations.push_back(std::move(to_add)); |
| 117 | 119 |
| 118 to_add = make_scoped_ptr(new TransformOperations()); | 120 to_add = base::WrapUnique(new TransformOperations()); |
| 119 to_add->AppendSkew(0, 0); | 121 to_add->AppendSkew(0, 0); |
| 120 operations.push_back(std::move(to_add)); | 122 operations.push_back(std::move(to_add)); |
| 121 | 123 |
| 122 to_add = make_scoped_ptr(new TransformOperations()); | 124 to_add = base::WrapUnique(new TransformOperations()); |
| 123 to_add->AppendSkew(0, 0); | 125 to_add->AppendSkew(0, 0); |
| 124 to_add->AppendSkew(0, 0); | 126 to_add->AppendSkew(0, 0); |
| 125 operations.push_back(std::move(to_add)); | 127 operations.push_back(std::move(to_add)); |
| 126 | 128 |
| 127 to_add = make_scoped_ptr(new TransformOperations()); | 129 to_add = base::WrapUnique(new TransformOperations()); |
| 128 to_add->AppendRotate(0, 0, 1, 0); | 130 to_add->AppendRotate(0, 0, 1, 0); |
| 129 operations.push_back(std::move(to_add)); | 131 operations.push_back(std::move(to_add)); |
| 130 | 132 |
| 131 to_add = make_scoped_ptr(new TransformOperations()); | 133 to_add = base::WrapUnique(new TransformOperations()); |
| 132 to_add->AppendRotate(0, 0, 1, 0); | 134 to_add->AppendRotate(0, 0, 1, 0); |
| 133 to_add->AppendRotate(0, 0, 1, 0); | 135 to_add->AppendRotate(0, 0, 1, 0); |
| 134 operations.push_back(std::move(to_add)); | 136 operations.push_back(std::move(to_add)); |
| 135 | 137 |
| 136 to_add = make_scoped_ptr(new TransformOperations()); | 138 to_add = base::WrapUnique(new TransformOperations()); |
| 137 to_add->AppendMatrix(gfx::Transform()); | 139 to_add->AppendMatrix(gfx::Transform()); |
| 138 operations.push_back(std::move(to_add)); | 140 operations.push_back(std::move(to_add)); |
| 139 | 141 |
| 140 to_add = make_scoped_ptr(new TransformOperations()); | 142 to_add = base::WrapUnique(new TransformOperations()); |
| 141 to_add->AppendMatrix(gfx::Transform()); | 143 to_add->AppendMatrix(gfx::Transform()); |
| 142 to_add->AppendMatrix(gfx::Transform()); | 144 to_add->AppendMatrix(gfx::Transform()); |
| 143 operations.push_back(std::move(to_add)); | 145 operations.push_back(std::move(to_add)); |
| 144 | 146 |
| 145 return operations; | 147 return operations; |
| 146 } | 148 } |
| 147 | 149 |
| 148 TEST(TransformOperationTest, MatchTypesOrder) { | 150 TEST(TransformOperationTest, MatchTypesOrder) { |
| 149 TransformOperations mix_order_identity; | 151 TransformOperations mix_order_identity; |
| 150 mix_order_identity.AppendTranslate(0, 0, 0); | 152 mix_order_identity.AppendTranslate(0, 0, 0); |
| 151 mix_order_identity.AppendScale(1, 1, 1); | 153 mix_order_identity.AppendScale(1, 1, 1); |
| 152 mix_order_identity.AppendTranslate(0, 0, 0); | 154 mix_order_identity.AppendTranslate(0, 0, 0); |
| 153 | 155 |
| 154 TransformOperations mix_order_one; | 156 TransformOperations mix_order_one; |
| 155 mix_order_one.AppendTranslate(0, 1, 0); | 157 mix_order_one.AppendTranslate(0, 1, 0); |
| 156 mix_order_one.AppendScale(2, 1, 3); | 158 mix_order_one.AppendScale(2, 1, 3); |
| 157 mix_order_one.AppendTranslate(1, 0, 0); | 159 mix_order_one.AppendTranslate(1, 0, 0); |
| 158 | 160 |
| 159 TransformOperations mix_order_two; | 161 TransformOperations mix_order_two; |
| 160 mix_order_two.AppendTranslate(0, 1, 0); | 162 mix_order_two.AppendTranslate(0, 1, 0); |
| 161 mix_order_two.AppendTranslate(1, 0, 0); | 163 mix_order_two.AppendTranslate(1, 0, 0); |
| 162 mix_order_two.AppendScale(2, 1, 3); | 164 mix_order_two.AppendScale(2, 1, 3); |
| 163 | 165 |
| 164 EXPECT_TRUE(mix_order_identity.MatchesTypes(mix_order_one)); | 166 EXPECT_TRUE(mix_order_identity.MatchesTypes(mix_order_one)); |
| 165 EXPECT_FALSE(mix_order_identity.MatchesTypes(mix_order_two)); | 167 EXPECT_FALSE(mix_order_identity.MatchesTypes(mix_order_two)); |
| 166 EXPECT_FALSE(mix_order_one.MatchesTypes(mix_order_two)); | 168 EXPECT_FALSE(mix_order_one.MatchesTypes(mix_order_two)); |
| 167 } | 169 } |
| 168 | 170 |
| 169 TEST(TransformOperationTest, NoneAlwaysMatches) { | 171 TEST(TransformOperationTest, NoneAlwaysMatches) { |
| 170 std::vector<scoped_ptr<TransformOperations>> operations = | 172 std::vector<std::unique_ptr<TransformOperations>> operations = |
| 171 GetIdentityOperations(); | 173 GetIdentityOperations(); |
| 172 | 174 |
| 173 TransformOperations none_operation; | 175 TransformOperations none_operation; |
| 174 for (size_t i = 0; i < operations.size(); ++i) | 176 for (size_t i = 0; i < operations.size(); ++i) |
| 175 EXPECT_TRUE(operations[i]->MatchesTypes(none_operation)); | 177 EXPECT_TRUE(operations[i]->MatchesTypes(none_operation)); |
| 176 } | 178 } |
| 177 | 179 |
| 178 TEST(TransformOperationTest, ApplyTranslate) { | 180 TEST(TransformOperationTest, ApplyTranslate) { |
| 179 SkMScalar x = 1; | 181 SkMScalar x = 1; |
| 180 SkMScalar y = 2; | 182 SkMScalar y = 2; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 operations_to.AppendRotate(0, 0, 1, 0); | 498 operations_to.AppendRotate(0, 0, 1, 0); |
| 497 | 499 |
| 498 SkMScalar progress = 0.5f; | 500 SkMScalar progress = 0.5f; |
| 499 gfx::Transform expected; | 501 gfx::Transform expected; |
| 500 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); | 502 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); |
| 501 EXPECT_TRANSFORMATION_MATRIX_EQ( | 503 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 502 expected, operations_to.Blend(operations_from, progress)); | 504 expected, operations_to.Blend(operations_from, progress)); |
| 503 } | 505 } |
| 504 | 506 |
| 505 TEST(TransformOperationTest, BlendRotationFromIdentity) { | 507 TEST(TransformOperationTest, BlendRotationFromIdentity) { |
| 506 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 508 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 507 GetIdentityOperations(); | 509 GetIdentityOperations(); |
| 508 | 510 |
| 509 for (size_t i = 0; i < identity_operations.size(); ++i) { | 511 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 510 TransformOperations operations; | 512 TransformOperations operations; |
| 511 operations.AppendRotate(0, 0, 1, 90); | 513 operations.AppendRotate(0, 0, 1, 90); |
| 512 | 514 |
| 513 SkMScalar progress = 0.5f; | 515 SkMScalar progress = 0.5f; |
| 514 | 516 |
| 515 gfx::Transform expected; | 517 gfx::Transform expected; |
| 516 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); | 518 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 530 | 532 |
| 531 expected.MakeIdentity(); | 533 expected.MakeIdentity(); |
| 532 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 135); | 534 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 135); |
| 533 | 535 |
| 534 EXPECT_TRANSFORMATION_MATRIX_EQ( | 536 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 535 expected, operations.Blend(*identity_operations[i], progress)); | 537 expected, operations.Blend(*identity_operations[i], progress)); |
| 536 } | 538 } |
| 537 } | 539 } |
| 538 | 540 |
| 539 TEST(TransformOperationTest, BlendTranslationFromIdentity) { | 541 TEST(TransformOperationTest, BlendTranslationFromIdentity) { |
| 540 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 542 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 541 GetIdentityOperations(); | 543 GetIdentityOperations(); |
| 542 | 544 |
| 543 for (size_t i = 0; i < identity_operations.size(); ++i) { | 545 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 544 TransformOperations operations; | 546 TransformOperations operations; |
| 545 operations.AppendTranslate(2, 2, 2); | 547 operations.AppendTranslate(2, 2, 2); |
| 546 | 548 |
| 547 SkMScalar progress = 0.5f; | 549 SkMScalar progress = 0.5f; |
| 548 | 550 |
| 549 gfx::Transform expected; | 551 gfx::Transform expected; |
| 550 expected.Translate3d(1, 1, 1); | 552 expected.Translate3d(1, 1, 1); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 564 | 566 |
| 565 expected.MakeIdentity(); | 567 expected.MakeIdentity(); |
| 566 expected.Translate3d(3, 3, 3); | 568 expected.Translate3d(3, 3, 3); |
| 567 | 569 |
| 568 EXPECT_TRANSFORMATION_MATRIX_EQ( | 570 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 569 expected, operations.Blend(*identity_operations[i], progress)); | 571 expected, operations.Blend(*identity_operations[i], progress)); |
| 570 } | 572 } |
| 571 } | 573 } |
| 572 | 574 |
| 573 TEST(TransformOperationTest, BlendScaleFromIdentity) { | 575 TEST(TransformOperationTest, BlendScaleFromIdentity) { |
| 574 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 576 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 575 GetIdentityOperations(); | 577 GetIdentityOperations(); |
| 576 | 578 |
| 577 for (size_t i = 0; i < identity_operations.size(); ++i) { | 579 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 578 TransformOperations operations; | 580 TransformOperations operations; |
| 579 operations.AppendScale(3, 3, 3); | 581 operations.AppendScale(3, 3, 3); |
| 580 | 582 |
| 581 SkMScalar progress = 0.5f; | 583 SkMScalar progress = 0.5f; |
| 582 | 584 |
| 583 gfx::Transform expected; | 585 gfx::Transform expected; |
| 584 expected.Scale3d(2, 2, 2); | 586 expected.Scale3d(2, 2, 2); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 progress = 1.5f; | 631 progress = 1.5f; |
| 630 | 632 |
| 631 expected.MakeIdentity(); | 633 expected.MakeIdentity(); |
| 632 expected.Skew(3, 3); | 634 expected.Skew(3, 3); |
| 633 | 635 |
| 634 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, | 636 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, |
| 635 operations.Blend(empty_operation, progress)); | 637 operations.Blend(empty_operation, progress)); |
| 636 } | 638 } |
| 637 | 639 |
| 638 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { | 640 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { |
| 639 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 641 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 640 GetIdentityOperations(); | 642 GetIdentityOperations(); |
| 641 | 643 |
| 642 for (size_t i = 0; i < identity_operations.size(); ++i) { | 644 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 643 TransformOperations operations; | 645 TransformOperations operations; |
| 644 operations.AppendPerspective(1000); | 646 operations.AppendPerspective(1000); |
| 645 | 647 |
| 646 SkMScalar progress = 0.5f; | 648 SkMScalar progress = 0.5f; |
| 647 | 649 |
| 648 gfx::Transform expected; | 650 gfx::Transform expected; |
| 649 expected.ApplyPerspectiveDepth(2000); | 651 expected.ApplyPerspectiveDepth(2000); |
| 650 | 652 |
| 651 EXPECT_TRANSFORMATION_MATRIX_EQ( | 653 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 652 expected, operations.Blend(*identity_operations[i], progress)); | 654 expected, operations.Blend(*identity_operations[i], progress)); |
| 653 } | 655 } |
| 654 } | 656 } |
| 655 | 657 |
| 656 TEST(TransformOperationTest, BlendRotationToIdentity) { | 658 TEST(TransformOperationTest, BlendRotationToIdentity) { |
| 657 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 659 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 658 GetIdentityOperations(); | 660 GetIdentityOperations(); |
| 659 | 661 |
| 660 for (size_t i = 0; i < identity_operations.size(); ++i) { | 662 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 661 TransformOperations operations; | 663 TransformOperations operations; |
| 662 operations.AppendRotate(0, 0, 1, 90); | 664 operations.AppendRotate(0, 0, 1, 90); |
| 663 | 665 |
| 664 SkMScalar progress = 0.5f; | 666 SkMScalar progress = 0.5f; |
| 665 | 667 |
| 666 gfx::Transform expected; | 668 gfx::Transform expected; |
| 667 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); | 669 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); |
| 668 | 670 |
| 669 EXPECT_TRANSFORMATION_MATRIX_EQ( | 671 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 670 expected, identity_operations[i]->Blend(operations, progress)); | 672 expected, identity_operations[i]->Blend(operations, progress)); |
| 671 } | 673 } |
| 672 } | 674 } |
| 673 | 675 |
| 674 TEST(TransformOperationTest, BlendTranslationToIdentity) { | 676 TEST(TransformOperationTest, BlendTranslationToIdentity) { |
| 675 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 677 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 676 GetIdentityOperations(); | 678 GetIdentityOperations(); |
| 677 | 679 |
| 678 for (size_t i = 0; i < identity_operations.size(); ++i) { | 680 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 679 TransformOperations operations; | 681 TransformOperations operations; |
| 680 operations.AppendTranslate(2, 2, 2); | 682 operations.AppendTranslate(2, 2, 2); |
| 681 | 683 |
| 682 SkMScalar progress = 0.5f; | 684 SkMScalar progress = 0.5f; |
| 683 | 685 |
| 684 gfx::Transform expected; | 686 gfx::Transform expected; |
| 685 expected.Translate3d(1, 1, 1); | 687 expected.Translate3d(1, 1, 1); |
| 686 | 688 |
| 687 EXPECT_TRANSFORMATION_MATRIX_EQ( | 689 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 688 expected, identity_operations[i]->Blend(operations, progress)); | 690 expected, identity_operations[i]->Blend(operations, progress)); |
| 689 } | 691 } |
| 690 } | 692 } |
| 691 | 693 |
| 692 TEST(TransformOperationTest, BlendScaleToIdentity) { | 694 TEST(TransformOperationTest, BlendScaleToIdentity) { |
| 693 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 695 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 694 GetIdentityOperations(); | 696 GetIdentityOperations(); |
| 695 | 697 |
| 696 for (size_t i = 0; i < identity_operations.size(); ++i) { | 698 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 697 TransformOperations operations; | 699 TransformOperations operations; |
| 698 operations.AppendScale(3, 3, 3); | 700 operations.AppendScale(3, 3, 3); |
| 699 | 701 |
| 700 SkMScalar progress = 0.5f; | 702 SkMScalar progress = 0.5f; |
| 701 | 703 |
| 702 gfx::Transform expected; | 704 gfx::Transform expected; |
| 703 expected.Scale3d(2, 2, 2); | 705 expected.Scale3d(2, 2, 2); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 716 SkMScalar progress = 0.5f; | 718 SkMScalar progress = 0.5f; |
| 717 | 719 |
| 718 gfx::Transform expected; | 720 gfx::Transform expected; |
| 719 expected.Skew(1, 1); | 721 expected.Skew(1, 1); |
| 720 | 722 |
| 721 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, | 723 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, |
| 722 empty_operation.Blend(operations, progress)); | 724 empty_operation.Blend(operations, progress)); |
| 723 } | 725 } |
| 724 | 726 |
| 725 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { | 727 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { |
| 726 std::vector<scoped_ptr<TransformOperations>> identity_operations = | 728 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 727 GetIdentityOperations(); | 729 GetIdentityOperations(); |
| 728 | 730 |
| 729 for (size_t i = 0; i < identity_operations.size(); ++i) { | 731 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 730 TransformOperations operations; | 732 TransformOperations operations; |
| 731 operations.AppendPerspective(1000); | 733 operations.AppendPerspective(1000); |
| 732 | 734 |
| 733 SkMScalar progress = 0.5f; | 735 SkMScalar progress = 0.5f; |
| 734 | 736 |
| 735 gfx::Transform expected; | 737 gfx::Transform expected; |
| 736 expected.ApplyPerspectiveDepth(2000); | 738 expected.ApplyPerspectiveDepth(2000); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1527 |
| 1526 // Scale + Perspective can't. | 1528 // Scale + Perspective can't. |
| 1527 TransformOperations operations11; | 1529 TransformOperations operations11; |
| 1528 operations11.AppendScale(2.f, 2.f, 2.f); | 1530 operations11.AppendScale(2.f, 2.f, 2.f); |
| 1529 operations11.AppendPerspective(1.f); | 1531 operations11.AppendPerspective(1.f); |
| 1530 EXPECT_FALSE(operations11.ScaleComponent(&scale)); | 1532 EXPECT_FALSE(operations11.ScaleComponent(&scale)); |
| 1531 } | 1533 } |
| 1532 | 1534 |
| 1533 } // namespace | 1535 } // namespace |
| 1534 } // namespace cc | 1536 } // namespace cc |
| OLD | NEW |