| 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 4685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4696 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 4696 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 4697 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 4697 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 4698 } | 4698 } |
| 4699 | 4699 |
| 4700 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 4700 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 4701 LCDTextTest, | 4701 LCDTextTest, |
| 4702 testing::Combine(testing::Bool(), | 4702 testing::Combine(testing::Bool(), |
| 4703 testing::Bool(), | 4703 testing::Bool(), |
| 4704 testing::Bool())); | 4704 testing::Bool())); |
| 4705 | 4705 |
| 4706 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | |
| 4707 FakeImplTaskRunnerProvider task_runner_provider; | |
| 4708 TestTaskGraphRunner task_graph_runner; | |
| 4709 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | |
| 4710 host_impl.CreatePendingTree(); | |
| 4711 | |
| 4712 std::unique_ptr<LayerImpl> root = | |
| 4713 LayerImpl::Create(host_impl.pending_tree(), 1); | |
| 4714 root->SetBounds(gfx::Size(50, 50)); | |
| 4715 root->SetDrawsContent(true); | |
| 4716 LayerImpl* root_layer = root.get(); | |
| 4717 | |
| 4718 std::unique_ptr<LayerImpl> child = | |
| 4719 LayerImpl::Create(host_impl.pending_tree(), 2); | |
| 4720 child->SetBounds(gfx::Size(40, 40)); | |
| 4721 child->SetDrawsContent(true); | |
| 4722 LayerImpl* child_layer = child.get(); | |
| 4723 | |
| 4724 std::unique_ptr<LayerImpl> grand_child = | |
| 4725 LayerImpl::Create(host_impl.pending_tree(), 3); | |
| 4726 grand_child->SetBounds(gfx::Size(30, 30)); | |
| 4727 grand_child->SetDrawsContent(true); | |
| 4728 grand_child->test_properties()->hide_layer_and_subtree = true; | |
| 4729 LayerImpl* grand_child_layer = grand_child.get(); | |
| 4730 | |
| 4731 child->test_properties()->AddChild(std::move(grand_child)); | |
| 4732 root->test_properties()->AddChild(std::move(child)); | |
| 4733 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
| 4734 | |
| 4735 RenderSurfaceList render_surface_list; | |
| 4736 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 4737 root_layer, root_layer->bounds(), &render_surface_list); | |
| 4738 inputs.can_adjust_raster_scales = true; | |
| 4739 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 4740 | |
| 4741 // We should have one render surface and two layers. The grand child has | |
| 4742 // hidden itself. | |
| 4743 ASSERT_EQ(1u, render_surface_list.size()); | |
| 4744 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | |
| 4745 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
| 4746 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); | |
| 4747 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | |
| 4748 } | |
| 4749 | |
| 4750 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | |
| 4751 FakeImplTaskRunnerProvider task_runner_provider; | |
| 4752 TestTaskGraphRunner task_graph_runner; | |
| 4753 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | |
| 4754 host_impl.CreatePendingTree(); | |
| 4755 | |
| 4756 std::unique_ptr<LayerImpl> root = | |
| 4757 LayerImpl::Create(host_impl.pending_tree(), 1); | |
| 4758 root->SetBounds(gfx::Size(50, 50)); | |
| 4759 root->SetDrawsContent(true); | |
| 4760 LayerImpl* root_layer = root.get(); | |
| 4761 | |
| 4762 std::unique_ptr<LayerImpl> child = | |
| 4763 LayerImpl::Create(host_impl.pending_tree(), 2); | |
| 4764 child->SetBounds(gfx::Size(40, 40)); | |
| 4765 child->SetDrawsContent(true); | |
| 4766 child->test_properties()->hide_layer_and_subtree = true; | |
| 4767 LayerImpl* child_layer = child.get(); | |
| 4768 | |
| 4769 std::unique_ptr<LayerImpl> grand_child = | |
| 4770 LayerImpl::Create(host_impl.pending_tree(), 3); | |
| 4771 grand_child->SetBounds(gfx::Size(30, 30)); | |
| 4772 grand_child->SetDrawsContent(true); | |
| 4773 LayerImpl* grand_child_layer = grand_child.get(); | |
| 4774 | |
| 4775 child->test_properties()->AddChild(std::move(grand_child)); | |
| 4776 root->test_properties()->AddChild(std::move(child)); | |
| 4777 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
| 4778 | |
| 4779 RenderSurfaceList render_surface_list; | |
| 4780 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 4781 root_layer, root_layer->bounds(), &render_surface_list); | |
| 4782 inputs.can_adjust_raster_scales = true; | |
| 4783 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 4784 | |
| 4785 // We should have one render surface and one layer. The child has | |
| 4786 // hidden itself and the grand child. | |
| 4787 ASSERT_EQ(1u, render_surface_list.size()); | |
| 4788 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); | |
| 4789 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
| 4790 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); | |
| 4791 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | |
| 4792 } | |
| 4793 | |
| 4794 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 4706 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 4795 | 4707 |
| 4796 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 4708 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
| 4797 FakeImplTaskRunnerProvider task_runner_provider; | 4709 scoped_refptr<Layer> root = Layer::Create(); |
| 4798 TestTaskGraphRunner task_graph_runner; | 4710 scoped_refptr<Layer> copy_grand_parent = Layer::Create(); |
| 4799 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 4711 scoped_refptr<Layer> copy_parent = Layer::Create(); |
| 4800 host_impl.CreatePendingTree(); | 4712 scoped_refptr<Layer> copy_layer = Layer::Create(); |
| 4713 scoped_refptr<Layer> copy_child = Layer::Create(); |
| 4714 scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
| 4715 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create(); |
| 4716 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create(); |
| 4801 | 4717 |
| 4802 std::unique_ptr<LayerImpl> root = | |
| 4803 LayerImpl::Create(host_impl.pending_tree(), 1); | |
| 4804 root->SetBounds(gfx::Size(50, 50)); | 4718 root->SetBounds(gfx::Size(50, 50)); |
| 4805 root->SetDrawsContent(true); | 4719 copy_grand_parent->SetBounds(gfx::Size(50, 50)); |
| 4806 LayerImpl* root_layer = root.get(); | 4720 copy_parent->SetBounds(gfx::Size(50, 50)); |
| 4721 copy_parent->SetForceRenderSurfaceForTesting(true); |
| 4722 copy_layer->SetBounds(gfx::Size(50, 50)); |
| 4723 copy_child->SetBounds(gfx::Size(50, 50)); |
| 4724 copy_grand_child->SetBounds(gfx::Size(50, 50)); |
| 4725 copy_grand_parent_sibling_before->SetBounds(gfx::Size(50, 50)); |
| 4726 copy_grand_parent_sibling_after->SetBounds(gfx::Size(50, 50)); |
| 4807 | 4727 |
| 4808 std::unique_ptr<LayerImpl> copy_grand_parent = | 4728 root->AddChild(copy_grand_parent_sibling_before); |
| 4809 LayerImpl::Create(host_impl.pending_tree(), 2); | 4729 root->AddChild(copy_grand_parent); |
| 4810 copy_grand_parent->SetBounds(gfx::Size(40, 40)); | 4730 root->AddChild(copy_grand_parent_sibling_after); |
| 4811 copy_grand_parent->SetDrawsContent(true); | 4731 copy_grand_parent->AddChild(copy_parent); |
| 4812 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); | 4732 copy_parent->AddChild(copy_layer); |
| 4733 copy_layer->AddChild(copy_child); |
| 4734 copy_child->AddChild(copy_grand_child); |
| 4735 host()->SetRootLayer(root); |
| 4813 | 4736 |
| 4814 std::unique_ptr<LayerImpl> copy_parent = | 4737 copy_layer->RequestCopyOfOutput( |
| 4815 LayerImpl::Create(host_impl.pending_tree(), 3); | |
| 4816 copy_parent->SetBounds(gfx::Size(30, 30)); | |
| 4817 copy_parent->SetDrawsContent(true); | |
| 4818 copy_parent->test_properties()->force_render_surface = true; | |
| 4819 LayerImpl* copy_parent_layer = copy_parent.get(); | |
| 4820 | |
| 4821 std::unique_ptr<LayerImpl> copy_request = | |
| 4822 LayerImpl::Create(host_impl.pending_tree(), 4); | |
| 4823 copy_request->SetBounds(gfx::Size(20, 20)); | |
| 4824 copy_request->SetDrawsContent(true); | |
| 4825 copy_request->test_properties()->force_render_surface = true; | |
| 4826 LayerImpl* copy_layer = copy_request.get(); | |
| 4827 | |
| 4828 std::unique_ptr<LayerImpl> copy_child = | |
| 4829 LayerImpl::Create(host_impl.pending_tree(), 5); | |
| 4830 copy_child->SetBounds(gfx::Size(20, 20)); | |
| 4831 copy_child->SetDrawsContent(true); | |
| 4832 LayerImpl* copy_child_layer = copy_child.get(); | |
| 4833 | |
| 4834 std::unique_ptr<LayerImpl> copy_grand_child = | |
| 4835 LayerImpl::Create(host_impl.pending_tree(), 6); | |
| 4836 copy_grand_child->SetBounds(gfx::Size(20, 20)); | |
| 4837 copy_grand_child->SetDrawsContent(true); | |
| 4838 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); | |
| 4839 | |
| 4840 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = | |
| 4841 LayerImpl::Create(host_impl.pending_tree(), 7); | |
| 4842 copy_grand_parent_sibling_before->SetBounds(gfx::Size(40, 40)); | |
| 4843 copy_grand_parent_sibling_before->SetDrawsContent(true); | |
| 4844 LayerImpl* copy_grand_parent_sibling_before_layer = | |
| 4845 copy_grand_parent_sibling_before.get(); | |
| 4846 | |
| 4847 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = | |
| 4848 LayerImpl::Create(host_impl.pending_tree(), 8); | |
| 4849 copy_grand_parent_sibling_after->SetBounds(gfx::Size(40, 40)); | |
| 4850 copy_grand_parent_sibling_after->SetDrawsContent(true); | |
| 4851 LayerImpl* copy_grand_parent_sibling_after_layer = | |
| 4852 copy_grand_parent_sibling_after.get(); | |
| 4853 | |
| 4854 copy_child->test_properties()->AddChild(std::move(copy_grand_child)); | |
| 4855 copy_request->test_properties()->AddChild(std::move(copy_child)); | |
| 4856 copy_parent->test_properties()->AddChild(std::move(copy_request)); | |
| 4857 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent)); | |
| 4858 root->test_properties()->AddChild( | |
| 4859 std::move(copy_grand_parent_sibling_before)); | |
| 4860 root->test_properties()->AddChild(std::move(copy_grand_parent)); | |
| 4861 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after)); | |
| 4862 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
| 4863 | |
| 4864 // Hide the copy_grand_parent and its subtree. But make a copy request in that | |
| 4865 // hidden subtree on copy_layer. Also hide the copy grand child and its | |
| 4866 // subtree. | |
| 4867 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true; | |
| 4868 copy_grand_parent_sibling_before_layer->test_properties() | |
| 4869 ->hide_layer_and_subtree = true; | |
| 4870 copy_grand_parent_sibling_after_layer->test_properties() | |
| 4871 ->hide_layer_and_subtree = true; | |
| 4872 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true; | |
| 4873 | |
| 4874 copy_layer->test_properties()->copy_requests.push_back( | |
| 4875 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 4738 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 4876 | 4739 |
| 4877 RenderSurfaceList render_surface_list; | 4740 copy_grand_parent->SetHideLayerAndSubtree(true); |
| 4878 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 4741 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); |
| 4879 root_layer, root_layer->bounds(), &render_surface_list); | 4742 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); |
| 4880 inputs.can_adjust_raster_scales = true; | 4743 copy_grand_child->SetHideLayerAndSubtree(true); |
| 4881 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 4882 | 4744 |
| 4883 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); | 4745 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 4884 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); | 4746 EXPECT_FALSE(copy_grand_parent->is_hidden()); |
| 4885 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); | 4747 EXPECT_TRUE(copy_grand_parent_sibling_after->is_hidden()); |
| 4886 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); | 4748 EXPECT_TRUE(copy_grand_parent_sibling_before->is_hidden()); |
| 4749 EXPECT_TRUE(copy_grand_child->is_hidden()); |
| 4887 | 4750 |
| 4888 // We should have four render surfaces, one for the root, one for the grand | 4751 EffectTree& tree = host()->property_trees()->effect_tree; |
| 4889 // parent since it has opacity and two drawing descendants, one for the parent | 4752 EffectNode* node = tree.Node(copy_grand_parent->effect_tree_index()); |
| 4890 // since it owns a surface, and one for the copy_layer. | |
| 4891 ASSERT_EQ(4u, render_surface_list.size()); | |
| 4892 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | |
| 4893 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); | |
| 4894 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); | |
| 4895 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); | |
| 4896 | |
| 4897 // The root render surface should have 2 contributing layers. | |
| 4898 EXPECT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | |
| 4899 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
| 4900 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); | |
| 4901 EXPECT_FALSE(copy_grand_parent_sibling_before_layer | |
| 4902 ->contributes_to_drawn_render_surface()); | |
| 4903 EXPECT_FALSE(copy_grand_parent_sibling_after_layer | |
| 4904 ->contributes_to_drawn_render_surface()); | |
| 4905 | |
| 4906 // Nothing actually draws into the copy parent, so only the copy_layer will | |
| 4907 // appear in its list, since it needs to be drawn for the copy request. | |
| 4908 ASSERT_EQ(1, GetRenderSurface(copy_parent_layer)->num_contributors()); | |
| 4909 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); | |
| 4910 | |
| 4911 // The copy layer's render surface should have 2 contributing layers. | |
| 4912 ASSERT_EQ(2, GetRenderSurface(copy_layer)->num_contributors()); | |
| 4913 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | |
| 4914 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); | |
| 4915 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); | |
| 4916 | |
| 4917 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | |
| 4918 // but the copy_layer and copy_child should be drawn for the copy request. | |
| 4919 // copy grand child should not be drawn as its hidden even in the copy | |
| 4920 // request. | |
| 4921 EffectTree& tree = | |
| 4922 root_layer->layer_tree_impl()->property_trees()->effect_tree; | |
| 4923 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | |
| 4924 EXPECT_FALSE(node->is_drawn); | 4753 EXPECT_FALSE(node->is_drawn); |
| 4925 node = tree.Node(copy_parent_layer->effect_tree_index()); | 4754 node = tree.Node(copy_parent->effect_tree_index()); |
| 4926 EXPECT_FALSE(node->is_drawn); | 4755 EXPECT_FALSE(node->is_drawn); |
| 4927 node = tree.Node(copy_layer->effect_tree_index()); | 4756 node = tree.Node(copy_layer->effect_tree_index()); |
| 4928 EXPECT_TRUE(node->is_drawn); | 4757 EXPECT_TRUE(node->is_drawn); |
| 4929 node = tree.Node(copy_child_layer->effect_tree_index()); | 4758 node = tree.Node(copy_child->effect_tree_index()); |
| 4930 EXPECT_TRUE(node->is_drawn); | 4759 EXPECT_TRUE(node->is_drawn); |
| 4931 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | |
| 4932 EXPECT_FALSE(node->is_drawn); | |
| 4933 | |
| 4934 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its | |
| 4935 // actually hidden. | |
| 4936 EXPECT_FALSE(GetRenderSurface(copy_layer)->contributes_to_drawn_surface()); | |
| 4937 } | 4760 } |
| 4938 | 4761 |
| 4939 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 4762 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 4940 FakeImplTaskRunnerProvider task_runner_provider; | 4763 FakeImplTaskRunnerProvider task_runner_provider; |
| 4941 TestTaskGraphRunner task_graph_runner; | 4764 TestTaskGraphRunner task_graph_runner; |
| 4942 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 4765 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 4943 host_impl.CreatePendingTree(); | 4766 host_impl.CreatePendingTree(); |
| 4944 | 4767 |
| 4945 std::unique_ptr<LayerImpl> root = | 4768 std::unique_ptr<LayerImpl> root = |
| 4946 LayerImpl::Create(host_impl.pending_tree(), 1); | 4769 LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4982 ASSERT_EQ(2u, render_surface_list.size()); | 4805 ASSERT_EQ(2u, render_surface_list.size()); |
| 4983 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 4806 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
| 4984 | 4807 |
| 4985 // The root render surface should have only 2 contributing layer, since the | 4808 // The root render surface should have only 2 contributing layer, since the |
| 4986 // other layers are clipped away. | 4809 // other layers are clipped away. |
| 4987 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | 4810 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
| 4988 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 4811 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 4989 } | 4812 } |
| 4990 | 4813 |
| 4991 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { | 4814 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { |
| 4992 LayerImpl* root = root_layer_for_testing(); | 4815 scoped_refptr<Layer> root = Layer::Create(); |
| 4816 scoped_refptr<Layer> singular_transform_layer = Layer::Create(); |
| 4817 scoped_refptr<Layer> copy_layer = Layer::Create(); |
| 4818 scoped_refptr<Layer> copy_child = Layer::Create(); |
| 4819 scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
| 4820 |
| 4821 root->AddChild(singular_transform_layer); |
| 4822 singular_transform_layer->AddChild(copy_layer); |
| 4823 copy_layer->AddChild(copy_child); |
| 4824 copy_child->AddChild(copy_grand_child); |
| 4825 host()->SetRootLayer(root); |
| 4826 |
| 4993 root->SetBounds(gfx::Size(50, 50)); | 4827 root->SetBounds(gfx::Size(50, 50)); |
| 4994 root->SetDrawsContent(true); | 4828 root->SetIsDrawable(true); |
| 4995 | |
| 4996 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); | |
| 4997 singular_transform_layer->SetBounds(gfx::Size(100, 100)); | 4829 singular_transform_layer->SetBounds(gfx::Size(100, 100)); |
| 4998 singular_transform_layer->SetDrawsContent(true); | |
| 4999 gfx::Transform singular; | 4830 gfx::Transform singular; |
| 5000 singular.Scale3d(6.f, 6.f, 0.f); | 4831 singular.Scale3d(6.f, 6.f, 0.f); |
| 5001 singular_transform_layer->test_properties()->transform = singular; | 4832 singular_transform_layer->SetTransform(singular); |
| 4833 singular_transform_layer->SetIsDrawable(true); |
| 4834 copy_layer->SetBounds(gfx::Size(100, 100)); |
| 4835 copy_layer->SetIsDrawable(true); |
| 4836 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 4837 base::Bind(&EmptyCopyOutputCallback))); |
| 4838 copy_child->SetBounds(gfx::Size(100, 100)); |
| 4839 copy_child->SetIsDrawable(true); |
| 4840 copy_grand_child->SetBounds(gfx::Size(100, 100)); |
| 4841 copy_grand_child->SetTransform(singular); |
| 4842 copy_grand_child->SetIsDrawable(true); |
| 5002 | 4843 |
| 5003 LayerImpl* copy_layer = AddChild<LayerImpl>(singular_transform_layer); | 4844 ExecuteCalculateDrawProperties(root.get()); |
| 5004 copy_layer->SetBounds(gfx::Size(100, 100)); | |
| 5005 copy_layer->SetDrawsContent(true); | |
| 5006 copy_layer->test_properties()->copy_requests.push_back( | |
| 5007 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | |
| 5008 | 4845 |
| 5009 LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); | 4846 host()->host_impl()->CreatePendingTree(); |
| 5010 copy_child->SetBounds(gfx::Size(100, 100)); | 4847 host()->CommitAndCreatePendingTree(); |
| 5011 copy_child->SetDrawsContent(true); | 4848 host()->host_impl()->ActivateSyncTree(); |
| 4849 LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree(); |
| 5012 | 4850 |
| 5013 LayerImpl* copy_grand_child = AddChild<LayerImpl>(copy_child); | 4851 LayerImpl* root_impl = layer_tree_impl->LayerById(root->id()); |
| 5014 copy_grand_child->SetBounds(gfx::Size(100, 100)); | 4852 LayerImpl* singular_transform_layer_impl = |
| 5015 copy_grand_child->SetDrawsContent(true); | 4853 layer_tree_impl->LayerById(singular_transform_layer->id()); |
| 5016 copy_grand_child->test_properties()->transform = singular; | 4854 LayerImpl* copy_layer_impl = layer_tree_impl->LayerById(copy_layer->id()); |
| 5017 | 4855 LayerImpl* copy_child_impl = layer_tree_impl->LayerById(copy_child->id()); |
| 5018 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); | 4856 LayerImpl* copy_grand_child_impl = |
| 5019 ExecuteCalculateDrawProperties(root); | 4857 layer_tree_impl->LayerById(copy_grand_child->id()); |
| 5020 DCHECK(copy_layer->test_properties()->copy_requests.empty()); | 4858 ExecuteCalculateDrawProperties(root_impl); |
| 5021 | 4859 |
| 5022 // A layer with singular transform should not contribute to drawn render | 4860 // A layer with singular transform should not contribute to drawn render |
| 5023 // surface. | 4861 // surface. |
| 5024 EXPECT_FALSE(singular_transform_layer->contributes_to_drawn_render_surface()); | 4862 EXPECT_FALSE( |
| 4863 singular_transform_layer_impl->contributes_to_drawn_render_surface()); |
| 5025 // Even though copy_layer and copy_child have singular screen space transform, | 4864 // Even though copy_layer and copy_child have singular screen space transform, |
| 5026 // they still contribute to drawn render surface as their transform to the | 4865 // they still contribute to drawn render surface as their transform to the |
| 5027 // closest ancestor with copy request is not singular. | 4866 // closest ancestor with copy request is not singular. |
| 5028 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | 4867 EXPECT_TRUE(copy_layer_impl->contributes_to_drawn_render_surface()); |
| 5029 EXPECT_TRUE(copy_child->contributes_to_drawn_render_surface()); | 4868 EXPECT_TRUE(copy_child_impl->contributes_to_drawn_render_surface()); |
| 5030 // copy_grand_child's transform to its closest ancestor with copy request is | 4869 // copy_grand_child's transform to its closest ancestor with copy request is |
| 5031 // also singular. So, it doesn't contribute to drawn render surface. | 4870 // also singular. So, it doesn't contribute to drawn render surface. |
| 5032 EXPECT_FALSE(copy_grand_child->contributes_to_drawn_render_surface()); | 4871 EXPECT_FALSE(copy_grand_child_impl->contributes_to_drawn_render_surface()); |
| 5033 } | 4872 } |
| 5034 | 4873 |
| 5035 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { | 4874 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
| 5036 LayerImpl* root = root_layer_for_testing(); | 4875 LayerImpl* root = root_layer_for_testing(); |
| 5037 root->SetBounds(gfx::Size(50, 50)); | 4876 root->SetBounds(gfx::Size(50, 50)); |
| 5038 root->SetDrawsContent(true); | 4877 root->SetDrawsContent(true); |
| 5039 root->SetMasksToBounds(true); | 4878 root->SetMasksToBounds(true); |
| 5040 | 4879 |
| 5041 LayerImpl* copy_layer = AddChild<LayerImpl>(root); | 4880 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
| 5042 copy_layer->SetBounds(gfx::Size(100, 100)); | 4881 copy_layer->SetBounds(gfx::Size(100, 100)); |
| (...skipping 3676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8719 | 8558 |
| 8720 child->SetTransform(singular); | 8559 child->SetTransform(singular); |
| 8721 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 8560 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 8722 update_list = GetUpdateLayerList(); | 8561 update_list = GetUpdateLayerList(); |
| 8723 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 8562 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
| 8724 child->SetTransform(gfx::Transform()); | 8563 child->SetTransform(gfx::Transform()); |
| 8725 | 8564 |
| 8726 child->SetHideLayerAndSubtree(true); | 8565 child->SetHideLayerAndSubtree(true); |
| 8727 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 8566 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 8728 update_list = GetUpdateLayerList(); | 8567 update_list = GetUpdateLayerList(); |
| 8568 EXPECT_TRUE(child->is_hidden()); |
| 8569 EXPECT_TRUE(grandchild->is_hidden()); |
| 8570 EXPECT_FALSE(VerifyLayerInList(child, update_list)); |
| 8729 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 8571 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
| 8730 child->SetHideLayerAndSubtree(false); | 8572 child->SetHideLayerAndSubtree(false); |
| 8731 | 8573 |
| 8732 gfx::Transform zero_z_scale; | 8574 gfx::Transform zero_z_scale; |
| 8733 zero_z_scale.Scale3d(1, 1, 0); | 8575 zero_z_scale.Scale3d(1, 1, 0); |
| 8734 child->SetTransform(zero_z_scale); | 8576 child->SetTransform(zero_z_scale); |
| 8735 | 8577 |
| 8736 // Add a transform animation with a start delay. Now, even though |child| has | 8578 // Add a transform animation with a start delay. Now, even though |child| has |
| 8737 // a singular transform, the subtree should still get processed. | 8579 // a singular transform, the subtree should still get processed. |
| 8738 int animation_id = 0; | 8580 int animation_id = 0; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8832 gfx::Transform rotate_back_and_translate; | 8674 gfx::Transform rotate_back_and_translate; |
| 8833 rotate_back_and_translate.RotateAboutYAxis(180); | 8675 rotate_back_and_translate.RotateAboutYAxis(180); |
| 8834 rotate_back_and_translate.Translate(-10, 0); | 8676 rotate_back_and_translate.Translate(-10, 0); |
| 8835 | 8677 |
| 8836 child_ptr->test_properties()->transform = singular; | 8678 child_ptr->test_properties()->transform = singular; |
| 8837 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8679 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8838 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 8680 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 8839 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8681 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8840 child_ptr->test_properties()->transform = gfx::Transform(); | 8682 child_ptr->test_properties()->transform = gfx::Transform(); |
| 8841 | 8683 |
| 8842 child_ptr->test_properties()->hide_layer_and_subtree = true; | |
| 8843 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | |
| 8844 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | |
| 8845 child_ptr->test_properties()->hide_layer_and_subtree = false; | |
| 8846 | |
| 8847 child_ptr->test_properties()->opacity = 0.f; | 8684 child_ptr->test_properties()->opacity = 0.f; |
| 8848 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8685 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8849 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 8686 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 8850 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8687 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8851 child_ptr->test_properties()->opacity = 1.f; | 8688 child_ptr->test_properties()->opacity = 1.f; |
| 8852 | 8689 |
| 8853 root_ptr->test_properties()->transform = singular; | 8690 root_ptr->test_properties()->transform = singular; |
| 8854 // Force transform tree to have a node for child, so that ancestor's | 8691 // Force transform tree to have a node for child, so that ancestor's |
| 8855 // invertible transform can be tested. | 8692 // invertible transform can be tested. |
| 8856 child_ptr->test_properties()->transform = rotate; | 8693 child_ptr->test_properties()->transform = rotate; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9031 LayerImpl* child = AddChild<LayerImpl>(root); | 8868 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9032 | 8869 |
| 9033 root->SetBounds(gfx::Size(100, 100)); | 8870 root->SetBounds(gfx::Size(100, 100)); |
| 9034 child->SetBounds(gfx::Size(10, 10)); | 8871 child->SetBounds(gfx::Size(10, 10)); |
| 9035 child->SetDrawsContent(true); | 8872 child->SetDrawsContent(true); |
| 9036 | 8873 |
| 9037 ExecuteCalculateDrawProperties(root); | 8874 ExecuteCalculateDrawProperties(root); |
| 9038 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 8875 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 9039 child->set_visible_layer_rect(gfx::Rect()); | 8876 child->set_visible_layer_rect(gfx::Rect()); |
| 9040 | 8877 |
| 9041 child->test_properties()->hide_layer_and_subtree = true; | |
| 9042 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | |
| 9043 ExecuteCalculateDrawProperties(root); | |
| 9044 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | |
| 9045 child->test_properties()->hide_layer_and_subtree = false; | |
| 9046 | |
| 9047 child->SetBounds(gfx::Size()); | 8878 child->SetBounds(gfx::Size()); |
| 9048 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8879 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9049 ExecuteCalculateDrawProperties(root); | 8880 ExecuteCalculateDrawProperties(root); |
| 9050 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8881 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 9051 child->SetBounds(gfx::Size(10, 10)); | 8882 child->SetBounds(gfx::Size(10, 10)); |
| 9052 | 8883 |
| 9053 gfx::Transform rotate; | 8884 gfx::Transform rotate; |
| 9054 child->test_properties()->double_sided = false; | 8885 child->test_properties()->double_sided = false; |
| 9055 rotate.RotateAboutXAxis(180.f); | 8886 rotate.RotateAboutXAxis(180.f); |
| 9056 child->test_properties()->transform = rotate; | 8887 child->test_properties()->transform = rotate; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9563 test_layer->SetDrawsContent(true); | 9394 test_layer->SetDrawsContent(true); |
| 9564 ExecuteCalculateDrawProperties(root); | 9395 ExecuteCalculateDrawProperties(root); |
| 9565 | 9396 |
| 9566 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); | 9397 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); |
| 9567 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); | 9398 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); |
| 9568 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); | 9399 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); |
| 9569 } | 9400 } |
| 9570 | 9401 |
| 9571 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { | 9402 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { |
| 9572 // Tests that subtree is hidden is updated. | 9403 // Tests that subtree is hidden is updated. |
| 9573 LayerImpl* root = root_layer_for_testing(); | 9404 scoped_refptr<Layer> root = Layer::Create(); |
| 9574 LayerImpl* hidden = AddChild<LayerImpl>(root); | 9405 scoped_refptr<Layer> hidden = Layer::Create(); |
| 9575 LayerImpl* test = AddChild<LayerImpl>(hidden); | 9406 scoped_refptr<Layer> test = Layer::Create(); |
| 9576 | 9407 |
| 9577 root->SetBounds(gfx::Size(30, 30)); | 9408 root->SetBounds(gfx::Size(30, 30)); |
| 9578 hidden->SetBounds(gfx::Size(30, 30)); | 9409 hidden->SetBounds(gfx::Size(30, 30)); |
| 9579 hidden->test_properties()->force_render_surface = true; | 9410 hidden->SetHideLayerAndSubtree(true); |
| 9580 hidden->test_properties()->hide_layer_and_subtree = true; | |
| 9581 test->SetBounds(gfx::Size(30, 30)); | 9411 test->SetBounds(gfx::Size(30, 30)); |
| 9582 test->test_properties()->force_render_surface = true; | |
| 9583 | 9412 |
| 9584 ExecuteCalculateDrawProperties(root); | 9413 root->AddChild(hidden); |
| 9585 EXPECT_EQ(0.f, | 9414 hidden->AddChild(test); |
| 9586 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); | 9415 host()->SetRootLayer(root); |
| 9587 | 9416 |
| 9588 hidden->test_properties()->hide_layer_and_subtree = false; | 9417 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9589 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9418 EXPECT_TRUE(test->is_hidden()); |
| 9590 ExecuteCalculateDrawProperties(root); | 9419 // Hidden layers should have invalid property tree indices. |
| 9591 EXPECT_EQ(1.f, | 9420 const int kInvalidNodeId = -1; |
| 9592 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); | 9421 EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId); |
| 9422 EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId); |
| 9423 EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId); |
| 9424 EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId); |
| 9425 |
| 9426 hidden->SetHideLayerAndSubtree(false); |
| 9427 root->layer_tree_host()->property_trees()->needs_rebuild = true; |
| 9428 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9429 EXPECT_FALSE(test->is_hidden()); |
| 9430 EXPECT_NE(test->effect_tree_index(), kInvalidNodeId); |
| 9431 EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId); |
| 9432 EXPECT_NE(test->clip_tree_index(), kInvalidNodeId); |
| 9433 EXPECT_NE(test->transform_tree_index(), kInvalidNodeId); |
| 9593 } | 9434 } |
| 9594 | 9435 |
| 9595 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9436 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 9596 LayerImpl* root = root_layer_for_testing(); | 9437 LayerImpl* root = root_layer_for_testing(); |
| 9597 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 9438 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 9598 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); | 9439 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 9599 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9440 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 9600 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9441 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 9601 | 9442 |
| 9602 root->SetBounds(gfx::Size(30, 30)); | 9443 root->SetBounds(gfx::Size(30, 30)); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10178 | 10019 |
| 10179 // Check child layer draw properties. | 10020 // Check child layer draw properties. |
| 10180 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10021 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10181 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10022 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10182 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10023 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10183 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10024 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10184 } | 10025 } |
| 10185 | 10026 |
| 10186 } // namespace | 10027 } // namespace |
| 10187 } // namespace cc | 10028 } // namespace cc |
| OLD | NEW |