| 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 4675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4686 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 4686 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 4687 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 4687 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 4688 } | 4688 } |
| 4689 | 4689 |
| 4690 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 4690 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 4691 LCDTextTest, | 4691 LCDTextTest, |
| 4692 testing::Combine(testing::Bool(), | 4692 testing::Combine(testing::Bool(), |
| 4693 testing::Bool(), | 4693 testing::Bool(), |
| 4694 testing::Bool())); | 4694 testing::Bool())); |
| 4695 | 4695 |
| 4696 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | |
| 4697 FakeImplTaskRunnerProvider task_runner_provider; | |
| 4698 TestTaskGraphRunner task_graph_runner; | |
| 4699 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | |
| 4700 host_impl.CreatePendingTree(); | |
| 4701 | |
| 4702 std::unique_ptr<LayerImpl> root = | |
| 4703 LayerImpl::Create(host_impl.pending_tree(), 1); | |
| 4704 root->SetBounds(gfx::Size(50, 50)); | |
| 4705 root->SetDrawsContent(true); | |
| 4706 LayerImpl* root_layer = root.get(); | |
| 4707 | |
| 4708 std::unique_ptr<LayerImpl> child = | |
| 4709 LayerImpl::Create(host_impl.pending_tree(), 2); | |
| 4710 child->SetBounds(gfx::Size(40, 40)); | |
| 4711 child->SetDrawsContent(true); | |
| 4712 LayerImpl* child_layer = child.get(); | |
| 4713 | |
| 4714 std::unique_ptr<LayerImpl> grand_child = | |
| 4715 LayerImpl::Create(host_impl.pending_tree(), 3); | |
| 4716 grand_child->SetBounds(gfx::Size(30, 30)); | |
| 4717 grand_child->SetDrawsContent(true); | |
| 4718 grand_child->test_properties()->hide_layer_and_subtree = true; | |
| 4719 LayerImpl* grand_child_layer = grand_child.get(); | |
| 4720 | |
| 4721 child->test_properties()->AddChild(std::move(grand_child)); | |
| 4722 root->test_properties()->AddChild(std::move(child)); | |
| 4723 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
| 4724 | |
| 4725 RenderSurfaceList render_surface_list; | |
| 4726 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 4727 root_layer, root_layer->bounds(), &render_surface_list); | |
| 4728 inputs.can_adjust_raster_scales = true; | |
| 4729 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 4730 | |
| 4731 // We should have one render surface and two layers. The grand child has | |
| 4732 // hidden itself. | |
| 4733 ASSERT_EQ(1u, render_surface_list.size()); | |
| 4734 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | |
| 4735 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
| 4736 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); | |
| 4737 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | |
| 4738 } | |
| 4739 | |
| 4740 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | |
| 4741 FakeImplTaskRunnerProvider task_runner_provider; | |
| 4742 TestTaskGraphRunner task_graph_runner; | |
| 4743 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | |
| 4744 host_impl.CreatePendingTree(); | |
| 4745 | |
| 4746 std::unique_ptr<LayerImpl> root = | |
| 4747 LayerImpl::Create(host_impl.pending_tree(), 1); | |
| 4748 root->SetBounds(gfx::Size(50, 50)); | |
| 4749 root->SetDrawsContent(true); | |
| 4750 LayerImpl* root_layer = root.get(); | |
| 4751 | |
| 4752 std::unique_ptr<LayerImpl> child = | |
| 4753 LayerImpl::Create(host_impl.pending_tree(), 2); | |
| 4754 child->SetBounds(gfx::Size(40, 40)); | |
| 4755 child->SetDrawsContent(true); | |
| 4756 child->test_properties()->hide_layer_and_subtree = true; | |
| 4757 LayerImpl* child_layer = child.get(); | |
| 4758 | |
| 4759 std::unique_ptr<LayerImpl> grand_child = | |
| 4760 LayerImpl::Create(host_impl.pending_tree(), 3); | |
| 4761 grand_child->SetBounds(gfx::Size(30, 30)); | |
| 4762 grand_child->SetDrawsContent(true); | |
| 4763 LayerImpl* grand_child_layer = grand_child.get(); | |
| 4764 | |
| 4765 child->test_properties()->AddChild(std::move(grand_child)); | |
| 4766 root->test_properties()->AddChild(std::move(child)); | |
| 4767 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
| 4768 | |
| 4769 RenderSurfaceList render_surface_list; | |
| 4770 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 4771 root_layer, root_layer->bounds(), &render_surface_list); | |
| 4772 inputs.can_adjust_raster_scales = true; | |
| 4773 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 4774 | |
| 4775 // We should have one render surface and one layer. The child has | |
| 4776 // hidden itself and the grand child. | |
| 4777 ASSERT_EQ(1u, render_surface_list.size()); | |
| 4778 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); | |
| 4779 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
| 4780 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); | |
| 4781 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | |
| 4782 } | |
| 4783 | |
| 4784 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 4696 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 4785 | 4697 |
| 4786 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 4698 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
| 4787 FakeImplTaskRunnerProvider task_runner_provider; | 4699 scoped_refptr<Layer> root = Layer::Create(); |
| 4788 TestTaskGraphRunner task_graph_runner; | 4700 scoped_refptr<Layer> copy_grand_parent = Layer::Create(); |
| 4789 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 4701 scoped_refptr<Layer> copy_parent = Layer::Create(); |
| 4790 host_impl.CreatePendingTree(); | 4702 scoped_refptr<Layer> copy_layer = Layer::Create(); |
| 4703 scoped_refptr<Layer> copy_child = Layer::Create(); |
| 4704 scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
| 4705 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create(); |
| 4706 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create(); |
| 4791 | 4707 |
| 4792 std::unique_ptr<LayerImpl> root = | |
| 4793 LayerImpl::Create(host_impl.pending_tree(), 1); | |
| 4794 root->SetBounds(gfx::Size(50, 50)); | 4708 root->SetBounds(gfx::Size(50, 50)); |
| 4795 root->SetDrawsContent(true); | 4709 copy_grand_parent->SetBounds(gfx::Size(50, 50)); |
| 4796 LayerImpl* root_layer = root.get(); | 4710 copy_parent->SetBounds(gfx::Size(50, 50)); |
| 4711 copy_parent->SetForceRenderSurfaceForTesting(true); |
| 4712 copy_layer->SetBounds(gfx::Size(50, 50)); |
| 4713 copy_child->SetBounds(gfx::Size(50, 50)); |
| 4714 copy_grand_child->SetBounds(gfx::Size(50, 50)); |
| 4715 copy_grand_parent_sibling_before->SetBounds(gfx::Size(50, 50)); |
| 4716 copy_grand_parent_sibling_after->SetBounds(gfx::Size(50, 50)); |
| 4797 | 4717 |
| 4798 std::unique_ptr<LayerImpl> copy_grand_parent = | 4718 root->AddChild(copy_grand_parent_sibling_before); |
| 4799 LayerImpl::Create(host_impl.pending_tree(), 2); | 4719 root->AddChild(copy_grand_parent); |
| 4800 copy_grand_parent->SetBounds(gfx::Size(40, 40)); | 4720 root->AddChild(copy_grand_parent_sibling_after); |
| 4801 copy_grand_parent->SetDrawsContent(true); | 4721 copy_grand_parent->AddChild(copy_parent); |
| 4802 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); | 4722 copy_parent->AddChild(copy_layer); |
| 4723 copy_layer->AddChild(copy_child); |
| 4724 copy_child->AddChild(copy_grand_child); |
| 4725 host()->SetRootLayer(root); |
| 4803 | 4726 |
| 4804 std::unique_ptr<LayerImpl> copy_parent = | 4727 copy_layer->RequestCopyOfOutput( |
| 4805 LayerImpl::Create(host_impl.pending_tree(), 3); | |
| 4806 copy_parent->SetBounds(gfx::Size(30, 30)); | |
| 4807 copy_parent->SetDrawsContent(true); | |
| 4808 copy_parent->test_properties()->force_render_surface = true; | |
| 4809 LayerImpl* copy_parent_layer = copy_parent.get(); | |
| 4810 | |
| 4811 std::unique_ptr<LayerImpl> copy_request = | |
| 4812 LayerImpl::Create(host_impl.pending_tree(), 4); | |
| 4813 copy_request->SetBounds(gfx::Size(20, 20)); | |
| 4814 copy_request->SetDrawsContent(true); | |
| 4815 copy_request->test_properties()->force_render_surface = true; | |
| 4816 LayerImpl* copy_layer = copy_request.get(); | |
| 4817 | |
| 4818 std::unique_ptr<LayerImpl> copy_child = | |
| 4819 LayerImpl::Create(host_impl.pending_tree(), 5); | |
| 4820 copy_child->SetBounds(gfx::Size(20, 20)); | |
| 4821 copy_child->SetDrawsContent(true); | |
| 4822 LayerImpl* copy_child_layer = copy_child.get(); | |
| 4823 | |
| 4824 std::unique_ptr<LayerImpl> copy_grand_child = | |
| 4825 LayerImpl::Create(host_impl.pending_tree(), 6); | |
| 4826 copy_grand_child->SetBounds(gfx::Size(20, 20)); | |
| 4827 copy_grand_child->SetDrawsContent(true); | |
| 4828 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); | |
| 4829 | |
| 4830 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = | |
| 4831 LayerImpl::Create(host_impl.pending_tree(), 7); | |
| 4832 copy_grand_parent_sibling_before->SetBounds(gfx::Size(40, 40)); | |
| 4833 copy_grand_parent_sibling_before->SetDrawsContent(true); | |
| 4834 LayerImpl* copy_grand_parent_sibling_before_layer = | |
| 4835 copy_grand_parent_sibling_before.get(); | |
| 4836 | |
| 4837 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = | |
| 4838 LayerImpl::Create(host_impl.pending_tree(), 8); | |
| 4839 copy_grand_parent_sibling_after->SetBounds(gfx::Size(40, 40)); | |
| 4840 copy_grand_parent_sibling_after->SetDrawsContent(true); | |
| 4841 LayerImpl* copy_grand_parent_sibling_after_layer = | |
| 4842 copy_grand_parent_sibling_after.get(); | |
| 4843 | |
| 4844 copy_child->test_properties()->AddChild(std::move(copy_grand_child)); | |
| 4845 copy_request->test_properties()->AddChild(std::move(copy_child)); | |
| 4846 copy_parent->test_properties()->AddChild(std::move(copy_request)); | |
| 4847 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent)); | |
| 4848 root->test_properties()->AddChild( | |
| 4849 std::move(copy_grand_parent_sibling_before)); | |
| 4850 root->test_properties()->AddChild(std::move(copy_grand_parent)); | |
| 4851 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after)); | |
| 4852 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
| 4853 | |
| 4854 // Hide the copy_grand_parent and its subtree. But make a copy request in that | |
| 4855 // hidden subtree on copy_layer. Also hide the copy grand child and its | |
| 4856 // subtree. | |
| 4857 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true; | |
| 4858 copy_grand_parent_sibling_before_layer->test_properties() | |
| 4859 ->hide_layer_and_subtree = true; | |
| 4860 copy_grand_parent_sibling_after_layer->test_properties() | |
| 4861 ->hide_layer_and_subtree = true; | |
| 4862 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true; | |
| 4863 | |
| 4864 copy_layer->test_properties()->copy_requests.push_back( | |
| 4865 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 4728 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 4866 | 4729 |
| 4867 RenderSurfaceList render_surface_list; | 4730 copy_grand_parent->SetHideLayerAndSubtree(true); |
| 4868 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 4731 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); |
| 4869 root_layer, root_layer->bounds(), &render_surface_list); | 4732 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); |
| 4870 inputs.can_adjust_raster_scales = true; | 4733 copy_grand_child->SetHideLayerAndSubtree(true); |
| 4871 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 4872 | 4734 |
| 4873 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); | 4735 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 4874 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); | 4736 EXPECT_FALSE(copy_grand_parent->is_hidden()); |
| 4875 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); | 4737 EXPECT_TRUE(copy_grand_parent_sibling_after->is_hidden()); |
| 4876 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); | 4738 EXPECT_TRUE(copy_grand_parent_sibling_before->is_hidden()); |
| 4739 EXPECT_TRUE(copy_grand_child->is_hidden()); |
| 4877 | 4740 |
| 4878 // We should have four render surfaces, one for the root, one for the grand | 4741 EffectTree& tree = host()->property_trees()->effect_tree; |
| 4879 // parent since it has opacity and two drawing descendants, one for the parent | 4742 EffectNode* node = tree.Node(copy_grand_parent->effect_tree_index()); |
| 4880 // since it owns a surface, and one for the copy_layer. | |
| 4881 ASSERT_EQ(4u, render_surface_list.size()); | |
| 4882 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | |
| 4883 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); | |
| 4884 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); | |
| 4885 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); | |
| 4886 | |
| 4887 // The root render surface should have 2 contributing layers. | |
| 4888 EXPECT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | |
| 4889 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
| 4890 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); | |
| 4891 EXPECT_FALSE(copy_grand_parent_sibling_before_layer | |
| 4892 ->contributes_to_drawn_render_surface()); | |
| 4893 EXPECT_FALSE(copy_grand_parent_sibling_after_layer | |
| 4894 ->contributes_to_drawn_render_surface()); | |
| 4895 | |
| 4896 // Nothing actually draws into the copy parent, so only the copy_layer will | |
| 4897 // appear in its list, since it needs to be drawn for the copy request. | |
| 4898 ASSERT_EQ(1, GetRenderSurface(copy_parent_layer)->num_contributors()); | |
| 4899 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); | |
| 4900 | |
| 4901 // The copy layer's render surface should have 2 contributing layers. | |
| 4902 ASSERT_EQ(2, GetRenderSurface(copy_layer)->num_contributors()); | |
| 4903 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | |
| 4904 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); | |
| 4905 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); | |
| 4906 | |
| 4907 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | |
| 4908 // but the copy_layer and copy_child should be drawn for the copy request. | |
| 4909 // copy grand child should not be drawn as its hidden even in the copy | |
| 4910 // request. | |
| 4911 EffectTree& tree = | |
| 4912 root_layer->layer_tree_impl()->property_trees()->effect_tree; | |
| 4913 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | |
| 4914 EXPECT_FALSE(node->is_drawn); | 4743 EXPECT_FALSE(node->is_drawn); |
| 4915 node = tree.Node(copy_parent_layer->effect_tree_index()); | 4744 node = tree.Node(copy_parent->effect_tree_index()); |
| 4916 EXPECT_FALSE(node->is_drawn); | 4745 EXPECT_FALSE(node->is_drawn); |
| 4917 node = tree.Node(copy_layer->effect_tree_index()); | 4746 node = tree.Node(copy_layer->effect_tree_index()); |
| 4918 EXPECT_TRUE(node->is_drawn); | 4747 EXPECT_TRUE(node->is_drawn); |
| 4919 node = tree.Node(copy_child_layer->effect_tree_index()); | 4748 node = tree.Node(copy_child->effect_tree_index()); |
| 4920 EXPECT_TRUE(node->is_drawn); | 4749 EXPECT_TRUE(node->is_drawn); |
| 4921 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | |
| 4922 EXPECT_FALSE(node->is_drawn); | |
| 4923 | |
| 4924 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its | |
| 4925 // actually hidden. | |
| 4926 EXPECT_FALSE(GetRenderSurface(copy_layer)->contributes_to_drawn_surface()); | |
| 4927 } | 4750 } |
| 4928 | 4751 |
| 4929 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 4752 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 4930 FakeImplTaskRunnerProvider task_runner_provider; | 4753 FakeImplTaskRunnerProvider task_runner_provider; |
| 4931 TestTaskGraphRunner task_graph_runner; | 4754 TestTaskGraphRunner task_graph_runner; |
| 4932 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 4755 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 4933 host_impl.CreatePendingTree(); | 4756 host_impl.CreatePendingTree(); |
| 4934 | 4757 |
| 4935 std::unique_ptr<LayerImpl> root = | 4758 std::unique_ptr<LayerImpl> root = |
| 4936 LayerImpl::Create(host_impl.pending_tree(), 1); | 4759 LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4972 ASSERT_EQ(2u, render_surface_list.size()); | 4795 ASSERT_EQ(2u, render_surface_list.size()); |
| 4973 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 4796 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
| 4974 | 4797 |
| 4975 // The root render surface should have only 2 contributing layer, since the | 4798 // The root render surface should have only 2 contributing layer, since the |
| 4976 // other layers are clipped away. | 4799 // other layers are clipped away. |
| 4977 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | 4800 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
| 4978 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 4801 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 4979 } | 4802 } |
| 4980 | 4803 |
| 4981 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { | 4804 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { |
| 4982 LayerImpl* root = root_layer_for_testing(); | 4805 scoped_refptr<Layer> root = Layer::Create(); |
| 4806 scoped_refptr<Layer> singular_transform_layer = Layer::Create(); |
| 4807 scoped_refptr<Layer> copy_layer = Layer::Create(); |
| 4808 scoped_refptr<Layer> copy_child = Layer::Create(); |
| 4809 scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
| 4810 |
| 4811 root->AddChild(singular_transform_layer); |
| 4812 singular_transform_layer->AddChild(copy_layer); |
| 4813 copy_layer->AddChild(copy_child); |
| 4814 copy_child->AddChild(copy_grand_child); |
| 4815 host()->SetRootLayer(root); |
| 4816 |
| 4983 root->SetBounds(gfx::Size(50, 50)); | 4817 root->SetBounds(gfx::Size(50, 50)); |
| 4984 root->SetDrawsContent(true); | 4818 root->SetIsDrawable(true); |
| 4985 | |
| 4986 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); | |
| 4987 singular_transform_layer->SetBounds(gfx::Size(100, 100)); | 4819 singular_transform_layer->SetBounds(gfx::Size(100, 100)); |
| 4988 singular_transform_layer->SetDrawsContent(true); | |
| 4989 gfx::Transform singular; | 4820 gfx::Transform singular; |
| 4990 singular.Scale3d(6.f, 6.f, 0.f); | 4821 singular.Scale3d(6.f, 6.f, 0.f); |
| 4991 singular_transform_layer->test_properties()->transform = singular; | 4822 singular_transform_layer->SetTransform(singular); |
| 4823 singular_transform_layer->SetIsDrawable(true); |
| 4824 copy_layer->SetBounds(gfx::Size(100, 100)); |
| 4825 copy_layer->SetIsDrawable(true); |
| 4826 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 4827 base::Bind(&EmptyCopyOutputCallback))); |
| 4828 copy_child->SetBounds(gfx::Size(100, 100)); |
| 4829 copy_child->SetIsDrawable(true); |
| 4830 copy_grand_child->SetBounds(gfx::Size(100, 100)); |
| 4831 copy_grand_child->SetTransform(singular); |
| 4832 copy_grand_child->SetIsDrawable(true); |
| 4992 | 4833 |
| 4993 LayerImpl* copy_layer = AddChild<LayerImpl>(singular_transform_layer); | 4834 ExecuteCalculateDrawProperties(root.get()); |
| 4994 copy_layer->SetBounds(gfx::Size(100, 100)); | |
| 4995 copy_layer->SetDrawsContent(true); | |
| 4996 copy_layer->test_properties()->copy_requests.push_back( | |
| 4997 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | |
| 4998 | 4835 |
| 4999 LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); | 4836 host()->host_impl()->CreatePendingTree(); |
| 5000 copy_child->SetBounds(gfx::Size(100, 100)); | 4837 host()->CommitAndCreatePendingTree(); |
| 5001 copy_child->SetDrawsContent(true); | 4838 host()->host_impl()->ActivateSyncTree(); |
| 4839 LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree(); |
| 5002 | 4840 |
| 5003 LayerImpl* copy_grand_child = AddChild<LayerImpl>(copy_child); | 4841 LayerImpl* root_impl = layer_tree_impl->LayerById(root->id()); |
| 5004 copy_grand_child->SetBounds(gfx::Size(100, 100)); | 4842 LayerImpl* singular_transform_layer_impl = |
| 5005 copy_grand_child->SetDrawsContent(true); | 4843 layer_tree_impl->LayerById(singular_transform_layer->id()); |
| 5006 copy_grand_child->test_properties()->transform = singular; | 4844 LayerImpl* copy_layer_impl = layer_tree_impl->LayerById(copy_layer->id()); |
| 5007 | 4845 LayerImpl* copy_child_impl = layer_tree_impl->LayerById(copy_child->id()); |
| 5008 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); | 4846 LayerImpl* copy_grand_child_impl = |
| 5009 ExecuteCalculateDrawProperties(root); | 4847 layer_tree_impl->LayerById(copy_grand_child->id()); |
| 5010 DCHECK(copy_layer->test_properties()->copy_requests.empty()); | 4848 ExecuteCalculateDrawProperties(root_impl); |
| 5011 | 4849 |
| 5012 // A layer with singular transform should not contribute to drawn render | 4850 // A layer with singular transform should not contribute to drawn render |
| 5013 // surface. | 4851 // surface. |
| 5014 EXPECT_FALSE(singular_transform_layer->contributes_to_drawn_render_surface()); | 4852 EXPECT_FALSE( |
| 4853 singular_transform_layer_impl->contributes_to_drawn_render_surface()); |
| 5015 // Even though copy_layer and copy_child have singular screen space transform, | 4854 // Even though copy_layer and copy_child have singular screen space transform, |
| 5016 // they still contribute to drawn render surface as their transform to the | 4855 // they still contribute to drawn render surface as their transform to the |
| 5017 // closest ancestor with copy request is not singular. | 4856 // closest ancestor with copy request is not singular. |
| 5018 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | 4857 EXPECT_TRUE(copy_layer_impl->contributes_to_drawn_render_surface()); |
| 5019 EXPECT_TRUE(copy_child->contributes_to_drawn_render_surface()); | 4858 EXPECT_TRUE(copy_child_impl->contributes_to_drawn_render_surface()); |
| 5020 // copy_grand_child's transform to its closest ancestor with copy request is | 4859 // copy_grand_child's transform to its closest ancestor with copy request is |
| 5021 // also singular. So, it doesn't contribute to drawn render surface. | 4860 // also singular. So, it doesn't contribute to drawn render surface. |
| 5022 EXPECT_FALSE(copy_grand_child->contributes_to_drawn_render_surface()); | 4861 EXPECT_FALSE(copy_grand_child_impl->contributes_to_drawn_render_surface()); |
| 5023 } | 4862 } |
| 5024 | 4863 |
| 5025 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { | 4864 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
| 5026 LayerImpl* root = root_layer_for_testing(); | 4865 LayerImpl* root = root_layer_for_testing(); |
| 5027 root->SetBounds(gfx::Size(50, 50)); | 4866 root->SetBounds(gfx::Size(50, 50)); |
| 5028 root->SetDrawsContent(true); | 4867 root->SetDrawsContent(true); |
| 5029 root->SetMasksToBounds(true); | 4868 root->SetMasksToBounds(true); |
| 5030 | 4869 |
| 5031 LayerImpl* copy_layer = AddChild<LayerImpl>(root); | 4870 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
| 5032 copy_layer->SetBounds(gfx::Size(100, 100)); | 4871 copy_layer->SetBounds(gfx::Size(100, 100)); |
| (...skipping 3665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8698 | 8537 |
| 8699 child->SetTransform(singular); | 8538 child->SetTransform(singular); |
| 8700 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 8539 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 8701 update_list = GetUpdateLayerList(); | 8540 update_list = GetUpdateLayerList(); |
| 8702 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 8541 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
| 8703 child->SetTransform(gfx::Transform()); | 8542 child->SetTransform(gfx::Transform()); |
| 8704 | 8543 |
| 8705 child->SetHideLayerAndSubtree(true); | 8544 child->SetHideLayerAndSubtree(true); |
| 8706 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 8545 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 8707 update_list = GetUpdateLayerList(); | 8546 update_list = GetUpdateLayerList(); |
| 8547 EXPECT_TRUE(child->is_hidden()); |
| 8548 EXPECT_TRUE(grandchild->is_hidden()); |
| 8549 EXPECT_FALSE(VerifyLayerInList(child, update_list)); |
| 8708 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 8550 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
| 8709 child->SetHideLayerAndSubtree(false); | 8551 child->SetHideLayerAndSubtree(false); |
| 8710 | 8552 |
| 8711 gfx::Transform zero_z_scale; | 8553 gfx::Transform zero_z_scale; |
| 8712 zero_z_scale.Scale3d(1, 1, 0); | 8554 zero_z_scale.Scale3d(1, 1, 0); |
| 8713 child->SetTransform(zero_z_scale); | 8555 child->SetTransform(zero_z_scale); |
| 8714 | 8556 |
| 8715 // Add a transform animation with a start delay. Now, even though |child| has | 8557 // Add a transform animation with a start delay. Now, even though |child| has |
| 8716 // a singular transform, the subtree should still get processed. | 8558 // a singular transform, the subtree should still get processed. |
| 8717 int animation_id = 0; | 8559 int animation_id = 0; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8811 gfx::Transform rotate_back_and_translate; | 8653 gfx::Transform rotate_back_and_translate; |
| 8812 rotate_back_and_translate.RotateAboutYAxis(180); | 8654 rotate_back_and_translate.RotateAboutYAxis(180); |
| 8813 rotate_back_and_translate.Translate(-10, 0); | 8655 rotate_back_and_translate.Translate(-10, 0); |
| 8814 | 8656 |
| 8815 child_ptr->test_properties()->transform = singular; | 8657 child_ptr->test_properties()->transform = singular; |
| 8816 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8658 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8817 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 8659 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 8818 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8660 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8819 child_ptr->test_properties()->transform = gfx::Transform(); | 8661 child_ptr->test_properties()->transform = gfx::Transform(); |
| 8820 | 8662 |
| 8821 child_ptr->test_properties()->hide_layer_and_subtree = true; | |
| 8822 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | |
| 8823 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | |
| 8824 child_ptr->test_properties()->hide_layer_and_subtree = false; | |
| 8825 | |
| 8826 child_ptr->test_properties()->opacity = 0.f; | 8663 child_ptr->test_properties()->opacity = 0.f; |
| 8827 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8664 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8828 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 8665 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 8829 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8666 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8830 child_ptr->test_properties()->opacity = 1.f; | 8667 child_ptr->test_properties()->opacity = 1.f; |
| 8831 | 8668 |
| 8832 root_ptr->test_properties()->transform = singular; | 8669 root_ptr->test_properties()->transform = singular; |
| 8833 // Force transform tree to have a node for child, so that ancestor's | 8670 // Force transform tree to have a node for child, so that ancestor's |
| 8834 // invertible transform can be tested. | 8671 // invertible transform can be tested. |
| 8835 child_ptr->test_properties()->transform = rotate; | 8672 child_ptr->test_properties()->transform = rotate; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9010 LayerImpl* child = AddChild<LayerImpl>(root); | 8847 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9011 | 8848 |
| 9012 root->SetBounds(gfx::Size(100, 100)); | 8849 root->SetBounds(gfx::Size(100, 100)); |
| 9013 child->SetBounds(gfx::Size(10, 10)); | 8850 child->SetBounds(gfx::Size(10, 10)); |
| 9014 child->SetDrawsContent(true); | 8851 child->SetDrawsContent(true); |
| 9015 | 8852 |
| 9016 ExecuteCalculateDrawProperties(root); | 8853 ExecuteCalculateDrawProperties(root); |
| 9017 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 8854 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 9018 child->set_visible_layer_rect(gfx::Rect()); | 8855 child->set_visible_layer_rect(gfx::Rect()); |
| 9019 | 8856 |
| 9020 child->test_properties()->hide_layer_and_subtree = true; | |
| 9021 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | |
| 9022 ExecuteCalculateDrawProperties(root); | |
| 9023 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | |
| 9024 child->test_properties()->hide_layer_and_subtree = false; | |
| 9025 | |
| 9026 child->SetBounds(gfx::Size()); | 8857 child->SetBounds(gfx::Size()); |
| 9027 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8858 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9028 ExecuteCalculateDrawProperties(root); | 8859 ExecuteCalculateDrawProperties(root); |
| 9029 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8860 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 9030 child->SetBounds(gfx::Size(10, 10)); | 8861 child->SetBounds(gfx::Size(10, 10)); |
| 9031 | 8862 |
| 9032 gfx::Transform rotate; | 8863 gfx::Transform rotate; |
| 9033 child->test_properties()->double_sided = false; | 8864 child->test_properties()->double_sided = false; |
| 9034 rotate.RotateAboutXAxis(180.f); | 8865 rotate.RotateAboutXAxis(180.f); |
| 9035 child->test_properties()->transform = rotate; | 8866 child->test_properties()->transform = rotate; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9542 test_layer->SetDrawsContent(true); | 9373 test_layer->SetDrawsContent(true); |
| 9543 ExecuteCalculateDrawProperties(root); | 9374 ExecuteCalculateDrawProperties(root); |
| 9544 | 9375 |
| 9545 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); | 9376 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); |
| 9546 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); | 9377 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); |
| 9547 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); | 9378 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); |
| 9548 } | 9379 } |
| 9549 | 9380 |
| 9550 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { | 9381 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { |
| 9551 // Tests that subtree is hidden is updated. | 9382 // Tests that subtree is hidden is updated. |
| 9552 LayerImpl* root = root_layer_for_testing(); | 9383 scoped_refptr<Layer> root = Layer::Create(); |
| 9553 LayerImpl* hidden = AddChild<LayerImpl>(root); | 9384 scoped_refptr<Layer> hidden = Layer::Create(); |
| 9554 LayerImpl* test = AddChild<LayerImpl>(hidden); | 9385 scoped_refptr<Layer> test = Layer::Create(); |
| 9555 | 9386 |
| 9556 root->SetBounds(gfx::Size(30, 30)); | 9387 root->SetBounds(gfx::Size(30, 30)); |
| 9557 hidden->SetBounds(gfx::Size(30, 30)); | 9388 hidden->SetBounds(gfx::Size(30, 30)); |
| 9558 hidden->test_properties()->force_render_surface = true; | 9389 hidden->SetHideLayerAndSubtree(true); |
| 9559 hidden->test_properties()->hide_layer_and_subtree = true; | |
| 9560 test->SetBounds(gfx::Size(30, 30)); | 9390 test->SetBounds(gfx::Size(30, 30)); |
| 9561 test->test_properties()->force_render_surface = true; | |
| 9562 | 9391 |
| 9563 ExecuteCalculateDrawProperties(root); | 9392 root->AddChild(hidden); |
| 9564 EXPECT_EQ(0.f, | 9393 hidden->AddChild(test); |
| 9565 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); | 9394 host()->SetRootLayer(root); |
| 9566 | 9395 |
| 9567 hidden->test_properties()->hide_layer_and_subtree = false; | 9396 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9568 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9397 EXPECT_TRUE(test->is_hidden()); |
| 9569 ExecuteCalculateDrawProperties(root); | 9398 // Hidden layers should have invalid property tree indices. |
| 9570 EXPECT_EQ(1.f, | 9399 const int kInvalidNodeId = -1; |
| 9571 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); | 9400 EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId); |
| 9401 EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId); |
| 9402 EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId); |
| 9403 EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId); |
| 9404 |
| 9405 hidden->SetHideLayerAndSubtree(false); |
| 9406 root->layer_tree_host()->property_trees()->needs_rebuild = true; |
| 9407 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9408 EXPECT_FALSE(test->is_hidden()); |
| 9409 EXPECT_NE(test->effect_tree_index(), kInvalidNodeId); |
| 9410 EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId); |
| 9411 EXPECT_NE(test->clip_tree_index(), kInvalidNodeId); |
| 9412 EXPECT_NE(test->transform_tree_index(), kInvalidNodeId); |
| 9572 } | 9413 } |
| 9573 | 9414 |
| 9574 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9415 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 9575 LayerImpl* root = root_layer_for_testing(); | 9416 LayerImpl* root = root_layer_for_testing(); |
| 9576 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 9417 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 9577 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); | 9418 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 9578 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9419 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 9579 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9420 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 9580 | 9421 |
| 9581 root->SetBounds(gfx::Size(30, 30)); | 9422 root->SetBounds(gfx::Size(30, 30)); |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10154 | 9995 |
| 10155 // Check child layer draw properties. | 9996 // Check child layer draw properties. |
| 10156 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 9997 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10157 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 9998 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10158 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 9999 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10159 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10000 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10160 } | 10001 } |
| 10161 | 10002 |
| 10162 } // namespace | 10003 } // namespace |
| 10163 } // namespace cc | 10004 } // namespace cc |
| OLD | NEW |