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

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
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/property_tree.h » ('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 <set> 10 #include <set>
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 } 1331 }
1332 // The layer is fully transparent, but has a background filter, so it 1332 // The layer is fully transparent, but has a background filter, so it
1333 // shouldn't be skipped and should be drawn. 1333 // shouldn't be skipped and should be drawn.
1334 ASSERT_TRUE(parent->render_surface()); 1334 ASSERT_TRUE(parent->render_surface());
1335 EXPECT_EQ(1U, parent->render_surface()->layer_list().size()); 1335 EXPECT_EQ(1U, parent->render_surface()->layer_list().size());
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_on_active);
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_on_active);
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 3814 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_on_active);
jaydasika 2016/04/13 00:17:52 This should be the main and pending bool.
5193 5195
5194 // A layer should be drawn and it should contribute to drawn surface when 5196 // A layer should be drawn and it should contribute to drawn surface when
5195 // it has animating opacity even if it has opacity 0. 5197 // it has animating opacity even if it has opacity 0.
5196 root_layer->SetOpacity(1.0f); 5198 root_layer->SetOpacity(1.0f);
5197 child_ptr->SetOpacity(0.0f); 5199 child_ptr->SetOpacity(0.0f);
5198 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5200 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5199 LayerImplList render_surface_layer_list3; 5201 LayerImplList render_surface_layer_list3;
5200 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 5202 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
5201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( 5203 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
5202 root_layer, root_layer->bounds(), &render_surface_layer_list3, 5204 root_layer, root_layer->bounds(), &render_surface_layer_list3,
5203 root_layer->layer_tree_impl()->current_render_surface_list_id()); 5205 root_layer->layer_tree_impl()->current_render_surface_list_id());
5204 inputs3.can_adjust_raster_scales = true; 5206 inputs3.can_adjust_raster_scales = true;
5205 LayerTreeHostCommon::CalculateDrawProperties(&inputs3); 5207 LayerTreeHostCommon::CalculateDrawProperties(&inputs3);
5206 5208
5207 child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5209 child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5208 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; 5210 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree;
5209 node = tree.Node(child_ptr->effect_tree_index()); 5211 node = tree.Node(child_ptr->effect_tree_index());
5210 EXPECT_TRUE(node->data.is_drawn); 5212 EXPECT_TRUE(node->data.is_drawn_on_main_and_pending);
5211 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); 5213 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index()));
5212 } 5214 }
5213 5215
5214 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; 5216 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>;
5215 class LCDTextTest : public LayerTreeHostCommonTestBase, 5217 class LCDTextTest : public LayerTreeHostCommonTestBase,
5216 public testing::TestWithParam<LCDTextTestParam> { 5218 public testing::TestWithParam<LCDTextTestParam> {
5217 public: 5219 public:
5218 LCDTextTest() 5220 LCDTextTest()
5219 : LayerTreeHostCommonTestBase(LayerTreeSettings()), 5221 : LayerTreeHostCommonTestBase(LayerTreeSettings()),
5220 host_impl_(&task_runner_provider_, 5222 host_impl_(&task_runner_provider_,
(...skipping 431 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.
5694 // copy grand child should not be drawn as its hidden even in the copy 5688 // copy grand child should not be drawn as its hidden even in the copy
5695 // request. 5689 // request.
5696 EffectTree tree = 5690 EffectTree tree =
5697 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5691 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5698 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); 5692 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
5699 EXPECT_FALSE(node->data.is_drawn); 5693 EXPECT_FALSE(node->data.is_drawn_on_active);
5700 node = tree.Node(copy_parent_layer->effect_tree_index()); 5694 node = tree.Node(copy_parent_layer->effect_tree_index());
5701 EXPECT_FALSE(node->data.is_drawn); 5695 EXPECT_FALSE(node->data.is_drawn_on_active);
5702 node = tree.Node(copy_layer->effect_tree_index()); 5696 node = tree.Node(copy_layer->effect_tree_index());
5703 EXPECT_TRUE(node->data.is_drawn); 5697 EXPECT_TRUE(node->data.is_drawn_on_active);
5704 node = tree.Node(copy_child_layer->effect_tree_index()); 5698 node = tree.Node(copy_child_layer->effect_tree_index());
5705 EXPECT_TRUE(node->data.is_drawn); 5699 EXPECT_TRUE(node->data.is_drawn_on_active);
5706 node = tree.Node(copy_grand_child_layer->effect_tree_index()); 5700 node = tree.Node(copy_grand_child_layer->effect_tree_index());
5707 EXPECT_FALSE(node->data.is_drawn); 5701 EXPECT_FALSE(node->data.is_drawn_on_active);
5708 5702
5709 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its 5703 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its
5710 // actually hidden. 5704 // actually hidden.
5711 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); 5705 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface());
5712 } 5706 }
5713 5707
5714 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 5708 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
5715 FakeImplTaskRunnerProvider task_runner_provider; 5709 FakeImplTaskRunnerProvider task_runner_provider;
5716 TestSharedBitmapManager shared_bitmap_manager; 5710 TestSharedBitmapManager shared_bitmap_manager;
5717 TestTaskGraphRunner task_graph_runner; 5711 TestTaskGraphRunner task_graph_runner;
(...skipping 4280 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
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698