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 "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 8865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8876 | 8876 |
8877 // It also shouldn't have grown to accomodate the clip child. | 8877 // It also shouldn't have grown to accomodate the clip child. |
8878 EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(), | 8878 EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(), |
8879 render_surface2->render_surface()->content_rect().ToString()); | 8879 render_surface2->render_surface()->content_rect().ToString()); |
8880 | 8880 |
8881 // Sanity check our num_unclipped_descendants values. | 8881 // Sanity check our num_unclipped_descendants values. |
8882 EXPECT_EQ(1, render_surface1->num_unclipped_descendants()); | 8882 EXPECT_EQ(1, render_surface1->num_unclipped_descendants()); |
8883 EXPECT_EQ(0, render_surface2->num_unclipped_descendants()); | 8883 EXPECT_EQ(0, render_surface2->num_unclipped_descendants()); |
8884 } | 8884 } |
8885 | 8885 |
| 8886 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { |
| 8887 FakeImplProxy proxy; |
| 8888 FakeLayerTreeHostImpl host_impl(&proxy); |
| 8889 scoped_ptr<LayerImpl> root = |
| 8890 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 8891 scoped_ptr<LayerImpl> child1 = |
| 8892 LayerImpl::Create(host_impl.active_tree(), 123456); |
| 8893 scoped_ptr<LayerImpl> child2 = |
| 8894 LayerImpl::Create(host_impl.active_tree(), 1234567); |
| 8895 scoped_ptr<LayerImpl> child3 = |
| 8896 LayerImpl::Create(host_impl.active_tree(), 12345678); |
| 8897 |
| 8898 gfx::Transform identity_matrix; |
| 8899 gfx::PointF anchor; |
| 8900 gfx::PointF position; |
| 8901 gfx::Size bounds(100, 100); |
| 8902 SetLayerPropertiesForTesting(root.get(), |
| 8903 identity_matrix, |
| 8904 identity_matrix, |
| 8905 anchor, |
| 8906 position, |
| 8907 bounds, |
| 8908 false); |
| 8909 root->SetDrawsContent(true); |
| 8910 |
| 8911 // This layer structure normally forces render surface due to preserves3d |
| 8912 // behavior. |
| 8913 bool preserves3d = true; |
| 8914 SetLayerPropertiesForTesting(child1.get(), |
| 8915 identity_matrix, |
| 8916 identity_matrix, |
| 8917 anchor, |
| 8918 position, |
| 8919 bounds, |
| 8920 preserves3d); |
| 8921 child1->SetDrawsContent(true); |
| 8922 SetLayerPropertiesForTesting(child2.get(), |
| 8923 identity_matrix, |
| 8924 identity_matrix, |
| 8925 anchor, |
| 8926 position, |
| 8927 bounds, |
| 8928 false); |
| 8929 child2->SetDrawsContent(true); |
| 8930 SetLayerPropertiesForTesting(child3.get(), |
| 8931 identity_matrix, |
| 8932 identity_matrix, |
| 8933 anchor, |
| 8934 position, |
| 8935 bounds, |
| 8936 false); |
| 8937 child3->SetDrawsContent(true); |
| 8938 |
| 8939 child2->AddChild(child3.Pass()); |
| 8940 child1->AddChild(child2.Pass()); |
| 8941 root->AddChild(child1.Pass()); |
| 8942 |
| 8943 { |
| 8944 LayerImplList render_surface_layer_list; |
| 8945 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 8946 root.get(), root->bounds(), &render_surface_layer_list); |
| 8947 inputs.can_render_to_separate_surface = true; |
| 8948 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 8949 |
| 8950 EXPECT_EQ(2u, render_surface_layer_list.size()); |
| 8951 } |
| 8952 |
| 8953 { |
| 8954 LayerImplList render_surface_layer_list; |
| 8955 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 8956 root.get(), root->bounds(), &render_surface_layer_list); |
| 8957 inputs.can_render_to_separate_surface = false; |
| 8958 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 8959 |
| 8960 EXPECT_EQ(1u, render_surface_layer_list.size()); |
| 8961 } |
| 8962 } |
| 8963 |
8886 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { | 8964 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { |
8887 scoped_refptr<Layer> root = Layer::Create(); | 8965 scoped_refptr<Layer> root = Layer::Create(); |
8888 scoped_refptr<Layer> render_surface = Layer::Create(); | 8966 scoped_refptr<Layer> render_surface = Layer::Create(); |
8889 scoped_refptr<LayerWithForcedDrawsContent> child = | 8967 scoped_refptr<LayerWithForcedDrawsContent> child = |
8890 make_scoped_refptr(new LayerWithForcedDrawsContent); | 8968 make_scoped_refptr(new LayerWithForcedDrawsContent); |
8891 | 8969 |
8892 root->AddChild(render_surface); | 8970 root->AddChild(render_surface); |
8893 render_surface->AddChild(child); | 8971 render_surface->AddChild(child); |
8894 | 8972 |
8895 gfx::Transform identity_transform; | 8973 gfx::Transform identity_transform; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8940 ExecuteCalculateDrawProperties(root.get()); | 9018 ExecuteCalculateDrawProperties(root.get()); |
8941 | 9019 |
8942 EXPECT_EQ(1u, render_surface_layer_list()->size()); | 9020 EXPECT_EQ(1u, render_surface_layer_list()->size()); |
8943 EXPECT_EQ(0u, | 9021 EXPECT_EQ(0u, |
8944 render_surface_layer_list()->at(0) | 9022 render_surface_layer_list()->at(0) |
8945 ->render_surface()->layer_list().size()); | 9023 ->render_surface()->layer_list().size()); |
8946 } | 9024 } |
8947 | 9025 |
8948 } // namespace | 9026 } // namespace |
8949 } // namespace cc | 9027 } // namespace cc |
OLD | NEW |