| 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 5069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5080 | 5080 |
| 5081 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, | 5081 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, |
| 5082 0.0f, 1.0f, false); | 5082 0.0f, 1.0f, false); |
| 5083 | 5083 |
| 5084 RenderSurfaceList render_surface_list; | 5084 RenderSurfaceList render_surface_list; |
| 5085 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5085 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5086 root_layer, root_layer->bounds(), &render_surface_list); | 5086 root_layer, root_layer->bounds(), &render_surface_list); |
| 5087 inputs.can_adjust_raster_scales = true; | 5087 inputs.can_adjust_raster_scales = true; |
| 5088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5089 | 5089 |
| 5090 // We should have one render surface and two layers. The child | 5090 // We should have one render surface and one layer. The child |
| 5091 // layer should be included even though it is transparent. | 5091 // layer should not be included as its transparent. |
| 5092 ASSERT_EQ(1u, render_surface_list.size()); | 5092 ASSERT_EQ(1u, render_surface_list.size()); |
| 5093 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5093 ASSERT_EQ(1, root_layer->GetRenderSurface()->num_contributors()); |
| 5094 | 5094 |
| 5095 // If the root itself is hidden, the child should not be drawn even if it has | 5095 // If the root itself is hidden, the child should not be drawn and should not |
| 5096 // an animating opacity. | 5096 // raster even if it has an animating opacity. |
| 5097 root_layer->test_properties()->opacity = 0.0f; | 5097 root_layer->test_properties()->opacity = 0.0f; |
| 5098 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5098 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5099 RenderSurfaceList render_surface_list2; | 5099 RenderSurfaceList render_surface_list2; |
| 5100 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( | 5100 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( |
| 5101 root_layer, root_layer->bounds(), &render_surface_list2); | 5101 root_layer, root_layer->bounds(), &render_surface_list2); |
| 5102 inputs2.can_adjust_raster_scales = true; | 5102 inputs2.can_adjust_raster_scales = true; |
| 5103 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); | 5103 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); |
| 5104 | 5104 |
| 5105 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); | 5105 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
| 5106 EffectTree& tree = | 5106 EXPECT_FALSE(child_ptr->contributes_to_drawn_render_surface()); |
| 5107 root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5107 EXPECT_FALSE(child_ptr->raster_even_if_not_in_rsll()); |
| 5108 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); | |
| 5109 EXPECT_FALSE(node->is_drawn); | |
| 5110 | 5108 |
| 5111 // A layer should be drawn and it should contribute to drawn surface when | 5109 // The child layer should not be drawn as its transparent but should raster |
| 5112 // it has animating opacity even if it has opacity 0. | 5110 // as its opacity is animating. |
| 5113 root_layer->test_properties()->opacity = 1.0f; | 5111 root_layer->test_properties()->opacity = 1.0f; |
| 5114 child_ptr->test_properties()->opacity = 0.0f; | 5112 child_ptr->test_properties()->opacity = 0.0f; |
| 5115 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5113 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5116 RenderSurfaceList render_surface_list3; | 5114 RenderSurfaceList render_surface_list3; |
| 5117 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( | 5115 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( |
| 5118 root_layer, root_layer->bounds(), &render_surface_list3); | 5116 root_layer, root_layer->bounds(), &render_surface_list3); |
| 5119 inputs3.can_adjust_raster_scales = true; | 5117 inputs3.can_adjust_raster_scales = true; |
| 5120 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); | 5118 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); |
| 5121 | 5119 |
| 5122 child_ptr = root_layer->layer_tree_impl()->LayerById(2); | 5120 child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
| 5123 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5121 EXPECT_FALSE(child_ptr->contributes_to_drawn_render_surface()); |
| 5124 node = tree.Node(child_ptr->effect_tree_index()); | 5122 EXPECT_TRUE(child_ptr->raster_even_if_not_in_rsll()); |
| 5125 EXPECT_TRUE(node->is_drawn); | |
| 5126 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); | |
| 5127 | 5123 |
| 5128 // But if the opacity of the layer remains 0 after activation, it should not | 5124 // The child layer should not be drawn as its transparent but should raster |
| 5129 // be drawn. | 5125 // as its opacity is animating even after activation. |
| 5130 host_impl.ActivateSyncTree(); | 5126 host_impl.ActivateSyncTree(); |
| 5131 LayerImpl* active_root = host_impl.active_tree()->LayerById(root_layer->id()); | 5127 LayerImpl* active_root = host_impl.active_tree()->LayerById(root_layer->id()); |
| 5132 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id()); | 5128 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id()); |
| 5133 | 5129 |
| 5134 EffectTree& active_effect_tree = | |
| 5135 host_impl.active_tree()->property_trees()->effect_tree; | |
| 5136 EXPECT_TRUE(active_effect_tree.needs_update()); | |
| 5137 | |
| 5138 ExecuteCalculateDrawProperties(active_root); | 5130 ExecuteCalculateDrawProperties(active_root); |
| 5139 | 5131 |
| 5140 node = active_effect_tree.Node(active_child->effect_tree_index()); | 5132 EXPECT_FALSE(active_child->contributes_to_drawn_render_surface()); |
| 5141 EXPECT_FALSE(node->is_drawn); | 5133 EXPECT_TRUE(active_child->raster_even_if_not_in_rsll()); |
| 5142 EXPECT_FALSE(active_effect_tree.ContributesToDrawnSurface( | |
| 5143 active_child->effect_tree_index())); | |
| 5144 } | 5134 } |
| 5145 | 5135 |
| 5146 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; | 5136 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; |
| 5147 class LCDTextTest : public LayerTreeHostCommonTestBase, | 5137 class LCDTextTest : public LayerTreeHostCommonTestBase, |
| 5148 public testing::TestWithParam<LCDTextTestParam> { | 5138 public testing::TestWithParam<LCDTextTestParam> { |
| 5149 public: | 5139 public: |
| 5150 LCDTextTest() | 5140 LCDTextTest() |
| 5151 : LayerTreeHostCommonTestBase(LCDTextTestLayerTreeSettings()), | 5141 : LayerTreeHostCommonTestBase(LCDTextTestLayerTreeSettings()), |
| 5152 host_impl_(LCDTextTestLayerTreeSettings(), | 5142 host_impl_(LCDTextTestLayerTreeSettings(), |
| 5153 &task_runner_provider_, | 5143 &task_runner_provider_, |
| (...skipping 5719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10873 | 10863 |
| 10874 // Check child layer draw properties. | 10864 // Check child layer draw properties. |
| 10875 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10865 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10876 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10866 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10877 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10867 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10878 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10868 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10879 } | 10869 } |
| 10880 | 10870 |
| 10881 } // namespace | 10871 } // namespace |
| 10882 } // namespace cc | 10872 } // namespace cc |
| OLD | NEW |