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

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 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after
5652 root_layer, root_layer->bounds(), &render_surface_layer_list, 5654 root_layer, root_layer->bounds(), &render_surface_layer_list,
5653 root_layer->layer_tree_impl()->current_render_surface_list_id()); 5655 root_layer->layer_tree_impl()->current_render_surface_list_id());
5654 inputs.can_adjust_raster_scales = true; 5656 inputs.can_adjust_raster_scales = true;
5655 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5657 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5656 5658
5657 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0); 5659 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); 5660 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); 5661 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0);
5660 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); 5662 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0);
5661 5663
5662 // We should have four render surfaces, one for the root, one for the grand 5664 // 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 5665 // copy_layer.
5664 // since it owns a surface, and one for the copy_layer. 5666 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()); 5667 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5667 EXPECT_EQ(copy_grand_parent_layer->id(), 5668 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 5669
5672 // The root render surface should have 2 contributing layers. 5670 // The root render surface should have 2 contributing layers.
5673 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5671 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5674 EXPECT_EQ(root_layer->id(), 5672 EXPECT_EQ(root_layer->id(),
5675 root_layer->render_surface()->layer_list().at(0)->id()); 5673 root_layer->render_surface()->layer_list().at(0)->id());
5676 EXPECT_EQ(copy_grand_parent_layer->id(), 5674 EXPECT_EQ(copy_layer->id(),
5677 root_layer->render_surface()->layer_list().at(1)->id()); 5675 root_layer->render_surface()->layer_list().at(1)->id());
5678 5676
5679 // Nothing actually draws into the copy parent, so only the copy_layer will 5677 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 5678
5685 // The copy_layer's render surface should have two contributing layers. 5679 // The copy_layer's render surface should have two contributing layers.
5686 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); 5680 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size());
5687 EXPECT_EQ(copy_layer->id(), 5681 EXPECT_EQ(copy_layer->id(),
5688 copy_layer->render_surface()->layer_list().at(0)->id()); 5682 copy_layer->render_surface()->layer_list().at(0)->id());
5689 EXPECT_EQ(copy_child_layer->id(), 5683 EXPECT_EQ(copy_child_layer->id(),
5690 copy_layer->render_surface()->layer_list().at(1)->id()); 5684 copy_layer->render_surface()->layer_list().at(1)->id());
5691 5685
5692 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, 5686 // 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. 5687 // 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()); 9992 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
9999 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 9993 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10000 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 9994 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10001 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 9995 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10002 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 9996 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10003 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 9997 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10004 } 9998 }
10005 9999
10006 } // namespace 10000 } // namespace
10007 } // namespace cc 10001 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698