| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "cc/animation/animation_curve.h" | 9 #include "cc/animation/animation_curve.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 void AfterTest() override {} | 746 void AfterTest() override {} |
| 747 | 747 |
| 748 private: | 748 private: |
| 749 FakeContentLayerClient client_; | 749 FakeContentLayerClient client_; |
| 750 scoped_refptr<FakePictureLayer> scroll_layer_; | 750 scoped_refptr<FakePictureLayer> scroll_layer_; |
| 751 }; | 751 }; |
| 752 | 752 |
| 753 SINGLE_AND_MULTI_THREAD_TEST_F( | 753 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 754 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated); | 754 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated); |
| 755 | 755 |
| 756 // Verifies that when a main thread scrolling reason gets added, the |
| 757 // notification to takover the animation on the main thread gets sent. |
| 758 class LayerTreeHostAnimationTestScrollOffsetAnimationTakeover |
| 759 : public LayerTreeHostAnimationTest { |
| 760 public: |
| 761 LayerTreeHostAnimationTestScrollOffsetAnimationTakeover() {} |
| 762 |
| 763 void SetupTree() override { |
| 764 LayerTreeHostAnimationTest::SetupTree(); |
| 765 |
| 766 scroll_layer_ = FakePictureLayer::Create(&client_); |
| 767 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
| 768 client_.set_bounds(scroll_layer_->bounds()); |
| 769 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 770 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 771 |
| 772 AttachPlayersToTimeline(); |
| 773 player_child_->AttachElement(scroll_layer_->id()); |
| 774 // Allows NotifyAnimationTakeover to get called. |
| 775 player_child_->set_animation_delegate(this); |
| 776 } |
| 777 |
| 778 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 779 |
| 780 void DidCommit() override { |
| 781 // Add a main thread scrolling reason after the first commit to trigger |
| 782 // the takeover path. |
| 783 if (layer_tree_host()->source_frame_number() == 1) { |
| 784 scroll_layer_->AddMainThreadScrollingReasons( |
| 785 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| 786 } |
| 787 } |
| 788 |
| 789 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 790 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 791 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
| 792 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), |
| 793 gfx::ScrollOffset(10, 20)); |
| 794 } |
| 795 } |
| 796 |
| 797 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, |
| 798 TargetProperty::Type target_property, |
| 799 double animation_start_time, |
| 800 std::unique_ptr<AnimationCurve> curve) override { |
| 801 EndTest(); |
| 802 } |
| 803 |
| 804 void AfterTest() override {} |
| 805 |
| 806 private: |
| 807 FakeContentLayerClient client_; |
| 808 scoped_refptr<FakePictureLayer> scroll_layer_; |
| 809 }; |
| 810 |
| 811 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestScrollOffsetAnimationTakeover); |
| 812 |
| 756 // Verifies that when the main thread removes a scroll animation and sets a new | 813 // Verifies that when the main thread removes a scroll animation and sets a new |
| 757 // scroll position, the active tree takes on exactly this new scroll position | 814 // scroll position, the active tree takes on exactly this new scroll position |
| 758 // after activation, and the main thread doesn't receive a spurious scroll | 815 // after activation, and the main thread doesn't receive a spurious scroll |
| 759 // delta. | 816 // delta. |
| 760 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval | 817 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval |
| 761 : public LayerTreeHostAnimationTest { | 818 : public LayerTreeHostAnimationTest { |
| 762 public: | 819 public: |
| 763 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() | 820 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() |
| 764 : final_postion_(50.0, 100.0) {} | 821 : final_postion_(50.0, 100.0) {} |
| 765 | 822 |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 private: | 1657 private: |
| 1601 scoped_refptr<Layer> layer_; | 1658 scoped_refptr<Layer> layer_; |
| 1602 FakeContentLayerClient client_; | 1659 FakeContentLayerClient client_; |
| 1603 }; | 1660 }; |
| 1604 | 1661 |
| 1605 MULTI_THREAD_TEST_F( | 1662 MULTI_THREAD_TEST_F( |
| 1606 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1663 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1607 | 1664 |
| 1608 } // namespace | 1665 } // namespace |
| 1609 } // namespace cc | 1666 } // namespace cc |
| OLD | NEW |