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 51ef650997dcd8bed83a2cde931694d836b9c304..5bbb41c5597f2b2112e4fa69350f3011d71dce23 100644 |
--- a/cc/trees/layer_tree_host_common_unittest.cc |
+++ b/cc/trees/layer_tree_host_common_unittest.cc |
@@ -5368,231 +5368,60 @@ INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
testing::Bool(), |
testing::Bool())); |
-TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
jaydasika
2017/04/27 21:36:58
Deleted these tests as hidden subtrees now don't e
|
- FakeImplTaskRunnerProvider task_runner_provider; |
- TestTaskGraphRunner task_graph_runner; |
- FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
- host_impl.CreatePendingTree(); |
- |
- std::unique_ptr<LayerImpl> root = |
- LayerImpl::Create(host_impl.pending_tree(), 1); |
- root->SetBounds(gfx::Size(50, 50)); |
- root->SetDrawsContent(true); |
- LayerImpl* root_layer = root.get(); |
- |
- std::unique_ptr<LayerImpl> child = |
- LayerImpl::Create(host_impl.pending_tree(), 2); |
- child->SetBounds(gfx::Size(40, 40)); |
- child->SetDrawsContent(true); |
- |
- std::unique_ptr<LayerImpl> grand_child = |
- LayerImpl::Create(host_impl.pending_tree(), 3); |
- grand_child->SetBounds(gfx::Size(30, 30)); |
- grand_child->SetDrawsContent(true); |
- grand_child->test_properties()->hide_layer_and_subtree = true; |
- |
- child->test_properties()->AddChild(std::move(grand_child)); |
- root->test_properties()->AddChild(std::move(child)); |
- host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
- |
- LayerImplList render_surface_layer_list; |
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
- root_layer, root_layer->bounds(), &render_surface_layer_list); |
- inputs.can_adjust_raster_scales = true; |
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
- |
- // 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_layer->GetRenderSurface()->layer_list().size()); |
- EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id()); |
- EXPECT_EQ(2, root_layer->GetRenderSurface()->layer_list().at(1)->id()); |
-} |
- |
-TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
- FakeImplTaskRunnerProvider task_runner_provider; |
- TestTaskGraphRunner task_graph_runner; |
- FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
- host_impl.CreatePendingTree(); |
- |
- std::unique_ptr<LayerImpl> root = |
- LayerImpl::Create(host_impl.pending_tree(), 1); |
- root->SetBounds(gfx::Size(50, 50)); |
- root->SetDrawsContent(true); |
- LayerImpl* root_layer = root.get(); |
- |
- std::unique_ptr<LayerImpl> child = |
- LayerImpl::Create(host_impl.pending_tree(), 2); |
- child->SetBounds(gfx::Size(40, 40)); |
- child->SetDrawsContent(true); |
- child->test_properties()->hide_layer_and_subtree = true; |
- |
- std::unique_ptr<LayerImpl> grand_child = |
- LayerImpl::Create(host_impl.pending_tree(), 3); |
- grand_child->SetBounds(gfx::Size(30, 30)); |
- grand_child->SetDrawsContent(true); |
- |
- child->test_properties()->AddChild(std::move(grand_child)); |
- root->test_properties()->AddChild(std::move(child)); |
- host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
- |
- LayerImplList render_surface_layer_list; |
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
- root_layer, root_layer->bounds(), &render_surface_layer_list); |
- inputs.can_adjust_raster_scales = true; |
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
- |
- // 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_layer->GetRenderSurface()->layer_list().size()); |
- EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id()); |
-} |
- |
void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
- FakeImplTaskRunnerProvider task_runner_provider; |
- TestTaskGraphRunner task_graph_runner; |
- FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
- host_impl.CreatePendingTree(); |
+ scoped_refptr<Layer> root = Layer::Create(); |
+ scoped_refptr<Layer> copy_grand_parent = Layer::Create(); |
+ scoped_refptr<Layer> copy_parent = Layer::Create(); |
+ scoped_refptr<Layer> copy_layer = Layer::Create(); |
+ scoped_refptr<Layer> copy_child = Layer::Create(); |
+ scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
+ scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create(); |
+ scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create(); |
- std::unique_ptr<LayerImpl> root = |
- LayerImpl::Create(host_impl.pending_tree(), 1); |
root->SetBounds(gfx::Size(50, 50)); |
- root->SetDrawsContent(true); |
- LayerImpl* root_layer = root.get(); |
- |
- std::unique_ptr<LayerImpl> copy_grand_parent = |
- LayerImpl::Create(host_impl.pending_tree(), 2); |
- copy_grand_parent->SetBounds(gfx::Size(40, 40)); |
- copy_grand_parent->SetDrawsContent(true); |
- LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); |
- |
- std::unique_ptr<LayerImpl> copy_parent = |
- LayerImpl::Create(host_impl.pending_tree(), 3); |
- copy_parent->SetBounds(gfx::Size(30, 30)); |
- copy_parent->SetDrawsContent(true); |
- copy_parent->test_properties()->force_render_surface = true; |
- LayerImpl* copy_parent_layer = copy_parent.get(); |
- |
- std::unique_ptr<LayerImpl> copy_request = |
- LayerImpl::Create(host_impl.pending_tree(), 4); |
- copy_request->SetBounds(gfx::Size(20, 20)); |
- copy_request->SetDrawsContent(true); |
- copy_request->test_properties()->force_render_surface = true; |
- LayerImpl* copy_layer = copy_request.get(); |
- |
- std::unique_ptr<LayerImpl> copy_child = |
- LayerImpl::Create(host_impl.pending_tree(), 5); |
- copy_child->SetBounds(gfx::Size(20, 20)); |
- copy_child->SetDrawsContent(true); |
- LayerImpl* copy_child_layer = copy_child.get(); |
- |
- std::unique_ptr<LayerImpl> copy_grand_child = |
- LayerImpl::Create(host_impl.pending_tree(), 6); |
- copy_grand_child->SetBounds(gfx::Size(20, 20)); |
- copy_grand_child->SetDrawsContent(true); |
- LayerImpl* copy_grand_child_layer = copy_grand_child.get(); |
- |
- std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = |
- LayerImpl::Create(host_impl.pending_tree(), 7); |
- copy_grand_parent_sibling_before->SetBounds(gfx::Size(40, 40)); |
- copy_grand_parent_sibling_before->SetDrawsContent(true); |
- LayerImpl* copy_grand_parent_sibling_before_layer = |
- copy_grand_parent_sibling_before.get(); |
- |
- std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = |
- LayerImpl::Create(host_impl.pending_tree(), 8); |
- copy_grand_parent_sibling_after->SetBounds(gfx::Size(40, 40)); |
- copy_grand_parent_sibling_after->SetDrawsContent(true); |
- LayerImpl* copy_grand_parent_sibling_after_layer = |
- copy_grand_parent_sibling_after.get(); |
- |
- copy_child->test_properties()->AddChild(std::move(copy_grand_child)); |
- copy_request->test_properties()->AddChild(std::move(copy_child)); |
- copy_parent->test_properties()->AddChild(std::move(copy_request)); |
- copy_grand_parent->test_properties()->AddChild(std::move(copy_parent)); |
- root->test_properties()->AddChild( |
- std::move(copy_grand_parent_sibling_before)); |
- root->test_properties()->AddChild(std::move(copy_grand_parent)); |
- root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after)); |
- host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
- |
- // Hide the copy_grand_parent and its subtree. But make a copy request in that |
- // hidden subtree on copy_layer. Also hide the copy grand child and its |
- // subtree. |
- copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true; |
- copy_grand_parent_sibling_before_layer->test_properties() |
- ->hide_layer_and_subtree = true; |
- copy_grand_parent_sibling_after_layer->test_properties() |
- ->hide_layer_and_subtree = true; |
- copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true; |
+ copy_grand_parent->SetBounds(gfx::Size(50, 50)); |
+ copy_parent->SetBounds(gfx::Size(50, 50)); |
+ copy_parent->SetForceRenderSurfaceForTesting(true); |
+ copy_layer->SetBounds(gfx::Size(50, 50)); |
+ copy_child->SetBounds(gfx::Size(50, 50)); |
+ copy_grand_child->SetBounds(gfx::Size(50, 50)); |
+ copy_grand_parent_sibling_before->SetBounds(gfx::Size(50, 50)); |
+ copy_grand_parent_sibling_after->SetBounds(gfx::Size(50, 50)); |
+ |
+ root->AddChild(copy_grand_parent_sibling_before); |
+ root->AddChild(copy_grand_parent); |
+ root->AddChild(copy_grand_parent_sibling_after); |
+ copy_grand_parent->AddChild(copy_parent); |
+ copy_parent->AddChild(copy_layer); |
+ copy_layer->AddChild(copy_child); |
+ copy_child->AddChild(copy_grand_child); |
+ host()->SetRootLayer(root); |
- copy_layer->test_properties()->copy_requests.push_back( |
+ copy_layer->RequestCopyOfOutput( |
CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
- LayerImplList render_surface_layer_list; |
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
- root_layer, root_layer->bounds(), &render_surface_layer_list); |
- inputs.can_adjust_raster_scales = true; |
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
- |
- EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); |
- EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); |
- EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); |
- EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); |
+ copy_grand_parent->SetHideLayerAndSubtree(true); |
+ copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); |
+ copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); |
+ copy_grand_child->SetHideLayerAndSubtree(true); |
- // 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(4u, render_surface_layer_list.size()); |
- EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->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()); |
+ ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
+ EXPECT_FALSE(copy_grand_parent->is_hidden()); |
+ EXPECT_TRUE(copy_grand_parent_sibling_after->is_hidden()); |
+ EXPECT_TRUE(copy_grand_parent_sibling_before->is_hidden()); |
+ EXPECT_TRUE(copy_grand_child->is_hidden()); |
- // The root render surface should have 2 contributing layers. |
- ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size()); |
- EXPECT_EQ(root_layer->id(), |
- root_layer->GetRenderSurface()->layer_list().at(0)->id()); |
- EXPECT_EQ(copy_grand_parent_layer->id(), |
- root_layer->GetRenderSurface()->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->GetRenderSurface()->layer_list().size()); |
- EXPECT_EQ(copy_layer->id(), |
- copy_parent_layer->GetRenderSurface()->layer_list().at(0)->id()); |
- |
- // The copy_layer's render surface should have two contributing layers. |
- ASSERT_EQ(2u, copy_layer->GetRenderSurface()->layer_list().size()); |
- EXPECT_EQ(copy_layer->id(), |
- copy_layer->GetRenderSurface()->layer_list().at(0)->id()); |
- EXPECT_EQ(copy_child_layer->id(), |
- copy_layer->GetRenderSurface()->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. |
- EffectTree& tree = |
- root_layer->layer_tree_impl()->property_trees()->effect_tree; |
- EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); |
+ EffectTree& tree = host()->property_trees()->effect_tree; |
+ EffectNode* node = tree.Node(copy_grand_parent->effect_tree_index()); |
EXPECT_FALSE(node->is_drawn); |
- node = tree.Node(copy_parent_layer->effect_tree_index()); |
+ node = tree.Node(copy_parent->effect_tree_index()); |
EXPECT_FALSE(node->is_drawn); |
node = tree.Node(copy_layer->effect_tree_index()); |
EXPECT_TRUE(node->is_drawn); |
- node = tree.Node(copy_child_layer->effect_tree_index()); |
+ node = tree.Node(copy_child->effect_tree_index()); |
EXPECT_TRUE(node->is_drawn); |
- node = tree.Node(copy_grand_child_layer->effect_tree_index()); |
- EXPECT_FALSE(node->is_drawn); |
- |
- // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its |
- // actually hidden. |
- EXPECT_FALSE(copy_layer->GetRenderSurface()->contributes_to_drawn_surface()); |
} |
TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
@@ -9414,6 +9243,9 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { |
child->SetHideLayerAndSubtree(true); |
ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
update_list = GetUpdateLayerList(); |
+ EXPECT_TRUE(child->is_hidden()); |
+ EXPECT_TRUE(grandchild->is_hidden()); |
+ EXPECT_FALSE(VerifyLayerInList(child, update_list)); |
EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
child->SetHideLayerAndSubtree(false); |
@@ -9527,11 +9359,6 @@ TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
child_ptr->test_properties()->transform = gfx::Transform(); |
- child_ptr->test_properties()->hide_layer_and_subtree = true; |
- ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
- EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
- child_ptr->test_properties()->hide_layer_and_subtree = false; |
- |
child_ptr->test_properties()->opacity = 0.f; |
host_impl.active_tree()->property_trees()->needs_rebuild = true; |
ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
@@ -9726,12 +9553,6 @@ TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
child->set_visible_layer_rect(gfx::Rect()); |
- child->test_properties()->hide_layer_and_subtree = true; |
- root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
- ExecuteCalculateDrawProperties(root); |
- EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
- child->test_properties()->hide_layer_and_subtree = false; |
- |
child->SetBounds(gfx::Size()); |
root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
ExecuteCalculateDrawProperties(root); |
@@ -10258,26 +10079,36 @@ TEST_F(LayerTreeHostCommonTest, |
TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { |
// Tests that subtree is hidden is updated. |
- LayerImpl* root = root_layer_for_testing(); |
- LayerImpl* hidden = AddChild<LayerImpl>(root); |
- LayerImpl* test = AddChild<LayerImpl>(hidden); |
+ scoped_refptr<Layer> root = Layer::Create(); |
+ scoped_refptr<Layer> hidden = Layer::Create(); |
+ scoped_refptr<Layer> test = Layer::Create(); |
root->SetBounds(gfx::Size(30, 30)); |
hidden->SetBounds(gfx::Size(30, 30)); |
- hidden->test_properties()->force_render_surface = true; |
- hidden->test_properties()->hide_layer_and_subtree = true; |
+ hidden->SetHideLayerAndSubtree(true); |
test->SetBounds(gfx::Size(30, 30)); |
- test->test_properties()->force_render_surface = true; |
- ExecuteCalculateDrawProperties(root); |
- EXPECT_EQ(0.f, |
- test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); |
+ root->AddChild(hidden); |
+ hidden->AddChild(test); |
+ host()->SetRootLayer(root); |
- hidden->test_properties()->hide_layer_and_subtree = false; |
- root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
- ExecuteCalculateDrawProperties(root); |
- EXPECT_EQ(1.f, |
- test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); |
+ ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
+ EXPECT_TRUE(test->is_hidden()); |
+ // Hidden layers should have invalid property tree indices. |
+ const int kInvalidNodeId = -1; |
+ EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId); |
+ EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId); |
+ EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId); |
+ EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId); |
+ |
+ hidden->SetHideLayerAndSubtree(false); |
+ root->layer_tree_host()->property_trees()->needs_rebuild = true; |
+ ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
+ EXPECT_FALSE(test->is_hidden()); |
+ EXPECT_NE(test->effect_tree_index(), kInvalidNodeId); |
+ EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId); |
+ EXPECT_NE(test->clip_tree_index(), kInvalidNodeId); |
+ EXPECT_NE(test->transform_tree_index(), kInvalidNodeId); |
} |
TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |