| 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 | 772 |
| 773 AttachPlayersToTimeline(); | 773 AttachPlayersToTimeline(); |
| 774 player_child_->AttachElement(scroll_layer_->id()); | 774 player_child_->AttachElement(scroll_layer_->id()); |
| 775 // Allows NotifyAnimationTakeover to get called. | 775 // Allows NotifyAnimationTakeover to get called. |
| 776 player_child_->set_animation_delegate(this); | 776 player_child_->set_animation_delegate(this); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 779 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 780 | 780 |
| 781 void DidCommit() override { | 781 void DidCommit() override { |
| 782 // Add a main thread scrolling reason after the first commit to trigger | |
| 783 // the takeover path. | |
| 784 if (layer_tree_host()->source_frame_number() == 1) { | 782 if (layer_tree_host()->source_frame_number() == 1) { |
| 785 scroll_layer_->AddMainThreadScrollingReasons( | 783 // Add an update after the first commit to trigger the animation takeover |
| 786 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 784 // path. |
| 785 layer_tree_host() |
| 786 ->animation_host() |
| 787 ->scroll_offset_animations() |
| 788 .AddTakeoverUpdate(scroll_layer_->id()); |
| 789 EXPECT_TRUE(layer_tree_host() |
| 790 ->animation_host() |
| 791 ->scroll_offset_animations() |
| 792 .HasUpdatesForTesting()); |
| 787 } | 793 } |
| 788 } | 794 } |
| 789 | 795 |
| 790 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 796 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 791 if (host_impl->sync_tree()->source_frame_number() == 0) { | 797 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 792 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( | 798 host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
| 793 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), | 799 scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), |
| 794 gfx::ScrollOffset(10, 20)); | 800 gfx::ScrollOffset(10, 20)); |
| 795 } | 801 } |
| 796 } | 802 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 AttachPlayersToTimeline(); | 836 AttachPlayersToTimeline(); |
| 831 player_child_->AttachElement(scroll_layer_->id()); | 837 player_child_->AttachElement(scroll_layer_->id()); |
| 832 } | 838 } |
| 833 | 839 |
| 834 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 840 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 835 | 841 |
| 836 void DidCommit() override { | 842 void DidCommit() override { |
| 837 if (layer_tree_host()->source_frame_number() == 1) { | 843 if (layer_tree_host()->source_frame_number() == 1) { |
| 838 // Add an update after the first commit to trigger the animation update | 844 // Add an update after the first commit to trigger the animation update |
| 839 // path. | 845 // path. |
| 840 ScrollOffsetAnimationUpdate update( | 846 layer_tree_host() |
| 841 ScrollOffsetAnimationUpdate::Type::SCROLL_OFFSET_CHANGED, | 847 ->animation_host() |
| 842 scroll_layer_->id()); | 848 ->scroll_offset_animations() |
| 843 update.adjustment_ = gfx::Vector2dF(100.f, 100.f); | 849 .AddAdjustmentUpdate(scroll_layer_->id(), |
| 844 layer_tree_host()->animation_host()->scroll_offset_animations().AddUpdate( | 850 gfx::Vector2dF(100.f, 100.f)); |
| 845 update); | |
| 846 EXPECT_TRUE(layer_tree_host() | 851 EXPECT_TRUE(layer_tree_host() |
| 847 ->animation_host() | 852 ->animation_host() |
| 848 ->scroll_offset_animations() | 853 ->scroll_offset_animations() |
| 849 .HasUpdatesForTesting()); | 854 .HasUpdatesForTesting()); |
| 850 } else if (layer_tree_host()->source_frame_number() == 2) { | 855 } else if (layer_tree_host()->source_frame_number() == 2) { |
| 851 // Verify that the update queue is cleared after the update is applied. | 856 // Verify that the update queue is cleared after the update is applied. |
| 852 EXPECT_FALSE(layer_tree_host() | 857 EXPECT_FALSE(layer_tree_host() |
| 853 ->animation_host() | 858 ->animation_host() |
| 854 ->scroll_offset_animations() | 859 ->scroll_offset_animations() |
| 855 .HasUpdatesForTesting()); | 860 .HasUpdatesForTesting()); |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 private: | 1768 private: |
| 1764 scoped_refptr<Layer> layer_; | 1769 scoped_refptr<Layer> layer_; |
| 1765 FakeContentLayerClient client_; | 1770 FakeContentLayerClient client_; |
| 1766 }; | 1771 }; |
| 1767 | 1772 |
| 1768 MULTI_THREAD_TEST_F( | 1773 MULTI_THREAD_TEST_F( |
| 1769 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1774 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
| 1770 | 1775 |
| 1771 } // namespace | 1776 } // namespace |
| 1772 } // namespace cc | 1777 } // namespace cc |
| OLD | NEW |