| 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 "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, | 103 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, |
| 104 scroll_amount_), | 104 scroll_amount_), |
| 105 scroll_layer->scroll_offset()); | 105 scroll_layer->scroll_offset()); |
| 106 | 106 |
| 107 // Pretend like Javascript updated the scroll position itself. | 107 // Pretend like Javascript updated the scroll position itself. |
| 108 scroll_layer->SetScrollOffset(second_scroll_); | 108 scroll_layer->SetScrollOffset(second_scroll_); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 112 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 113 LayerImpl* root = impl->active_tree()->root_layer(); | 113 LayerImpl* root = impl->active_tree()->root_layer_for_testing(); |
| 114 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); | 114 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); |
| 115 EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer)); | 115 EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer)); |
| 116 | 116 |
| 117 scroll_layer->SetScrollClipLayer(outer_viewport_container_layer_id_); | 117 scroll_layer->SetScrollClipLayer(outer_viewport_container_layer_id_); |
| 118 scroll_layer->SetBounds( | 118 scroll_layer->SetBounds( |
| 119 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); | 119 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); |
| 120 scroll_layer->ScrollBy(scroll_amount_); | 120 scroll_layer->ScrollBy(scroll_amount_); |
| 121 | 121 |
| 122 switch (impl->active_tree()->source_frame_number()) { | 122 switch (impl->active_tree()->source_frame_number()) { |
| 123 case 0: | 123 case 0: |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 // We force a second draw here of the first commit before activating | 905 // We force a second draw here of the first commit before activating |
| 906 // the second commit. | 906 // the second commit. |
| 907 if (impl->active_tree()->source_frame_number() == 0) | 907 if (impl->active_tree()->source_frame_number() == 0) |
| 908 impl->SetNeedsRedraw(); | 908 impl->SetNeedsRedraw(); |
| 909 } | 909 } |
| 910 | 910 |
| 911 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 911 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 912 if (impl->pending_tree()) | 912 if (impl->pending_tree()) |
| 913 impl->SetNeedsRedraw(); | 913 impl->SetNeedsRedraw(); |
| 914 | 914 |
| 915 LayerImpl* root = impl->active_tree()->root_layer(); | 915 LayerImpl* root = impl->active_tree()->root_layer_for_testing(); |
| 916 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); | 916 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); |
| 917 LayerImpl* pending_root = | 917 LayerImpl* pending_root = |
| 918 impl->active_tree()->FindPendingTreeLayerById(root->id()); | 918 impl->active_tree()->FindPendingTreeLayerById(root->id()); |
| 919 | 919 |
| 920 switch (impl->active_tree()->source_frame_number()) { | 920 switch (impl->active_tree()->source_frame_number()) { |
| 921 case 0: | 921 case 0: |
| 922 if (!impl->pending_tree()) { | 922 if (!impl->pending_tree()) { |
| 923 impl->BlockNotifyReadyToActivateForTesting(true); | 923 impl->BlockNotifyReadyToActivateForTesting(true); |
| 924 EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer)); | 924 EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer)); |
| 925 scroll_layer->ScrollBy(impl_thread_scroll1_); | 925 scroll_layer->ScrollBy(impl_thread_scroll1_); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 EXPECT_FALSE( | 1024 EXPECT_FALSE( |
| 1025 scroll_layer->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 1025 scroll_layer->layer_tree_host()->LayerNeedsPushPropertiesForTesting( |
| 1026 scroll_layer)); | 1026 scroll_layer)); |
| 1027 break; | 1027 break; |
| 1028 } | 1028 } |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { | 1031 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { |
| 1032 // Scroll after the 2nd commit has started. | 1032 // Scroll after the 2nd commit has started. |
| 1033 if (impl->active_tree()->source_frame_number() == 0) { | 1033 if (impl->active_tree()->source_frame_number() == 0) { |
| 1034 LayerImpl* active_root = impl->active_tree()->root_layer(); | 1034 LayerImpl* active_root = impl->active_tree()->root_layer_for_testing(); |
| 1035 LayerImpl* active_scroll_layer = impl->OuterViewportScrollLayer(); | 1035 LayerImpl* active_scroll_layer = impl->OuterViewportScrollLayer(); |
| 1036 ASSERT_TRUE(active_root); | 1036 ASSERT_TRUE(active_root); |
| 1037 ASSERT_TRUE(active_scroll_layer); | 1037 ASSERT_TRUE(active_scroll_layer); |
| 1038 active_scroll_layer->ScrollBy(impl_thread_scroll_); | 1038 active_scroll_layer->ScrollBy(impl_thread_scroll_); |
| 1039 impl->active_tree()->SetPageScaleOnActiveTree(impl_scale_); | 1039 impl->active_tree()->SetPageScaleOnActiveTree(impl_scale_); |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1043 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1044 // We force a second draw here of the first commit before activating | 1044 // We force a second draw here of the first commit before activating |
| 1045 // the second commit. | 1045 // the second commit. |
| 1046 LayerImpl* active_root = impl->active_tree()->root_layer(); | 1046 LayerImpl* active_root = impl->active_tree()->root_layer_for_testing(); |
| 1047 LayerImpl* active_scroll_layer = | 1047 LayerImpl* active_scroll_layer = |
| 1048 active_root ? impl->OuterViewportScrollLayer() : NULL; | 1048 active_root ? impl->OuterViewportScrollLayer() : NULL; |
| 1049 LayerImpl* pending_root = impl->pending_tree()->root_layer(); | 1049 LayerImpl* pending_root = impl->pending_tree()->root_layer_for_testing(); |
| 1050 LayerImpl* pending_scroll_layer = | 1050 LayerImpl* pending_scroll_layer = |
| 1051 impl->pending_tree()->OuterViewportScrollLayer(); | 1051 impl->pending_tree()->OuterViewportScrollLayer(); |
| 1052 | 1052 |
| 1053 ASSERT_TRUE(pending_root); | 1053 ASSERT_TRUE(pending_root); |
| 1054 ASSERT_TRUE(pending_scroll_layer); | 1054 ASSERT_TRUE(pending_scroll_layer); |
| 1055 switch (impl->pending_tree()->source_frame_number()) { | 1055 switch (impl->pending_tree()->source_frame_number()) { |
| 1056 case 0: | 1056 case 0: |
| 1057 EXPECT_VECTOR_EQ( | 1057 EXPECT_VECTOR_EQ( |
| 1058 initial_scroll_, | 1058 initial_scroll_, |
| 1059 ScrollTreeForLayer(pending_scroll_layer) | 1059 ScrollTreeForLayer(pending_scroll_layer) |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 num_scrolls_++; | 1620 num_scrolls_++; |
| 1621 } | 1621 } |
| 1622 | 1622 |
| 1623 void AfterTest() override { | 1623 void AfterTest() override { |
| 1624 EXPECT_EQ(3, num_commits_); | 1624 EXPECT_EQ(3, num_commits_); |
| 1625 EXPECT_EQ(1, num_scrolls_); | 1625 EXPECT_EQ(1, num_scrolls_); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 private: | 1628 private: |
| 1629 void Scroll(LayerTreeHostImpl* impl) { | 1629 void Scroll(LayerTreeHostImpl* impl) { |
| 1630 LayerImpl* root = impl->active_tree()->root_layer(); | 1630 LayerImpl* root = impl->active_tree()->root_layer_for_testing(); |
| 1631 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); | 1631 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); |
| 1632 | 1632 |
| 1633 scroll_layer->SetScrollClipLayer(outer_viewport_container_layer_id_); | 1633 scroll_layer->SetScrollClipLayer(outer_viewport_container_layer_id_); |
| 1634 scroll_layer->SetBounds( | 1634 scroll_layer->SetBounds( |
| 1635 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); | 1635 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); |
| 1636 scroll_layer->ScrollBy(scroll_amount_); | 1636 scroll_layer->ScrollBy(scroll_amount_); |
| 1637 } | 1637 } |
| 1638 | 1638 |
| 1639 gfx::ScrollOffset initial_scroll_; | 1639 gfx::ScrollOffset initial_scroll_; |
| 1640 gfx::ScrollOffset second_scroll_; | 1640 gfx::ScrollOffset second_scroll_; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 int num_impl_commits_; | 1867 int num_impl_commits_; |
| 1868 int num_aborted_commits_; | 1868 int num_aborted_commits_; |
| 1869 int num_impl_scrolls_; | 1869 int num_impl_scrolls_; |
| 1870 int num_draws_; | 1870 int num_draws_; |
| 1871 }; | 1871 }; |
| 1872 | 1872 |
| 1873 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommitMFBA); | 1873 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommitMFBA); |
| 1874 | 1874 |
| 1875 } // namespace | 1875 } // namespace |
| 1876 } // namespace cc | 1876 } // namespace cc |
| OLD | NEW |