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

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

Issue 2087963003: cc: Stop creating unused 0 property tree nodes other than transform 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/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 9819 matching lines...) Expand 10 before | Expand all | Expand 10 after
9830 gfx::PointF(), gfx::Size(30, 30), true, false, 9830 gfx::PointF(), gfx::Size(30, 30), true, false,
9831 true); 9831 true);
9832 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), 9832 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(),
9833 gfx::PointF(), gfx::Size(30, 30), true, false, 9833 gfx::PointF(), gfx::Size(30, 30), true, false,
9834 false); 9834 false);
9835 ExecuteCalculateDrawProperties(root); 9835 ExecuteCalculateDrawProperties(root);
9836 9836
9837 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); 9837 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect());
9838 // A clip node is created for every render surface and for layers that have 9838 // A clip node is created for every render surface and for layers that have
9839 // local clip. So, here it should be craeted for every layer. 9839 // local clip. So, here it should be craeted for every layer.
9840 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); 9840 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 4u);
9841 } 9841 }
9842 9842
9843 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) { 9843 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) {
9844 // Tests that a mask layer's draw properties are computed correctly. 9844 // Tests that a mask layer's draw properties are computed correctly.
9845 LayerImpl* root = root_layer_for_testing(); 9845 LayerImpl* root = root_layer_for_testing();
9846 LayerImpl* child = AddChild<LayerImpl>(root); 9846 LayerImpl* child = AddChild<LayerImpl>(root);
9847 child->test_properties()->SetMaskLayer( 9847 child->test_properties()->SetMaskLayer(
9848 LayerImpl::Create(root->layer_tree_impl(), 100)); 9848 LayerImpl::Create(root->layer_tree_impl(), 100));
9849 LayerImpl* mask = child->test_properties()->mask_layer; 9849 LayerImpl* mask = child->test_properties()->mask_layer;
9850 9850
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
10257 // +----parent3(3) 10257 // +----parent3(3)
10258 // +------child7(7)[scrollable] 10258 // +------child7(7)[scrollable]
10259 // +------child8(8)[scroll_parent=7] 10259 // +------child8(8)[scroll_parent=7]
10260 // +--------grand_child11(11)[scrollable] 10260 // +--------grand_child11(11)[scrollable]
10261 // +----parent4(4) 10261 // +----parent4(4)
10262 // +------child9(9) 10262 // +------child9(9)
10263 // +--------grand_child12(12) 10263 // +--------grand_child12(12)
10264 // +----parent5(5)[contains_non_fast_scrollable_region] 10264 // +----parent5(5)[contains_non_fast_scrollable_region]
10265 // 10265 //
10266 // Expected scroll tree topology: 10266 // Expected scroll tree topology:
10267 // +property_tree_root---owner:-1 10267 // +root---owner:1, id:0
10268 // +--root---owner:1, id:1 10268 // +--node---owner:2, id:1
10269 // +----node---owner:2, id:2 10269 // +----node---owner:6, id:2
10270 // +------node---owner:6, id:3 10270 // +--node---owner:7, id:3
10271 // +----node---owner:7, id:4 10271 // +----node---owner:11, id:4
10272 // +------node---owner:11, id:5 10272 // +--node---owner:5, id:5
10273 // +----node---owner:5, id:6
10274 // 10273 //
10275 // Extra check: 10274 // Extra check:
10276 // scroll_tree_index() of: 10275 // scroll_tree_index() of:
10277 // grand_child10:3 10276 // grand_child10:2
10278 // parent3:1 10277 // parent3:0
10279 // child8:4 10278 // child8:3
10280 // parent4:1 10279 // parent4:0
10281 // child9:1 10280 // child9:0
10282 // grand_child12:1 10281 // grand_child12:0
10283 scoped_refptr<Layer> root1 = Layer::Create(); 10282 scoped_refptr<Layer> root1 = Layer::Create();
10284 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 10283 scoped_refptr<Layer> page_scale_layer = Layer::Create();
10285 scoped_refptr<Layer> parent2 = Layer::Create(); 10284 scoped_refptr<Layer> parent2 = Layer::Create();
10286 scoped_refptr<Layer> parent3 = Layer::Create(); 10285 scoped_refptr<Layer> parent3 = Layer::Create();
10287 scoped_refptr<Layer> parent4 = Layer::Create(); 10286 scoped_refptr<Layer> parent4 = Layer::Create();
10288 scoped_refptr<Layer> parent5 = Layer::Create(); 10287 scoped_refptr<Layer> parent5 = Layer::Create();
10289 scoped_refptr<Layer> child6 = Layer::Create(); 10288 scoped_refptr<Layer> child6 = Layer::Create();
10290 scoped_refptr<Layer> child7 = Layer::Create(); 10289 scoped_refptr<Layer> child7 = Layer::Create();
10291 scoped_refptr<Layer> child8 = Layer::Create(); 10290 scoped_refptr<Layer> child8 = Layer::Create();
10292 scoped_refptr<Layer> child9 = Layer::Create(); 10291 scoped_refptr<Layer> child9 = Layer::Create();
(...skipping 29 matching lines...) Expand all
10322 10321
10323 child8->SetScrollParent(child7.get()); 10322 child8->SetScrollParent(child7.get());
10324 grand_child11->SetScrollClipLayerId(parent3->id()); 10323 grand_child11->SetScrollClipLayerId(parent3->id());
10325 10324
10326 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 10325 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
10327 parent5->SetBounds(gfx::Size(10, 10)); 10326 parent5->SetBounds(gfx::Size(10, 10));
10328 10327
10329 host()->RegisterViewportLayers(NULL, page_scale_layer, parent2, NULL); 10328 host()->RegisterViewportLayers(NULL, page_scale_layer, parent2, NULL);
10330 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get()); 10329 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get());
10331 10330
10332 const int kInvalidPropertyTreeNodeId = -1;
10333 const int kRootPropertyTreeNodeId = 0;
10334
10335 // Property tree root 10331 // Property tree root
10336 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; 10332 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree;
10337 PropertyTrees property_trees; 10333 PropertyTrees property_trees;
10338 property_trees.is_main_thread = true; 10334 property_trees.is_main_thread = true;
10339 property_trees.is_active = false; 10335 property_trees.is_active = false;
10340 ScrollTree& expected_scroll_tree = property_trees.scroll_tree; 10336 ScrollTree& expected_scroll_tree = property_trees.scroll_tree;
10341 ScrollNode* property_tree_root = expected_scroll_tree.Node(0);
10342 property_tree_root->id = kRootPropertyTreeNodeId;
10343 property_tree_root->parent_id = kInvalidPropertyTreeNodeId;
10344 property_tree_root->owner_id = kInvalidPropertyTreeNodeId;
10345 property_tree_root->scrollable = false;
10346 property_tree_root->main_thread_scrolling_reasons =
10347 MainThreadScrollingReason::kNotScrollingOnMain;
10348 property_tree_root->contains_non_fast_scrollable_region = false;
10349 property_tree_root->transform_id = kRootPropertyTreeNodeId;
10350 10337
10351 // The node owned by root1 10338 // The node owned by root1
10352 ScrollNode scroll_root1; 10339 ScrollNode scroll_root1;
10353 scroll_root1.id = 1; 10340 scroll_root1.id = 0;
10354 scroll_root1.owner_id = root1->id(); 10341 scroll_root1.owner_id = root1->id();
10355 scroll_root1.user_scrollable_horizontal = true; 10342 scroll_root1.user_scrollable_horizontal = true;
10356 scroll_root1.user_scrollable_vertical = true; 10343 scroll_root1.user_scrollable_vertical = true;
10357 scroll_root1.transform_id = root1->transform_tree_index(); 10344 scroll_root1.transform_id = root1->transform_tree_index();
10358 expected_scroll_tree.Insert(scroll_root1, 0); 10345 expected_scroll_tree.Insert(scroll_root1, -1);
10359 10346
10360 // The node owned by parent2 10347 // The node owned by parent2
10361 ScrollNode scroll_parent2; 10348 ScrollNode scroll_parent2;
10362 scroll_parent2.id = 2; 10349 scroll_parent2.id = 1;
10363 scroll_parent2.owner_id = parent2->id(); 10350 scroll_parent2.owner_id = parent2->id();
10364 scroll_parent2.scrollable = true; 10351 scroll_parent2.scrollable = true;
10365 scroll_parent2.main_thread_scrolling_reasons = 10352 scroll_parent2.main_thread_scrolling_reasons =
10366 parent2->main_thread_scrolling_reasons(); 10353 parent2->main_thread_scrolling_reasons();
10367 scroll_parent2.scroll_clip_layer_bounds = root1->bounds(); 10354 scroll_parent2.scroll_clip_layer_bounds = root1->bounds();
10368 scroll_parent2.bounds = parent2->bounds(); 10355 scroll_parent2.bounds = parent2->bounds();
10369 scroll_parent2.max_scroll_offset_affected_by_page_scale = true; 10356 scroll_parent2.max_scroll_offset_affected_by_page_scale = true;
10370 scroll_parent2.is_inner_viewport_scroll_layer = true; 10357 scroll_parent2.is_inner_viewport_scroll_layer = true;
10371 scroll_parent2.user_scrollable_horizontal = true; 10358 scroll_parent2.user_scrollable_horizontal = true;
10372 scroll_parent2.user_scrollable_vertical = true; 10359 scroll_parent2.user_scrollable_vertical = true;
10373 scroll_parent2.transform_id = parent2->transform_tree_index(); 10360 scroll_parent2.transform_id = parent2->transform_tree_index();
10374 expected_scroll_tree.Insert(scroll_parent2, 1); 10361 expected_scroll_tree.Insert(scroll_parent2, 0);
10375 10362
10376 // The node owned by child6 10363 // The node owned by child6
10377 ScrollNode scroll_child6; 10364 ScrollNode scroll_child6;
10378 scroll_child6.id = 3; 10365 scroll_child6.id = 2;
10379 scroll_child6.owner_id = child6->id(); 10366 scroll_child6.owner_id = child6->id();
10380 scroll_child6.main_thread_scrolling_reasons = 10367 scroll_child6.main_thread_scrolling_reasons =
10381 child6->main_thread_scrolling_reasons(); 10368 child6->main_thread_scrolling_reasons();
10382 scroll_child6.should_flatten = true; 10369 scroll_child6.should_flatten = true;
10383 scroll_child6.user_scrollable_horizontal = true; 10370 scroll_child6.user_scrollable_horizontal = true;
10384 scroll_child6.user_scrollable_vertical = true; 10371 scroll_child6.user_scrollable_vertical = true;
10385 scroll_child6.transform_id = child6->transform_tree_index(); 10372 scroll_child6.transform_id = child6->transform_tree_index();
10386 expected_scroll_tree.Insert(scroll_child6, 2); 10373 expected_scroll_tree.Insert(scroll_child6, 1);
10387 10374
10388 // The node owned by child7, child7 also owns a transform node 10375 // The node owned by child7, child7 also owns a transform node
10389 ScrollNode scroll_child7; 10376 ScrollNode scroll_child7;
10390 scroll_child7.id = 4; 10377 scroll_child7.id = 3;
10391 scroll_child7.owner_id = child7->id(); 10378 scroll_child7.owner_id = child7->id();
10392 scroll_child7.scrollable = true; 10379 scroll_child7.scrollable = true;
10393 scroll_child7.scroll_clip_layer_bounds = parent3->bounds(); 10380 scroll_child7.scroll_clip_layer_bounds = parent3->bounds();
10394 scroll_child7.bounds = child7->bounds(); 10381 scroll_child7.bounds = child7->bounds();
10395 scroll_child7.user_scrollable_horizontal = true; 10382 scroll_child7.user_scrollable_horizontal = true;
10396 scroll_child7.user_scrollable_vertical = true; 10383 scroll_child7.user_scrollable_vertical = true;
10397 scroll_child7.transform_id = child7->transform_tree_index(); 10384 scroll_child7.transform_id = child7->transform_tree_index();
10398 expected_scroll_tree.Insert(scroll_child7, 1); 10385 expected_scroll_tree.Insert(scroll_child7, 0);
10399 10386
10400 // The node owned by grand_child11, grand_child11 also owns a transform node 10387 // The node owned by grand_child11, grand_child11 also owns a transform node
10401 ScrollNode scroll_grand_child11; 10388 ScrollNode scroll_grand_child11;
10402 scroll_grand_child11.id = 5; 10389 scroll_grand_child11.id = 4;
10403 scroll_grand_child11.owner_id = grand_child11->id(); 10390 scroll_grand_child11.owner_id = grand_child11->id();
10404 scroll_grand_child11.scrollable = true; 10391 scroll_grand_child11.scrollable = true;
10405 scroll_grand_child11.user_scrollable_horizontal = true; 10392 scroll_grand_child11.user_scrollable_horizontal = true;
10406 scroll_grand_child11.user_scrollable_vertical = true; 10393 scroll_grand_child11.user_scrollable_vertical = true;
10407 scroll_grand_child11.transform_id = grand_child11->transform_tree_index(); 10394 scroll_grand_child11.transform_id = grand_child11->transform_tree_index();
10408 expected_scroll_tree.Insert(scroll_grand_child11, 4); 10395 expected_scroll_tree.Insert(scroll_grand_child11, 3);
10409 10396
10410 // The node owned by parent5 10397 // The node owned by parent5
10411 ScrollNode scroll_parent5; 10398 ScrollNode scroll_parent5;
10412 scroll_parent5.id = 8; 10399 scroll_parent5.id = 5;
10413 scroll_parent5.owner_id = parent5->id(); 10400 scroll_parent5.owner_id = parent5->id();
10414 scroll_parent5.contains_non_fast_scrollable_region = true; 10401 scroll_parent5.contains_non_fast_scrollable_region = true;
10415 scroll_parent5.bounds = gfx::Size(10, 10); 10402 scroll_parent5.bounds = gfx::Size(10, 10);
10416 scroll_parent5.should_flatten = true; 10403 scroll_parent5.should_flatten = true;
10417 scroll_parent5.user_scrollable_horizontal = true; 10404 scroll_parent5.user_scrollable_horizontal = true;
10418 scroll_parent5.user_scrollable_vertical = true; 10405 scroll_parent5.user_scrollable_vertical = true;
10419 scroll_parent5.transform_id = parent5->transform_tree_index(); 10406 scroll_parent5.transform_id = parent5->transform_tree_index();
10420 expected_scroll_tree.Insert(scroll_parent5, 1); 10407 expected_scroll_tree.Insert(scroll_parent5, 0);
10421 10408
10422 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); 10409 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0));
10423 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); 10410 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0));
10424 expected_scroll_tree.SetScrollOffset(grand_child11->id(), 10411 expected_scroll_tree.SetScrollOffset(grand_child11->id(),
10425 gfx::ScrollOffset(0, 0)); 10412 gfx::ScrollOffset(0, 0));
10426 expected_scroll_tree.set_needs_update(false); 10413 expected_scroll_tree.set_needs_update(false);
10427 10414
10428 EXPECT_EQ(expected_scroll_tree, scroll_tree); 10415 EXPECT_EQ(expected_scroll_tree, scroll_tree);
10429 10416
10430 // Check other layers' scroll_tree_index 10417 // Check other layers' scroll_tree_index
10431 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); 10418 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index());
10432 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10419 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10433 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10420 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10434 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10421 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10435 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10422 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10436 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10423 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10437 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10424 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10438 } 10425 }
10439 10426
10440 } // namespace 10427 } // namespace
10441 } // namespace cc 10428 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698