Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698