| 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 495b4c8ebdd56697dd730292647df03c1598781b..22acc199a20c556c23f172714efb74f9041051a0 100644
|
| --- a/cc/trees/layer_tree_host_common_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_common_unittest.cc
|
| @@ -148,7 +148,10 @@ TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) {
|
| grand_child->screen_space_transform());
|
| }
|
|
|
| -TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
|
| +TEST_F(LayerTreeHostCommonTest,
|
| + ScreenSpaceTransformOfSkippedLayersWithHandlers) {
|
| + // Even for layers that are skipped, we need to compute the correct screen
|
| + // space transform because it is used during hit testing.
|
| LayerImpl* parent = root_layer();
|
| LayerImpl* child = AddChild<LayerImpl>(parent);
|
| LayerImpl* grand_child = AddChild<LayerImpl>(child);
|
| @@ -161,9 +164,7 @@ TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
|
| SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
|
| gfx::PointF(10, 10), gfx::Size(100, 100), true,
|
| false);
|
| - // This would have previously caused us to skip our subtree, but this would be
|
| - // wrong; we need up-to-date draw properties to do hit testing on the layers
|
| - // with handlers.
|
| + // This will cause the subtree to be skipped.
|
| child->SetOpacity(0.f);
|
| SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
|
| gfx::PointF(10, 10), gfx::Size(100, 100), true,
|
| @@ -176,10 +177,8 @@ TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
|
| EXPECT_FALSE(grand_child->has_render_surface());
|
| // Check that we've computed draw properties for the subtree rooted at
|
| // |child|.
|
| - EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity());
|
| - EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity());
|
| - EXPECT_FALSE(
|
| - grand_child->draw_properties().target_space_transform.IsIdentity());
|
| + EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity());
|
| + EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity());
|
| }
|
|
|
| TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) {
|
| @@ -1299,6 +1298,8 @@ TEST_F(LayerTreeHostCommonTest,
|
| gfx::PointF(), gfx::Size(10, 10), true, false,
|
| false);
|
| render_surface1->SetOpacity(0.f);
|
| + render_surface1->SetDrawsContent(true);
|
| + child->SetDrawsContent(true);
|
| FilterOperations filters;
|
| filters.Append(FilterOperation::CreateBlurFilter(1.5f));
|
| render_surface1->SetBackgroundFilters(filters);
|
| @@ -5344,7 +5345,8 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
|
| gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
|
| true, false, false);
|
| grand_child->SetDrawsContent(true);
|
| - grand_child->SetHideLayerAndSubtree(true);
|
| + // Setting opacity to 0 will hide the subtree.
|
| + grand_child->SetOpacity(0.f);
|
|
|
| child->AddChild(std::move(grand_child));
|
| root->AddChild(std::move(child));
|
| @@ -5386,7 +5388,8 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
|
| gfx::PointF(), gfx::Size(40, 40), true, false,
|
| false);
|
| child->SetDrawsContent(true);
|
| - child->SetHideLayerAndSubtree(true);
|
| + // Setting opacity to 0 will hide the subtree.
|
| + child->SetOpacity(0.f);
|
|
|
| scoped_ptr<LayerImpl> grand_child =
|
| LayerImpl::Create(host_impl.pending_tree(), 3);
|
| @@ -5462,8 +5465,16 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
|
| copy_child->SetDrawsContent(true);
|
| LayerImpl* copy_child_layer = copy_child.get();
|
|
|
| - scoped_ptr<LayerImpl> copy_grand_parent_sibling_before =
|
| + scoped_ptr<LayerImpl> copy_grand_child =
|
| LayerImpl::Create(host_impl.pending_tree(), 6);
|
| + SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix,
|
| + gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
|
| + true, false, false);
|
| + copy_child->SetDrawsContent(true);
|
| + LayerImpl* copy_grand_child_layer = copy_grand_child.get();
|
| +
|
| + scoped_ptr<LayerImpl> copy_grand_parent_sibling_before =
|
| + LayerImpl::Create(host_impl.pending_tree(), 7);
|
| SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(),
|
| identity_matrix, gfx::Point3F(), gfx::PointF(),
|
| gfx::Size(40, 40), true, false, false);
|
| @@ -5472,7 +5483,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
|
| copy_grand_parent_sibling_before.get();
|
|
|
| scoped_ptr<LayerImpl> copy_grand_parent_sibling_after =
|
| - LayerImpl::Create(host_impl.pending_tree(), 7);
|
| + LayerImpl::Create(host_impl.pending_tree(), 8);
|
| SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(),
|
| identity_matrix, gfx::Point3F(), gfx::PointF(),
|
| gfx::Size(40, 40), true, false, false);
|
| @@ -5480,6 +5491,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
|
| LayerImpl* copy_grand_parent_sibling_after_layer =
|
| copy_grand_parent_sibling_after.get();
|
|
|
| + copy_child->AddChild(std::move(copy_grand_child));
|
| copy_request->AddChild(std::move(copy_child));
|
| copy_parent->AddChild(std::move(copy_request));
|
| copy_grand_parent->AddChild(std::move(copy_parent));
|
| @@ -5488,10 +5500,12 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
|
| root->AddChild(std::move(copy_grand_parent_sibling_after));
|
|
|
| // Hide the copy_grand_parent and its subtree. But make a copy request in that
|
| - // hidden subtree on copy_layer.
|
| - copy_grand_parent_layer->SetHideLayerAndSubtree(true);
|
| - copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true);
|
| - copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true);
|
| + // hidden subtree on copy_layer. Also hide the copy grand child and its
|
| + // subtree.
|
| + copy_grand_parent_layer->SetOpacity(0.f);
|
| + copy_grand_parent_sibling_before_layer->SetOpacity(0.f);
|
| + copy_grand_parent_sibling_after_layer->SetOpacity(0.f);
|
| + copy_grand_child_layer->SetOpacity(0.f);
|
|
|
| std::vector<scoped_ptr<CopyOutputRequest>> copy_requests;
|
| copy_requests.push_back(
|
| @@ -5512,27 +5526,27 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
|
| EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0);
|
| EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0);
|
|
|
| - // We should have three render surfaces, one for the root, one for the parent
|
| + // We should have four render surfaces, one for the root, one for the grand
|
| + // parent since it has opacity and two drawing descendants, one for the parent
|
| // since it owns a surface, and one for the copy_layer.
|
| - ASSERT_EQ(3u, render_surface_layer_list.size());
|
| + ASSERT_EQ(4u, render_surface_layer_list.size());
|
| EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id());
|
| - EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id());
|
| - EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id());
|
| + EXPECT_EQ(copy_grand_parent_layer->id(),
|
| + render_surface_layer_list.at(1)->id());
|
| + EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
|
| + EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
|
|
|
| - // The root render surface should have 2 contributing layers. The
|
| - // copy_grand_parent is hidden along with its siblings, but the copy_parent
|
| - // will appear since something in its subtree needs to be drawn for a copy
|
| - // request.
|
| + // The root render surface should have 2 contributing layers.
|
| ASSERT_EQ(2u, root->render_surface()->layer_list().size());
|
| EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id());
|
| - EXPECT_EQ(copy_parent_layer->id(),
|
| + EXPECT_EQ(copy_grand_parent_layer->id(),
|
| root->render_surface()->layer_list().at(1)->id());
|
|
|
| // Nothing actually draws into the copy parent, so only the copy_layer will
|
| // appear in its list, since it needs to be drawn for the copy request.
|
| ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size());
|
| EXPECT_EQ(copy_layer->id(),
|
| - copy_parent_layer->render_surface()->layer_list().at(0)->id());
|
| + copy_layer->render_surface()->layer_list().at(0)->id());
|
|
|
| // The copy_layer's render surface should have two contributing layers.
|
| ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size());
|
| @@ -5540,6 +5554,20 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
|
| copy_layer->render_surface()->layer_list().at(0)->id());
|
| EXPECT_EQ(copy_child_layer->id(),
|
| copy_layer->render_surface()->layer_list().at(1)->id());
|
| +
|
| + // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
|
| + // but the copy_layer and copy_child should be drawn for the copy request.
|
| + // copy grand child should not be drawn as its hidden even in the copy
|
| + // request.
|
| + EXPECT_FALSE(copy_grand_parent_layer->IsDrawnFromPropertyTrees());
|
| + EXPECT_FALSE(copy_parent_layer->IsDrawnFromPropertyTrees());
|
| + EXPECT_TRUE(copy_layer->IsDrawnFromPropertyTrees());
|
| + EXPECT_TRUE(copy_child_layer->IsDrawnFromPropertyTrees());
|
| + EXPECT_FALSE(copy_grand_child_layer->IsDrawnFromPropertyTrees());
|
| +
|
| + // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its
|
| + // actually hidden.
|
| + EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface());
|
| }
|
|
|
| TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
|
| @@ -8641,10 +8669,11 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
|
| EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
|
| child->SetTransform(identity);
|
|
|
| - child->SetHideLayerAndSubtree(true);
|
| + // Set opacity to 0 to hide subtree.
|
| + child->SetOpacity(0.f);
|
| ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
|
| - child->SetHideLayerAndSubtree(false);
|
| + child->SetOpacity(1.f);
|
|
|
| gfx::Transform zero_z_scale;
|
| zero_z_scale.Scale3d(1, 1, 0);
|
| @@ -8682,11 +8711,11 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
|
| // Now, even though child has zero opacity, we will configure |grandchild| and
|
| // |greatgrandchild| in several ways that should force the subtree to be
|
| // processed anyhow.
|
| - greatgrandchild->RequestCopyOfOutput(
|
| + grandchild->RequestCopyOfOutput(
|
| CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
|
| ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees());
|
| - grandchild->set_visible_rect_from_property_trees(gfx::Rect());
|
| + greatgrandchild->set_visible_rect_from_property_trees(gfx::Rect());
|
|
|
| // Add an opacity animation with a start delay.
|
| animation_id = 1;
|
| @@ -8734,15 +8763,10 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
|
| SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
|
| gfx::PointF(), gfx::Size(10, 10), true, false,
|
| false);
|
| - SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(),
|
| - gfx::PointF(), gfx::Size(10, 10), true, false,
|
| - true);
|
|
|
| LayerImpl* child_ptr = child.get();
|
| LayerImpl* grandchild_ptr = grandchild.get();
|
| - LayerImpl* greatgrandchild_ptr = greatgrandchild.get();
|
|
|
| - grandchild->AddChild(std::move(greatgrandchild));
|
| child->AddChild(std::move(grandchild));
|
| root->AddChild(std::move(child));
|
|
|
| @@ -8765,12 +8789,6 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
|
| grandchild_ptr->visible_rect_from_property_trees());
|
| child_ptr->SetTransform(identity);
|
|
|
| - child_ptr->SetHideLayerAndSubtree(true);
|
| - ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| - EXPECT_EQ(gfx::Rect(0, 0),
|
| - grandchild_ptr->visible_rect_from_property_trees());
|
| - child_ptr->SetHideLayerAndSubtree(false);
|
| -
|
| child_ptr->SetOpacity(0.f);
|
| ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| EXPECT_EQ(gfx::Rect(0, 0),
|
| @@ -8782,7 +8800,7 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
|
| std::vector<scoped_ptr<CopyOutputRequest>> requests;
|
| requests.push_back(CopyOutputRequest::CreateEmptyRequest());
|
|
|
| - greatgrandchild_ptr->PassCopyRequests(&requests);
|
| + grandchild_ptr->PassCopyRequests(&requests);
|
| root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true;
|
| ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| EXPECT_EQ(gfx::Rect(10, 10),
|
| @@ -8808,10 +8826,11 @@ TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
|
| EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees());
|
| child->set_visible_rect_from_property_trees(gfx::Rect());
|
|
|
| - child->SetHideLayerAndSubtree(true);
|
| + // Set opacity to 0 to hide subtree.
|
| + child->SetOpacity(0.f);
|
| ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees());
|
| - child->SetHideLayerAndSubtree(false);
|
| + child->SetOpacity(1.f);
|
|
|
| child->SetBounds(gfx::Size());
|
| ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
|
| @@ -9374,7 +9393,9 @@ TEST_F(LayerTreeHostCommonTest, LayerWithInputHandlerAndZeroOpacity) {
|
| SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(),
|
| gfx::PointF(), gfx::Size(30, 30), true, false,
|
| true);
|
| - SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
|
| + gfx::Transform translation;
|
| + translation.Translate(10, 10);
|
| + SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(),
|
| gfx::PointF(), gfx::Size(20, 20), true, false,
|
| false);
|
|
|
| @@ -9384,9 +9405,7 @@ TEST_F(LayerTreeHostCommonTest, LayerWithInputHandlerAndZeroOpacity) {
|
| test_layer->SetHaveWheelEventHandlers(true);
|
|
|
| ExecuteCalculateDrawProperties(root);
|
| - EXPECT_EQ(gfx::Rect(20, 20), test_layer->drawable_content_rect());
|
| - EXPECT_EQ(gfx::RectF(20, 20),
|
| - render_surface->render_surface()->DrawableContentRect());
|
| + EXPECT_EQ(translation, test_layer->ScreenSpaceTransform());
|
| }
|
|
|
| TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) {
|
| @@ -9467,14 +9486,15 @@ TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) {
|
| gfx::PointF(), gfx::Size(30, 30), true, false,
|
| true);
|
|
|
| - hidden->SetHideLayerAndSubtree(true);
|
| + // Set opacity to 0 to hide subtree.
|
| + hidden->SetOpacity(0.f);
|
| ExecuteCalculateDrawProperties(root);
|
| - EXPECT_TRUE(test->LayerIsHidden());
|
| + EXPECT_TRUE(test->IsHidden());
|
|
|
| - hidden->SetHideLayerAndSubtree(false);
|
| + hidden->SetOpacity(1.f);
|
| root->layer_tree_impl()->property_trees()->needs_rebuild = true;
|
| ExecuteCalculateDrawProperties(root);
|
| - EXPECT_FALSE(test->LayerIsHidden());
|
| + EXPECT_FALSE(test->IsHidden());
|
| }
|
|
|
| TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) {
|
|
|