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

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

Issue 1884613005: cc : Simplify layer skipping logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <set> 10 #include <set>
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), 1336 EXPECT_EQ(gfx::RectF(0, 0, 10, 10),
1337 parent->render_surface()->DrawableContentRect()); 1337 parent->render_surface()->DrawableContentRect());
1338 EffectTree& effect_tree = 1338 EffectTree& effect_tree =
1339 parent->layer_tree_impl()->property_trees()->effect_tree; 1339 parent->layer_tree_impl()->property_trees()->effect_tree;
1340 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); 1340 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index());
1341 EXPECT_TRUE(node->data.is_drawn); 1341 EXPECT_TRUE(node->data.is_drawn);
1342 1342
1343 // When parent is transparent, the layer should not be drawn. 1343 // When parent is transparent, the layer should not be drawn.
1344 parent->OnOpacityAnimated(0.f); 1344 parent->OnOpacityAnimated(0.f);
1345 render_surface1->OnOpacityAnimated(1.f); 1345 render_surface1->OnOpacityAnimated(1.f);
1346 render_surface1->set_visible_layer_rect(gfx::Rect());
1346 { 1347 {
1347 LayerImplList render_surface_layer_list; 1348 LayerImplList render_surface_layer_list;
1348 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 1349 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
1349 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1350 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1350 parent, parent->bounds(), &render_surface_layer_list, 1351 parent, parent->bounds(), &render_surface_layer_list,
1351 parent->layer_tree_impl()->current_render_surface_list_id()); 1352 parent->layer_tree_impl()->current_render_surface_list_id());
1352 inputs.can_adjust_raster_scales = true; 1353 inputs.can_adjust_raster_scales = true;
1353 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1354 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1354 } 1355 }
1355 1356
1356 node = effect_tree.Node(render_surface1->effect_tree_index()); 1357 node = effect_tree.Node(render_surface1->effect_tree_index());
1357 EXPECT_FALSE(node->data.is_drawn); 1358 EXPECT_FALSE(node->data.is_drawn);
1359 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect());
1358 } 1360 }
1359 1361
1360 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { 1362 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) {
1361 LayerImpl* root = root_layer(); 1363 LayerImpl* root = root_layer();
1362 LayerImpl* parent = AddChild<LayerImpl>(root); 1364 LayerImpl* parent = AddChild<LayerImpl>(root);
1363 LayerImpl* child1 = AddChild<LayerImpl>(parent); 1365 LayerImpl* child1 = AddChild<LayerImpl>(parent);
1364 LayerImpl* child2 = AddChild<LayerImpl>(parent); 1366 LayerImpl* child2 = AddChild<LayerImpl>(parent);
1365 child1->SetDrawsContent(true); 1367 child1->SetDrawsContent(true);
1366 child2->SetDrawsContent(true); 1368 child2->SetDrawsContent(true);
1367 1369
(...skipping 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after
5179 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5181 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5180 LayerImplList render_surface_layer_list2; 5182 LayerImplList render_surface_layer_list2;
5181 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 5183 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
5182 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( 5184 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2(
5183 root_layer, root_layer->bounds(), &render_surface_layer_list2, 5185 root_layer, root_layer->bounds(), &render_surface_layer_list2,
5184 root_layer->layer_tree_impl()->current_render_surface_list_id()); 5186 root_layer->layer_tree_impl()->current_render_surface_list_id());
5185 inputs2.can_adjust_raster_scales = true; 5187 inputs2.can_adjust_raster_scales = true;
5186 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); 5188 LayerTreeHostCommon::CalculateDrawProperties(&inputs2);
5187 5189
5188 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5190 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5189 EffectTree tree = 5191 EffectTree& tree =
5190 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5192 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5191 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); 5193 EffectNode* node = tree.Node(child_ptr->effect_tree_index());
5192 EXPECT_FALSE(node->data.is_drawn); 5194 EXPECT_FALSE(node->data.is_drawn);
5195 EXPECT_TRUE(tree.needs_update());
5193 5196
5194 // A layer should be drawn and it should contribute to drawn surface when 5197 // A layer should be drawn and it should contribute to drawn surface when
5195 // it has animating opacity even if it has opacity 0. 5198 // it has animating opacity even if it has opacity 0.
5196 root_layer->SetOpacity(1.0f); 5199 root_layer->SetOpacity(1.0f);
5197 child_ptr->SetOpacity(0.0f); 5200 child_ptr->SetOpacity(0.0f);
5198 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5201 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5199 LayerImplList render_surface_layer_list3; 5202 LayerImplList render_surface_layer_list3;
5200 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 5203 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
5201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( 5204 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
5202 root_layer, root_layer->bounds(), &render_surface_layer_list3, 5205 root_layer, root_layer->bounds(), &render_surface_layer_list3,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
5652 root_layer, root_layer->bounds(), &render_surface_layer_list, 5655 root_layer, root_layer->bounds(), &render_surface_layer_list,
5653 root_layer->layer_tree_impl()->current_render_surface_list_id()); 5656 root_layer->layer_tree_impl()->current_render_surface_list_id());
5654 inputs.can_adjust_raster_scales = true; 5657 inputs.can_adjust_raster_scales = true;
5655 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5658 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5656 5659
5657 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0); 5660 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0);
5658 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); 5661 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0);
5659 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); 5662 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0);
5660 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); 5663 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0);
5661 5664
5662 // We should have four render surfaces, one for the root, one for the grand 5665 // We should have two render surfaces, one for the root and one for the
5663 // parent since it has opacity and two drawing descendants, one for the parent 5666 // copy_layer.
5664 // since it owns a surface, and one for the copy_layer. 5667 ASSERT_EQ(2u, render_surface_layer_list.size());
5665 ASSERT_EQ(4u, render_surface_layer_list.size());
5666 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5668 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5667 EXPECT_EQ(copy_grand_parent_layer->id(), 5669 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(1)->id());
5668 render_surface_layer_list.at(1)->id());
5669 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
5670 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
5671 5670
5672 // The root render surface should have 2 contributing layers. 5671 // The root render surface should have 2 contributing layers.
5673 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5672 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5674 EXPECT_EQ(root_layer->id(), 5673 EXPECT_EQ(root_layer->id(),
5675 root_layer->render_surface()->layer_list().at(0)->id()); 5674 root_layer->render_surface()->layer_list().at(0)->id());
5676 EXPECT_EQ(copy_grand_parent_layer->id(), 5675 EXPECT_EQ(copy_layer->id(),
5677 root_layer->render_surface()->layer_list().at(1)->id()); 5676 root_layer->render_surface()->layer_list().at(1)->id());
5678 5677
5679 // Nothing actually draws into the copy parent, so only the copy_layer will 5678 ASSERT_EQ(0u, copy_parent_layer->render_surface()->layer_list().size());
5680 // appear in its list, since it needs to be drawn for the copy request.
5681 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size());
5682 EXPECT_EQ(copy_layer->id(),
5683 copy_layer->render_surface()->layer_list().at(0)->id());
5684 5679
5685 // The copy_layer's render surface should have two contributing layers. 5680 // The copy_layer's render surface should have two contributing layers.
5686 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); 5681 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size());
5687 EXPECT_EQ(copy_layer->id(), 5682 EXPECT_EQ(copy_layer->id(),
5688 copy_layer->render_surface()->layer_list().at(0)->id()); 5683 copy_layer->render_surface()->layer_list().at(0)->id());
5689 EXPECT_EQ(copy_child_layer->id(), 5684 EXPECT_EQ(copy_child_layer->id(),
5690 copy_layer->render_surface()->layer_list().at(1)->id()); 5685 copy_layer->render_surface()->layer_list().at(1)->id());
5691 5686
5692 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, 5687 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
5693 // but the copy_layer and copy_child should be drawn for the copy request. 5688 // but the copy_layer and copy_child should be drawn for the copy request.
(...skipping 4304 matching lines...) Expand 10 before | Expand all | Expand 10 after
9998 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 9993 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
9999 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 9994 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10000 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 9995 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10001 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 9996 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10002 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 9997 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10003 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 9998 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10004 } 9999 }
10005 10000
10006 } // namespace 10001 } // namespace
10007 } // namespace cc 10002 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698