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 f5b9502a603c6bbdcbed583a91cd23b68afe2c5f..1a16de8dd9a44e8dcbdadcc1a57f4c064f736ee9 100644 |
--- a/cc/trees/layer_tree_host_common_unittest.cc |
+++ b/cc/trees/layer_tree_host_common_unittest.cc |
@@ -4740,241 +4740,60 @@ INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
testing::Bool(), |
testing::Bool())); |
-TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
- 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); |
- LayerImpl* child_layer = child.get(); |
- |
- 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; |
- LayerImpl* grand_child_layer = grand_child.get(); |
- |
- child->test_properties()->AddChild(std::move(grand_child)); |
- root->test_properties()->AddChild(std::move(child)); |
- host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
- |
- RenderSurfaceList render_surface_list; |
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
- root_layer, root_layer->bounds(), &render_surface_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_list.size()); |
- ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
- EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
- EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); |
-} |
- |
-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; |
- LayerImpl* child_layer = child.get(); |
- |
- std::unique_ptr<LayerImpl> grand_child = |
- LayerImpl::Create(host_impl.pending_tree(), 3); |
- grand_child->SetBounds(gfx::Size(30, 30)); |
- grand_child->SetDrawsContent(true); |
- LayerImpl* grand_child_layer = grand_child.get(); |
- |
- child->test_properties()->AddChild(std::move(grand_child)); |
- root->test_properties()->AddChild(std::move(child)); |
- host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
- |
- RenderSurfaceList render_surface_list; |
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
- root_layer, root_layer->bounds(), &render_surface_list); |
- inputs.can_adjust_raster_scales = true; |
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
- |
- // We should have one render surface and one layer. The child has |
- // hidden itself and the grand child. |
- ASSERT_EQ(1u, render_surface_list.size()); |
- ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); |
- EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); |
-} |
- |
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))); |
- RenderSurfaceList render_surface_list; |
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
- root_layer, root_layer->bounds(), &render_surface_list); |
- inputs.can_adjust_raster_scales = true; |
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
+ copy_grand_parent->SetHideLayerAndSubtree(true); |
+ copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); |
+ copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); |
+ copy_grand_child->SetHideLayerAndSubtree(true); |
- 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()); |
+ 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()); |
- // 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_list.size()); |
- EXPECT_EQ(static_cast<uint64_t>(root_layer->id()), |
- render_surface_list.at(0)->id()); |
- EXPECT_EQ(static_cast<uint64_t>(copy_grand_parent_layer->id()), |
- render_surface_list.at(1)->id()); |
- EXPECT_EQ(static_cast<uint64_t>(copy_parent_layer->id()), |
- render_surface_list.at(2)->id()); |
- EXPECT_EQ(static_cast<uint64_t>(copy_layer->id()), |
- render_surface_list.at(3)->id()); |
- |
- // The root render surface should have 2 contributing layers. |
- EXPECT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
- EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(copy_grand_parent_sibling_before_layer |
- ->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(copy_grand_parent_sibling_after_layer |
- ->contributes_to_drawn_render_surface()); |
- |
- // 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(1, GetRenderSurface(copy_parent_layer)->num_contributors()); |
- EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); |
- |
- // The copy layer's render surface should have 2 contributing layers. |
- ASSERT_EQ(2, GetRenderSurface(copy_layer)->num_contributors()); |
- EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); |
- EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); |
- EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); |
- |
- // 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(GetRenderSurface(copy_layer)->contributes_to_drawn_surface()); |
} |
TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
@@ -5031,47 +4850,63 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
} |
TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { |
- LayerImpl* root = root_layer_for_testing(); |
- root->SetBounds(gfx::Size(50, 50)); |
- root->SetDrawsContent(true); |
+ scoped_refptr<Layer> root = Layer::Create(); |
+ scoped_refptr<Layer> singular_transform_layer = Layer::Create(); |
+ scoped_refptr<Layer> copy_layer = Layer::Create(); |
+ scoped_refptr<Layer> copy_child = Layer::Create(); |
+ scoped_refptr<Layer> copy_grand_child = Layer::Create(); |
+ |
+ root->AddChild(singular_transform_layer); |
+ singular_transform_layer->AddChild(copy_layer); |
+ copy_layer->AddChild(copy_child); |
+ copy_child->AddChild(copy_grand_child); |
+ host()->SetRootLayer(root); |
- LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); |
+ root->SetBounds(gfx::Size(50, 50)); |
+ root->SetIsDrawable(true); |
singular_transform_layer->SetBounds(gfx::Size(100, 100)); |
- singular_transform_layer->SetDrawsContent(true); |
gfx::Transform singular; |
singular.Scale3d(6.f, 6.f, 0.f); |
- singular_transform_layer->test_properties()->transform = singular; |
- |
- LayerImpl* copy_layer = AddChild<LayerImpl>(singular_transform_layer); |
+ singular_transform_layer->SetTransform(singular); |
+ singular_transform_layer->SetIsDrawable(true); |
copy_layer->SetBounds(gfx::Size(100, 100)); |
- copy_layer->SetDrawsContent(true); |
- copy_layer->test_properties()->copy_requests.push_back( |
- CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
- |
- LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); |
+ copy_layer->SetIsDrawable(true); |
+ copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
+ base::Bind(&EmptyCopyOutputCallback))); |
copy_child->SetBounds(gfx::Size(100, 100)); |
- copy_child->SetDrawsContent(true); |
- |
- LayerImpl* copy_grand_child = AddChild<LayerImpl>(copy_child); |
+ copy_child->SetIsDrawable(true); |
copy_grand_child->SetBounds(gfx::Size(100, 100)); |
- copy_grand_child->SetDrawsContent(true); |
- copy_grand_child->test_properties()->transform = singular; |
+ copy_grand_child->SetTransform(singular); |
+ copy_grand_child->SetIsDrawable(true); |
- DCHECK(!copy_layer->test_properties()->copy_requests.empty()); |
- ExecuteCalculateDrawProperties(root); |
- DCHECK(copy_layer->test_properties()->copy_requests.empty()); |
+ ExecuteCalculateDrawProperties(root.get()); |
+ |
+ host()->host_impl()->CreatePendingTree(); |
+ host()->CommitAndCreatePendingTree(); |
+ host()->host_impl()->ActivateSyncTree(); |
+ LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree(); |
+ |
+ LayerImpl* root_impl = layer_tree_impl->LayerById(root->id()); |
+ LayerImpl* singular_transform_layer_impl = |
+ layer_tree_impl->LayerById(singular_transform_layer->id()); |
+ LayerImpl* copy_layer_impl = layer_tree_impl->LayerById(copy_layer->id()); |
+ LayerImpl* copy_child_impl = layer_tree_impl->LayerById(copy_child->id()); |
+ LayerImpl* copy_grand_child_impl = |
+ layer_tree_impl->LayerById(copy_grand_child->id()); |
+ ExecuteCalculateDrawProperties(root_impl); |
// A layer with singular transform should not contribute to drawn render |
// surface. |
- EXPECT_FALSE(singular_transform_layer->contributes_to_drawn_render_surface()); |
+ EXPECT_FALSE( |
+ singular_transform_layer_impl->contributes_to_drawn_render_surface()); |
// Even though copy_layer and copy_child have singular screen space transform, |
// they still contribute to drawn render surface as their transform to the |
// closest ancestor with copy request is not singular. |
- EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); |
- EXPECT_TRUE(copy_child->contributes_to_drawn_render_surface()); |
+ EXPECT_TRUE(copy_layer_impl->contributes_to_drawn_render_surface()); |
+ EXPECT_TRUE(copy_child_impl->contributes_to_drawn_render_surface()); |
// copy_grand_child's transform to its closest ancestor with copy request is |
// also singular. So, it doesn't contribute to drawn render surface. |
- EXPECT_FALSE(copy_grand_child->contributes_to_drawn_render_surface()); |
+ EXPECT_FALSE(copy_grand_child_impl->contributes_to_drawn_render_surface()); |
} |
TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
@@ -8760,6 +8595,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); |
@@ -8873,11 +8711,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); |
@@ -9072,12 +8905,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); |
@@ -9601,26 +9428,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, |
- GetRenderSurface(test)->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, |
- GetRenderSurface(test)->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) { |