| 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 8fa91ceb46e7643d2adf11f936fcff993b7250a4..4dd4d0f37983ae0050230915c22ebb6326ac0cc2 100644
|
| --- a/cc/trees/layer_tree_host_common_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_common_unittest.cc
|
| @@ -7734,7 +7734,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(),
|
| @@ -7901,5 +7901,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
|
|
|