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

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
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 WillCommit() override {
ajuma 2016/06/09 15:15:19 If this is changed to UpdateLayerTreeHost, it will
jaydasika 2016/06/09 16:56:25 Done.
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 root->layer_tree_host()->BuildPropertyTreesForTesting();
1160 break;
1161 case 1:
1162 // Set max_scroll_offset = (0, 0).
1163 scroll_layer->SetBounds(root->bounds());
1164 root->layer_tree_host()->BuildPropertyTreesForTesting();
1165 break;
1166 case 2:
1167 // Set max_scroll_offset = (-100, -100).
1168 scroll_layer->SetBounds(gfx::Size());
1169 root->layer_tree_host()->BuildPropertyTreesForTesting();
1170 break;
1171 }
1172 }
1173
1150 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1174 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1151 LayerImpl* root = impl->active_tree()->root_layer();
1152 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 1175 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 1176
1161 ScrollTree& scroll_tree = 1177 ScrollTree& scroll_tree =
1162 impl->active_tree()->property_trees()->scroll_tree; 1178 impl->active_tree()->property_trees()->scroll_tree;
1163 ScrollNode* scroll_node = 1179 ScrollNode* scroll_node =
1164 scroll_tree.Node(scroll_layer->scroll_tree_index()); 1180 scroll_tree.Node(scroll_layer->scroll_tree_index());
1165
1166 InputHandler::ScrollStatus status = 1181 InputHandler::ScrollStatus status =
1167 impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN, 1182 impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN,
1168 scroll_tree, scroll_node); 1183 scroll_tree, scroll_node);
1169 1184 switch (impl->active_tree()->source_frame_number()) {
1170 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1185 case 0:
1171 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1186 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1172 status.main_thread_scrolling_reasons); 1187 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1173 1188 status.main_thread_scrolling_reasons);
1174 // Set max_scroll_offset = (0, 0). 1189 PostSetNeedsCommitToMainThread();
1175 scroll_layer->SetBounds(root->bounds()); 1190 break;
1176 impl->active_tree()->property_trees()->needs_rebuild = true; 1191 case 1:
1177 impl->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 1192 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1178 scroll_tree = impl->active_tree()->property_trees()->scroll_tree; 1193 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1179 scroll_node = scroll_tree.Node(scroll_layer->scroll_tree_index()); 1194 status.main_thread_scrolling_reasons);
1180 status = impl->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::TOUCHSCREEN, 1195 PostSetNeedsCommitToMainThread();
1181 scroll_tree, scroll_node); 1196 break;
1182 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 1197 case 2:
1183 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, 1198 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1184 status.main_thread_scrolling_reasons); 1199 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
1185 1200 status.main_thread_scrolling_reasons);
1186 // Set max_scroll_offset = (-100, -100). 1201 EndTest();
1187 scroll_layer->SetBounds(gfx::Size()); 1202 break;
1188 impl->active_tree()->property_trees()->needs_rebuild = true; 1203 }
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 } 1204 }
1200 1205
1201 void AfterTest() override {} 1206 void AfterTest() override {}
1202 1207
1203 private: 1208 private:
1204 int outer_viewport_container_layer_id_; 1209 int outer_viewport_container_layer_id_;
1205 }; 1210 };
1206 1211
1207 SINGLE_AND_MULTI_THREAD_TEST_F( 1212 SINGLE_AND_MULTI_THREAD_TEST_F(
1208 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); 1213 LayerTreeHostScrollTestScrollZeroMaxScrollOffset);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 RunTest(CompositorMode::THREADED, false); 1515 RunTest(CompositorMode::THREADED, false);
1511 } 1516 }
1512 1517
1513 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1518 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1514 scroll_destroy_whole_tree_ = true; 1519 scroll_destroy_whole_tree_ = true;
1515 RunTest(CompositorMode::THREADED, false); 1520 RunTest(CompositorMode::THREADED, false);
1516 } 1521 }
1517 1522
1518 } // namespace 1523 } // namespace
1519 } // namespace cc 1524 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698