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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 4918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4929 | 4929 |
4930 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 4930 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
4931 FakeImplProxy proxy; | 4931 FakeImplProxy proxy; |
4932 TestSharedBitmapManager shared_bitmap_manager; | 4932 TestSharedBitmapManager shared_bitmap_manager; |
4933 TestTaskGraphRunner task_graph_runner; | 4933 TestTaskGraphRunner task_graph_runner; |
4934 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 4934 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
4935 &task_graph_runner); | 4935 &task_graph_runner); |
4936 host_impl.CreatePendingTree(); | 4936 host_impl.CreatePendingTree(); |
4937 const gfx::Transform identity_matrix; | 4937 const gfx::Transform identity_matrix; |
4938 | 4938 |
4939 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 4939 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
4940 SetLayerPropertiesForTesting(root.get(), | 4940 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
4941 identity_matrix, | 4941 gfx::PointF(), gfx::Size(50, 50), true, false, |
4942 gfx::Point3F(), | 4942 true); |
4943 gfx::PointF(), | 4943 root->SetDrawsContent(true); |
4944 gfx::Size(50, 50), | |
4945 true, | |
4946 false); | |
4947 root->SetIsDrawable(true); | |
4948 | 4944 |
4949 scoped_refptr<Layer> copy_grand_parent = Layer::Create(layer_settings()); | 4945 scoped_ptr<LayerImpl> copy_grand_parent = |
4950 SetLayerPropertiesForTesting(copy_grand_parent.get(), | 4946 LayerImpl::Create(host_impl.pending_tree(), 2); |
4951 identity_matrix, | 4947 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix, |
4952 gfx::Point3F(), | 4948 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
4953 gfx::PointF(), | 4949 true, false, false); |
4954 gfx::Size(40, 40), | 4950 copy_grand_parent->SetDrawsContent(true); |
4955 true, | 4951 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); |
4956 false); | |
4957 copy_grand_parent->SetIsDrawable(true); | |
4958 | 4952 |
4959 scoped_refptr<Layer> copy_parent = Layer::Create(layer_settings()); | 4953 scoped_ptr<LayerImpl> copy_parent = |
4960 SetLayerPropertiesForTesting(copy_parent.get(), | 4954 LayerImpl::Create(host_impl.pending_tree(), 3); |
4961 identity_matrix, | 4955 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, |
4962 gfx::Point3F(), | 4956 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
4963 gfx::PointF(), | 4957 true, false, true); |
4964 gfx::Size(30, 30), | 4958 copy_parent->SetDrawsContent(true); |
4965 true, | 4959 LayerImpl* copy_parent_layer = copy_parent.get(); |
4966 false); | |
4967 copy_parent->SetIsDrawable(true); | |
4968 copy_parent->SetForceRenderSurface(true); | |
4969 | 4960 |
4970 scoped_refptr<Layer> copy_layer = Layer::Create(layer_settings()); | 4961 scoped_ptr<LayerImpl> copy_request = |
4971 SetLayerPropertiesForTesting(copy_layer.get(), | 4962 LayerImpl::Create(host_impl.pending_tree(), 4); |
4972 identity_matrix, | 4963 SetLayerPropertiesForTesting(copy_request.get(), identity_matrix, |
4973 gfx::Point3F(), | 4964 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
4974 gfx::PointF(), | 4965 true, false, true); |
4975 gfx::Size(20, 20), | 4966 copy_request->SetDrawsContent(true); |
4976 true, | 4967 LayerImpl* copy_layer = copy_request.get(); |
4977 false); | |
4978 copy_layer->SetIsDrawable(true); | |
4979 | 4968 |
4980 scoped_refptr<Layer> copy_child = Layer::Create(layer_settings()); | 4969 scoped_ptr<LayerImpl> copy_child = |
4981 SetLayerPropertiesForTesting(copy_child.get(), | 4970 LayerImpl::Create(host_impl.pending_tree(), 5); |
4982 identity_matrix, | 4971 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
4983 gfx::Point3F(), | 4972 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
4984 gfx::PointF(), | 4973 true, false, false); |
4985 gfx::Size(20, 20), | 4974 copy_child->SetDrawsContent(true); |
4986 true, | 4975 LayerImpl* copy_child_layer = copy_child.get(); |
4987 false); | |
4988 copy_child->SetIsDrawable(true); | |
4989 | 4976 |
4990 scoped_refptr<Layer> copy_grand_parent_sibling_before = | 4977 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = |
4991 Layer::Create(layer_settings()); | 4978 LayerImpl::Create(host_impl.pending_tree(), 6); |
4992 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), | 4979 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), |
4993 identity_matrix, | 4980 identity_matrix, gfx::Point3F(), gfx::PointF(), |
4994 gfx::Point3F(), | 4981 gfx::Size(40, 40), true, false, false); |
4995 gfx::PointF(), | 4982 copy_grand_parent_sibling_before->SetDrawsContent(true); |
4996 gfx::Size(40, 40), | 4983 LayerImpl* copy_grand_parent_sibling_before_layer = |
4997 true, | 4984 copy_grand_parent_sibling_before.get(); |
4998 false); | |
4999 copy_grand_parent_sibling_before->SetIsDrawable(true); | |
5000 | 4985 |
5001 scoped_refptr<Layer> copy_grand_parent_sibling_after = | 4986 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = |
5002 Layer::Create(layer_settings()); | 4987 LayerImpl::Create(host_impl.pending_tree(), 7); |
5003 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), | 4988 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), |
5004 identity_matrix, | 4989 identity_matrix, gfx::Point3F(), gfx::PointF(), |
5005 gfx::Point3F(), | 4990 gfx::Size(40, 40), true, false, false); |
5006 gfx::PointF(), | 4991 copy_grand_parent_sibling_after->SetDrawsContent(true); |
5007 gfx::Size(40, 40), | 4992 LayerImpl* copy_grand_parent_sibling_after_layer = |
5008 true, | 4993 copy_grand_parent_sibling_after.get(); |
5009 false); | |
5010 copy_grand_parent_sibling_after->SetIsDrawable(true); | |
5011 | 4994 |
5012 copy_layer->AddChild(copy_child); | 4995 copy_request->AddChild(copy_child.Pass()); |
5013 copy_parent->AddChild(copy_layer); | 4996 copy_parent->AddChild(copy_request.Pass()); |
5014 copy_grand_parent->AddChild(copy_parent); | 4997 copy_grand_parent->AddChild(copy_parent.Pass()); |
5015 root->AddChild(copy_grand_parent_sibling_before); | 4998 root->AddChild(copy_grand_parent_sibling_before.Pass()); |
5016 root->AddChild(copy_grand_parent); | 4999 root->AddChild(copy_grand_parent.Pass()); |
5017 root->AddChild(copy_grand_parent_sibling_after); | 5000 root->AddChild(copy_grand_parent_sibling_after.Pass()); |
5018 | |
5019 host()->SetRootLayer(root); | |
5020 | 5001 |
5021 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5002 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
5022 // hidden subtree on copy_layer. | 5003 // hidden subtree on copy_layer. |
5023 copy_grand_parent->SetHideLayerAndSubtree(true); | 5004 copy_grand_parent_layer->SetHideLayerAndSubtree(true); |
5024 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); | 5005 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); |
5025 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); | 5006 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); |
5026 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( | 5007 |
5027 base::Bind(&EmptyCopyOutputCallback))); | 5008 ScopedPtrVector<CopyOutputRequest> copy_requests; |
| 5009 copy_requests.push_back( |
| 5010 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5011 copy_layer->PassCopyRequests(©_requests); |
5028 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5012 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5029 | 5013 |
5030 RenderSurfaceLayerList render_surface_layer_list; | 5014 LayerImplList render_surface_layer_list; |
5031 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5015 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5032 root.get(), root->bounds(), &render_surface_layer_list); | 5016 root.get(), root->bounds(), &render_surface_layer_list); |
5033 inputs.can_adjust_raster_scales = true; | 5017 inputs.can_adjust_raster_scales = true; |
5034 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5018 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5035 | 5019 |
5036 EXPECT_TRUE(root->draw_properties().layer_or_descendant_has_copy_request); | 5020 EXPECT_TRUE(root->draw_properties().layer_or_descendant_has_copy_request); |
5037 EXPECT_TRUE(copy_grand_parent->draw_properties(). | 5021 EXPECT_TRUE(copy_grand_parent_layer->draw_properties() |
5038 layer_or_descendant_has_copy_request); | 5022 .layer_or_descendant_has_copy_request); |
5039 EXPECT_TRUE(copy_parent->draw_properties(). | 5023 EXPECT_TRUE(copy_parent_layer->draw_properties() |
5040 layer_or_descendant_has_copy_request); | 5024 .layer_or_descendant_has_copy_request); |
5041 EXPECT_TRUE(copy_layer->draw_properties(). | 5025 EXPECT_TRUE( |
5042 layer_or_descendant_has_copy_request); | 5026 copy_layer->draw_properties().layer_or_descendant_has_copy_request); |
5043 EXPECT_FALSE(copy_child->draw_properties(). | 5027 EXPECT_FALSE( |
5044 layer_or_descendant_has_copy_request); | 5028 copy_child_layer->draw_properties().layer_or_descendant_has_copy_request); |
5045 EXPECT_FALSE(copy_grand_parent_sibling_before->draw_properties(). | 5029 EXPECT_FALSE(copy_grand_parent_sibling_before_layer->draw_properties() |
5046 layer_or_descendant_has_copy_request); | 5030 .layer_or_descendant_has_copy_request); |
5047 EXPECT_FALSE(copy_grand_parent_sibling_after->draw_properties(). | 5031 EXPECT_FALSE(copy_grand_parent_sibling_after_layer->draw_properties() |
5048 layer_or_descendant_has_copy_request); | 5032 .layer_or_descendant_has_copy_request); |
5049 | 5033 |
5050 // We should have three render surfaces, one for the root, one for the parent | 5034 // We should have three render surfaces, one for the root, one for the parent |
5051 // since it owns a surface, and one for the copy_layer. | 5035 // since it owns a surface, and one for the copy_layer. |
5052 ASSERT_EQ(3u, render_surface_layer_list.size()); | 5036 ASSERT_EQ(3u, render_surface_layer_list.size()); |
5053 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5037 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
5054 EXPECT_EQ(copy_parent->id(), render_surface_layer_list.at(1)->id()); | 5038 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id()); |
5055 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); | 5039 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); |
5056 | 5040 |
5057 // The root render surface should have 2 contributing layers. The | 5041 // The root render surface should have 2 contributing layers. The |
5058 // copy_grand_parent is hidden along with its siblings, but the copy_parent | 5042 // copy_grand_parent is hidden along with its siblings, but the copy_parent |
5059 // will appear since something in its subtree needs to be drawn for a copy | 5043 // will appear since something in its subtree needs to be drawn for a copy |
5060 // request. | 5044 // request. |
5061 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5045 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5062 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5046 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
5063 EXPECT_EQ(copy_parent->id(), | 5047 EXPECT_EQ(copy_parent_layer->id(), |
5064 root->render_surface()->layer_list().at(1)->id()); | 5048 root->render_surface()->layer_list().at(1)->id()); |
5065 | 5049 |
5066 // Nothing actually draws into the copy parent, so only the copy_layer will | 5050 // Nothing actually draws into the copy parent, so only the copy_layer will |
5067 // appear in its list, since it needs to be drawn for the copy request. | 5051 // appear in its list, since it needs to be drawn for the copy request. |
5068 ASSERT_EQ(1u, copy_parent->render_surface()->layer_list().size()); | 5052 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
5069 EXPECT_EQ(copy_layer->id(), | 5053 EXPECT_EQ(copy_layer->id(), |
5070 copy_parent->render_surface()->layer_list().at(0)->id()); | 5054 copy_parent_layer->render_surface()->layer_list().at(0)->id()); |
5071 | 5055 |
5072 // The copy_layer's render surface should have two contributing layers. | 5056 // The copy_layer's render surface should have two contributing layers. |
5073 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5057 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
5074 EXPECT_EQ(copy_layer->id(), | 5058 EXPECT_EQ(copy_layer->id(), |
5075 copy_layer->render_surface()->layer_list().at(0)->id()); | 5059 copy_layer->render_surface()->layer_list().at(0)->id()); |
5076 EXPECT_EQ(copy_child->id(), | 5060 EXPECT_EQ(copy_child_layer->id(), |
5077 copy_layer->render_surface()->layer_list().at(1)->id()); | 5061 copy_layer->render_surface()->layer_list().at(1)->id()); |
5078 } | 5062 } |
5079 | 5063 |
5080 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5064 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
5081 FakeImplProxy proxy; | 5065 FakeImplProxy proxy; |
5082 TestSharedBitmapManager shared_bitmap_manager; | 5066 TestSharedBitmapManager shared_bitmap_manager; |
5083 TestTaskGraphRunner task_graph_runner; | 5067 TestTaskGraphRunner task_graph_runner; |
5084 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 5068 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
5085 &task_graph_runner); | 5069 &task_graph_runner); |
5086 host_impl.CreatePendingTree(); | 5070 host_impl.CreatePendingTree(); |
5087 const gfx::Transform identity_matrix; | 5071 const gfx::Transform identity_matrix; |
5088 | 5072 |
5089 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 5073 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
5090 SetLayerPropertiesForTesting(root.get(), | 5074 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
5091 identity_matrix, | 5075 gfx::PointF(), gfx::Size(50, 50), true, false, |
5092 gfx::Point3F(), | 5076 true); |
5093 gfx::PointF(), | 5077 root->SetDrawsContent(true); |
5094 gfx::Size(50, 50), | |
5095 true, | |
5096 false); | |
5097 root->SetIsDrawable(true); | |
5098 | 5078 |
5099 scoped_refptr<Layer> copy_parent = Layer::Create(layer_settings()); | 5079 scoped_ptr<LayerImpl> copy_parent = |
5100 SetLayerPropertiesForTesting(copy_parent.get(), | 5080 LayerImpl::Create(host_impl.pending_tree(), 2); |
5101 identity_matrix, | 5081 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, |
5102 gfx::Point3F(), | 5082 gfx::Point3F(), gfx::PointF(), gfx::Size(), true, |
5103 gfx::PointF(), | 5083 false, false); |
5104 gfx::Size(), | 5084 copy_parent->SetDrawsContent(true); |
5105 true, | |
5106 false); | |
5107 copy_parent->SetIsDrawable(true); | |
5108 copy_parent->SetMasksToBounds(true); | 5085 copy_parent->SetMasksToBounds(true); |
5109 | 5086 |
5110 scoped_refptr<Layer> copy_layer = Layer::Create(layer_settings()); | 5087 scoped_ptr<LayerImpl> copy_layer = |
5111 SetLayerPropertiesForTesting(copy_layer.get(), | 5088 LayerImpl::Create(host_impl.pending_tree(), 3); |
5112 identity_matrix, | 5089 SetLayerPropertiesForTesting(copy_layer.get(), identity_matrix, |
5113 gfx::Point3F(), | 5090 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
5114 gfx::PointF(), | 5091 true, false, true); |
5115 gfx::Size(30, 30), | 5092 copy_layer->SetDrawsContent(true); |
5116 true, | |
5117 false); | |
5118 copy_layer->SetIsDrawable(true); | |
5119 | 5093 |
5120 scoped_refptr<Layer> copy_child = Layer::Create(layer_settings()); | 5094 scoped_ptr<LayerImpl> copy_child = |
5121 SetLayerPropertiesForTesting(copy_child.get(), | 5095 LayerImpl::Create(host_impl.pending_tree(), 4); |
5122 identity_matrix, | 5096 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
5123 gfx::Point3F(), | 5097 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
5124 gfx::PointF(), | 5098 true, false, false); |
5125 gfx::Size(20, 20), | 5099 copy_child->SetDrawsContent(true); |
5126 true, | |
5127 false); | |
5128 copy_child->SetIsDrawable(true); | |
5129 | 5100 |
5130 copy_layer->AddChild(copy_child); | 5101 ScopedPtrVector<CopyOutputRequest> copy_requests; |
5131 copy_parent->AddChild(copy_layer); | 5102 copy_requests.push_back( |
5132 root->AddChild(copy_parent); | 5103 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5133 | 5104 copy_layer->PassCopyRequests(©_requests); |
5134 host()->SetRootLayer(root); | |
5135 | |
5136 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( | |
5137 base::Bind(&EmptyCopyOutputCallback))); | |
5138 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5105 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5139 | 5106 |
5140 RenderSurfaceLayerList render_surface_layer_list; | 5107 copy_layer->AddChild(copy_child.Pass()); |
5141 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5108 copy_parent->AddChild(copy_layer.Pass()); |
| 5109 root->AddChild(copy_parent.Pass()); |
| 5110 |
| 5111 LayerImplList render_surface_layer_list; |
| 5112 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5142 root.get(), root->bounds(), &render_surface_layer_list); | 5113 root.get(), root->bounds(), &render_surface_layer_list); |
5143 inputs.can_adjust_raster_scales = true; | 5114 inputs.can_adjust_raster_scales = true; |
5144 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5115 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5145 | 5116 |
5146 // We should have one render surface, as the others are clipped out. | 5117 // We should have one render surface, as the others are clipped out. |
5147 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5118 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5148 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5119 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
5149 | 5120 |
5150 // The root render surface should only have 1 contributing layer, since the | 5121 // The root render surface should only have 1 contributing layer, since the |
5151 // other layers are empty/clipped away. | 5122 // other layers are empty/clipped away. |
(...skipping 3085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8237 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); | 8208 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); |
8238 EXPECT_FALSE(root->visited()); | 8209 EXPECT_FALSE(root->visited()); |
8239 EXPECT_FALSE(root->sorted_for_recursion()); | 8210 EXPECT_FALSE(root->sorted_for_recursion()); |
8240 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); | 8211 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); |
8241 EXPECT_FALSE(child->visited()); | 8212 EXPECT_FALSE(child->visited()); |
8242 EXPECT_FALSE(child->sorted_for_recursion()); | 8213 EXPECT_FALSE(child->sorted_for_recursion()); |
8243 } | 8214 } |
8244 | 8215 |
8245 } // namespace | 8216 } // namespace |
8246 } // namespace cc | 8217 } // namespace cc |
OLD | NEW |