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

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

Issue 2894953003: Revert of cc : Don't draw animating layers which are transparent but raster them. (Closed)
Patch Set: rebase Created 3 years, 7 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/layer_tree_impl.cc » ('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 <memory> 10 #include <memory>
(...skipping 4408 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 4419
4420 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, 4420 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0,
4421 0.0f, 1.0f, false); 4421 0.0f, 1.0f, false);
4422 4422
4423 RenderSurfaceList render_surface_list; 4423 RenderSurfaceList render_surface_list;
4424 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 4424 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
4425 root_layer, root_layer->bounds(), &render_surface_list); 4425 root_layer, root_layer->bounds(), &render_surface_list);
4426 inputs.can_adjust_raster_scales = true; 4426 inputs.can_adjust_raster_scales = true;
4427 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 4427 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
4428 4428
4429 // We should have one render surface and one layer. The child 4429 // We should have one render surface and two layers. The child
4430 // layer should not be included as its transparent. 4430 // layer should be included even though it is transparent.
4431 ASSERT_EQ(1u, render_surface_list.size()); 4431 ASSERT_EQ(1u, render_surface_list.size());
4432 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); 4432 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors());
4433 4433
4434 // If the root itself is hidden, the child should not be drawn and should not 4434 // If the root itself is hidden, the child should not be drawn even if it has
4435 // raster even if it has an animating opacity. 4435 // an animating opacity.
4436 root_layer->test_properties()->opacity = 0.0f; 4436 root_layer->test_properties()->opacity = 0.0f;
4437 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 4437 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
4438 RenderSurfaceList render_surface_list2; 4438 RenderSurfaceList render_surface_list2;
4439 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( 4439 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2(
4440 root_layer, root_layer->bounds(), &render_surface_list2); 4440 root_layer, root_layer->bounds(), &render_surface_list2);
4441 inputs2.can_adjust_raster_scales = true; 4441 inputs2.can_adjust_raster_scales = true;
4442 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); 4442 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2);
4443 4443
4444 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); 4444 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2);
4445 EXPECT_FALSE(child_ptr->contributes_to_drawn_render_surface()); 4445 EffectTree& tree =
4446 EXPECT_FALSE(child_ptr->raster_even_if_not_in_rsll()); 4446 root_layer->layer_tree_impl()->property_trees()->effect_tree;
4447 EffectNode* node = tree.Node(child_ptr->effect_tree_index());
4448 EXPECT_FALSE(node->is_drawn);
4447 4449
4448 // The child layer should not be drawn as its transparent but should raster 4450 // A layer should be drawn and it should contribute to drawn surface when
4449 // as its opacity is animating. 4451 // it has animating opacity even if it has opacity 0.
4450 root_layer->test_properties()->opacity = 1.0f; 4452 root_layer->test_properties()->opacity = 1.0f;
4451 child_ptr->test_properties()->opacity = 0.0f; 4453 child_ptr->test_properties()->opacity = 0.0f;
4452 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 4454 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
4453 RenderSurfaceList render_surface_list3; 4455 RenderSurfaceList render_surface_list3;
4454 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( 4456 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
4455 root_layer, root_layer->bounds(), &render_surface_list3); 4457 root_layer, root_layer->bounds(), &render_surface_list3);
4456 inputs3.can_adjust_raster_scales = true; 4458 inputs3.can_adjust_raster_scales = true;
4457 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); 4459 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3);
4458 4460
4459 child_ptr = root_layer->layer_tree_impl()->LayerById(2); 4461 child_ptr = root_layer->layer_tree_impl()->LayerById(2);
4460 EXPECT_FALSE(child_ptr->contributes_to_drawn_render_surface()); 4462 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree;
4461 EXPECT_TRUE(child_ptr->raster_even_if_not_in_rsll()); 4463 node = tree.Node(child_ptr->effect_tree_index());
4464 EXPECT_TRUE(node->is_drawn);
4465 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index()));
4462 4466
4463 // The child layer should not be drawn as its transparent but should raster 4467 // But if the opacity of the layer remains 0 after activation, it should not
4464 // as its opacity is animating even after activation. 4468 // be drawn.
4465 host_impl.ActivateSyncTree(); 4469 host_impl.ActivateSyncTree();
4466 LayerImpl* active_root = host_impl.active_tree()->LayerById(root_layer->id()); 4470 LayerImpl* active_root = host_impl.active_tree()->LayerById(root_layer->id());
4467 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id()); 4471 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id());
4468 4472
4473 EffectTree& active_effect_tree =
4474 host_impl.active_tree()->property_trees()->effect_tree;
4475 EXPECT_TRUE(active_effect_tree.needs_update());
4476
4469 ExecuteCalculateDrawProperties(active_root); 4477 ExecuteCalculateDrawProperties(active_root);
4470 4478
4471 EXPECT_FALSE(active_child->contributes_to_drawn_render_surface()); 4479 node = active_effect_tree.Node(active_child->effect_tree_index());
4472 EXPECT_TRUE(active_child->raster_even_if_not_in_rsll()); 4480 EXPECT_FALSE(node->is_drawn);
4481 EXPECT_FALSE(active_effect_tree.ContributesToDrawnSurface(
4482 active_child->effect_tree_index()));
4473 } 4483 }
4474 4484
4475 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; 4485 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>;
4476 class LCDTextTest : public LayerTreeHostCommonTestBase, 4486 class LCDTextTest : public LayerTreeHostCommonTestBase,
4477 public testing::TestWithParam<LCDTextTestParam> { 4487 public testing::TestWithParam<LCDTextTestParam> {
4478 public: 4488 public:
4479 LCDTextTest() 4489 LCDTextTest()
4480 : LayerTreeHostCommonTestBase(LCDTextTestLayerTreeSettings()), 4490 : LayerTreeHostCommonTestBase(LCDTextTestLayerTreeSettings()),
4481 host_impl_(LCDTextTestLayerTreeSettings(), 4491 host_impl_(LCDTextTestLayerTreeSettings(),
4482 &task_runner_provider_, 4492 &task_runner_provider_,
(...skipping 5671 matching lines...) Expand 10 before | Expand all | Expand 10 after
10154 10164
10155 // Check child layer draw properties. 10165 // Check child layer draw properties.
10156 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10166 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10157 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10167 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10158 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10168 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10159 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10169 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10160 } 10170 }
10161 10171
10162 } // namespace 10172 } // namespace
10163 } // namespace cc 10173 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698