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

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

Issue 2051013002: cc : Push layer lists instead of layer tree at commit and activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/layer_tree_impl.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/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} 1140 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {}
1141 1141
1142 void BeginTest() override { 1142 void BeginTest() override {
1143 outer_viewport_container_layer_id_ = layer_tree_host() 1143 outer_viewport_container_layer_id_ = layer_tree_host()
1144 ->outer_viewport_scroll_layer() 1144 ->outer_viewport_scroll_layer()
1145 ->scroll_clip_layer() 1145 ->scroll_clip_layer()
1146 ->id(); 1146 ->id();
1147 PostSetNeedsCommitToMainThread(); 1147 PostSetNeedsCommitToMainThread();
1148 } 1148 }
1149 1149
1150 void UpdateLayerTreeHost() override {
1151 Layer* root = layer_tree_host()->root_layer();
1152 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
1153 switch (layer_tree_host()->source_frame_number()) {
1154 case 0:
1155 scroll_layer->SetScrollClipLayerId(outer_viewport_container_layer_id_);
1156 // Set max_scroll_offset = (100, 100).
1157 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 100,
1158 root->bounds().height() + 100));
1159 break;
1160 case 1:
1161 // Set max_scroll_offset = (0, 0).
1162 scroll_layer->SetBounds(root->bounds());
1163 break;
1164 case 2:
1165 // Set max_scroll_offset = (-100, -100).
1166 scroll_layer->SetBounds(gfx::Size());
1167 break;
1168 }
1169 }
1170
1150 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1171 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1151 LayerImpl* root = impl->active_tree()->root_layer();
1152 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 1172 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
1153 scroll_layer->SetScrollClipLayer(outer_viewport_container_layer_id_);
1154
1155 // Set max_scroll_offset = (100, 100).
1156 scroll_layer->SetBounds(
1157 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100));
1158 impl->active_tree()->property_trees()->needs_rebuild = true;
1159 impl->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1160 1173
1161 ScrollTree& scroll_tree = 1174 ScrollTree& scroll_tree =
1162 impl->active_tree()->property_trees()->scroll_tree; 1175 impl->active_tree()->property_trees()->scroll_tree;
1163 ScrollNode* scroll_node = 1176 ScrollNode* scroll_node =
1164 scroll_tree.Node(scroll_layer->scroll_tree_index()); 1177 scroll_tree.Node(scroll_layer->scroll_tree_index());
1165
1166 InputHandler::ScrollStatus status = 1178 InputHandler::ScrollStatus status =
1167 impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN, 1179 impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN,
1168 scroll_tree, scroll_node); 1180 scroll_tree, scroll_node);
1169 1181 switch (impl->active_tree()->source_frame_number()) {
1170 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1182 case 0:
1171 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1183 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1172 status.main_thread_scrolling_reasons); 1184 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1173 1185 status.main_thread_scrolling_reasons);
1174 // Set max_scroll_offset = (0, 0). 1186 PostSetNeedsCommitToMainThread();
1175 scroll_layer->SetBounds(root->bounds()); 1187 break;
1176 impl->active_tree()->property_trees()->needs_rebuild = true; 1188 case 1:
1177 impl->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 1189 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1178 scroll_tree = impl->active_tree()->property_trees()->scroll_tree; 1190 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1179 scroll_node = scroll_tree.Node(scroll_layer->scroll_tree_index()); 1191 status.main_thread_scrolling_reasons);
1180 status = impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN, 1192 PostSetNeedsCommitToMainThread();
1181 scroll_tree, scroll_node); 1193 break;
1182 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 1194 case 2:
1183 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, 1195 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1184 status.main_thread_scrolling_reasons); 1196 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1185 1197 status.main_thread_scrolling_reasons);
1186 // Set max_scroll_offset = (-100, -100). 1198 EndTest();
1187 scroll_layer->SetBounds(gfx::Size()); 1199 break;
1188 impl->active_tree()->property_trees()->needs_rebuild = true; 1200 }
1189 impl->active_tree()->BuildLayerListAndPropertyTreesForTesting();
1190 scroll_tree = impl->active_tree()->property_trees()->scroll_tree;
1191 scroll_node = scroll_tree.Node(scroll_layer->scroll_tree_index());
1192 status = impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN,
1193 scroll_tree, scroll_node);
1194 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1195 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1196 status.main_thread_scrolling_reasons);
1197
1198 EndTest();
1199 } 1201 }
1200 1202
1201 void AfterTest() override {} 1203 void AfterTest() override {}
1202 1204
1203 private: 1205 private:
1204 int outer_viewport_container_layer_id_; 1206 int outer_viewport_container_layer_id_;
1205 }; 1207 };
1206 1208
1207 SINGLE_AND_MULTI_THREAD_TEST_F( 1209 SINGLE_AND_MULTI_THREAD_TEST_F(
1208 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); 1210 LayerTreeHostScrollTestScrollZeroMaxScrollOffset);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 RunTest(CompositorMode::THREADED, false); 1512 RunTest(CompositorMode::THREADED, false);
1511 } 1513 }
1512 1514
1513 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1515 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1514 scroll_destroy_whole_tree_ = true; 1516 scroll_destroy_whole_tree_ = true;
1515 RunTest(CompositorMode::THREADED, false); 1517 RunTest(CompositorMode::THREADED, false);
1516 } 1518 }
1517 1519
1518 } // namespace 1520 } // namespace
1519 } // namespace cc 1521 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698