Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 1689293002: cc: Move TryScroll from LayerImpl to LayerTreeHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master and fix unit test failures. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 LayerImpl* root = impl->active_tree()->root_layer(); 1042 LayerImpl* root = impl->active_tree()->root_layer();
1043 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 1043 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
1044 scroll_layer->SetScrollClipLayer(root->children()[0]->id()); 1044 scroll_layer->SetScrollClipLayer(root->children()[0]->id());
1045 1045
1046 // Set max_scroll_offset = (100, 100). 1046 // Set max_scroll_offset = (100, 100).
1047 scroll_layer->SetBounds( 1047 scroll_layer->SetBounds(
1048 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); 1048 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100));
1049 impl->active_tree()->property_trees()->needs_rebuild = true; 1049 impl->active_tree()->property_trees()->needs_rebuild = true;
1050 impl->active_tree()->BuildPropertyTreesForTesting(); 1050 impl->active_tree()->BuildPropertyTreesForTesting();
1051 1051
1052 InputHandler::ScrollStatus status = scroll_layer->TryScroll( 1052 ScrollTree& scroll_tree =
1053 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); 1053 impl->active_tree()->property_trees()->scroll_tree;
1054 ScrollNode* scroll_node =
1055 scroll_tree.Node(scroll_layer->scroll_tree_index());
1056
1057 InputHandler::ScrollStatus status =
1058 impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE,
1059 scroll_tree, scroll_node);
1054 1060
1055 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1061 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1056 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1062 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1057 status.main_thread_scrolling_reasons); 1063 status.main_thread_scrolling_reasons);
1058 1064
1059 // Set max_scroll_offset = (0, 0). 1065 // Set max_scroll_offset = (0, 0).
1060 scroll_layer->SetBounds(root->bounds()); 1066 scroll_layer->SetBounds(root->bounds());
1061 impl->active_tree()->property_trees()->needs_rebuild = true; 1067 impl->active_tree()->property_trees()->needs_rebuild = true;
1062 impl->active_tree()->BuildPropertyTreesForTesting(); 1068 impl->active_tree()->BuildPropertyTreesForTesting();
1063 status = scroll_layer->TryScroll( 1069 scroll_tree = impl->active_tree()->property_trees()->scroll_tree;
1064 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); 1070 scroll_node = scroll_tree.Node(scroll_layer->scroll_tree_index());
1071 status = impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE,
1072 scroll_tree, scroll_node);
1065 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 1073 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1066 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, 1074 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1067 status.main_thread_scrolling_reasons); 1075 status.main_thread_scrolling_reasons);
1068 1076
1069 // Set max_scroll_offset = (-100, -100). 1077 // Set max_scroll_offset = (-100, -100).
1070 scroll_layer->SetBounds(gfx::Size()); 1078 scroll_layer->SetBounds(gfx::Size());
1071 impl->active_tree()->property_trees()->needs_rebuild = true; 1079 impl->active_tree()->property_trees()->needs_rebuild = true;
1072 impl->active_tree()->BuildPropertyTreesForTesting(); 1080 impl->active_tree()->BuildPropertyTreesForTesting();
1073 status = scroll_layer->TryScroll( 1081 scroll_tree = impl->active_tree()->property_trees()->scroll_tree;
1074 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); 1082 scroll_node = scroll_tree.Node(scroll_layer->scroll_tree_index());
1083 status = impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE,
1084 scroll_tree, scroll_node);
1075 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 1085 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1076 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, 1086 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1077 status.main_thread_scrolling_reasons); 1087 status.main_thread_scrolling_reasons);
1078 1088
1079 EndTest(); 1089 EndTest();
1080 } 1090 }
1081 1091
1082 void AfterTest() override {} 1092 void AfterTest() override {}
1083 }; 1093 };
1084 1094
(...skipping 13 matching lines...) Expand all
1098 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset( 1108 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
1099 gfx::ScrollOffset(20.f, 20.f)); 1109 gfx::ScrollOffset(20.f, 20.f));
1100 layer_tree_host() 1110 layer_tree_host()
1101 ->outer_viewport_scroll_layer() 1111 ->outer_viewport_scroll_layer()
1102 ->SetNonFastScrollableRegion(gfx::Rect(20, 20, 20, 20)); 1112 ->SetNonFastScrollableRegion(gfx::Rect(20, 20, 20, 20));
1103 } 1113 }
1104 1114
1105 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1115 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1106 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 1116 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
1107 1117
1118 ScrollTree& scroll_tree =
1119 impl->active_tree()->property_trees()->scroll_tree;
1120 ScrollNode* scroll_node =
1121 scroll_tree.Node(scroll_layer->scroll_tree_index());
1122
1108 // Verify that the scroll layer's scroll offset is taken into account when 1123 // Verify that the scroll layer's scroll offset is taken into account when
1109 // checking whether the screen space point is inside the non-fast 1124 // checking whether the screen space point is inside the non-fast
1110 // scrollable region. 1125 // scrollable region.
1111 1126
1112 InputHandler::ScrollStatus status = scroll_layer->TryScroll( 1127 InputHandler::ScrollStatus status = impl->TryScroll(
1113 gfx::PointF(1.f, 1.f), InputHandler::GESTURE); 1128 gfx::PointF(1.f, 1.f), InputHandler::GESTURE, scroll_tree, scroll_node);
1114 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1129 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1115 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, 1130 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion,
1116 status.main_thread_scrolling_reasons); 1131 status.main_thread_scrolling_reasons);
1117 1132
1118 status = scroll_layer->TryScroll( 1133 status = impl->TryScroll(gfx::PointF(21.f, 21.f), InputHandler::GESTURE,
1119 gfx::PointF(21.f, 21.f), InputHandler::GESTURE); 1134 scroll_tree, scroll_node);
1120 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1135 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1121 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1136 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1122 status.main_thread_scrolling_reasons); 1137 status.main_thread_scrolling_reasons);
1123 1138
1124 EndTest(); 1139 EndTest();
1125 } 1140 }
1126 1141
1127 void AfterTest() override {} 1142 void AfterTest() override {}
1128 }; 1143 };
1129 1144
(...skipping 11 matching lines...) Expand all
1141 layer_tree_host() 1156 layer_tree_host()
1142 ->inner_viewport_scroll_layer() 1157 ->inner_viewport_scroll_layer()
1143 ->AddMainThreadScrollingReasons( 1158 ->AddMainThreadScrollingReasons(
1144 MainThreadScrollingReason::kEventHandlers); 1159 MainThreadScrollingReason::kEventHandlers);
1145 } 1160 }
1146 1161
1147 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1162 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1148 LayerImpl* inner_scroll_layer = impl->InnerViewportScrollLayer(); 1163 LayerImpl* inner_scroll_layer = impl->InnerViewportScrollLayer();
1149 LayerImpl* outer_scroll_layer = impl->OuterViewportScrollLayer(); 1164 LayerImpl* outer_scroll_layer = impl->OuterViewportScrollLayer();
1150 1165
1151 InputHandler::ScrollStatus status = inner_scroll_layer->TryScroll( 1166 ScrollTree& scroll_tree =
1152 gfx::PointF(1.f, 1.f), InputHandler::GESTURE); 1167 impl->active_tree()->property_trees()->scroll_tree;
1168 ScrollNode* inner_scroll_node =
1169 scroll_tree.Node(inner_scroll_layer->scroll_tree_index());
1170 ScrollNode* outer_scroll_node =
1171 scroll_tree.Node(outer_scroll_layer->scroll_tree_index());
1172
1173 InputHandler::ScrollStatus status =
1174 impl->TryScroll(gfx::PointF(1.f, 1.f), InputHandler::GESTURE,
1175 scroll_tree, inner_scroll_node);
1153 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1176 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1154 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, 1177 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
1155 status.main_thread_scrolling_reasons); 1178 status.main_thread_scrolling_reasons);
1156 1179
1157 status = outer_scroll_layer->TryScroll(gfx::PointF(1.f, 1.f), 1180 status = impl->TryScroll(gfx::PointF(1.f, 1.f), InputHandler::GESTURE,
1158 InputHandler::GESTURE); 1181 scroll_tree, outer_scroll_node);
1159 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1182 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1160 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1183 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1161 status.main_thread_scrolling_reasons); 1184 status.main_thread_scrolling_reasons);
1162 EndTest(); 1185 EndTest();
1163 } 1186 }
1164 1187
1165 void AfterTest() override {} 1188 void AfterTest() override {}
1166 }; 1189 };
1167 1190
1168 SINGLE_AND_MULTI_THREAD_TEST_F( 1191 SINGLE_AND_MULTI_THREAD_TEST_F(
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 RunTest(CompositorMode::THREADED, false); 1376 RunTest(CompositorMode::THREADED, false);
1354 } 1377 }
1355 1378
1356 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1379 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1357 scroll_destroy_whole_tree_ = true; 1380 scroll_destroy_whole_tree_ = true;
1358 RunTest(CompositorMode::THREADED, false); 1381 RunTest(CompositorMode::THREADED, false);
1359 } 1382 }
1360 1383
1361 } // namespace 1384 } // namespace
1362 } // namespace cc 1385 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698