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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 2080223010: cc: Clean up root_layer code in LTI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase++ Created 4 years, 5 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/layers/heads_up_display_layer_impl_unittest.cc ('k') | cc/layers/layer_iterator_unittest.cc » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "cc/animation/mutable_properties.h" 7 #include "cc/animation/mutable_properties.h"
8 #include "cc/layers/painted_scrollbar_layer_impl.h" 8 #include "cc/layers/painted_scrollbar_layer_impl.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
10 #include "cc/output/filter_operation.h" 10 #include "cc/output/filter_operation.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 &task_graph_runner); 121 &task_graph_runner);
122 host_impl.SetVisible(true); 122 host_impl.SetVisible(true);
123 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 123 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get()));
124 std::unique_ptr<LayerImpl> root_clip_ptr = 124 std::unique_ptr<LayerImpl> root_clip_ptr =
125 LayerImpl::Create(host_impl.active_tree(), 1); 125 LayerImpl::Create(host_impl.active_tree(), 1);
126 LayerImpl* root_clip = root_clip_ptr.get(); 126 LayerImpl* root_clip = root_clip_ptr.get();
127 std::unique_ptr<LayerImpl> root_ptr = 127 std::unique_ptr<LayerImpl> root_ptr =
128 LayerImpl::Create(host_impl.active_tree(), 2); 128 LayerImpl::Create(host_impl.active_tree(), 2);
129 LayerImpl* root = root_ptr.get(); 129 LayerImpl* root = root_ptr.get();
130 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr)); 130 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr));
131 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); 131 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_clip_ptr));
132 132
133 root->test_properties()->force_render_surface = true; 133 root->test_properties()->force_render_surface = true;
134 root->layer_tree_impl()->ResetAllChangeTracking(); 134 root->layer_tree_impl()->ResetAllChangeTracking();
135 135
136 root->test_properties()->AddChild( 136 root->test_properties()->AddChild(
137 LayerImpl::Create(host_impl.active_tree(), 7)); 137 LayerImpl::Create(host_impl.active_tree(), 7));
138 LayerImpl* child = root->test_properties()->children[0]; 138 LayerImpl* child = root->test_properties()->children[0];
139 child->test_properties()->AddChild( 139 child->test_properties()->AddChild(
140 LayerImpl::Create(host_impl.active_tree(), 8)); 140 LayerImpl::Create(host_impl.active_tree(), 8));
141 LayerImpl* grand_child = child->test_properties()->children[0]; 141 LayerImpl* grand_child = child->test_properties()->children[0];
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { 227 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
228 FakeImplTaskRunnerProvider task_runner_provider; 228 FakeImplTaskRunnerProvider task_runner_provider;
229 TestSharedBitmapManager shared_bitmap_manager; 229 TestSharedBitmapManager shared_bitmap_manager;
230 TestTaskGraphRunner task_graph_runner; 230 TestTaskGraphRunner task_graph_runner;
231 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 231 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
232 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 232 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
233 &task_graph_runner); 233 &task_graph_runner);
234 host_impl.SetVisible(true); 234 host_impl.SetVisible(true);
235 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 235 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get()));
236 host_impl.active_tree()->SetRootLayer( 236 host_impl.active_tree()->SetRootLayerForTesting(
237 LayerImpl::Create(host_impl.active_tree(), 1)); 237 LayerImpl::Create(host_impl.active_tree(), 1));
238 LayerImpl* root = host_impl.active_tree()->root_layer(); 238 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing();
239 root->SetHasRenderSurface(true); 239 root->SetHasRenderSurface(true);
240 std::unique_ptr<LayerImpl> layer_ptr = 240 std::unique_ptr<LayerImpl> layer_ptr =
241 LayerImpl::Create(host_impl.active_tree(), 2); 241 LayerImpl::Create(host_impl.active_tree(), 2);
242 LayerImpl* layer = layer_ptr.get(); 242 LayerImpl* layer = layer_ptr.get();
243 root->test_properties()->AddChild(std::move(layer_ptr)); 243 root->test_properties()->AddChild(std::move(layer_ptr));
244 layer->SetScrollClipLayer(root->id()); 244 layer->SetScrollClipLayer(root->id());
245 std::unique_ptr<LayerImpl> layer2_ptr = 245 std::unique_ptr<LayerImpl> layer2_ptr =
246 LayerImpl::Create(host_impl.active_tree(), 3); 246 LayerImpl::Create(host_impl.active_tree(), 3);
247 LayerImpl* layer2 = layer2_ptr.get(); 247 LayerImpl* layer2 = layer2_ptr.get();
248 root->test_properties()->AddChild(std::move(layer2_ptr)); 248 root->test_properties()->AddChild(std::move(layer2_ptr));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { 344 TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
345 FakeImplTaskRunnerProvider task_runner_provider; 345 FakeImplTaskRunnerProvider task_runner_provider;
346 TestSharedBitmapManager shared_bitmap_manager; 346 TestSharedBitmapManager shared_bitmap_manager;
347 TestTaskGraphRunner task_graph_runner; 347 TestTaskGraphRunner task_graph_runner;
348 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 348 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
349 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 349 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
350 &task_graph_runner); 350 &task_graph_runner);
351 host_impl.SetVisible(true); 351 host_impl.SetVisible(true);
352 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 352 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get()));
353 host_impl.active_tree()->SetRootLayer( 353 host_impl.active_tree()->SetRootLayerForTesting(
354 LayerImpl::Create(host_impl.active_tree(), 1)); 354 LayerImpl::Create(host_impl.active_tree(), 1));
355 LayerImpl* layer = host_impl.active_tree()->root_layer(); 355 LayerImpl* layer = host_impl.active_tree()->root_layer_for_testing();
356 356
357 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { 357 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) {
358 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { 358 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) {
359 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { 359 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) {
360 layer->SetContentsOpaque(!!contents_opaque); 360 layer->SetContentsOpaque(!!contents_opaque);
361 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED 361 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED
362 : SK_ColorTRANSPARENT); 362 : SK_ColorTRANSPARENT);
363 host_impl.active_tree()->set_background_color( 363 host_impl.active_tree()->set_background_color(
364 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); 364 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT);
365 host_impl.active_tree()->property_trees()->needs_rebuild = true; 365 host_impl.active_tree()->property_trees()->needs_rebuild = true;
(...skipping 15 matching lines...) Expand all
381 } 381 }
382 382
383 class LayerImplScrollTest : public testing::Test { 383 class LayerImplScrollTest : public testing::Test {
384 public: 384 public:
385 LayerImplScrollTest() 385 LayerImplScrollTest()
386 : host_impl_(settings(), 386 : host_impl_(settings(),
387 &task_runner_provider_, 387 &task_runner_provider_,
388 &shared_bitmap_manager_, 388 &shared_bitmap_manager_,
389 &task_graph_runner_), 389 &task_graph_runner_),
390 root_id_(7) { 390 root_id_(7) {
391 host_impl_.active_tree()->SetRootLayer( 391 host_impl_.active_tree()->SetRootLayerForTesting(
392 LayerImpl::Create(host_impl_.active_tree(), root_id_)); 392 LayerImpl::Create(host_impl_.active_tree(), root_id_));
393 host_impl_.active_tree()->root_layer()->test_properties()->AddChild( 393 host_impl_.active_tree()
394 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); 394 ->root_layer_for_testing()
395 ->test_properties()
396 ->AddChild(LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1));
395 layer()->SetScrollClipLayer(root_id_); 397 layer()->SetScrollClipLayer(root_id_);
396 // Set the max scroll offset by noting that the root layer has bounds (1,1), 398 // Set the max scroll offset by noting that the root layer has bounds (1,1),
397 // thus whatever bounds are set for the layer will be the max scroll 399 // thus whatever bounds are set for the layer will be the max scroll
398 // offset plus 1 in each direction. 400 // offset plus 1 in each direction.
399 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); 401 host_impl_.active_tree()->root_layer_for_testing()->SetBounds(
402 gfx::Size(1, 1));
400 gfx::Vector2d max_scroll_offset(51, 81); 403 gfx::Vector2d max_scroll_offset(51, 81);
401 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); 404 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y()));
402 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 405 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
403 } 406 }
404 407
405 LayerImpl* layer() { 408 LayerImpl* layer() {
406 return host_impl_.active_tree() 409 return host_impl_.active_tree()
407 ->root_layer() 410 ->root_layer_for_testing()
408 ->test_properties() 411 ->test_properties()
409 ->children[0]; 412 ->children[0];
410 } 413 }
411 414
412 ScrollTree* scroll_tree(LayerImpl* layer_impl) { 415 ScrollTree* scroll_tree(LayerImpl* layer_impl) {
413 return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree; 416 return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree;
414 } 417 }
415 418
416 LayerTreeHostImpl& host_impl() { return host_impl_; } 419 LayerTreeHostImpl& host_impl() { return host_impl_; }
417 420
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 560
558 pending_layer->PushPropertiesTo(layer()); 561 pending_layer->PushPropertiesTo(layer());
559 562
560 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 563 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
561 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 564 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
562 pending_layer->CurrentScrollOffset()); 565 pending_layer->CurrentScrollOffset());
563 } 566 }
564 567
565 } // namespace 568 } // namespace
566 } // namespace cc 569 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/heads_up_display_layer_impl_unittest.cc ('k') | cc/layers/layer_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698