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