| 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 4815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4826 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 4826 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
| 4827 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 4827 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 4828 } | 4828 } |
| 4829 | 4829 |
| 4830 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 4830 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 4831 LCDTextTest, | 4831 LCDTextTest, |
| 4832 testing::Combine(testing::Bool(), | 4832 testing::Combine(testing::Bool(), |
| 4833 testing::Bool(), | 4833 testing::Bool(), |
| 4834 testing::Bool())); | 4834 testing::Bool())); |
| 4835 | 4835 |
| 4836 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { | |
| 4837 FakeImplProxy proxy; | |
| 4838 TestSharedBitmapManager shared_bitmap_manager; | |
| 4839 TestTaskGraphRunner task_graph_runner; | |
| 4840 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | |
| 4841 &task_graph_runner); | |
| 4842 host_impl.CreatePendingTree(); | |
| 4843 const gfx::Transform identity_matrix; | |
| 4844 | |
| 4845 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | |
| 4846 SetLayerPropertiesForTesting(root.get(), | |
| 4847 identity_matrix, | |
| 4848 gfx::Point3F(), | |
| 4849 gfx::PointF(), | |
| 4850 gfx::Size(50, 50), | |
| 4851 true, | |
| 4852 false); | |
| 4853 root->SetIsDrawable(true); | |
| 4854 | |
| 4855 scoped_refptr<Layer> child = Layer::Create(layer_settings()); | |
| 4856 SetLayerPropertiesForTesting(child.get(), | |
| 4857 identity_matrix, | |
| 4858 gfx::Point3F(), | |
| 4859 gfx::PointF(), | |
| 4860 gfx::Size(40, 40), | |
| 4861 true, | |
| 4862 false); | |
| 4863 child->SetIsDrawable(true); | |
| 4864 | |
| 4865 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings()); | |
| 4866 SetLayerPropertiesForTesting(grand_child.get(), | |
| 4867 identity_matrix, | |
| 4868 gfx::Point3F(), | |
| 4869 gfx::PointF(), | |
| 4870 gfx::Size(30, 30), | |
| 4871 true, | |
| 4872 false); | |
| 4873 grand_child->SetIsDrawable(true); | |
| 4874 grand_child->SetHideLayerAndSubtree(true); | |
| 4875 | |
| 4876 child->AddChild(grand_child); | |
| 4877 root->AddChild(child); | |
| 4878 | |
| 4879 host()->SetRootLayer(root); | |
| 4880 | |
| 4881 RenderSurfaceLayerList render_surface_layer_list; | |
| 4882 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | |
| 4883 root.get(), root->bounds(), &render_surface_layer_list); | |
| 4884 inputs.can_adjust_raster_scales = true; | |
| 4885 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
| 4886 | |
| 4887 // We should have one render surface and two layers. The grand child has | |
| 4888 // hidden itself. | |
| 4889 ASSERT_EQ(1u, render_surface_layer_list.size()); | |
| 4890 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | |
| 4891 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | |
| 4892 EXPECT_EQ(child->id(), root->render_surface()->layer_list().at(1)->id()); | |
| 4893 } | |
| 4894 | |
| 4895 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | 4836 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
| 4896 FakeImplProxy proxy; | 4837 FakeImplProxy proxy; |
| 4897 TestSharedBitmapManager shared_bitmap_manager; | 4838 TestSharedBitmapManager shared_bitmap_manager; |
| 4898 TestTaskGraphRunner task_graph_runner; | 4839 TestTaskGraphRunner task_graph_runner; |
| 4899 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 4840 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 4900 &task_graph_runner); | 4841 &task_graph_runner); |
| 4901 host_impl.CreatePendingTree(); | 4842 host_impl.CreatePendingTree(); |
| 4902 const gfx::Transform identity_matrix; | 4843 const gfx::Transform identity_matrix; |
| 4903 | 4844 |
| 4904 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 4845 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4932 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4873 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4933 | 4874 |
| 4934 // We should have one render surface and two layers. The grand child has | 4875 // We should have one render surface and two layers. The grand child has |
| 4935 // hidden itself. | 4876 // hidden itself. |
| 4936 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4877 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4937 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 4878 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 4938 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); | 4879 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); |
| 4939 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id()); | 4880 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id()); |
| 4940 } | 4881 } |
| 4941 | 4882 |
| 4942 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) { | |
| 4943 FakeImplProxy proxy; | |
| 4944 TestSharedBitmapManager shared_bitmap_manager; | |
| 4945 TestTaskGraphRunner task_graph_runner; | |
| 4946 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | |
| 4947 &task_graph_runner); | |
| 4948 host_impl.CreatePendingTree(); | |
| 4949 const gfx::Transform identity_matrix; | |
| 4950 | |
| 4951 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | |
| 4952 SetLayerPropertiesForTesting(root.get(), | |
| 4953 identity_matrix, | |
| 4954 gfx::Point3F(), | |
| 4955 gfx::PointF(), | |
| 4956 gfx::Size(50, 50), | |
| 4957 true, | |
| 4958 false); | |
| 4959 root->SetIsDrawable(true); | |
| 4960 | |
| 4961 scoped_refptr<Layer> child = Layer::Create(layer_settings()); | |
| 4962 SetLayerPropertiesForTesting(child.get(), | |
| 4963 identity_matrix, | |
| 4964 gfx::Point3F(), | |
| 4965 gfx::PointF(), | |
| 4966 gfx::Size(40, 40), | |
| 4967 true, | |
| 4968 false); | |
| 4969 child->SetIsDrawable(true); | |
| 4970 child->SetHideLayerAndSubtree(true); | |
| 4971 | |
| 4972 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings()); | |
| 4973 SetLayerPropertiesForTesting(grand_child.get(), | |
| 4974 identity_matrix, | |
| 4975 gfx::Point3F(), | |
| 4976 gfx::PointF(), | |
| 4977 gfx::Size(30, 30), | |
| 4978 true, | |
| 4979 false); | |
| 4980 grand_child->SetIsDrawable(true); | |
| 4981 | |
| 4982 child->AddChild(grand_child); | |
| 4983 root->AddChild(child); | |
| 4984 | |
| 4985 host()->SetRootLayer(root); | |
| 4986 | |
| 4987 RenderSurfaceLayerList render_surface_layer_list; | |
| 4988 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | |
| 4989 root.get(), root->bounds(), &render_surface_layer_list); | |
| 4990 inputs.can_adjust_raster_scales = true; | |
| 4991 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
| 4992 | |
| 4993 // We should have one render surface and one layers. The child has | |
| 4994 // hidden itself and the grand child. | |
| 4995 ASSERT_EQ(1u, render_surface_layer_list.size()); | |
| 4996 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | |
| 4997 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | |
| 4998 } | |
| 4999 | |
| 5000 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 4883 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 5001 FakeImplProxy proxy; | 4884 FakeImplProxy proxy; |
| 5002 TestSharedBitmapManager shared_bitmap_manager; | 4885 TestSharedBitmapManager shared_bitmap_manager; |
| 5003 TestTaskGraphRunner task_graph_runner; | 4886 TestTaskGraphRunner task_graph_runner; |
| 5004 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 4887 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 5005 &task_graph_runner); | 4888 &task_graph_runner); |
| 5006 host_impl.CreatePendingTree(); | 4889 host_impl.CreatePendingTree(); |
| 5007 const gfx::Transform identity_matrix; | 4890 const gfx::Transform identity_matrix; |
| 5008 | 4891 |
| 5009 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 4892 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8354 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); | 8237 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); |
| 8355 EXPECT_FALSE(root->visited()); | 8238 EXPECT_FALSE(root->visited()); |
| 8356 EXPECT_FALSE(root->sorted_for_recursion()); | 8239 EXPECT_FALSE(root->sorted_for_recursion()); |
| 8357 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); | 8240 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); |
| 8358 EXPECT_FALSE(child->visited()); | 8241 EXPECT_FALSE(child->visited()); |
| 8359 EXPECT_FALSE(child->sorted_for_recursion()); | 8242 EXPECT_FALSE(child->sorted_for_recursion()); |
| 8360 } | 8243 } |
| 8361 | 8244 |
| 8362 } // namespace | 8245 } // namespace |
| 8363 } // namespace cc | 8246 } // namespace cc |
| OLD | NEW |