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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 850768e779a3623de45148f0a20a017792ca319a..793d5daab44ef7f7676f4614b58c594be169feea 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -7733,7 +7733,7 @@ TEST(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
root->AddChild(child.Pass());
- std::vector<LayerImpl*> render_surface_layer_list;
+ LayerImplList render_surface_layer_list;
int dummy_max_texture_size = 512;
LayerTreeHostCommon::CalculateDrawProperties(root.get(),
root->bounds(),
@@ -7900,5 +7900,249 @@ INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
LCDTextTest,
testing::Combine(testing::Bool(), testing::Bool()));
+TEST(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
+ FakeImplProxy proxy;
+ FakeLayerTreeHostImpl host_impl(&proxy);
+ host_impl.CreatePendingTree();
+ const gfx::Transform identity_matrix;
+
+ scoped_refptr<Layer> root = Layer::Create();
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(50, 50),
+ false);
+ root->SetIsDrawable(true);
+
+ scoped_refptr<Layer> child = Layer::Create();
+ SetLayerPropertiesForTesting(child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(40, 40),
+ false);
+ child->SetIsDrawable(true);
+
+ scoped_refptr<Layer> grand_child = Layer::Create();
+ SetLayerPropertiesForTesting(grand_child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(30, 30),
+ false);
+ grand_child->SetIsDrawable(true);
+ grand_child->SetHideLayerAndSubtree(true);
+
+ child->AddChild(grand_child);
+ root->AddChild(child);
+
+ LayerList render_surface_layer_list;
+ int dummy_max_texture_size = 512;
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ gfx::Transform(),
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+
+ // We should have one render surface and two layers. The grand child has
+ // hidden itself.
+ ASSERT_EQ(1u, render_surface_layer_list.size());
+ ASSERT_EQ(2u, root->render_surface()->layer_list().size());
+ EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id());
+ EXPECT_EQ(child->id(), root->render_surface()->layer_list()[1]->id());
+}
+
+TEST(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
+ FakeImplProxy proxy;
+ FakeLayerTreeHostImpl host_impl(&proxy);
+ host_impl.CreatePendingTree();
+ const gfx::Transform identity_matrix;
+
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(50, 50),
+ false);
+ root->SetDrawsContent(true);
+
+ scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
+ SetLayerPropertiesForTesting(child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(40, 40),
+ false);
+ child->SetDrawsContent(true);
+
+ scoped_ptr<LayerImpl> grand_child =
+ LayerImpl::Create(host_impl.pending_tree(), 3);
+ SetLayerPropertiesForTesting(grand_child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(30, 30),
+ false);
+ grand_child->SetDrawsContent(true);
+ grand_child->SetHideLayerAndSubtree(true);
+
+ child->AddChild(grand_child.Pass());
+ root->AddChild(child.Pass());
+
+ LayerImplList render_surface_layer_list;
+ int dummy_max_texture_size = 512;
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ gfx::Transform(),
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+
+ // We should have one render surface and two layers. The grand child has
+ // hidden itself.
+ ASSERT_EQ(1u, render_surface_layer_list.size());
+ ASSERT_EQ(2u, root->render_surface()->layer_list().size());
+ EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id());
+ EXPECT_EQ(2, root->render_surface()->layer_list()[1]->id());
+}
+
+TEST(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
+ FakeImplProxy proxy;
+ FakeLayerTreeHostImpl host_impl(&proxy);
+ host_impl.CreatePendingTree();
+ const gfx::Transform identity_matrix;
+
+ scoped_refptr<Layer> root = Layer::Create();
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(50, 50),
+ false);
+ root->SetIsDrawable(true);
+
+ scoped_refptr<Layer> child = Layer::Create();
+ SetLayerPropertiesForTesting(child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(40, 40),
+ false);
+ child->SetIsDrawable(true);
+ child->SetHideLayerAndSubtree(true);
+
+ scoped_refptr<Layer> grand_child = Layer::Create();
+ SetLayerPropertiesForTesting(grand_child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(30, 30),
+ false);
+ grand_child->SetIsDrawable(true);
+
+ child->AddChild(grand_child);
+ root->AddChild(child);
+
+ LayerList render_surface_layer_list;
+ int dummy_max_texture_size = 512;
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ gfx::Transform(),
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+
+ // We should have one render surface and one layers. The child has
+ // hidden itself and the grand child.
+ ASSERT_EQ(1u, render_surface_layer_list.size());
+ ASSERT_EQ(1u, root->render_surface()->layer_list().size());
+ EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id());
+}
+
+TEST(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
+ FakeImplProxy proxy;
+ FakeLayerTreeHostImpl host_impl(&proxy);
+ host_impl.CreatePendingTree();
+ const gfx::Transform identity_matrix;
+
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(50, 50),
+ false);
+ root->SetDrawsContent(true);
+
+ scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
+ SetLayerPropertiesForTesting(child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(40, 40),
+ false);
+ child->SetDrawsContent(true);
+ child->SetHideLayerAndSubtree(true);
+
+ scoped_ptr<LayerImpl> grand_child =
+ LayerImpl::Create(host_impl.pending_tree(), 3);
+ SetLayerPropertiesForTesting(grand_child.get(),
+ identity_matrix,
+ identity_matrix,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(30, 30),
+ false);
+ grand_child->SetDrawsContent(true);
+
+ child->AddChild(grand_child.Pass());
+ root->AddChild(child.Pass());
+
+ LayerImplList render_surface_layer_list;
+ int dummy_max_texture_size = 512;
+ LayerTreeHostCommon::CalculateDrawProperties(root.get(),
+ root->bounds(),
+ gfx::Transform(),
+ 1.f,
+ 1.f,
+ NULL,
+ dummy_max_texture_size,
+ false,
+ true, // can_adjust_raster_scale
+ &render_surface_layer_list);
+
+ // We should have one render surface and one layers. The child has
+ // hidden itself and the grand child.
+ ASSERT_EQ(1u, render_surface_layer_list.size());
+ ASSERT_EQ(1u, root->render_surface()->layer_list().size());
+ EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id());
+}
+
} // namespace
} // namespace cc
« 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