Chromium Code Reviews| 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_->AttachLayer(scroll_layer_->id()); | |
| 774 // Allows NotifyAnimationTakeover to get called. | |
| 775 player_child_->set_layer_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 bool have_animations = !host_impl->animation_host() | |
| 791 ->active_element_animations_for_testing() | |
| 792 .empty(); | |
| 793 if (!have_animations) { | |
|
ajuma
2016/04/28 13:43:54
Check host_impl->sync_tree()->source_frame_number(
ymalik
2016/04/28 14:23:45
Confirmed with you that this should be 0. Done.
| |
| 794 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( | |
| 795 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), | |
| 796 gfx::ScrollOffset(10, 20)); | |
| 797 } | |
| 798 } | |
| 799 | |
| 800 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, | |
| 801 TargetProperty::Type target_property, | |
| 802 double animation_start_time, | |
| 803 std::unique_ptr<AnimationCurve> curve) override { | |
| 804 EndTest(); | |
| 805 } | |
| 806 | |
| 807 void AfterTest() override {} | |
| 808 | |
| 809 private: | |
| 810 FakeContentLayerClient client_; | |
| 811 scoped_refptr<FakePictureLayer> scroll_layer_; | |
| 812 }; | |
| 813 | |
| 814 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestScrollOffsetAnimationTakeover); | |
| 815 | |
| 756 // Verifies that when the main thread removes a scroll animation and sets a new | 816 // 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 | 817 // 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 | 818 // after activation, and the main thread doesn't receive a spurious scroll |
| 759 // delta. | 819 // delta. |
| 760 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval | 820 class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval |
| 761 : public LayerTreeHostAnimationTest { | 821 : public LayerTreeHostAnimationTest { |
| 762 public: | 822 public: |
| 763 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() | 823 LayerTreeHostAnimationTestScrollOffsetAnimationRemoval() |
| 764 : final_postion_(50.0, 100.0) {} | 824 : final_postion_(50.0, 100.0) {} |
| 765 | 825 |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1600 private: | 1660 private: |
| 1601 scoped_refptr<Layer> layer_; | 1661 scoped_refptr<Layer> layer_; |
| 1602 FakeContentLayerClient client_; | 1662 FakeContentLayerClient client_; |
| 1603 }; | 1663 }; |
| 1604 | 1664 |
| 1605 MULTI_THREAD_TEST_F( | 1665 MULTI_THREAD_TEST_F( |
| 1606 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1666 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1607 | 1667 |
| 1608 } // namespace | 1668 } // namespace |
| 1609 } // namespace cc | 1669 } // namespace cc |
| OLD | NEW |