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/base/thread.h" | 9 #include "cc/base/thread.h" |
10 #include "cc/layers/content_layer.h" | 10 #include "cc/layers/content_layer.h" |
(...skipping 7716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7727 false); | 7727 false); |
7728 child->SetDrawsContent(true); | 7728 child->SetDrawsContent(true); |
7729 child->SetOpacity(0.0f); | 7729 child->SetOpacity(0.0f); |
7730 | 7730 |
7731 // Add opacity animation. | 7731 // Add opacity animation. |
7732 AddOpacityTransitionToController( | 7732 AddOpacityTransitionToController( |
7733 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); | 7733 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); |
7734 | 7734 |
7735 root->AddChild(child.Pass()); | 7735 root->AddChild(child.Pass()); |
7736 | 7736 |
7737 std::vector<LayerImpl*> render_surface_layer_list; | 7737 LayerImplList render_surface_layer_list; |
7738 int dummy_max_texture_size = 512; | 7738 int dummy_max_texture_size = 512; |
7739 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 7739 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
7740 root->bounds(), | 7740 root->bounds(), |
7741 gfx::Transform(), | 7741 gfx::Transform(), |
7742 1.f, | 7742 1.f, |
7743 1.f, | 7743 1.f, |
7744 NULL, | 7744 NULL, |
7745 dummy_max_texture_size, | 7745 dummy_max_texture_size, |
7746 false, | 7746 false, |
7747 true, // can_adjust_raster_scale | 7747 true, // can_adjust_raster_scale |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7894 // Make sure LCD text AA setting remains unchanged. | 7894 // Make sure LCD text AA setting remains unchanged. |
7895 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); | 7895 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); |
7896 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); | 7896 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); |
7897 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); | 7897 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); |
7898 } | 7898 } |
7899 | 7899 |
7900 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 7900 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
7901 LCDTextTest, | 7901 LCDTextTest, |
7902 testing::Combine(testing::Bool(), testing::Bool())); | 7902 testing::Combine(testing::Bool(), testing::Bool())); |
7903 | 7903 |
| 7904 TEST(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { |
| 7905 FakeImplProxy proxy; |
| 7906 FakeLayerTreeHostImpl host_impl(&proxy); |
| 7907 host_impl.CreatePendingTree(); |
| 7908 const gfx::Transform identity_matrix; |
| 7909 |
| 7910 scoped_refptr<Layer> root = Layer::Create(); |
| 7911 SetLayerPropertiesForTesting(root.get(), |
| 7912 identity_matrix, |
| 7913 identity_matrix, |
| 7914 gfx::PointF(), |
| 7915 gfx::PointF(), |
| 7916 gfx::Size(50, 50), |
| 7917 false); |
| 7918 root->SetIsDrawable(true); |
| 7919 |
| 7920 scoped_refptr<Layer> child = Layer::Create(); |
| 7921 SetLayerPropertiesForTesting(child.get(), |
| 7922 identity_matrix, |
| 7923 identity_matrix, |
| 7924 gfx::PointF(), |
| 7925 gfx::PointF(), |
| 7926 gfx::Size(40, 40), |
| 7927 false); |
| 7928 child->SetIsDrawable(true); |
| 7929 |
| 7930 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 7931 SetLayerPropertiesForTesting(grand_child.get(), |
| 7932 identity_matrix, |
| 7933 identity_matrix, |
| 7934 gfx::PointF(), |
| 7935 gfx::PointF(), |
| 7936 gfx::Size(30, 30), |
| 7937 false); |
| 7938 grand_child->SetIsDrawable(true); |
| 7939 grand_child->SetHideLayerAndSubtree(true); |
| 7940 |
| 7941 child->AddChild(grand_child); |
| 7942 root->AddChild(child); |
| 7943 |
| 7944 LayerList render_surface_layer_list; |
| 7945 int dummy_max_texture_size = 512; |
| 7946 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 7947 root->bounds(), |
| 7948 gfx::Transform(), |
| 7949 1.f, |
| 7950 1.f, |
| 7951 NULL, |
| 7952 dummy_max_texture_size, |
| 7953 false, |
| 7954 true, // can_adjust_raster_scale |
| 7955 &render_surface_layer_list); |
| 7956 |
| 7957 // We should have one render surface and two layers. The grand child has |
| 7958 // hidden itself. |
| 7959 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 7960 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 7961 EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id()); |
| 7962 EXPECT_EQ(child->id(), root->render_surface()->layer_list()[1]->id()); |
| 7963 } |
| 7964 |
| 7965 TEST(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
| 7966 FakeImplProxy proxy; |
| 7967 FakeLayerTreeHostImpl host_impl(&proxy); |
| 7968 host_impl.CreatePendingTree(); |
| 7969 const gfx::Transform identity_matrix; |
| 7970 |
| 7971 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
| 7972 SetLayerPropertiesForTesting(root.get(), |
| 7973 identity_matrix, |
| 7974 identity_matrix, |
| 7975 gfx::PointF(), |
| 7976 gfx::PointF(), |
| 7977 gfx::Size(50, 50), |
| 7978 false); |
| 7979 root->SetDrawsContent(true); |
| 7980 |
| 7981 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
| 7982 SetLayerPropertiesForTesting(child.get(), |
| 7983 identity_matrix, |
| 7984 identity_matrix, |
| 7985 gfx::PointF(), |
| 7986 gfx::PointF(), |
| 7987 gfx::Size(40, 40), |
| 7988 false); |
| 7989 child->SetDrawsContent(true); |
| 7990 |
| 7991 scoped_ptr<LayerImpl> grand_child = |
| 7992 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 7993 SetLayerPropertiesForTesting(grand_child.get(), |
| 7994 identity_matrix, |
| 7995 identity_matrix, |
| 7996 gfx::PointF(), |
| 7997 gfx::PointF(), |
| 7998 gfx::Size(30, 30), |
| 7999 false); |
| 8000 grand_child->SetDrawsContent(true); |
| 8001 grand_child->SetHideLayerAndSubtree(true); |
| 8002 |
| 8003 child->AddChild(grand_child.Pass()); |
| 8004 root->AddChild(child.Pass()); |
| 8005 |
| 8006 LayerImplList render_surface_layer_list; |
| 8007 int dummy_max_texture_size = 512; |
| 8008 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 8009 root->bounds(), |
| 8010 gfx::Transform(), |
| 8011 1.f, |
| 8012 1.f, |
| 8013 NULL, |
| 8014 dummy_max_texture_size, |
| 8015 false, |
| 8016 true, // can_adjust_raster_scale |
| 8017 &render_surface_layer_list); |
| 8018 |
| 8019 // We should have one render surface and two layers. The grand child has |
| 8020 // hidden itself. |
| 8021 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 8022 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 8023 EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id()); |
| 8024 EXPECT_EQ(2, root->render_surface()->layer_list()[1]->id()); |
| 8025 } |
| 8026 |
| 8027 TEST(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) { |
| 8028 FakeImplProxy proxy; |
| 8029 FakeLayerTreeHostImpl host_impl(&proxy); |
| 8030 host_impl.CreatePendingTree(); |
| 8031 const gfx::Transform identity_matrix; |
| 8032 |
| 8033 scoped_refptr<Layer> root = Layer::Create(); |
| 8034 SetLayerPropertiesForTesting(root.get(), |
| 8035 identity_matrix, |
| 8036 identity_matrix, |
| 8037 gfx::PointF(), |
| 8038 gfx::PointF(), |
| 8039 gfx::Size(50, 50), |
| 8040 false); |
| 8041 root->SetIsDrawable(true); |
| 8042 |
| 8043 scoped_refptr<Layer> child = Layer::Create(); |
| 8044 SetLayerPropertiesForTesting(child.get(), |
| 8045 identity_matrix, |
| 8046 identity_matrix, |
| 8047 gfx::PointF(), |
| 8048 gfx::PointF(), |
| 8049 gfx::Size(40, 40), |
| 8050 false); |
| 8051 child->SetIsDrawable(true); |
| 8052 child->SetHideLayerAndSubtree(true); |
| 8053 |
| 8054 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 8055 SetLayerPropertiesForTesting(grand_child.get(), |
| 8056 identity_matrix, |
| 8057 identity_matrix, |
| 8058 gfx::PointF(), |
| 8059 gfx::PointF(), |
| 8060 gfx::Size(30, 30), |
| 8061 false); |
| 8062 grand_child->SetIsDrawable(true); |
| 8063 |
| 8064 child->AddChild(grand_child); |
| 8065 root->AddChild(child); |
| 8066 |
| 8067 LayerList render_surface_layer_list; |
| 8068 int dummy_max_texture_size = 512; |
| 8069 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 8070 root->bounds(), |
| 8071 gfx::Transform(), |
| 8072 1.f, |
| 8073 1.f, |
| 8074 NULL, |
| 8075 dummy_max_texture_size, |
| 8076 false, |
| 8077 true, // can_adjust_raster_scale |
| 8078 &render_surface_layer_list); |
| 8079 |
| 8080 // We should have one render surface and one layers. The child has |
| 8081 // hidden itself and the grand child. |
| 8082 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 8083 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 8084 EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id()); |
| 8085 } |
| 8086 |
| 8087 TEST(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 8088 FakeImplProxy proxy; |
| 8089 FakeLayerTreeHostImpl host_impl(&proxy); |
| 8090 host_impl.CreatePendingTree(); |
| 8091 const gfx::Transform identity_matrix; |
| 8092 |
| 8093 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
| 8094 SetLayerPropertiesForTesting(root.get(), |
| 8095 identity_matrix, |
| 8096 identity_matrix, |
| 8097 gfx::PointF(), |
| 8098 gfx::PointF(), |
| 8099 gfx::Size(50, 50), |
| 8100 false); |
| 8101 root->SetDrawsContent(true); |
| 8102 |
| 8103 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
| 8104 SetLayerPropertiesForTesting(child.get(), |
| 8105 identity_matrix, |
| 8106 identity_matrix, |
| 8107 gfx::PointF(), |
| 8108 gfx::PointF(), |
| 8109 gfx::Size(40, 40), |
| 8110 false); |
| 8111 child->SetDrawsContent(true); |
| 8112 child->SetHideLayerAndSubtree(true); |
| 8113 |
| 8114 scoped_ptr<LayerImpl> grand_child = |
| 8115 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 8116 SetLayerPropertiesForTesting(grand_child.get(), |
| 8117 identity_matrix, |
| 8118 identity_matrix, |
| 8119 gfx::PointF(), |
| 8120 gfx::PointF(), |
| 8121 gfx::Size(30, 30), |
| 8122 false); |
| 8123 grand_child->SetDrawsContent(true); |
| 8124 |
| 8125 child->AddChild(grand_child.Pass()); |
| 8126 root->AddChild(child.Pass()); |
| 8127 |
| 8128 LayerImplList render_surface_layer_list; |
| 8129 int dummy_max_texture_size = 512; |
| 8130 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 8131 root->bounds(), |
| 8132 gfx::Transform(), |
| 8133 1.f, |
| 8134 1.f, |
| 8135 NULL, |
| 8136 dummy_max_texture_size, |
| 8137 false, |
| 8138 true, // can_adjust_raster_scale |
| 8139 &render_surface_layer_list); |
| 8140 |
| 8141 // We should have one render surface and one layers. The child has |
| 8142 // hidden itself and the grand child. |
| 8143 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 8144 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 8145 EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id()); |
| 8146 } |
| 8147 |
7904 } // namespace | 8148 } // namespace |
7905 } // namespace cc | 8149 } // namespace cc |
OLD | NEW |