| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/animation/animation_delegate.h" | 8 #include "cc/animation/animation_delegate.h" |
| 9 #include "cc/animation/animation_events.h" | 9 #include "cc/animation/animation_events.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 1782 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 1783 operations3.AppendMatrix(transform3); | 1783 operations3.AppendMatrix(transform3); |
| 1784 curve3->AddKeyframe(TransformKeyframe::Create( | 1784 curve3->AddKeyframe(TransformKeyframe::Create( |
| 1785 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 1785 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 1786 animation = | 1786 animation = |
| 1787 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 1787 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
| 1788 player_impl_->AddAnimation(std::move(animation)); | 1788 player_impl_->AddAnimation(std::move(animation)); |
| 1789 EXPECT_FALSE(player_impl_->TransformAnimationBoundsForBox(box, &bounds)); | 1789 EXPECT_FALSE(player_impl_->TransformAnimationBoundsForBox(box, &bounds)); |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 TEST_F(ElementAnimationsTest, TransformAnimationBoundsTwoPlayers) { |
| 1793 AttachTimelinePlayerLayer(); |
| 1794 CreateImplTimelineAndPlayer(); |
| 1795 |
| 1796 scoped_refptr<AnimationPlayer> player2 = |
| 1797 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 1798 timeline_->AttachPlayer(player2); |
| 1799 player2->AttachElement(element_id_); |
| 1800 |
| 1801 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 1802 KeyframedTransformAnimationCurve::Create()); |
| 1803 |
| 1804 TransformOperations operations; |
| 1805 curve->AddKeyframe( |
| 1806 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr)); |
| 1807 operations.AppendScale(2.0, 3.0, 4.0); |
| 1808 curve->AddKeyframe(TransformKeyframe::Create( |
| 1809 base::TimeDelta::FromSecondsD(1.0), operations, nullptr)); |
| 1810 |
| 1811 std::unique_ptr<Animation> animation( |
| 1812 Animation::Create(std::move(curve), 1, 1, TargetProperty::TRANSFORM)); |
| 1813 player2->AddAnimation(std::move(animation)); |
| 1814 |
| 1815 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
| 1816 gfx::BoxF bounds; |
| 1817 |
| 1818 EXPECT_FALSE(player_impl_->HasTransformAnimationThatInflatesBounds()); |
| 1819 EXPECT_TRUE(player2->TransformAnimationBoundsForBox(box, &bounds)); |
| 1820 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), |
| 1821 bounds.ToString()); |
| 1822 |
| 1823 EXPECT_TRUE( |
| 1824 element_animations_->TransformAnimationBoundsForBox(box, &bounds)); |
| 1825 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), |
| 1826 bounds.ToString()); |
| 1827 } |
| 1828 |
| 1792 // Tests that AbortAnimations aborts all animations targeting the specified | 1829 // Tests that AbortAnimations aborts all animations targeting the specified |
| 1793 // property. | 1830 // property. |
| 1794 TEST_F(ElementAnimationsTest, AbortAnimations) { | 1831 TEST_F(ElementAnimationsTest, AbortAnimations) { |
| 1795 CreateTestLayer(false, false); | 1832 CreateTestLayer(false, false); |
| 1796 AttachTimelinePlayerLayer(); | 1833 AttachTimelinePlayerLayer(); |
| 1797 | 1834 |
| 1798 // Start with several animations, and allow some of them to reach the finished | 1835 // Start with several animations, and allow some of them to reach the finished |
| 1799 // state. | 1836 // state. |
| 1800 player_->AddAnimation(Animation::Create( | 1837 player_->AddAnimation(Animation::Create( |
| 1801 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1, | 1838 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1, |
| (...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3550 DestroyTestMainLayer(); | 3587 DestroyTestMainLayer(); |
| 3551 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); | 3588 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); |
| 3552 | 3589 |
| 3553 PushProperties(); | 3590 PushProperties(); |
| 3554 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); | 3591 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); |
| 3555 EXPECT_EQ(0u, host_impl_->ticking_players_for_testing().size()); | 3592 EXPECT_EQ(0u, host_impl_->ticking_players_for_testing().size()); |
| 3556 } | 3593 } |
| 3557 | 3594 |
| 3558 } // namespace | 3595 } // namespace |
| 3559 } // namespace cc | 3596 } // namespace cc |
| OLD | NEW |