| OLD | NEW |
| 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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), | 1337 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), |
| 1338 parent->render_surface()->DrawableContentRect()); | 1338 parent->render_surface()->DrawableContentRect()); |
| 1339 EffectTree& effect_tree = | 1339 EffectTree& effect_tree = |
| 1340 parent->layer_tree_impl()->property_trees()->effect_tree; | 1340 parent->layer_tree_impl()->property_trees()->effect_tree; |
| 1341 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); | 1341 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); |
| 1342 EXPECT_TRUE(node->data.is_drawn); | 1342 EXPECT_TRUE(node->data.is_drawn); |
| 1343 | 1343 |
| 1344 // When parent is transparent, the layer should not be drawn. | 1344 // When parent is transparent, the layer should not be drawn. |
| 1345 parent->OnOpacityAnimated(0.f); | 1345 parent->OnOpacityAnimated(0.f); |
| 1346 render_surface1->OnOpacityAnimated(1.f); | 1346 render_surface1->OnOpacityAnimated(1.f); |
| 1347 render_surface1->set_visible_layer_rect(gfx::Rect()); |
| 1347 { | 1348 { |
| 1348 LayerImplList render_surface_layer_list; | 1349 LayerImplList render_surface_layer_list; |
| 1349 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 1350 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 1350 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1351 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1351 parent, parent->bounds(), &render_surface_layer_list, | 1352 parent, parent->bounds(), &render_surface_layer_list, |
| 1352 parent->layer_tree_impl()->current_render_surface_list_id()); | 1353 parent->layer_tree_impl()->current_render_surface_list_id()); |
| 1353 inputs.can_adjust_raster_scales = true; | 1354 inputs.can_adjust_raster_scales = true; |
| 1354 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1355 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 1355 } | 1356 } |
| 1356 | 1357 |
| 1357 node = effect_tree.Node(render_surface1->effect_tree_index()); | 1358 node = effect_tree.Node(render_surface1->effect_tree_index()); |
| 1358 EXPECT_FALSE(node->data.is_drawn); | 1359 EXPECT_FALSE(node->data.is_drawn); |
| 1360 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect()); |
| 1359 } | 1361 } |
| 1360 | 1362 |
| 1361 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { | 1363 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { |
| 1362 LayerImpl* root = root_layer(); | 1364 LayerImpl* root = root_layer(); |
| 1363 LayerImpl* parent = AddChild<LayerImpl>(root); | 1365 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 1364 LayerImpl* child1 = AddChild<LayerImpl>(parent); | 1366 LayerImpl* child1 = AddChild<LayerImpl>(parent); |
| 1365 LayerImpl* child2 = AddChild<LayerImpl>(parent); | 1367 LayerImpl* child2 = AddChild<LayerImpl>(parent); |
| 1366 child1->SetDrawsContent(true); | 1368 child1->SetDrawsContent(true); |
| 1367 child2->SetDrawsContent(true); | 1369 child2->SetDrawsContent(true); |
| 1368 | 1370 |
| (...skipping 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5180 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5182 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5181 LayerImplList render_surface_layer_list2; | 5183 LayerImplList render_surface_layer_list2; |
| 5182 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5184 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5183 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( | 5185 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( |
| 5184 root_layer, root_layer->bounds(), &render_surface_layer_list2, | 5186 root_layer, root_layer->bounds(), &render_surface_layer_list2, |
| 5185 root_layer->layer_tree_impl()->current_render_surface_list_id()); | 5187 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 5186 inputs2.can_adjust_raster_scales = true; | 5188 inputs2.can_adjust_raster_scales = true; |
| 5187 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); | 5189 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); |
| 5188 | 5190 |
| 5189 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); | 5191 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
| 5190 EffectTree tree = | 5192 EffectTree& tree = |
| 5191 root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5193 root_layer->layer_tree_impl()->property_trees()->effect_tree; |
| 5192 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); | 5194 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); |
| 5193 EXPECT_FALSE(node->data.is_drawn); | 5195 EXPECT_FALSE(node->data.is_drawn); |
| 5194 | 5196 |
| 5195 // 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 |
| 5196 // it has animating opacity even if it has opacity 0. | 5198 // it has animating opacity even if it has opacity 0. |
| 5197 root_layer->SetOpacity(1.0f); | 5199 root_layer->SetOpacity(1.0f); |
| 5198 child_ptr->SetOpacity(0.0f); | 5200 child_ptr->SetOpacity(0.0f); |
| 5199 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5201 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5200 LayerImplList render_surface_layer_list3; | 5202 LayerImplList render_surface_layer_list3; |
| 5201 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5203 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5202 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( | 5204 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( |
| 5203 root_layer, root_layer->bounds(), &render_surface_layer_list3, | 5205 root_layer, root_layer->bounds(), &render_surface_layer_list3, |
| 5204 root_layer->layer_tree_impl()->current_render_surface_list_id()); | 5206 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 5205 inputs3.can_adjust_raster_scales = true; | 5207 inputs3.can_adjust_raster_scales = true; |
| 5206 LayerTreeHostCommon::CalculateDrawProperties(&inputs3); | 5208 LayerTreeHostCommon::CalculateDrawProperties(&inputs3); |
| 5207 | 5209 |
| 5208 child_ptr = root_layer->layer_tree_impl()->LayerById(2); | 5210 child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
| 5209 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5211 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; |
| 5210 node = tree.Node(child_ptr->effect_tree_index()); | 5212 node = tree.Node(child_ptr->effect_tree_index()); |
| 5211 EXPECT_TRUE(node->data.is_drawn); | 5213 EXPECT_TRUE(node->data.is_drawn); |
| 5212 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); | 5214 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); |
| 5215 |
| 5216 // But if the opacity of the layer remains 0 after activation, it should not |
| 5217 // be drawn. |
| 5218 host_impl.ActivateSyncTree(); |
| 5219 LayerImpl* active_root = host_impl.active_tree()->root_layer(); |
| 5220 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id()); |
| 5221 |
| 5222 EffectTree& active_effect_tree = |
| 5223 host_impl.active_tree()->property_trees()->effect_tree; |
| 5224 EXPECT_TRUE(active_effect_tree.needs_update()); |
| 5225 |
| 5226 ExecuteCalculateDrawProperties(active_root); |
| 5227 |
| 5228 node = active_effect_tree.Node(active_child->effect_tree_index()); |
| 5229 EXPECT_FALSE(node->data.is_drawn); |
| 5230 EXPECT_FALSE(active_effect_tree.ContributesToDrawnSurface( |
| 5231 active_child->effect_tree_index())); |
| 5213 } | 5232 } |
| 5214 | 5233 |
| 5215 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; | 5234 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; |
| 5216 class LCDTextTest : public LayerTreeHostCommonTestBase, | 5235 class LCDTextTest : public LayerTreeHostCommonTestBase, |
| 5217 public testing::TestWithParam<LCDTextTestParam> { | 5236 public testing::TestWithParam<LCDTextTestParam> { |
| 5218 public: | 5237 public: |
| 5219 LCDTextTest() | 5238 LCDTextTest() |
| 5220 : LayerTreeHostCommonTestBase(LayerTreeSettings()), | 5239 : LayerTreeHostCommonTestBase(LayerTreeSettings()), |
| 5221 host_impl_(&task_runner_provider_, | 5240 host_impl_(&task_runner_provider_, |
| 5222 &shared_bitmap_manager_, | 5241 &shared_bitmap_manager_, |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5674 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); | 5693 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
| 5675 EXPECT_EQ(root_layer->id(), | 5694 EXPECT_EQ(root_layer->id(), |
| 5676 root_layer->render_surface()->layer_list().at(0)->id()); | 5695 root_layer->render_surface()->layer_list().at(0)->id()); |
| 5677 EXPECT_EQ(copy_grand_parent_layer->id(), | 5696 EXPECT_EQ(copy_grand_parent_layer->id(), |
| 5678 root_layer->render_surface()->layer_list().at(1)->id()); | 5697 root_layer->render_surface()->layer_list().at(1)->id()); |
| 5679 | 5698 |
| 5680 // Nothing actually draws into the copy parent, so only the copy_layer will | 5699 // Nothing actually draws into the copy parent, so only the copy_layer will |
| 5681 // appear in its list, since it needs to be drawn for the copy request. | 5700 // appear in its list, since it needs to be drawn for the copy request. |
| 5682 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); | 5701 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
| 5683 EXPECT_EQ(copy_layer->id(), | 5702 EXPECT_EQ(copy_layer->id(), |
| 5684 copy_layer->render_surface()->layer_list().at(0)->id()); | 5703 copy_parent_layer->render_surface()->layer_list().at(0)->id()); |
| 5685 | 5704 |
| 5686 // The copy_layer's render surface should have two contributing layers. | 5705 // The copy_layer's render surface should have two contributing layers. |
| 5687 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5706 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
| 5688 EXPECT_EQ(copy_layer->id(), | 5707 EXPECT_EQ(copy_layer->id(), |
| 5689 copy_layer->render_surface()->layer_list().at(0)->id()); | 5708 copy_layer->render_surface()->layer_list().at(0)->id()); |
| 5690 EXPECT_EQ(copy_child_layer->id(), | 5709 EXPECT_EQ(copy_child_layer->id(), |
| 5691 copy_layer->render_surface()->layer_list().at(1)->id()); | 5710 copy_layer->render_surface()->layer_list().at(1)->id()); |
| 5692 | 5711 |
| 5693 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | 5712 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, |
| 5694 // but the copy_layer and copy_child should be drawn for the copy request. | 5713 // 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 Loading... |
| 9999 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10018 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10000 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10019 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10001 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10020 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10002 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10021 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10003 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10022 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10004 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10023 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10005 } | 10024 } |
| 10006 | 10025 |
| 10007 } // namespace | 10026 } // namespace |
| 10008 } // namespace cc | 10027 } // namespace cc |
| OLD | NEW |