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 4716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4727 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 4727 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
4728 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 4728 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
4729 } | 4729 } |
4730 | 4730 |
4731 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 4731 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
4732 LCDTextTest, | 4732 LCDTextTest, |
4733 testing::Combine(testing::Bool(), | 4733 testing::Combine(testing::Bool(), |
4734 testing::Bool(), | 4734 testing::Bool(), |
4735 testing::Bool())); | 4735 testing::Bool())); |
4736 | 4736 |
4737 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | |
4738 FakeImplTaskRunnerProvider task_runner_provider; | |
4739 TestTaskGraphRunner task_graph_runner; | |
4740 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | |
4741 host_impl.CreatePendingTree(); | |
4742 | |
4743 std::unique_ptr<LayerImpl> root = | |
4744 LayerImpl::Create(host_impl.pending_tree(), 1); | |
4745 root->SetBounds(gfx::Size(50, 50)); | |
4746 root->SetDrawsContent(true); | |
4747 LayerImpl* root_layer = root.get(); | |
4748 | |
4749 std::unique_ptr<LayerImpl> child = | |
4750 LayerImpl::Create(host_impl.pending_tree(), 2); | |
4751 child->SetBounds(gfx::Size(40, 40)); | |
4752 child->SetDrawsContent(true); | |
4753 LayerImpl* child_layer = child.get(); | |
4754 | |
4755 std::unique_ptr<LayerImpl> grand_child = | |
4756 LayerImpl::Create(host_impl.pending_tree(), 3); | |
4757 grand_child->SetBounds(gfx::Size(30, 30)); | |
4758 grand_child->SetDrawsContent(true); | |
4759 grand_child->test_properties()->hide_layer_and_subtree = true; | |
4760 LayerImpl* grand_child_layer = grand_child.get(); | |
4761 | |
4762 child->test_properties()->AddChild(std::move(grand_child)); | |
4763 root->test_properties()->AddChild(std::move(child)); | |
4764 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
4765 | |
4766 RenderSurfaceList render_surface_list; | |
4767 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
4768 root_layer, root_layer->bounds(), &render_surface_list); | |
4769 inputs.can_adjust_raster_scales = true; | |
4770 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
4771 | |
4772 // We should have one render surface and two layers. The grand child has | |
4773 // hidden itself. | |
4774 ASSERT_EQ(1u, render_surface_list.size()); | |
4775 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | |
4776 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
4777 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); | |
4778 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | |
4779 } | |
4780 | |
4781 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | |
4782 FakeImplTaskRunnerProvider task_runner_provider; | |
4783 TestTaskGraphRunner task_graph_runner; | |
4784 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | |
4785 host_impl.CreatePendingTree(); | |
4786 | |
4787 std::unique_ptr<LayerImpl> root = | |
4788 LayerImpl::Create(host_impl.pending_tree(), 1); | |
4789 root->SetBounds(gfx::Size(50, 50)); | |
4790 root->SetDrawsContent(true); | |
4791 LayerImpl* root_layer = root.get(); | |
4792 | |
4793 std::unique_ptr<LayerImpl> child = | |
4794 LayerImpl::Create(host_impl.pending_tree(), 2); | |
4795 child->SetBounds(gfx::Size(40, 40)); | |
4796 child->SetDrawsContent(true); | |
4797 child->test_properties()->hide_layer_and_subtree = true; | |
4798 LayerImpl* child_layer = child.get(); | |
4799 | |
4800 std::unique_ptr<LayerImpl> grand_child = | |
4801 LayerImpl::Create(host_impl.pending_tree(), 3); | |
4802 grand_child->SetBounds(gfx::Size(30, 30)); | |
4803 grand_child->SetDrawsContent(true); | |
4804 LayerImpl* grand_child_layer = grand_child.get(); | |
4805 | |
4806 child->test_properties()->AddChild(std::move(grand_child)); | |
4807 root->test_properties()->AddChild(std::move(child)); | |
4808 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
4809 | |
4810 RenderSurfaceList render_surface_list; | |
4811 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
4812 root_layer, root_layer->bounds(), &render_surface_list); | |
4813 inputs.can_adjust_raster_scales = true; | |
4814 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
4815 | |
4816 // We should have one render surface and one layer. The child has | |
4817 // hidden itself and the grand child. | |
4818 ASSERT_EQ(1u, render_surface_list.size()); | |
4819 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); | |
4820 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
4821 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); | |
4822 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | |
4823 } | |
4824 | |
4825 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 4737 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
4826 | 4738 |
4827 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 4739 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
4828 FakeImplTaskRunnerProvider task_runner_provider; | 4740 scoped_refptr<Layer> root = Layer::Create(); |
4829 TestTaskGraphRunner task_graph_runner; | 4741 scoped_refptr<Layer> copy_grand_parent = Layer::Create(); |
4830 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 4742 scoped_refptr<Layer> copy_parent = Layer::Create(); |
4831 host_impl.CreatePendingTree(); | 4743 scoped_refptr<Layer> copy_layer = Layer::Create(); |
| 4744 scoped_refptr<Layer> copy_child = Layer::Create(); |
| 4745 scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
| 4746 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create(); |
| 4747 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create(); |
4832 | 4748 |
4833 std::unique_ptr<LayerImpl> root = | |
4834 LayerImpl::Create(host_impl.pending_tree(), 1); | |
4835 root->SetBounds(gfx::Size(50, 50)); | 4749 root->SetBounds(gfx::Size(50, 50)); |
4836 root->SetDrawsContent(true); | 4750 copy_grand_parent->SetBounds(gfx::Size(50, 50)); |
4837 LayerImpl* root_layer = root.get(); | 4751 copy_parent->SetBounds(gfx::Size(50, 50)); |
| 4752 copy_parent->SetForceRenderSurfaceForTesting(true); |
| 4753 copy_layer->SetBounds(gfx::Size(50, 50)); |
| 4754 copy_child->SetBounds(gfx::Size(50, 50)); |
| 4755 copy_grand_child->SetBounds(gfx::Size(50, 50)); |
| 4756 copy_grand_parent_sibling_before->SetBounds(gfx::Size(50, 50)); |
| 4757 copy_grand_parent_sibling_after->SetBounds(gfx::Size(50, 50)); |
4838 | 4758 |
4839 std::unique_ptr<LayerImpl> copy_grand_parent = | 4759 root->AddChild(copy_grand_parent_sibling_before); |
4840 LayerImpl::Create(host_impl.pending_tree(), 2); | 4760 root->AddChild(copy_grand_parent); |
4841 copy_grand_parent->SetBounds(gfx::Size(40, 40)); | 4761 root->AddChild(copy_grand_parent_sibling_after); |
4842 copy_grand_parent->SetDrawsContent(true); | 4762 copy_grand_parent->AddChild(copy_parent); |
4843 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); | 4763 copy_parent->AddChild(copy_layer); |
| 4764 copy_layer->AddChild(copy_child); |
| 4765 copy_child->AddChild(copy_grand_child); |
| 4766 host()->SetRootLayer(root); |
4844 | 4767 |
4845 std::unique_ptr<LayerImpl> copy_parent = | 4768 copy_layer->RequestCopyOfOutput( |
4846 LayerImpl::Create(host_impl.pending_tree(), 3); | |
4847 copy_parent->SetBounds(gfx::Size(30, 30)); | |
4848 copy_parent->SetDrawsContent(true); | |
4849 copy_parent->test_properties()->force_render_surface = true; | |
4850 LayerImpl* copy_parent_layer = copy_parent.get(); | |
4851 | |
4852 std::unique_ptr<LayerImpl> copy_request = | |
4853 LayerImpl::Create(host_impl.pending_tree(), 4); | |
4854 copy_request->SetBounds(gfx::Size(20, 20)); | |
4855 copy_request->SetDrawsContent(true); | |
4856 copy_request->test_properties()->force_render_surface = true; | |
4857 LayerImpl* copy_layer = copy_request.get(); | |
4858 | |
4859 std::unique_ptr<LayerImpl> copy_child = | |
4860 LayerImpl::Create(host_impl.pending_tree(), 5); | |
4861 copy_child->SetBounds(gfx::Size(20, 20)); | |
4862 copy_child->SetDrawsContent(true); | |
4863 LayerImpl* copy_child_layer = copy_child.get(); | |
4864 | |
4865 std::unique_ptr<LayerImpl> copy_grand_child = | |
4866 LayerImpl::Create(host_impl.pending_tree(), 6); | |
4867 copy_grand_child->SetBounds(gfx::Size(20, 20)); | |
4868 copy_grand_child->SetDrawsContent(true); | |
4869 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); | |
4870 | |
4871 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = | |
4872 LayerImpl::Create(host_impl.pending_tree(), 7); | |
4873 copy_grand_parent_sibling_before->SetBounds(gfx::Size(40, 40)); | |
4874 copy_grand_parent_sibling_before->SetDrawsContent(true); | |
4875 LayerImpl* copy_grand_parent_sibling_before_layer = | |
4876 copy_grand_parent_sibling_before.get(); | |
4877 | |
4878 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = | |
4879 LayerImpl::Create(host_impl.pending_tree(), 8); | |
4880 copy_grand_parent_sibling_after->SetBounds(gfx::Size(40, 40)); | |
4881 copy_grand_parent_sibling_after->SetDrawsContent(true); | |
4882 LayerImpl* copy_grand_parent_sibling_after_layer = | |
4883 copy_grand_parent_sibling_after.get(); | |
4884 | |
4885 copy_child->test_properties()->AddChild(std::move(copy_grand_child)); | |
4886 copy_request->test_properties()->AddChild(std::move(copy_child)); | |
4887 copy_parent->test_properties()->AddChild(std::move(copy_request)); | |
4888 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent)); | |
4889 root->test_properties()->AddChild( | |
4890 std::move(copy_grand_parent_sibling_before)); | |
4891 root->test_properties()->AddChild(std::move(copy_grand_parent)); | |
4892 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after)); | |
4893 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | |
4894 | |
4895 // Hide the copy_grand_parent and its subtree. But make a copy request in that | |
4896 // hidden subtree on copy_layer. Also hide the copy grand child and its | |
4897 // subtree. | |
4898 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true; | |
4899 copy_grand_parent_sibling_before_layer->test_properties() | |
4900 ->hide_layer_and_subtree = true; | |
4901 copy_grand_parent_sibling_after_layer->test_properties() | |
4902 ->hide_layer_and_subtree = true; | |
4903 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true; | |
4904 | |
4905 copy_layer->test_properties()->copy_requests.push_back( | |
4906 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 4769 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
4907 | 4770 |
4908 RenderSurfaceList render_surface_list; | 4771 copy_grand_parent->SetHideLayerAndSubtree(true); |
4909 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 4772 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); |
4910 root_layer, root_layer->bounds(), &render_surface_list); | 4773 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); |
4911 inputs.can_adjust_raster_scales = true; | 4774 copy_grand_child->SetHideLayerAndSubtree(true); |
4912 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
4913 | 4775 |
4914 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); | 4776 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
4915 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); | 4777 EXPECT_FALSE(copy_grand_parent->is_hidden()); |
4916 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); | 4778 EXPECT_TRUE(copy_grand_parent_sibling_after->is_hidden()); |
4917 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); | 4779 EXPECT_TRUE(copy_grand_parent_sibling_before->is_hidden()); |
| 4780 EXPECT_TRUE(copy_grand_child->is_hidden()); |
4918 | 4781 |
4919 // We should have four render surfaces, one for the root, one for the grand | 4782 EffectTree& tree = host()->property_trees()->effect_tree; |
4920 // parent since it has opacity and two drawing descendants, one for the parent | 4783 EffectNode* node = tree.Node(copy_grand_parent->effect_tree_index()); |
4921 // since it owns a surface, and one for the copy_layer. | |
4922 ASSERT_EQ(4u, render_surface_list.size()); | |
4923 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | |
4924 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); | |
4925 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); | |
4926 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); | |
4927 | |
4928 // The root render surface should have 2 contributing layers. | |
4929 EXPECT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | |
4930 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | |
4931 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); | |
4932 EXPECT_FALSE(copy_grand_parent_sibling_before_layer | |
4933 ->contributes_to_drawn_render_surface()); | |
4934 EXPECT_FALSE(copy_grand_parent_sibling_after_layer | |
4935 ->contributes_to_drawn_render_surface()); | |
4936 | |
4937 // Nothing actually draws into the copy parent, so only the copy_layer will | |
4938 // appear in its list, since it needs to be drawn for the copy request. | |
4939 ASSERT_EQ(1, GetRenderSurface(copy_parent_layer)->num_contributors()); | |
4940 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); | |
4941 | |
4942 // The copy layer's render surface should have 2 contributing layers. | |
4943 ASSERT_EQ(2, GetRenderSurface(copy_layer)->num_contributors()); | |
4944 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | |
4945 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); | |
4946 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); | |
4947 | |
4948 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | |
4949 // but the copy_layer and copy_child should be drawn for the copy request. | |
4950 // copy grand child should not be drawn as its hidden even in the copy | |
4951 // request. | |
4952 EffectTree& tree = | |
4953 root_layer->layer_tree_impl()->property_trees()->effect_tree; | |
4954 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | |
4955 EXPECT_FALSE(node->is_drawn); | 4784 EXPECT_FALSE(node->is_drawn); |
4956 node = tree.Node(copy_parent_layer->effect_tree_index()); | 4785 node = tree.Node(copy_parent->effect_tree_index()); |
4957 EXPECT_FALSE(node->is_drawn); | 4786 EXPECT_FALSE(node->is_drawn); |
4958 node = tree.Node(copy_layer->effect_tree_index()); | 4787 node = tree.Node(copy_layer->effect_tree_index()); |
4959 EXPECT_TRUE(node->is_drawn); | 4788 EXPECT_TRUE(node->is_drawn); |
4960 node = tree.Node(copy_child_layer->effect_tree_index()); | 4789 node = tree.Node(copy_child->effect_tree_index()); |
4961 EXPECT_TRUE(node->is_drawn); | 4790 EXPECT_TRUE(node->is_drawn); |
4962 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | |
4963 EXPECT_FALSE(node->is_drawn); | |
4964 | |
4965 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its | |
4966 // actually hidden. | |
4967 EXPECT_FALSE(GetRenderSurface(copy_layer)->contributes_to_drawn_surface()); | |
4968 } | 4791 } |
4969 | 4792 |
4970 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 4793 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
4971 FakeImplTaskRunnerProvider task_runner_provider; | 4794 FakeImplTaskRunnerProvider task_runner_provider; |
4972 TestTaskGraphRunner task_graph_runner; | 4795 TestTaskGraphRunner task_graph_runner; |
4973 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 4796 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
4974 host_impl.CreatePendingTree(); | 4797 host_impl.CreatePendingTree(); |
4975 | 4798 |
4976 std::unique_ptr<LayerImpl> root = | 4799 std::unique_ptr<LayerImpl> root = |
4977 LayerImpl::Create(host_impl.pending_tree(), 1); | 4800 LayerImpl::Create(host_impl.pending_tree(), 1); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5013 ASSERT_EQ(2u, render_surface_list.size()); | 4836 ASSERT_EQ(2u, render_surface_list.size()); |
5014 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 4837 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
5015 | 4838 |
5016 // The root render surface should have only 2 contributing layer, since the | 4839 // The root render surface should have only 2 contributing layer, since the |
5017 // other layers are clipped away. | 4840 // other layers are clipped away. |
5018 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); | 4841 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
5019 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 4842 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
5020 } | 4843 } |
5021 | 4844 |
5022 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { | 4845 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { |
5023 LayerImpl* root = root_layer_for_testing(); | 4846 scoped_refptr<Layer> root = Layer::Create(); |
| 4847 scoped_refptr<Layer> singular_transform_layer = Layer::Create(); |
| 4848 scoped_refptr<Layer> copy_layer = Layer::Create(); |
| 4849 scoped_refptr<Layer> copy_child = Layer::Create(); |
| 4850 scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
| 4851 |
| 4852 root->AddChild(singular_transform_layer); |
| 4853 singular_transform_layer->AddChild(copy_layer); |
| 4854 copy_layer->AddChild(copy_child); |
| 4855 copy_child->AddChild(copy_grand_child); |
| 4856 host()->SetRootLayer(root); |
| 4857 |
5024 root->SetBounds(gfx::Size(50, 50)); | 4858 root->SetBounds(gfx::Size(50, 50)); |
5025 root->SetDrawsContent(true); | 4859 root->SetIsDrawable(true); |
5026 | |
5027 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); | |
5028 singular_transform_layer->SetBounds(gfx::Size(100, 100)); | 4860 singular_transform_layer->SetBounds(gfx::Size(100, 100)); |
5029 singular_transform_layer->SetDrawsContent(true); | |
5030 gfx::Transform singular; | 4861 gfx::Transform singular; |
5031 singular.Scale3d(6.f, 6.f, 0.f); | 4862 singular.Scale3d(6.f, 6.f, 0.f); |
5032 singular_transform_layer->test_properties()->transform = singular; | 4863 singular_transform_layer->SetTransform(singular); |
| 4864 singular_transform_layer->SetIsDrawable(true); |
| 4865 copy_layer->SetBounds(gfx::Size(100, 100)); |
| 4866 copy_layer->SetIsDrawable(true); |
| 4867 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 4868 base::Bind(&EmptyCopyOutputCallback))); |
| 4869 copy_child->SetBounds(gfx::Size(100, 100)); |
| 4870 copy_child->SetIsDrawable(true); |
| 4871 copy_grand_child->SetBounds(gfx::Size(100, 100)); |
| 4872 copy_grand_child->SetTransform(singular); |
| 4873 copy_grand_child->SetIsDrawable(true); |
5033 | 4874 |
5034 LayerImpl* copy_layer = AddChild<LayerImpl>(singular_transform_layer); | 4875 ExecuteCalculateDrawProperties(root.get()); |
5035 copy_layer->SetBounds(gfx::Size(100, 100)); | |
5036 copy_layer->SetDrawsContent(true); | |
5037 copy_layer->test_properties()->copy_requests.push_back( | |
5038 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | |
5039 | 4876 |
5040 LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); | 4877 host()->host_impl()->CreatePendingTree(); |
5041 copy_child->SetBounds(gfx::Size(100, 100)); | 4878 host()->CommitAndCreatePendingTree(); |
5042 copy_child->SetDrawsContent(true); | 4879 host()->host_impl()->ActivateSyncTree(); |
| 4880 LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree(); |
5043 | 4881 |
5044 LayerImpl* copy_grand_child = AddChild<LayerImpl>(copy_child); | 4882 LayerImpl* root_impl = layer_tree_impl->LayerById(root->id()); |
5045 copy_grand_child->SetBounds(gfx::Size(100, 100)); | 4883 LayerImpl* singular_transform_layer_impl = |
5046 copy_grand_child->SetDrawsContent(true); | 4884 layer_tree_impl->LayerById(singular_transform_layer->id()); |
5047 copy_grand_child->test_properties()->transform = singular; | 4885 LayerImpl* copy_layer_impl = layer_tree_impl->LayerById(copy_layer->id()); |
5048 | 4886 LayerImpl* copy_child_impl = layer_tree_impl->LayerById(copy_child->id()); |
5049 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); | 4887 LayerImpl* copy_grand_child_impl = |
5050 ExecuteCalculateDrawProperties(root); | 4888 layer_tree_impl->LayerById(copy_grand_child->id()); |
5051 DCHECK(copy_layer->test_properties()->copy_requests.empty()); | 4889 ExecuteCalculateDrawProperties(root_impl); |
5052 | 4890 |
5053 // A layer with singular transform should not contribute to drawn render | 4891 // A layer with singular transform should not contribute to drawn render |
5054 // surface. | 4892 // surface. |
5055 EXPECT_FALSE(singular_transform_layer->contributes_to_drawn_render_surface()); | 4893 EXPECT_FALSE( |
| 4894 singular_transform_layer_impl->contributes_to_drawn_render_surface()); |
5056 // Even though copy_layer and copy_child have singular screen space transform, | 4895 // Even though copy_layer and copy_child have singular screen space transform, |
5057 // they still contribute to drawn render surface as their transform to the | 4896 // they still contribute to drawn render surface as their transform to the |
5058 // closest ancestor with copy request is not singular. | 4897 // closest ancestor with copy request is not singular. |
5059 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | 4898 EXPECT_TRUE(copy_layer_impl->contributes_to_drawn_render_surface()); |
5060 EXPECT_TRUE(copy_child->contributes_to_drawn_render_surface()); | 4899 EXPECT_TRUE(copy_child_impl->contributes_to_drawn_render_surface()); |
5061 // copy_grand_child's transform to its closest ancestor with copy request is | 4900 // copy_grand_child's transform to its closest ancestor with copy request is |
5062 // also singular. So, it doesn't contribute to drawn render surface. | 4901 // also singular. So, it doesn't contribute to drawn render surface. |
5063 EXPECT_FALSE(copy_grand_child->contributes_to_drawn_render_surface()); | 4902 EXPECT_FALSE(copy_grand_child_impl->contributes_to_drawn_render_surface()); |
5064 } | 4903 } |
5065 | 4904 |
5066 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { | 4905 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
5067 LayerImpl* root = root_layer_for_testing(); | 4906 LayerImpl* root = root_layer_for_testing(); |
5068 root->SetBounds(gfx::Size(50, 50)); | 4907 root->SetBounds(gfx::Size(50, 50)); |
5069 root->SetDrawsContent(true); | 4908 root->SetDrawsContent(true); |
5070 root->SetMasksToBounds(true); | 4909 root->SetMasksToBounds(true); |
5071 | 4910 |
5072 LayerImpl* copy_layer = AddChild<LayerImpl>(root); | 4911 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
5073 copy_layer->SetBounds(gfx::Size(100, 100)); | 4912 copy_layer->SetBounds(gfx::Size(100, 100)); |
(...skipping 3676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8750 | 8589 |
8751 child->SetTransform(singular); | 8590 child->SetTransform(singular); |
8752 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 8591 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
8753 update_list = GetUpdateLayerList(); | 8592 update_list = GetUpdateLayerList(); |
8754 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 8593 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
8755 child->SetTransform(gfx::Transform()); | 8594 child->SetTransform(gfx::Transform()); |
8756 | 8595 |
8757 child->SetHideLayerAndSubtree(true); | 8596 child->SetHideLayerAndSubtree(true); |
8758 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 8597 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
8759 update_list = GetUpdateLayerList(); | 8598 update_list = GetUpdateLayerList(); |
| 8599 EXPECT_TRUE(child->is_hidden()); |
| 8600 EXPECT_TRUE(grandchild->is_hidden()); |
| 8601 EXPECT_FALSE(VerifyLayerInList(child, update_list)); |
8760 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 8602 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
8761 child->SetHideLayerAndSubtree(false); | 8603 child->SetHideLayerAndSubtree(false); |
8762 | 8604 |
8763 gfx::Transform zero_z_scale; | 8605 gfx::Transform zero_z_scale; |
8764 zero_z_scale.Scale3d(1, 1, 0); | 8606 zero_z_scale.Scale3d(1, 1, 0); |
8765 child->SetTransform(zero_z_scale); | 8607 child->SetTransform(zero_z_scale); |
8766 | 8608 |
8767 // Add a transform animation with a start delay. Now, even though |child| has | 8609 // Add a transform animation with a start delay. Now, even though |child| has |
8768 // a singular transform, the subtree should still get processed. | 8610 // a singular transform, the subtree should still get processed. |
8769 int animation_id = 0; | 8611 int animation_id = 0; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8863 gfx::Transform rotate_back_and_translate; | 8705 gfx::Transform rotate_back_and_translate; |
8864 rotate_back_and_translate.RotateAboutYAxis(180); | 8706 rotate_back_and_translate.RotateAboutYAxis(180); |
8865 rotate_back_and_translate.Translate(-10, 0); | 8707 rotate_back_and_translate.Translate(-10, 0); |
8866 | 8708 |
8867 child_ptr->test_properties()->transform = singular; | 8709 child_ptr->test_properties()->transform = singular; |
8868 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8710 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
8869 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 8711 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
8870 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8712 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8871 child_ptr->test_properties()->transform = gfx::Transform(); | 8713 child_ptr->test_properties()->transform = gfx::Transform(); |
8872 | 8714 |
8873 child_ptr->test_properties()->hide_layer_and_subtree = true; | |
8874 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | |
8875 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | |
8876 child_ptr->test_properties()->hide_layer_and_subtree = false; | |
8877 | |
8878 child_ptr->test_properties()->opacity = 0.f; | 8715 child_ptr->test_properties()->opacity = 0.f; |
8879 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8716 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
8880 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 8717 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
8881 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8718 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8882 child_ptr->test_properties()->opacity = 1.f; | 8719 child_ptr->test_properties()->opacity = 1.f; |
8883 | 8720 |
8884 root_ptr->test_properties()->transform = singular; | 8721 root_ptr->test_properties()->transform = singular; |
8885 // Force transform tree to have a node for child, so that ancestor's | 8722 // Force transform tree to have a node for child, so that ancestor's |
8886 // invertible transform can be tested. | 8723 // invertible transform can be tested. |
8887 child_ptr->test_properties()->transform = rotate; | 8724 child_ptr->test_properties()->transform = rotate; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9062 LayerImpl* child = AddChild<LayerImpl>(root); | 8899 LayerImpl* child = AddChild<LayerImpl>(root); |
9063 | 8900 |
9064 root->SetBounds(gfx::Size(100, 100)); | 8901 root->SetBounds(gfx::Size(100, 100)); |
9065 child->SetBounds(gfx::Size(10, 10)); | 8902 child->SetBounds(gfx::Size(10, 10)); |
9066 child->SetDrawsContent(true); | 8903 child->SetDrawsContent(true); |
9067 | 8904 |
9068 ExecuteCalculateDrawProperties(root); | 8905 ExecuteCalculateDrawProperties(root); |
9069 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 8906 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
9070 child->set_visible_layer_rect(gfx::Rect()); | 8907 child->set_visible_layer_rect(gfx::Rect()); |
9071 | 8908 |
9072 child->test_properties()->hide_layer_and_subtree = true; | |
9073 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | |
9074 ExecuteCalculateDrawProperties(root); | |
9075 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | |
9076 child->test_properties()->hide_layer_and_subtree = false; | |
9077 | |
9078 child->SetBounds(gfx::Size()); | 8909 child->SetBounds(gfx::Size()); |
9079 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8910 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
9080 ExecuteCalculateDrawProperties(root); | 8911 ExecuteCalculateDrawProperties(root); |
9081 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8912 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
9082 child->SetBounds(gfx::Size(10, 10)); | 8913 child->SetBounds(gfx::Size(10, 10)); |
9083 | 8914 |
9084 gfx::Transform rotate; | 8915 gfx::Transform rotate; |
9085 child->test_properties()->double_sided = false; | 8916 child->test_properties()->double_sided = false; |
9086 rotate.RotateAboutXAxis(180.f); | 8917 rotate.RotateAboutXAxis(180.f); |
9087 child->test_properties()->transform = rotate; | 8918 child->test_properties()->transform = rotate; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9594 test_layer->SetDrawsContent(true); | 9425 test_layer->SetDrawsContent(true); |
9595 ExecuteCalculateDrawProperties(root); | 9426 ExecuteCalculateDrawProperties(root); |
9596 | 9427 |
9597 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); | 9428 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); |
9598 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); | 9429 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); |
9599 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); | 9430 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); |
9600 } | 9431 } |
9601 | 9432 |
9602 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { | 9433 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { |
9603 // Tests that subtree is hidden is updated. | 9434 // Tests that subtree is hidden is updated. |
9604 LayerImpl* root = root_layer_for_testing(); | 9435 scoped_refptr<Layer> root = Layer::Create(); |
9605 LayerImpl* hidden = AddChild<LayerImpl>(root); | 9436 scoped_refptr<Layer> hidden = Layer::Create(); |
9606 LayerImpl* test = AddChild<LayerImpl>(hidden); | 9437 scoped_refptr<Layer> test = Layer::Create(); |
9607 | 9438 |
9608 root->SetBounds(gfx::Size(30, 30)); | 9439 root->SetBounds(gfx::Size(30, 30)); |
9609 hidden->SetBounds(gfx::Size(30, 30)); | 9440 hidden->SetBounds(gfx::Size(30, 30)); |
9610 hidden->test_properties()->force_render_surface = true; | 9441 hidden->SetHideLayerAndSubtree(true); |
9611 hidden->test_properties()->hide_layer_and_subtree = true; | |
9612 test->SetBounds(gfx::Size(30, 30)); | 9442 test->SetBounds(gfx::Size(30, 30)); |
9613 test->test_properties()->force_render_surface = true; | |
9614 | 9443 |
9615 ExecuteCalculateDrawProperties(root); | 9444 root->AddChild(hidden); |
9616 EXPECT_EQ(0.f, | 9445 hidden->AddChild(test); |
9617 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); | 9446 host()->SetRootLayer(root); |
9618 | 9447 |
9619 hidden->test_properties()->hide_layer_and_subtree = false; | 9448 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
9620 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9449 EXPECT_TRUE(test->is_hidden()); |
9621 ExecuteCalculateDrawProperties(root); | 9450 // Hidden layers should have invalid property tree indices. |
9622 EXPECT_EQ(1.f, | 9451 const int kInvalidNodeId = -1; |
9623 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); | 9452 EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId); |
| 9453 EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId); |
| 9454 EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId); |
| 9455 EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId); |
| 9456 |
| 9457 hidden->SetHideLayerAndSubtree(false); |
| 9458 root->layer_tree_host()->property_trees()->needs_rebuild = true; |
| 9459 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9460 EXPECT_FALSE(test->is_hidden()); |
| 9461 EXPECT_NE(test->effect_tree_index(), kInvalidNodeId); |
| 9462 EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId); |
| 9463 EXPECT_NE(test->clip_tree_index(), kInvalidNodeId); |
| 9464 EXPECT_NE(test->transform_tree_index(), kInvalidNodeId); |
9624 } | 9465 } |
9625 | 9466 |
9626 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9467 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
9627 LayerImpl* root = root_layer_for_testing(); | 9468 LayerImpl* root = root_layer_for_testing(); |
9628 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 9469 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
9629 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); | 9470 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
9630 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9471 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
9631 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9472 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
9632 | 9473 |
9633 root->SetBounds(gfx::Size(30, 30)); | 9474 root->SetBounds(gfx::Size(30, 30)); |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10209 | 10050 |
10210 // Check child layer draw properties. | 10051 // Check child layer draw properties. |
10211 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10052 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
10212 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10053 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
10213 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10054 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
10214 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10055 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
10215 } | 10056 } |
10216 | 10057 |
10217 } // namespace | 10058 } // namespace |
10218 } // namespace cc | 10059 } // namespace cc |
OLD | NEW |