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

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: 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 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 9652 matching lines...) Expand 10 before | Expand all | Expand 10 after
9663 gfx::PointF(), gfx::Size(30, 30), true, false, 9663 gfx::PointF(), gfx::Size(30, 30), true, false,
9664 true); 9664 true);
9665 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), 9665 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(),
9666 gfx::PointF(), gfx::Size(30, 30), true, false, 9666 gfx::PointF(), gfx::Size(30, 30), true, false,
9667 false); 9667 false);
9668 ExecuteCalculateDrawProperties(root); 9668 ExecuteCalculateDrawProperties(root);
9669 9669
9670 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); 9670 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect());
9671 // A clip node is created for every render surface and for layers that have 9671 // A clip node is created for every render surface and for layers that have
9672 // local clip. So, here it should be craeted for every layer. 9672 // local clip. So, here it should be craeted for every layer.
9673 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); 9673 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 4u);
9674 } 9674 }
9675 9675
9676 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) { 9676 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) {
9677 // Tests that a mask layer's draw properties are computed correctly. 9677 // Tests that a mask layer's draw properties are computed correctly.
9678 LayerImpl* root = root_layer(); 9678 LayerImpl* root = root_layer();
9679 LayerImpl* child = AddChild<LayerImpl>(root); 9679 LayerImpl* child = AddChild<LayerImpl>(root);
9680 child->test_properties()->SetMaskLayer( 9680 child->test_properties()->SetMaskLayer(
9681 LayerImpl::Create(root->layer_tree_impl(), 100)); 9681 LayerImpl::Create(root->layer_tree_impl(), 100));
9682 LayerImpl* mask = child->test_properties()->mask_layer; 9682 LayerImpl* mask = child->test_properties()->mask_layer;
9683 9683
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
10085 // +----parent3(3) 10085 // +----parent3(3)
10086 // +------child7(7)[scrollable] 10086 // +------child7(7)[scrollable]
10087 // +------child8(8)[scroll_parent=7] 10087 // +------child8(8)[scroll_parent=7]
10088 // +--------grand_child11(11)[scrollable] 10088 // +--------grand_child11(11)[scrollable]
10089 // +----parent4(4) 10089 // +----parent4(4)
10090 // +------child9(9) 10090 // +------child9(9)
10091 // +--------grand_child12(12) 10091 // +--------grand_child12(12)
10092 // +----parent5(5)[contains_non_fast_scrollable_region] 10092 // +----parent5(5)[contains_non_fast_scrollable_region]
10093 // 10093 //
10094 // Expected scroll tree topology: 10094 // Expected scroll tree topology:
10095 // +property_tree_root---owner:-1 10095 // +root---owner:1, id:0
10096 // +--root---owner:1, id:1 10096 // +--node---owner:2, id:1
10097 // +----node---owner:2, id:2 10097 // +----node---owner:6, id:2
10098 // +------node---owner:6, id:3 10098 // +--node---owner:7, id:3
10099 // +----node---owner:7, id:4 10099 // +----node---owner:11, id:4
10100 // +------node---owner:11, id:5 10100 // +--node---owner:5, id:5
10101 // +----node---owner:5, id:6
10102 // 10101 //
10103 // Extra check: 10102 // Extra check:
10104 // scroll_tree_index() of: 10103 // scroll_tree_index() of:
10105 // grand_child10:3 10104 // grand_child10:2
10106 // parent3:1 10105 // parent3:0
10107 // child8:4 10106 // child8:3
10108 // parent4:1 10107 // parent4:0
10109 // child9:1 10108 // child9:0
10110 // grand_child12:1 10109 // grand_child12:0
10111 scoped_refptr<Layer> root1 = Layer::Create(); 10110 scoped_refptr<Layer> root1 = Layer::Create();
10112 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 10111 scoped_refptr<Layer> page_scale_layer = Layer::Create();
10113 scoped_refptr<Layer> parent2 = Layer::Create(); 10112 scoped_refptr<Layer> parent2 = Layer::Create();
10114 scoped_refptr<Layer> parent3 = Layer::Create(); 10113 scoped_refptr<Layer> parent3 = Layer::Create();
10115 scoped_refptr<Layer> parent4 = Layer::Create(); 10114 scoped_refptr<Layer> parent4 = Layer::Create();
10116 scoped_refptr<Layer> parent5 = Layer::Create(); 10115 scoped_refptr<Layer> parent5 = Layer::Create();
10117 scoped_refptr<Layer> child6 = Layer::Create(); 10116 scoped_refptr<Layer> child6 = Layer::Create();
10118 scoped_refptr<Layer> child7 = Layer::Create(); 10117 scoped_refptr<Layer> child7 = Layer::Create();
10119 scoped_refptr<Layer> child8 = Layer::Create(); 10118 scoped_refptr<Layer> child8 = Layer::Create();
10120 scoped_refptr<Layer> child9 = Layer::Create(); 10119 scoped_refptr<Layer> child9 = Layer::Create();
(...skipping 29 matching lines...) Expand all
10150 10149
10151 child8->SetScrollParent(child7.get()); 10150 child8->SetScrollParent(child7.get());
10152 grand_child11->SetScrollClipLayerId(parent3->id()); 10151 grand_child11->SetScrollClipLayerId(parent3->id());
10153 10152
10154 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 10153 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
10155 parent5->SetBounds(gfx::Size(10, 10)); 10154 parent5->SetBounds(gfx::Size(10, 10));
10156 10155
10157 host()->RegisterViewportLayers(NULL, page_scale_layer, parent2, NULL); 10156 host()->RegisterViewportLayers(NULL, page_scale_layer, parent2, NULL);
10158 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get()); 10157 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get());
10159 10158
10160 const int kInvalidPropertyTreeNodeId = -1;
10161 const int kRootPropertyTreeNodeId = 0;
10162
10163 // Property tree root 10159 // Property tree root
10164 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; 10160 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree;
10165 PropertyTrees property_trees; 10161 PropertyTrees property_trees;
10166 property_trees.is_main_thread = true; 10162 property_trees.is_main_thread = true;
10167 property_trees.is_active = false; 10163 property_trees.is_active = false;
10168 ScrollTree& expected_scroll_tree = property_trees.scroll_tree; 10164 ScrollTree& expected_scroll_tree = property_trees.scroll_tree;
10169 ScrollNode* property_tree_root = expected_scroll_tree.Node(0);
10170 property_tree_root->id = kRootPropertyTreeNodeId;
10171 property_tree_root->parent_id = kInvalidPropertyTreeNodeId;
10172 property_tree_root->owner_id = kInvalidPropertyTreeNodeId;
10173 property_tree_root->data.scrollable = false;
10174 property_tree_root->data.main_thread_scrolling_reasons =
10175 MainThreadScrollingReason::kNotScrollingOnMain;
10176 property_tree_root->data.contains_non_fast_scrollable_region = false;
10177 property_tree_root->data.transform_id = kRootPropertyTreeNodeId;
10178 10165
10179 // The node owned by root1 10166 // The node owned by root1
10180 ScrollNode scroll_root1; 10167 ScrollNode scroll_root1;
10181 scroll_root1.id = 1; 10168 scroll_root1.id = 0;
10182 scroll_root1.owner_id = root1->id(); 10169 scroll_root1.owner_id = root1->id();
10183 scroll_root1.data.user_scrollable_horizontal = true; 10170 scroll_root1.data.user_scrollable_horizontal = true;
10184 scroll_root1.data.user_scrollable_vertical = true; 10171 scroll_root1.data.user_scrollable_vertical = true;
10185 scroll_root1.data.transform_id = root1->transform_tree_index(); 10172 scroll_root1.data.transform_id = root1->transform_tree_index();
10186 expected_scroll_tree.Insert(scroll_root1, 0); 10173 expected_scroll_tree.Insert(scroll_root1, -1);
10187 10174
10188 // The node owned by parent2 10175 // The node owned by parent2
10189 ScrollNode scroll_parent2; 10176 ScrollNode scroll_parent2;
10190 scroll_parent2.id = 2; 10177 scroll_parent2.id = 1;
10191 scroll_parent2.owner_id = parent2->id(); 10178 scroll_parent2.owner_id = parent2->id();
10192 scroll_parent2.data.scrollable = true; 10179 scroll_parent2.data.scrollable = true;
10193 scroll_parent2.data.main_thread_scrolling_reasons = 10180 scroll_parent2.data.main_thread_scrolling_reasons =
10194 parent2->main_thread_scrolling_reasons(); 10181 parent2->main_thread_scrolling_reasons();
10195 scroll_parent2.data.scroll_clip_layer_bounds = root1->bounds(); 10182 scroll_parent2.data.scroll_clip_layer_bounds = root1->bounds();
10196 scroll_parent2.data.bounds = parent2->bounds(); 10183 scroll_parent2.data.bounds = parent2->bounds();
10197 scroll_parent2.data.max_scroll_offset_affected_by_page_scale = true; 10184 scroll_parent2.data.max_scroll_offset_affected_by_page_scale = true;
10198 scroll_parent2.data.is_inner_viewport_scroll_layer = true; 10185 scroll_parent2.data.is_inner_viewport_scroll_layer = true;
10199 scroll_parent2.data.user_scrollable_horizontal = true; 10186 scroll_parent2.data.user_scrollable_horizontal = true;
10200 scroll_parent2.data.user_scrollable_vertical = true; 10187 scroll_parent2.data.user_scrollable_vertical = true;
10201 scroll_parent2.data.transform_id = parent2->transform_tree_index(); 10188 scroll_parent2.data.transform_id = parent2->transform_tree_index();
10202 expected_scroll_tree.Insert(scroll_parent2, 1); 10189 expected_scroll_tree.Insert(scroll_parent2, 0);
10203 10190
10204 // The node owned by child6 10191 // The node owned by child6
10205 ScrollNode scroll_child6; 10192 ScrollNode scroll_child6;
10206 scroll_child6.id = 3; 10193 scroll_child6.id = 2;
10207 scroll_child6.owner_id = child6->id(); 10194 scroll_child6.owner_id = child6->id();
10208 scroll_child6.data.main_thread_scrolling_reasons = 10195 scroll_child6.data.main_thread_scrolling_reasons =
10209 child6->main_thread_scrolling_reasons(); 10196 child6->main_thread_scrolling_reasons();
10210 scroll_child6.data.should_flatten = true; 10197 scroll_child6.data.should_flatten = true;
10211 scroll_child6.data.user_scrollable_horizontal = true; 10198 scroll_child6.data.user_scrollable_horizontal = true;
10212 scroll_child6.data.user_scrollable_vertical = true; 10199 scroll_child6.data.user_scrollable_vertical = true;
10213 scroll_child6.data.transform_id = child6->transform_tree_index(); 10200 scroll_child6.data.transform_id = child6->transform_tree_index();
10214 expected_scroll_tree.Insert(scroll_child6, 2); 10201 expected_scroll_tree.Insert(scroll_child6, 1);
10215 10202
10216 // The node owned by child7, child7 also owns a transform node 10203 // The node owned by child7, child7 also owns a transform node
10217 ScrollNode scroll_child7; 10204 ScrollNode scroll_child7;
10218 scroll_child7.id = 4; 10205 scroll_child7.id = 3;
10219 scroll_child7.owner_id = child7->id(); 10206 scroll_child7.owner_id = child7->id();
10220 scroll_child7.data.scrollable = true; 10207 scroll_child7.data.scrollable = true;
10221 scroll_child7.data.scroll_clip_layer_bounds = parent3->bounds(); 10208 scroll_child7.data.scroll_clip_layer_bounds = parent3->bounds();
10222 scroll_child7.data.bounds = child7->bounds(); 10209 scroll_child7.data.bounds = child7->bounds();
10223 scroll_child7.data.user_scrollable_horizontal = true; 10210 scroll_child7.data.user_scrollable_horizontal = true;
10224 scroll_child7.data.user_scrollable_vertical = true; 10211 scroll_child7.data.user_scrollable_vertical = true;
10225 scroll_child7.data.transform_id = child7->transform_tree_index(); 10212 scroll_child7.data.transform_id = child7->transform_tree_index();
10226 expected_scroll_tree.Insert(scroll_child7, 1); 10213 expected_scroll_tree.Insert(scroll_child7, 0);
10227 10214
10228 // The node owned by grand_child11, grand_child11 also owns a transform node 10215 // The node owned by grand_child11, grand_child11 also owns a transform node
10229 ScrollNode scroll_grand_child11; 10216 ScrollNode scroll_grand_child11;
10230 scroll_grand_child11.id = 5; 10217 scroll_grand_child11.id = 4;
10231 scroll_grand_child11.owner_id = grand_child11->id(); 10218 scroll_grand_child11.owner_id = grand_child11->id();
10232 scroll_grand_child11.data.scrollable = true; 10219 scroll_grand_child11.data.scrollable = true;
10233 scroll_grand_child11.data.user_scrollable_horizontal = true; 10220 scroll_grand_child11.data.user_scrollable_horizontal = true;
10234 scroll_grand_child11.data.user_scrollable_vertical = true; 10221 scroll_grand_child11.data.user_scrollable_vertical = true;
10235 scroll_grand_child11.data.transform_id = 10222 scroll_grand_child11.data.transform_id =
10236 grand_child11->transform_tree_index(); 10223 grand_child11->transform_tree_index();
10237 expected_scroll_tree.Insert(scroll_grand_child11, 4); 10224 expected_scroll_tree.Insert(scroll_grand_child11, 3);
10238 10225
10239 // The node owned by parent5 10226 // The node owned by parent5
10240 ScrollNode scroll_parent5; 10227 ScrollNode scroll_parent5;
10241 scroll_parent5.id = 8; 10228 scroll_parent5.id = 5;
10242 scroll_parent5.owner_id = parent5->id(); 10229 scroll_parent5.owner_id = parent5->id();
10243 scroll_parent5.data.contains_non_fast_scrollable_region = true; 10230 scroll_parent5.data.contains_non_fast_scrollable_region = true;
10244 scroll_parent5.data.bounds = gfx::Size(10, 10); 10231 scroll_parent5.data.bounds = gfx::Size(10, 10);
10245 scroll_parent5.data.should_flatten = true; 10232 scroll_parent5.data.should_flatten = true;
10246 scroll_parent5.data.user_scrollable_horizontal = true; 10233 scroll_parent5.data.user_scrollable_horizontal = true;
10247 scroll_parent5.data.user_scrollable_vertical = true; 10234 scroll_parent5.data.user_scrollable_vertical = true;
10248 scroll_parent5.data.transform_id = parent5->transform_tree_index(); 10235 scroll_parent5.data.transform_id = parent5->transform_tree_index();
10249 expected_scroll_tree.Insert(scroll_parent5, 1); 10236 expected_scroll_tree.Insert(scroll_parent5, 0);
10250 10237
10251 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); 10238 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0));
10252 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); 10239 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0));
10253 expected_scroll_tree.SetScrollOffset(grand_child11->id(), 10240 expected_scroll_tree.SetScrollOffset(grand_child11->id(),
10254 gfx::ScrollOffset(0, 0)); 10241 gfx::ScrollOffset(0, 0));
10255 expected_scroll_tree.set_needs_update(false); 10242 expected_scroll_tree.set_needs_update(false);
10256 10243
10257 EXPECT_EQ(expected_scroll_tree, scroll_tree); 10244 EXPECT_EQ(expected_scroll_tree, scroll_tree);
10258 10245
10259 // Check other layers' scroll_tree_index 10246 // Check other layers' scroll_tree_index
10260 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); 10247 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index());
10261 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10248 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10262 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10249 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10263 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10250 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10264 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10251 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10265 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10252 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10266 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10253 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10267 } 10254 }
10268 10255
10269 } // namespace 10256 } // namespace
10270 } // namespace cc 10257 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698