Chromium Code Reviews| 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 5385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5396 RenderSurfaceList render_surface_list; | 5396 RenderSurfaceList render_surface_list; |
| 5397 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5397 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5398 root_layer, root_layer->bounds(), &render_surface_list); | 5398 root_layer, root_layer->bounds(), &render_surface_list); |
| 5399 inputs.can_adjust_raster_scales = true; | 5399 inputs.can_adjust_raster_scales = true; |
| 5400 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5400 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5401 | 5401 |
| 5402 // We should have one render surface and two layers. The grand child has | 5402 // We should have one render surface and two layers. The grand child has |
| 5403 // hidden itself. | 5403 // hidden itself. |
| 5404 ASSERT_EQ(1u, render_surface_list.size()); | 5404 ASSERT_EQ(1u, render_surface_list.size()); |
| 5405 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5405 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); |
| 5406 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member()); | 5406 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5407 EXPECT_TRUE(child_layer->is_drawn_render_surface_layer_list_member()); | 5407 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); |
| 5408 EXPECT_FALSE(grand_child_layer->is_drawn_render_surface_layer_list_member()); | 5408 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); |
| 5409 } | 5409 } |
| 5410 | 5410 |
| 5411 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 5411 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 5412 FakeImplTaskRunnerProvider task_runner_provider; | 5412 FakeImplTaskRunnerProvider task_runner_provider; |
| 5413 TestTaskGraphRunner task_graph_runner; | 5413 TestTaskGraphRunner task_graph_runner; |
| 5414 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 5414 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 5415 host_impl.CreatePendingTree(); | 5415 host_impl.CreatePendingTree(); |
| 5416 | 5416 |
| 5417 std::unique_ptr<LayerImpl> root = | 5417 std::unique_ptr<LayerImpl> root = |
| 5418 LayerImpl::Create(host_impl.pending_tree(), 1); | 5418 LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 5440 RenderSurfaceList render_surface_list; | 5440 RenderSurfaceList render_surface_list; |
| 5441 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5441 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5442 root_layer, root_layer->bounds(), &render_surface_list); | 5442 root_layer, root_layer->bounds(), &render_surface_list); |
| 5443 inputs.can_adjust_raster_scales = true; | 5443 inputs.can_adjust_raster_scales = true; |
| 5444 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5444 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5445 | 5445 |
| 5446 // We should have one render surface and one layer. The child has | 5446 // We should have one render surface and one layer. The child has |
| 5447 // hidden itself and the grand child. | 5447 // hidden itself and the grand child. |
| 5448 ASSERT_EQ(1u, render_surface_list.size()); | 5448 ASSERT_EQ(1u, render_surface_list.size()); |
| 5449 ASSERT_EQ(1, root_layer->GetRenderSurface()->num_contributors()); | 5449 ASSERT_EQ(1, root_layer->GetRenderSurface()->num_contributors()); |
| 5450 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member()); | 5450 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5451 EXPECT_FALSE(child_layer->is_drawn_render_surface_layer_list_member()); | 5451 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); |
| 5452 EXPECT_FALSE(grand_child_layer->is_drawn_render_surface_layer_list_member()); | 5452 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); |
| 5453 } | 5453 } |
| 5454 | 5454 |
| 5455 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 5455 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 5456 | 5456 |
| 5457 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 5457 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
| 5458 FakeImplTaskRunnerProvider task_runner_provider; | 5458 FakeImplTaskRunnerProvider task_runner_provider; |
| 5459 TestTaskGraphRunner task_graph_runner; | 5459 TestTaskGraphRunner task_graph_runner; |
| 5460 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 5460 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 5461 host_impl.CreatePendingTree(); | 5461 host_impl.CreatePendingTree(); |
| 5462 | 5462 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5550 // parent since it has opacity and two drawing descendants, one for the parent | 5550 // parent since it has opacity and two drawing descendants, one for the parent |
| 5551 // since it owns a surface, and one for the copy_layer. | 5551 // since it owns a surface, and one for the copy_layer. |
| 5552 ASSERT_EQ(4u, render_surface_list.size()); | 5552 ASSERT_EQ(4u, render_surface_list.size()); |
| 5553 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 5553 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
| 5554 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); | 5554 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); |
| 5555 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); | 5555 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); |
| 5556 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); | 5556 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); |
| 5557 | 5557 |
| 5558 // The root render surface should have 2 contributing layers. | 5558 // The root render surface should have 2 contributing layers. |
| 5559 EXPECT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5559 EXPECT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); |
| 5560 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member()); | 5560 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5561 EXPECT_FALSE( | 5561 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); |
| 5562 copy_grand_parent_layer->is_drawn_render_surface_layer_list_member()); | |
| 5563 EXPECT_FALSE(copy_grand_parent_sibling_before_layer | 5562 EXPECT_FALSE(copy_grand_parent_sibling_before_layer |
| 5564 ->is_drawn_render_surface_layer_list_member()); | 5563 ->contributes_to_drawn_render_surface()); |
| 5565 EXPECT_FALSE(copy_grand_parent_sibling_after_layer | 5564 EXPECT_FALSE(copy_grand_parent_sibling_after_layer |
| 5566 ->is_drawn_render_surface_layer_list_member()); | 5565 ->contributes_to_drawn_render_surface()); |
| 5567 | 5566 |
| 5568 // Nothing actually draws into the copy parent, so only the copy_layer will | 5567 // Nothing actually draws into the copy parent, so only the copy_layer will |
| 5569 // appear in its list, since it needs to be drawn for the copy request. | 5568 // appear in its list, since it needs to be drawn for the copy request. |
| 5570 ASSERT_EQ(1, copy_parent_layer->GetRenderSurface()->num_contributors()); | 5569 ASSERT_EQ(1, copy_parent_layer->GetRenderSurface()->num_contributors()); |
| 5571 EXPECT_FALSE(copy_parent_layer->is_drawn_render_surface_layer_list_member()); | 5570 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); |
| 5572 | 5571 |
| 5573 // The copy layer's render surface should have 2 contributing layers. | 5572 // The copy layer's render surface should have 2 contributing layers. |
| 5574 ASSERT_EQ(2, copy_layer->GetRenderSurface()->num_contributors()); | 5573 ASSERT_EQ(2, copy_layer->GetRenderSurface()->num_contributors()); |
| 5575 EXPECT_TRUE(copy_layer->is_drawn_render_surface_layer_list_member()); | 5574 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); |
| 5576 EXPECT_TRUE(copy_child_layer->is_drawn_render_surface_layer_list_member()); | 5575 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); |
| 5577 EXPECT_FALSE( | 5576 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); |
| 5578 copy_grand_child_layer->is_drawn_render_surface_layer_list_member()); | |
| 5579 | 5577 |
| 5580 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | 5578 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, |
| 5581 // but the copy_layer and copy_child should be drawn for the copy request. | 5579 // but the copy_layer and copy_child should be drawn for the copy request. |
| 5582 // copy grand child should not be drawn as its hidden even in the copy | 5580 // copy grand child should not be drawn as its hidden even in the copy |
| 5583 // request. | 5581 // request. |
| 5584 EffectTree& tree = | 5582 EffectTree& tree = |
| 5585 root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5583 root_layer->layer_tree_impl()->property_trees()->effect_tree; |
| 5586 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | 5584 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); |
| 5587 EXPECT_FALSE(node->is_drawn); | 5585 EXPECT_FALSE(node->is_drawn); |
| 5588 node = tree.Node(copy_parent_layer->effect_tree_index()); | 5586 node = tree.Node(copy_parent_layer->effect_tree_index()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5641 inputs.can_adjust_raster_scales = true; | 5639 inputs.can_adjust_raster_scales = true; |
| 5642 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5640 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5643 | 5641 |
| 5644 // We should have two render surface, as the others are clipped out. | 5642 // We should have two render surface, as the others are clipped out. |
| 5645 ASSERT_EQ(2u, render_surface_list.size()); | 5643 ASSERT_EQ(2u, render_surface_list.size()); |
| 5646 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 5644 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
| 5647 | 5645 |
| 5648 // The root render surface should have only 2 contributing layer, since the | 5646 // The root render surface should have only 2 contributing layer, since the |
| 5649 // other layers are clipped away. | 5647 // other layers are clipped away. |
| 5650 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5648 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); |
| 5651 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member()); | 5649 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5652 } | 5650 } |
| 5653 | 5651 |
| 5654 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { | 5652 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
| 5655 LayerImpl* root = root_layer_for_testing(); | 5653 LayerImpl* root = root_layer_for_testing(); |
| 5656 root->SetBounds(gfx::Size(50, 50)); | 5654 root->SetBounds(gfx::Size(50, 50)); |
| 5657 root->SetDrawsContent(true); | 5655 root->SetDrawsContent(true); |
| 5658 root->SetMasksToBounds(true); | 5656 root->SetMasksToBounds(true); |
| 5659 | 5657 |
| 5660 LayerImpl* copy_layer = AddChild<LayerImpl>(root); | 5658 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
| 5661 copy_layer->SetBounds(gfx::Size(100, 100)); | 5659 copy_layer->SetBounds(gfx::Size(100, 100)); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6276 child->SetBounds(gfx::Size(30, 30)); | 6274 child->SetBounds(gfx::Size(30, 30)); |
| 6277 child->test_properties()->double_sided = false; | 6275 child->test_properties()->double_sided = false; |
| 6278 child->test_properties()->should_flatten_transform = false; | 6276 child->test_properties()->should_flatten_transform = false; |
| 6279 grand_child->SetBounds(gfx::Size(20, 20)); | 6277 grand_child->SetBounds(gfx::Size(20, 20)); |
| 6280 grand_child->SetDrawsContent(true); | 6278 grand_child->SetDrawsContent(true); |
| 6281 grand_child->SetUseParentBackfaceVisibility(true); | 6279 grand_child->SetUseParentBackfaceVisibility(true); |
| 6282 grand_child->test_properties()->should_flatten_transform = false; | 6280 grand_child->test_properties()->should_flatten_transform = false; |
| 6283 ExecuteCalculateDrawProperties(root); | 6281 ExecuteCalculateDrawProperties(root); |
| 6284 | 6282 |
| 6285 EXPECT_EQ(1u, render_surface_list_impl()->size()); | 6283 EXPECT_EQ(1u, render_surface_list_impl()->size()); |
| 6286 EXPECT_TRUE(grand_child->is_drawn_render_surface_layer_list_member()); | 6284 EXPECT_TRUE(grand_child->contributes_to_drawn_render_surface()); |
| 6287 | 6285 |
| 6288 // As all layers have identity transform, we shouldn't check for backface | 6286 // As all layers have identity transform, we shouldn't check for backface |
| 6289 // visibility. | 6287 // visibility. |
| 6290 EXPECT_FALSE(root->should_check_backface_visibility()); | 6288 EXPECT_FALSE(root->should_check_backface_visibility()); |
| 6291 EXPECT_FALSE(child->should_check_backface_visibility()); | 6289 EXPECT_FALSE(child->should_check_backface_visibility()); |
| 6292 EXPECT_FALSE(grand_child->should_check_backface_visibility()); | 6290 EXPECT_FALSE(grand_child->should_check_backface_visibility()); |
| 6293 // As there are no 3d rendering contexts, all layers should use their local | 6291 // As there are no 3d rendering contexts, all layers should use their local |
| 6294 // transform for backface visibility. | 6292 // transform for backface visibility. |
| 6295 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); | 6293 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); |
| 6296 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); | 6294 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6616 ExecuteCalculateDrawProperties(root); | 6614 ExecuteCalculateDrawProperties(root); |
| 6617 | 6615 |
| 6618 EXPECT_TRUE(root->GetRenderSurface()); | 6616 EXPECT_TRUE(root->GetRenderSurface()); |
| 6619 | 6617 |
| 6620 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); | 6618 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); |
| 6621 EXPECT_TRUE(scroll_child->is_clipped()); | 6619 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6622 | 6620 |
| 6623 // Despite the fact that we visited the above layers out of order to get the | 6621 // Despite the fact that we visited the above layers out of order to get the |
| 6624 // correct clip, the layer lists should be unaffected. | 6622 // correct clip, the layer lists should be unaffected. |
| 6625 EXPECT_EQ(3, root->GetRenderSurface()->num_contributors()); | 6623 EXPECT_EQ(3, root->GetRenderSurface()->num_contributors()); |
| 6626 EXPECT_TRUE(scroll_child->is_drawn_render_surface_layer_list_member()); | 6624 EXPECT_TRUE(scroll_child->contributes_to_drawn_render_surface()); |
| 6627 EXPECT_TRUE(scroll_parent->is_drawn_render_surface_layer_list_member()); | 6625 EXPECT_TRUE(scroll_parent->contributes_to_drawn_render_surface()); |
| 6628 EXPECT_TRUE(scroll_grandparent->is_drawn_render_surface_layer_list_member()); | 6626 EXPECT_TRUE(scroll_grandparent->contributes_to_drawn_render_surface()); |
| 6629 } | 6627 } |
| 6630 | 6628 |
| 6631 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { | 6629 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { |
| 6632 // Ensures that even if we visit layers out of order, we still produce a | 6630 // Ensures that even if we visit layers out of order, we still produce a |
| 6633 // correctly ordered render surface layer list. | 6631 // correctly ordered render surface layer list. |
| 6634 // + root | 6632 // + root |
| 6635 // + scroll_child | 6633 // + scroll_child |
| 6636 // + scroll_parent_border | 6634 // + scroll_parent_border |
| 6637 // + scroll_parent_clip | 6635 // + scroll_parent_clip |
| 6638 // + scroll_parent | 6636 // + scroll_parent |
| (...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8367 | 8365 |
| 8368 child->test_properties()->AddChild(std::move(grand_child1)); | 8366 child->test_properties()->AddChild(std::move(grand_child1)); |
| 8369 child->test_properties()->AddChild(std::move(grand_child2)); | 8367 child->test_properties()->AddChild(std::move(grand_child2)); |
| 8370 parent->test_properties()->AddChild(std::move(child)); | 8368 parent->test_properties()->AddChild(std::move(child)); |
| 8371 grand_parent->test_properties()->AddChild(std::move(parent)); | 8369 grand_parent->test_properties()->AddChild(std::move(parent)); |
| 8372 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); | 8370 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); |
| 8373 | 8371 |
| 8374 // Start with nothing being drawn. | 8372 // Start with nothing being drawn. |
| 8375 ExecuteCalculateDrawProperties(grand_parent_raw); | 8373 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8376 | 8374 |
| 8377 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8375 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8378 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8376 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8379 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8377 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8380 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8378 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8381 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8379 EXPECT_FALSE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8382 | 8380 |
| 8383 std::set<LayerImpl*> expected; | 8381 std::set<LayerImpl*> expected; |
| 8384 std::set<LayerImpl*> actual; | 8382 std::set<LayerImpl*> actual; |
| 8385 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8383 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8386 EXPECT_EQ(expected, actual); | 8384 EXPECT_EQ(expected, actual); |
| 8387 | 8385 |
| 8388 // If we force render surface, but none of the layers are in the layer list, | 8386 // If we force render surface, but none of the layers are in the layer list, |
| 8389 // then this layer should not appear in RSLL. | 8387 // then this layer should not appear in RSLL. |
| 8390 grand_child1_raw->test_properties()->force_render_surface = true; | 8388 grand_child1_raw->test_properties()->force_render_surface = true; |
| 8391 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8389 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8392 | 8390 |
| 8393 ExecuteCalculateDrawProperties(grand_parent_raw); | 8391 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8394 | 8392 |
| 8395 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8393 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8396 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8394 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8397 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8395 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8398 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8396 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8399 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8397 EXPECT_FALSE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8400 | 8398 |
| 8401 expected.clear(); | 8399 expected.clear(); |
| 8402 actual.clear(); | 8400 actual.clear(); |
| 8403 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8401 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8404 EXPECT_EQ(expected, actual); | 8402 EXPECT_EQ(expected, actual); |
| 8405 | 8403 |
| 8406 // However, if we say that this layer also draws content, it will appear in | 8404 // However, if we say that this layer also draws content, it will appear in |
| 8407 // RSLL. | 8405 // RSLL. |
| 8408 grand_child1_raw->SetDrawsContent(true); | 8406 grand_child1_raw->SetDrawsContent(true); |
| 8409 | 8407 |
| 8410 ExecuteCalculateDrawProperties(grand_parent_raw); | 8408 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8411 | 8409 |
| 8412 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8410 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8413 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8411 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8414 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8412 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8415 EXPECT_TRUE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8413 EXPECT_TRUE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8416 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8414 EXPECT_FALSE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8417 | 8415 |
| 8418 expected.clear(); | 8416 expected.clear(); |
| 8419 expected.insert(grand_child1_raw); | 8417 expected.insert(grand_child1_raw); |
| 8420 | 8418 |
| 8421 actual.clear(); | 8419 actual.clear(); |
| 8422 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8420 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8423 EXPECT_EQ(expected, actual); | 8421 EXPECT_EQ(expected, actual); |
| 8424 | 8422 |
| 8425 // Now child is forced to have a render surface, and one if its children draws | 8423 // Now child is forced to have a render surface, and one if its children draws |
| 8426 // content. | 8424 // content. |
| 8427 grand_child1_raw->SetDrawsContent(false); | 8425 grand_child1_raw->SetDrawsContent(false); |
| 8428 grand_child1_raw->test_properties()->force_render_surface = false; | 8426 grand_child1_raw->test_properties()->force_render_surface = false; |
| 8429 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8427 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8430 child_raw->test_properties()->force_render_surface = true; | 8428 child_raw->test_properties()->force_render_surface = true; |
| 8431 grand_child2_raw->SetDrawsContent(true); | 8429 grand_child2_raw->SetDrawsContent(true); |
| 8432 | 8430 |
| 8433 ExecuteCalculateDrawProperties(grand_parent_raw); | 8431 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8434 | 8432 |
| 8435 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8433 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8436 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8434 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8437 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8435 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8438 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8436 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8439 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8437 EXPECT_TRUE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8440 | 8438 |
| 8441 expected.clear(); | 8439 expected.clear(); |
| 8442 expected.insert(grand_child2_raw); | 8440 expected.insert(grand_child2_raw); |
| 8443 | 8441 |
| 8444 actual.clear(); | 8442 actual.clear(); |
| 8445 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8443 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8446 EXPECT_EQ(expected, actual); | 8444 EXPECT_EQ(expected, actual); |
| 8447 | 8445 |
| 8448 // Add a mask layer to child. | 8446 // Add a mask layer to child. |
| 8449 child_raw->test_properties()->SetMaskLayer( | 8447 child_raw->test_properties()->SetMaskLayer( |
| 8450 LayerImpl::Create(host_impl.active_tree(), 6)); | 8448 LayerImpl::Create(host_impl.active_tree(), 6)); |
| 8451 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8449 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8452 | 8450 |
| 8453 ExecuteCalculateDrawProperties(grand_parent_raw); | 8451 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8454 | 8452 |
| 8455 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8453 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8456 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8454 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8457 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8455 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8458 EXPECT_TRUE(child_raw->test_properties() | 8456 EXPECT_TRUE(child_raw->test_properties() |
| 8459 ->mask_layer->is_drawn_render_surface_layer_list_member()); | 8457 ->mask_layer->contributes_to_drawn_render_surface()); |
| 8460 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8458 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8461 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8459 EXPECT_TRUE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8462 | 8460 |
| 8463 expected.clear(); | 8461 expected.clear(); |
| 8464 expected.insert(grand_child2_raw); | 8462 expected.insert(grand_child2_raw); |
| 8465 expected.insert(child_raw->test_properties()->mask_layer); | 8463 expected.insert(child_raw->test_properties()->mask_layer); |
| 8466 | 8464 |
| 8467 expected.clear(); | 8465 expected.clear(); |
| 8468 expected.insert(grand_child2_raw); | 8466 expected.insert(grand_child2_raw); |
| 8469 expected.insert(child_raw->test_properties()->mask_layer); | 8467 expected.insert(child_raw->test_properties()->mask_layer); |
| 8470 | 8468 |
| 8471 actual.clear(); | 8469 actual.clear(); |
| 8472 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8470 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8473 EXPECT_EQ(expected, actual); | 8471 EXPECT_EQ(expected, actual); |
| 8474 | 8472 |
| 8475 ExecuteCalculateDrawProperties(grand_parent_raw); | 8473 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8476 | 8474 |
| 8477 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8475 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8478 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8476 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8479 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8477 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8480 EXPECT_TRUE(child_raw->test_properties() | 8478 EXPECT_TRUE(child_raw->test_properties() |
| 8481 ->mask_layer->is_drawn_render_surface_layer_list_member()); | 8479 ->mask_layer->contributes_to_drawn_render_surface()); |
| 8482 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8480 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8483 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8481 EXPECT_TRUE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8484 | 8482 |
| 8485 expected.clear(); | 8483 expected.clear(); |
| 8486 expected.insert(grand_child2_raw); | 8484 expected.insert(grand_child2_raw); |
| 8487 expected.insert(child_raw->test_properties()->mask_layer); | 8485 expected.insert(child_raw->test_properties()->mask_layer); |
| 8488 | 8486 |
| 8489 actual.clear(); | 8487 actual.clear(); |
| 8490 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8488 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8491 EXPECT_EQ(expected, actual); | 8489 EXPECT_EQ(expected, actual); |
| 8492 | 8490 |
| 8493 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8491 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8494 | 8492 |
| 8495 // With nothing drawing, we should have no layers. | 8493 // With nothing drawing, we should have no layers. |
| 8496 grand_child2_raw->SetDrawsContent(false); | 8494 grand_child2_raw->SetDrawsContent(false); |
| 8497 | 8495 |
| 8498 ExecuteCalculateDrawProperties(grand_parent_raw); | 8496 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8499 | 8497 |
| 8500 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8498 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8501 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8499 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8502 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8500 EXPECT_FALSE(child_raw->contributes_to_drawn_render_surface()); |
| 8503 EXPECT_FALSE(child_raw->test_properties() | 8501 EXPECT_FALSE(child_raw->test_properties() |
| 8504 ->mask_layer->is_drawn_render_surface_layer_list_member()); | 8502 ->mask_layer->contributes_to_drawn_render_surface()); |
| 8505 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8503 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8506 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8504 EXPECT_FALSE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8507 | 8505 |
| 8508 expected.clear(); | 8506 expected.clear(); |
| 8509 actual.clear(); | 8507 actual.clear(); |
| 8510 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8508 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8511 EXPECT_EQ(expected, actual); | 8509 EXPECT_EQ(expected, actual); |
| 8512 | 8510 |
| 8513 // Child itself draws means that we should have the child and the mask in the | 8511 // Child itself draws means that we should have the child and the mask in the |
| 8514 // list. | 8512 // list. |
| 8515 child_raw->SetDrawsContent(true); | 8513 child_raw->SetDrawsContent(true); |
| 8516 | 8514 |
| 8517 ExecuteCalculateDrawProperties(grand_parent_raw); | 8515 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8518 | 8516 |
| 8519 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8517 EXPECT_FALSE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8520 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8518 EXPECT_FALSE(parent_raw->contributes_to_drawn_render_surface()); |
| 8521 EXPECT_TRUE(child_raw->is_drawn_render_surface_layer_list_member()); | 8519 EXPECT_TRUE(child_raw->contributes_to_drawn_render_surface()); |
| 8522 EXPECT_TRUE(child_raw->test_properties() | 8520 EXPECT_TRUE(child_raw->test_properties() |
| 8523 ->mask_layer->is_drawn_render_surface_layer_list_member()); | 8521 ->mask_layer->contributes_to_drawn_render_surface()); |
| 8524 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8522 EXPECT_FALSE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8525 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8523 EXPECT_FALSE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8526 | 8524 |
| 8527 expected.clear(); | 8525 expected.clear(); |
| 8528 expected.insert(child_raw); | 8526 expected.insert(child_raw); |
| 8529 expected.insert(child_raw->test_properties()->mask_layer); | 8527 expected.insert(child_raw->test_properties()->mask_layer); |
| 8530 actual.clear(); | 8528 actual.clear(); |
| 8531 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8529 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| 8532 EXPECT_EQ(expected, actual); | 8530 EXPECT_EQ(expected, actual); |
| 8533 | 8531 |
| 8534 child_raw->test_properties()->SetMaskLayer(nullptr); | 8532 child_raw->test_properties()->SetMaskLayer(nullptr); |
| 8535 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8533 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8536 | 8534 |
| 8537 // Now everyone's a member! | 8535 // Now everyone's a member! |
| 8538 grand_parent_raw->SetDrawsContent(true); | 8536 grand_parent_raw->SetDrawsContent(true); |
| 8539 parent_raw->SetDrawsContent(true); | 8537 parent_raw->SetDrawsContent(true); |
| 8540 child_raw->SetDrawsContent(true); | 8538 child_raw->SetDrawsContent(true); |
| 8541 grand_child1_raw->SetDrawsContent(true); | 8539 grand_child1_raw->SetDrawsContent(true); |
| 8542 grand_child2_raw->SetDrawsContent(true); | 8540 grand_child2_raw->SetDrawsContent(true); |
| 8543 | 8541 |
| 8544 ExecuteCalculateDrawProperties(grand_parent_raw); | 8542 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8545 | 8543 |
| 8546 EXPECT_TRUE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8544 EXPECT_TRUE(grand_parent_raw->contributes_to_drawn_render_surface()); |
| 8547 EXPECT_TRUE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8545 EXPECT_TRUE(parent_raw->contributes_to_drawn_render_surface()); |
| 8548 EXPECT_TRUE(child_raw->is_drawn_render_surface_layer_list_member()); | 8546 EXPECT_TRUE(child_raw->contributes_to_drawn_render_surface()); |
| 8549 EXPECT_TRUE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8547 EXPECT_TRUE(grand_child1_raw->contributes_to_drawn_render_surface()); |
| 8550 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8548 EXPECT_TRUE(grand_child2_raw->contributes_to_drawn_render_surface()); |
| 8551 | 8549 |
| 8552 expected.clear(); | 8550 expected.clear(); |
| 8553 expected.insert(grand_parent_raw); | 8551 expected.insert(grand_parent_raw); |
| 8554 expected.insert(parent_raw); | 8552 expected.insert(parent_raw); |
| 8555 expected.insert(child_raw); | 8553 expected.insert(child_raw); |
| 8556 expected.insert(grand_child1_raw); | 8554 expected.insert(grand_child1_raw); |
| 8557 expected.insert(grand_child2_raw); | 8555 expected.insert(grand_child2_raw); |
| 8558 | 8556 |
| 8559 actual.clear(); | 8557 actual.clear(); |
| 8560 GatherDrawnLayers(host_impl.active_tree(), &actual); | 8558 GatherDrawnLayers(host_impl.active_tree(), &actual); |
| (...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10300 | 10298 |
| 10301 root->SetBounds(gfx::Size(40, 40)); | 10299 root->SetBounds(gfx::Size(40, 40)); |
| 10302 root->SetDrawsContent(true); | 10300 root->SetDrawsContent(true); |
| 10303 child->test_properties()->transform = transform; | 10301 child->test_properties()->transform = transform; |
| 10304 child->SetBounds(gfx::Size(30, 30)); | 10302 child->SetBounds(gfx::Size(30, 30)); |
| 10305 child->SetDrawsContent(false); | 10303 child->SetDrawsContent(false); |
| 10306 mask->SetBounds(gfx::Size(20, 20)); | 10304 mask->SetBounds(gfx::Size(20, 20)); |
| 10307 ExecuteCalculateDrawProperties(root); | 10305 ExecuteCalculateDrawProperties(root); |
| 10308 | 10306 |
| 10309 // The render surface created for the mask has no contributing content, so the | 10307 // The render surface created for the mask has no contributing content, so the |
| 10310 // mask isn't a drawn RSLL member. This means it has an empty visible rect, | 10308 // mask isn't a drawn RSLL member. This means it has an empty visible rect, |
|
jaydasika
2017/05/01 16:49:22
Can you also change the comment, since there is no
ajuma
2017/05/01 17:23:59
Done.
| |
| 10311 // but its screen space transform can still be computed correctly on-demand. | 10309 // but its screen space transform can still be computed correctly on-demand. |
| 10312 EXPECT_FALSE(mask->is_drawn_render_surface_layer_list_member()); | 10310 EXPECT_FALSE(mask->contributes_to_drawn_render_surface()); |
| 10313 EXPECT_EQ(gfx::Rect(), mask->visible_layer_rect()); | 10311 EXPECT_EQ(gfx::Rect(), mask->visible_layer_rect()); |
| 10314 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 10312 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 10315 | 10313 |
| 10316 // Make the child's render surface have contributing content. | 10314 // Make the child's render surface have contributing content. |
| 10317 child->SetDrawsContent(true); | 10315 child->SetDrawsContent(true); |
| 10318 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 10316 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 10319 ExecuteCalculateDrawProperties(root); | 10317 ExecuteCalculateDrawProperties(root); |
| 10320 EXPECT_TRUE(mask->is_drawn_render_surface_layer_list_member()); | 10318 EXPECT_TRUE(mask->contributes_to_drawn_render_surface()); |
| 10321 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); | 10319 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); |
| 10322 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 10320 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 10323 | 10321 |
| 10324 transform.Translate(10, 10); | 10322 transform.Translate(10, 10); |
| 10325 child->test_properties()->transform = transform; | 10323 child->test_properties()->transform = transform; |
| 10326 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 10324 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 10327 ExecuteCalculateDrawProperties(root); | 10325 ExecuteCalculateDrawProperties(root); |
| 10328 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 10326 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 10329 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); | 10327 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); |
| 10330 } | 10328 } |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10837 | 10835 |
| 10838 // Check child layer draw properties. | 10836 // Check child layer draw properties. |
| 10839 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10837 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10840 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10838 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10841 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10839 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10842 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10840 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10843 } | 10841 } |
| 10844 | 10842 |
| 10845 } // namespace | 10843 } // namespace |
| 10846 } // namespace cc | 10844 } // namespace cc |
| OLD | NEW |