| 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 <set> | 10 #include <set> |
| (...skipping 5241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5252 // Add opacity animation. | 5252 // Add opacity animation. |
| 5253 scoped_refptr<AnimationTimeline> timeline = | 5253 scoped_refptr<AnimationTimeline> timeline = |
| 5254 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5254 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 5255 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5255 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 5256 | 5256 |
| 5257 AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 1.0f, | 5257 AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 1.0f, |
| 5258 false); | 5258 false); |
| 5259 | 5259 |
| 5260 root->AddChild(std::move(child)); | 5260 root->AddChild(std::move(child)); |
| 5261 root->SetHasRenderSurface(true); | 5261 root->SetHasRenderSurface(true); |
| 5262 LayerImpl* root_layer = root.get(); |
| 5263 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 5262 | 5264 |
| 5263 LayerImplList render_surface_layer_list; | 5265 LayerImplList render_surface_layer_list; |
| 5264 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5266 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5265 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5267 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5266 root.get(), root->bounds(), &render_surface_layer_list, | 5268 root_layer, root_layer->bounds(), &render_surface_layer_list, |
| 5267 root->layer_tree_impl()->current_render_surface_list_id()); | 5269 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 5268 inputs.can_adjust_raster_scales = true; | 5270 inputs.can_adjust_raster_scales = true; |
| 5269 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5271 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 5270 | 5272 |
| 5271 // We should have one render surface and two layers. The child | 5273 // We should have one render surface and two layers. The child |
| 5272 // layer should be included even though it is transparent. | 5274 // layer should be included even though it is transparent. |
| 5273 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5275 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5274 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5276 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
| 5275 | 5277 |
| 5276 // If the root itself is hidden, the child should not be drawn even if it has | 5278 // If the root itself is hidden, the child should not be drawn even if it has |
| 5277 // an animating opacity. | 5279 // an animating opacity. |
| 5278 root->SetOpacity(0.0f); | 5280 root_layer->SetOpacity(0.0f); |
| 5279 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5281 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5280 LayerImplList render_surface_layer_list2; | 5282 LayerImplList render_surface_layer_list2; |
| 5281 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5283 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5282 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( | 5284 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( |
| 5283 root.get(), root->bounds(), &render_surface_layer_list2, | 5285 root_layer, root_layer->bounds(), &render_surface_layer_list2, |
| 5284 root->layer_tree_impl()->current_render_surface_list_id()); | 5286 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 5285 inputs2.can_adjust_raster_scales = true; | 5287 inputs2.can_adjust_raster_scales = true; |
| 5286 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); | 5288 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); |
| 5287 | 5289 |
| 5288 LayerImpl* child_ptr = root->layer_tree_impl()->LayerById(2); | 5290 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
| 5289 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; | 5291 EffectTree tree = |
| 5292 root_layer->layer_tree_impl()->property_trees()->effect_tree; |
| 5290 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); | 5293 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); |
| 5291 EXPECT_FALSE(node->data.is_drawn); | 5294 EXPECT_FALSE(node->data.is_drawn); |
| 5292 | 5295 |
| 5293 // A layer should be drawn and it should contribute to drawn surface when | 5296 // A layer should be drawn and it should contribute to drawn surface when |
| 5294 // it has animating opacity even if it has opacity 0. | 5297 // it has animating opacity even if it has opacity 0. |
| 5295 root->SetOpacity(1.0f); | 5298 root_layer->SetOpacity(1.0f); |
| 5296 child_ptr->SetOpacity(0.0f); | 5299 child_ptr->SetOpacity(0.0f); |
| 5297 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5300 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5298 LayerImplList render_surface_layer_list3; | 5301 LayerImplList render_surface_layer_list3; |
| 5299 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5302 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( | 5303 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( |
| 5301 root.get(), root->bounds(), &render_surface_layer_list3, | 5304 root_layer, root_layer->bounds(), &render_surface_layer_list3, |
| 5302 root->layer_tree_impl()->current_render_surface_list_id()); | 5305 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 5303 inputs3.can_adjust_raster_scales = true; | 5306 inputs3.can_adjust_raster_scales = true; |
| 5304 LayerTreeHostCommon::CalculateDrawProperties(&inputs3); | 5307 LayerTreeHostCommon::CalculateDrawProperties(&inputs3); |
| 5305 | 5308 |
| 5306 child_ptr = root->layer_tree_impl()->LayerById(2); | 5309 child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
| 5307 tree = root->layer_tree_impl()->property_trees()->effect_tree; | 5310 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; |
| 5308 node = tree.Node(child_ptr->effect_tree_index()); | 5311 node = tree.Node(child_ptr->effect_tree_index()); |
| 5309 EXPECT_TRUE(node->data.is_drawn); | 5312 EXPECT_TRUE(node->data.is_drawn); |
| 5310 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); | 5313 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); |
| 5311 } | 5314 } |
| 5312 | 5315 |
| 5313 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; | 5316 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; |
| 5314 class LCDTextTest : public LayerTreeHostCommonTestBase, | 5317 class LCDTextTest : public LayerTreeHostCommonTestBase, |
| 5315 public testing::TestWithParam<LCDTextTestParam> { | 5318 public testing::TestWithParam<LCDTextTestParam> { |
| 5316 public: | 5319 public: |
| 5317 LCDTextTest() | 5320 LCDTextTest() |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5544 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | 5547 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
| 5545 FakeImplTaskRunnerProvider task_runner_provider; | 5548 FakeImplTaskRunnerProvider task_runner_provider; |
| 5546 TestSharedBitmapManager shared_bitmap_manager; | 5549 TestSharedBitmapManager shared_bitmap_manager; |
| 5547 TestTaskGraphRunner task_graph_runner; | 5550 TestTaskGraphRunner task_graph_runner; |
| 5548 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5551 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5549 &task_graph_runner); | 5552 &task_graph_runner); |
| 5550 host_impl.CreatePendingTree(); | 5553 host_impl.CreatePendingTree(); |
| 5551 const gfx::Transform identity_matrix; | 5554 const gfx::Transform identity_matrix; |
| 5552 | 5555 |
| 5553 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 5556 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
| 5557 LayerImpl* root_layer = root.get(); |
| 5554 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5558 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5555 gfx::PointF(), gfx::Size(50, 50), true, false, | 5559 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5556 false); | 5560 false); |
| 5557 root->SetDrawsContent(true); | 5561 root->SetDrawsContent(true); |
| 5558 | 5562 |
| 5559 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 5563 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5560 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5564 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 5561 gfx::PointF(), gfx::Size(40, 40), true, false, | 5565 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5562 false); | 5566 false); |
| 5563 child->SetDrawsContent(true); | 5567 child->SetDrawsContent(true); |
| 5564 | 5568 |
| 5565 scoped_ptr<LayerImpl> grand_child = | 5569 scoped_ptr<LayerImpl> grand_child = |
| 5566 LayerImpl::Create(host_impl.pending_tree(), 3); | 5570 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 5567 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5571 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5568 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5572 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5569 true, false, false); | 5573 true, false, false); |
| 5570 grand_child->SetDrawsContent(true); | 5574 grand_child->SetDrawsContent(true); |
| 5571 grand_child->SetHideLayerAndSubtree(true); | 5575 grand_child->SetHideLayerAndSubtree(true); |
| 5572 | 5576 |
| 5573 child->AddChild(std::move(grand_child)); | 5577 child->AddChild(std::move(grand_child)); |
| 5574 root->AddChild(std::move(child)); | 5578 root->AddChild(std::move(child)); |
| 5575 root->SetHasRenderSurface(true); | 5579 root->SetHasRenderSurface(true); |
| 5580 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 5576 | 5581 |
| 5577 LayerImplList render_surface_layer_list; | 5582 LayerImplList render_surface_layer_list; |
| 5578 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5583 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5579 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5584 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5580 root.get(), root->bounds(), &render_surface_layer_list, | 5585 root_layer, root_layer->bounds(), &render_surface_layer_list, |
| 5581 root->layer_tree_impl()->current_render_surface_list_id()); | 5586 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 5582 inputs.can_adjust_raster_scales = true; | 5587 inputs.can_adjust_raster_scales = true; |
| 5583 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5588 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 5584 | 5589 |
| 5585 // We should have one render surface and two layers. The grand child has | 5590 // We should have one render surface and two layers. The grand child has |
| 5586 // hidden itself. | 5591 // hidden itself. |
| 5587 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5592 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5588 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5593 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
| 5589 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); | 5594 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id()); |
| 5590 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id()); | 5595 EXPECT_EQ(2, root_layer->render_surface()->layer_list().at(1)->id()); |
| 5591 } | 5596 } |
| 5592 | 5597 |
| 5593 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 5598 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 5594 FakeImplTaskRunnerProvider task_runner_provider; | 5599 FakeImplTaskRunnerProvider task_runner_provider; |
| 5595 TestSharedBitmapManager shared_bitmap_manager; | 5600 TestSharedBitmapManager shared_bitmap_manager; |
| 5596 TestTaskGraphRunner task_graph_runner; | 5601 TestTaskGraphRunner task_graph_runner; |
| 5597 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5602 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5598 &task_graph_runner); | 5603 &task_graph_runner); |
| 5599 host_impl.CreatePendingTree(); | 5604 host_impl.CreatePendingTree(); |
| 5600 const gfx::Transform identity_matrix; | 5605 const gfx::Transform identity_matrix; |
| (...skipping 4398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9999 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10004 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10000 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10005 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10001 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10006 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10002 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10007 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10003 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10008 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10004 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10009 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10005 } | 10010 } |
| 10006 | 10011 |
| 10007 } // namespace | 10012 } // namespace |
| 10008 } // namespace cc | 10013 } // namespace cc |
| OLD | NEW |