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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1588093004: Compute if a layer is drawn without LayerTree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); 144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform());
145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
146 child->screen_space_transform()); 146 child->screen_space_transform());
147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
148 grand_child->draw_transform()); 148 grand_child->draw_transform());
149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
150 grand_child->screen_space_transform()); 150 grand_child->screen_space_transform());
151 } 151 }
152 152
153 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { 153 TEST_F(LayerTreeHostCommonTest,
154 ScreenSpaceTransformOfSkippedLayersWithHandlers) {
155 // Even for layers that are skipped, we need to compute the correct screen
156 // space transform because it is used during hit testing.
154 LayerImpl* parent = root_layer(); 157 LayerImpl* parent = root_layer();
155 LayerImpl* child = AddChild<LayerImpl>(parent); 158 LayerImpl* child = AddChild<LayerImpl>(parent);
156 LayerImpl* grand_child = AddChild<LayerImpl>(child); 159 LayerImpl* grand_child = AddChild<LayerImpl>(child);
157 child->SetDrawsContent(true); 160 child->SetDrawsContent(true);
158 grand_child->SetDrawsContent(true); 161 grand_child->SetDrawsContent(true);
159 162
160 gfx::Transform identity_matrix; 163 gfx::Transform identity_matrix;
161 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 164 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
162 gfx::PointF(), gfx::Size(100, 100), true, false); 165 gfx::PointF(), gfx::Size(100, 100), true, false);
163 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 166 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
164 gfx::PointF(10, 10), gfx::Size(100, 100), true, 167 gfx::PointF(10, 10), gfx::Size(100, 100), true,
165 false); 168 false);
166 // This would have previously caused us to skip our subtree, but this would be 169 // This will cause the subtree to be skipped.
167 // wrong; we need up-to-date draw properties to do hit testing on the layers
168 // with handlers.
169 child->SetOpacity(0.f); 170 child->SetOpacity(0.f);
170 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 171 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
171 gfx::PointF(10, 10), gfx::Size(100, 100), true, 172 gfx::PointF(10, 10), gfx::Size(100, 100), true,
172 false); 173 false);
173 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); 174 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
174 175
175 ExecuteCalculateDrawProperties(parent); 176 ExecuteCalculateDrawProperties(parent);
176 177
177 EXPECT_TRUE(child->has_render_surface()); 178 EXPECT_TRUE(child->has_render_surface());
178 EXPECT_FALSE(grand_child->has_render_surface()); 179 EXPECT_FALSE(grand_child->has_render_surface());
179 // Check that we've computed draw properties for the subtree rooted at 180 // Check that we've computed draw properties for the subtree rooted at
180 // |child|. 181 // |child|.
181 EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity()); 182 EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity());
182 EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity()); 183 EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity());
183 EXPECT_FALSE(
184 grand_child->draw_properties().target_space_transform.IsIdentity());
185 } 184 }
186 185
187 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { 186 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) {
188 // Tests that effect tree node gets a valid transform id when a layer 187 // Tests that effect tree node gets a valid transform id when a layer
189 // has opacity but doesn't create a render surface. 188 // has opacity but doesn't create a render surface.
190 LayerImpl* parent = root_layer(); 189 LayerImpl* parent = root_layer();
191 LayerImpl* child = AddChild<LayerImpl>(parent); 190 LayerImpl* child = AddChild<LayerImpl>(parent);
192 child->SetDrawsContent(true); 191 child->SetDrawsContent(true);
193 192
194 gfx::Transform identity_matrix; 193 gfx::Transform identity_matrix;
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1333 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1335 gfx::PointF(), gfx::Size(10, 10), true, false, 1334 gfx::PointF(), gfx::Size(10, 10), true, false,
1336 true); 1335 true);
1337 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1336 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1338 gfx::PointF(), gfx::Size(10, 10), true, false, 1337 gfx::PointF(), gfx::Size(10, 10), true, false,
1339 true); 1338 true);
1340 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1339 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1341 gfx::PointF(), gfx::Size(10, 10), true, false, 1340 gfx::PointF(), gfx::Size(10, 10), true, false,
1342 false); 1341 false);
1343 render_surface1->SetOpacity(0.f); 1342 render_surface1->SetOpacity(0.f);
1343 render_surface1->SetDrawsContent(true);
1344 child->SetDrawsContent(true);
1344 FilterOperations filters; 1345 FilterOperations filters;
1345 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); 1346 filters.Append(FilterOperation::CreateBlurFilter(1.5f));
1346 render_surface1->SetBackgroundFilters(filters); 1347 render_surface1->SetBackgroundFilters(filters);
1347 1348
1348 LayerImplList render_surface_layer_list; 1349 LayerImplList render_surface_layer_list;
1349 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 1350 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
1350 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1351 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1351 parent, parent->bounds(), &render_surface_layer_list, 1352 parent, parent->bounds(), &render_surface_layer_list,
1352 parent->layer_tree_impl()->current_render_surface_list_id()); 1353 parent->layer_tree_impl()->current_render_surface_list_id());
1353 inputs.can_adjust_raster_scales = true; 1354 inputs.can_adjust_raster_scales = true;
(...skipping 4143 matching lines...) Expand 10 before | Expand all | Expand 10 after
5497 LayerImpl* copy_layer = copy_request.get(); 5498 LayerImpl* copy_layer = copy_request.get();
5498 5499
5499 scoped_ptr<LayerImpl> copy_child = 5500 scoped_ptr<LayerImpl> copy_child =
5500 LayerImpl::Create(host_impl.pending_tree(), 5); 5501 LayerImpl::Create(host_impl.pending_tree(), 5);
5501 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, 5502 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix,
5502 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), 5503 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5503 true, false, false); 5504 true, false, false);
5504 copy_child->SetDrawsContent(true); 5505 copy_child->SetDrawsContent(true);
5505 LayerImpl* copy_child_layer = copy_child.get(); 5506 LayerImpl* copy_child_layer = copy_child.get();
5506 5507
5508 scoped_ptr<LayerImpl> copy_grand_child =
5509 LayerImpl::Create(host_impl.pending_tree(), 6);
5510 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix,
5511 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5512 true, false, false);
5513 copy_child->SetDrawsContent(true);
5514 LayerImpl* copy_grand_child_layer = copy_grand_child.get();
5515
5507 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = 5516 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before =
5508 LayerImpl::Create(host_impl.pending_tree(), 6); 5517 LayerImpl::Create(host_impl.pending_tree(), 7);
5509 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), 5518 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(),
5510 identity_matrix, gfx::Point3F(), gfx::PointF(), 5519 identity_matrix, gfx::Point3F(), gfx::PointF(),
5511 gfx::Size(40, 40), true, false, false); 5520 gfx::Size(40, 40), true, false, false);
5512 copy_grand_parent_sibling_before->SetDrawsContent(true); 5521 copy_grand_parent_sibling_before->SetDrawsContent(true);
5513 LayerImpl* copy_grand_parent_sibling_before_layer = 5522 LayerImpl* copy_grand_parent_sibling_before_layer =
5514 copy_grand_parent_sibling_before.get(); 5523 copy_grand_parent_sibling_before.get();
5515 5524
5516 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = 5525 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after =
5517 LayerImpl::Create(host_impl.pending_tree(), 7); 5526 LayerImpl::Create(host_impl.pending_tree(), 8);
5518 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), 5527 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(),
5519 identity_matrix, gfx::Point3F(), gfx::PointF(), 5528 identity_matrix, gfx::Point3F(), gfx::PointF(),
5520 gfx::Size(40, 40), true, false, false); 5529 gfx::Size(40, 40), true, false, false);
5521 copy_grand_parent_sibling_after->SetDrawsContent(true); 5530 copy_grand_parent_sibling_after->SetDrawsContent(true);
5522 LayerImpl* copy_grand_parent_sibling_after_layer = 5531 LayerImpl* copy_grand_parent_sibling_after_layer =
5523 copy_grand_parent_sibling_after.get(); 5532 copy_grand_parent_sibling_after.get();
5524 5533
5534 copy_child->AddChild(std::move(copy_grand_child));
5525 copy_request->AddChild(std::move(copy_child)); 5535 copy_request->AddChild(std::move(copy_child));
5526 copy_parent->AddChild(std::move(copy_request)); 5536 copy_parent->AddChild(std::move(copy_request));
5527 copy_grand_parent->AddChild(std::move(copy_parent)); 5537 copy_grand_parent->AddChild(std::move(copy_parent));
5528 root->AddChild(std::move(copy_grand_parent_sibling_before)); 5538 root->AddChild(std::move(copy_grand_parent_sibling_before));
5529 root->AddChild(std::move(copy_grand_parent)); 5539 root->AddChild(std::move(copy_grand_parent));
5530 root->AddChild(std::move(copy_grand_parent_sibling_after)); 5540 root->AddChild(std::move(copy_grand_parent_sibling_after));
5531 5541
5532 // Hide the copy_grand_parent and its subtree. But make a copy request in that 5542 // Hide the copy_grand_parent and its subtree. But make a copy request in that
5533 // hidden subtree on copy_layer. 5543 // hidden subtree on copy_layer. Also hide the copy grand child and its
5544 // subtree.
5534 copy_grand_parent_layer->SetHideLayerAndSubtree(true); 5545 copy_grand_parent_layer->SetHideLayerAndSubtree(true);
5535 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); 5546 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true);
5536 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); 5547 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true);
5548 copy_grand_child_layer->SetHideLayerAndSubtree(true);
5537 5549
5538 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; 5550 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests;
5539 copy_requests.push_back( 5551 copy_requests.push_back(
5540 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5552 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5541 copy_layer->PassCopyRequests(&copy_requests); 5553 copy_layer->PassCopyRequests(&copy_requests);
5542 EXPECT_TRUE(copy_layer->HasCopyRequest()); 5554 EXPECT_TRUE(copy_layer->HasCopyRequest());
5543 5555
5544 LayerImplList render_surface_layer_list; 5556 LayerImplList render_surface_layer_list;
5545 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 5557 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
5546 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5558 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5547 root.get(), root->bounds(), &render_surface_layer_list, 5559 root.get(), root->bounds(), &render_surface_layer_list,
5548 root->layer_tree_impl()->current_render_surface_list_id()); 5560 root->layer_tree_impl()->current_render_surface_list_id());
5549 inputs.can_adjust_raster_scales = true; 5561 inputs.can_adjust_raster_scales = true;
5550 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5562 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5551 5563
5552 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); 5564 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0);
5553 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); 5565 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0);
5554 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); 5566 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0);
5555 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); 5567 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0);
5556 5568
5557 // We should have three render surfaces, one for the root, one for the parent 5569 // We should have four render surfaces, one for the root, one for the grand
5570 // parent since it has opacity and two drawing descendants, one for the parent
5558 // since it owns a surface, and one for the copy_layer. 5571 // since it owns a surface, and one for the copy_layer.
5559 ASSERT_EQ(3u, render_surface_layer_list.size()); 5572 ASSERT_EQ(4u, render_surface_layer_list.size());
5560 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); 5573 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id());
5561 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id()); 5574 EXPECT_EQ(copy_grand_parent_layer->id(),
5562 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); 5575 render_surface_layer_list.at(1)->id());
5576 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
5577 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
5563 5578
5564 // The root render surface should have 2 contributing layers. The 5579 // The root render surface should have 2 contributing layers.
5565 // copy_grand_parent is hidden along with its siblings, but the copy_parent
5566 // will appear since something in its subtree needs to be drawn for a copy
5567 // request.
5568 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 5580 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
5569 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); 5581 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id());
5570 EXPECT_EQ(copy_parent_layer->id(), 5582 EXPECT_EQ(copy_grand_parent_layer->id(),
5571 root->render_surface()->layer_list().at(1)->id()); 5583 root->render_surface()->layer_list().at(1)->id());
5572 5584
5573 // Nothing actually draws into the copy parent, so only the copy_layer will 5585 // Nothing actually draws into the copy parent, so only the copy_layer will
5574 // appear in its list, since it needs to be drawn for the copy request. 5586 // appear in its list, since it needs to be drawn for the copy request.
5575 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); 5587 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size());
5576 EXPECT_EQ(copy_layer->id(), 5588 EXPECT_EQ(copy_layer->id(),
5577 copy_parent_layer->render_surface()->layer_list().at(0)->id()); 5589 copy_layer->render_surface()->layer_list().at(0)->id());
5578 5590
5579 // The copy_layer's render surface should have two contributing layers. 5591 // The copy_layer's render surface should have two contributing layers.
5580 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); 5592 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size());
5581 EXPECT_EQ(copy_layer->id(), 5593 EXPECT_EQ(copy_layer->id(),
5582 copy_layer->render_surface()->layer_list().at(0)->id()); 5594 copy_layer->render_surface()->layer_list().at(0)->id());
5583 EXPECT_EQ(copy_child_layer->id(), 5595 EXPECT_EQ(copy_child_layer->id(),
5584 copy_layer->render_surface()->layer_list().at(1)->id()); 5596 copy_layer->render_surface()->layer_list().at(1)->id());
5597
5598 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
5599 // but the copy_layer and copy_child should be drawn for the copy request.
5600 // copy grand child should not be drawn as its hidden even in the copy
5601 // request.
5602 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree;
5603 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
5604 EXPECT_FALSE(node->data.is_drawn);
5605 node = tree.Node(copy_parent_layer->effect_tree_index());
5606 EXPECT_FALSE(node->data.is_drawn);
5607 node = tree.Node(copy_layer->effect_tree_index());
5608 EXPECT_TRUE(node->data.is_drawn);
5609 node = tree.Node(copy_child_layer->effect_tree_index());
5610 EXPECT_TRUE(node->data.is_drawn);
5611 node = tree.Node(copy_grand_child_layer->effect_tree_index());
5612 EXPECT_FALSE(node->data.is_drawn);
5613
5614 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its
5615 // actually hidden.
5616 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface());
5585 } 5617 }
5586 5618
5587 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 5619 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
5588 FakeImplTaskRunnerProvider task_runner_provider; 5620 FakeImplTaskRunnerProvider task_runner_provider;
5589 TestSharedBitmapManager shared_bitmap_manager; 5621 TestSharedBitmapManager shared_bitmap_manager;
5590 TestTaskGraphRunner task_graph_runner; 5622 TestTaskGraphRunner task_graph_runner;
5591 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 5623 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
5592 &task_graph_runner); 5624 &task_graph_runner);
5593 host_impl.CreatePendingTree(); 5625 host_impl.CreatePendingTree();
5594 const gfx::Transform identity_matrix; 5626 const gfx::Transform identity_matrix;
(...skipping 3122 matching lines...) Expand 10 before | Expand all | Expand 10 after
8717 child->RemoveAnimation(animation_id); 8749 child->RemoveAnimation(animation_id);
8718 } 8750 }
8719 child->SetTransform(identity); 8751 child->SetTransform(identity);
8720 child->SetOpacity(0.f); 8752 child->SetOpacity(0.f);
8721 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8753 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8722 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); 8754 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees());
8723 8755
8724 // Now, even though child has zero opacity, we will configure |grandchild| and 8756 // Now, even though child has zero opacity, we will configure |grandchild| and
8725 // |greatgrandchild| in several ways that should force the subtree to be 8757 // |greatgrandchild| in several ways that should force the subtree to be
8726 // processed anyhow. 8758 // processed anyhow.
8727 greatgrandchild->RequestCopyOfOutput( 8759 grandchild->RequestCopyOfOutput(
8728 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 8760 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
8729 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8761 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8730 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); 8762 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees());
8731 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); 8763 greatgrandchild->set_visible_rect_from_property_trees(gfx::Rect());
8732 8764
8733 // Add an opacity animation with a start delay. 8765 // Add an opacity animation with a start delay.
8734 animation_id = 1; 8766 animation_id = 1;
8735 animation = Animation::Create( 8767 animation = Animation::Create(
8736 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 8768 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
8737 animation_id, 1, Animation::OPACITY); 8769 animation_id, 1, Animation::OPACITY);
8738 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8770 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8739 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8771 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8740 if (layer_settings().use_compositor_animation_timelines) { 8772 if (layer_settings().use_compositor_animation_timelines) {
8741 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), 8773 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(),
(...skipping 27 matching lines...) Expand all
8769 8801
8770 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 8802 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8771 gfx::PointF(), gfx::Size(100, 100), true, false, 8803 gfx::PointF(), gfx::Size(100, 100), true, false,
8772 true); 8804 true);
8773 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), 8805 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
8774 gfx::PointF(), gfx::Size(10, 10), true, false, 8806 gfx::PointF(), gfx::Size(10, 10), true, false,
8775 false); 8807 false);
8776 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), 8808 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
8777 gfx::PointF(), gfx::Size(10, 10), true, false, 8809 gfx::PointF(), gfx::Size(10, 10), true, false,
8778 false); 8810 false);
8779 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(),
8780 gfx::PointF(), gfx::Size(10, 10), true, false,
8781 true);
8782 8811
8783 LayerImpl* child_ptr = child.get(); 8812 LayerImpl* child_ptr = child.get();
8784 LayerImpl* grandchild_ptr = grandchild.get(); 8813 LayerImpl* grandchild_ptr = grandchild.get();
8785 LayerImpl* greatgrandchild_ptr = greatgrandchild.get();
8786 8814
8787 grandchild->AddChild(std::move(greatgrandchild));
8788 child->AddChild(std::move(grandchild)); 8815 child->AddChild(std::move(grandchild));
8789 root->AddChild(std::move(child)); 8816 root->AddChild(std::move(child));
8790 8817
8791 // Check the non-skipped case. 8818 // Check the non-skipped case.
8792 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8819 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8793 EXPECT_EQ(gfx::Rect(10, 10), 8820 EXPECT_EQ(gfx::Rect(10, 10),
8794 grandchild_ptr->visible_rect_from_property_trees()); 8821 grandchild_ptr->visible_rect_from_property_trees());
8795 8822
8796 // Now we will reset the visible rect from property trees for the grandchild, 8823 // Now we will reset the visible rect from property trees for the grandchild,
8797 // and we will configure |child| in several ways that should force the subtree 8824 // and we will configure |child| in several ways that should force the subtree
(...skipping 19 matching lines...) Expand all
8817 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8844 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8818 EXPECT_EQ(gfx::Rect(0, 0), 8845 EXPECT_EQ(gfx::Rect(0, 0),
8819 grandchild_ptr->visible_rect_from_property_trees()); 8846 grandchild_ptr->visible_rect_from_property_trees());
8820 8847
8821 // Now, even though child has zero opacity, we will configure |grandchild| and 8848 // Now, even though child has zero opacity, we will configure |grandchild| and
8822 // |greatgrandchild| in several ways that should force the subtree to be 8849 // |greatgrandchild| in several ways that should force the subtree to be
8823 // processed anyhow. 8850 // processed anyhow.
8824 std::vector<scoped_ptr<CopyOutputRequest>> requests; 8851 std::vector<scoped_ptr<CopyOutputRequest>> requests;
8825 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 8852 requests.push_back(CopyOutputRequest::CreateEmptyRequest());
8826 8853
8827 greatgrandchild_ptr->PassCopyRequests(&requests); 8854 grandchild_ptr->PassCopyRequests(&requests);
8828 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; 8855 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true;
8829 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8856 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8830 EXPECT_EQ(gfx::Rect(10, 10), 8857 EXPECT_EQ(gfx::Rect(10, 10),
8831 grandchild_ptr->visible_rect_from_property_trees()); 8858 grandchild_ptr->visible_rect_from_property_trees());
8832 } 8859 }
8833 8860
8834 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 8861 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
8835 gfx::Transform identity; 8862 gfx::Transform identity;
8836 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 8863 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8837 FakeContentLayerClient client; 8864 FakeContentLayerClient client;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
9409 LayerImpl* render_surface = AddChild<LayerImpl>(root); 9436 LayerImpl* render_surface = AddChild<LayerImpl>(root);
9410 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); 9437 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
9411 9438
9412 const gfx::Transform identity_matrix; 9439 const gfx::Transform identity_matrix;
9413 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9440 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
9414 gfx::PointF(), gfx::Size(30, 30), true, false, 9441 gfx::PointF(), gfx::Size(30, 30), true, false,
9415 true); 9442 true);
9416 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), 9443 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(),
9417 gfx::PointF(), gfx::Size(30, 30), true, false, 9444 gfx::PointF(), gfx::Size(30, 30), true, false,
9418 true); 9445 true);
9419 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), 9446 gfx::Transform translation;
9447 translation.Translate(10, 10);
9448 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(),
9420 gfx::PointF(), gfx::Size(20, 20), true, false, 9449 gfx::PointF(), gfx::Size(20, 20), true, false,
9421 false); 9450 false);
9422 9451
9423 render_surface->SetMasksToBounds(true); 9452 render_surface->SetMasksToBounds(true);
9424 test_layer->SetDrawsContent(true); 9453 test_layer->SetDrawsContent(true);
9425 test_layer->SetOpacity(0); 9454 test_layer->SetOpacity(0);
9426 test_layer->SetHaveWheelEventHandlers(true); 9455 test_layer->SetHaveWheelEventHandlers(true);
9427 9456
9428 ExecuteCalculateDrawProperties(root); 9457 ExecuteCalculateDrawProperties(root);
9429 EXPECT_EQ(gfx::Rect(20, 20), test_layer->drawable_content_rect()); 9458 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform());
9430 EXPECT_EQ(gfx::RectF(20, 20),
9431 render_surface->render_surface()->DrawableContentRect());
9432 } 9459 }
9433 9460
9434 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { 9461 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) {
9435 LayerImpl* root = root_layer(); 9462 LayerImpl* root = root_layer();
9436 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9463 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9437 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9464 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
9438 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); 9465 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface);
9439 9466
9440 const gfx::Transform identity_matrix; 9467 const gfx::Transform identity_matrix;
9441 clip_parent->SetMasksToBounds(true); 9468 clip_parent->SetMasksToBounds(true);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
9504 true); 9531 true);
9505 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), 9532 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(),
9506 gfx::PointF(10, 10), gfx::Size(30, 30), true, 9533 gfx::PointF(10, 10), gfx::Size(30, 30), true,
9507 false, true); 9534 false, true);
9508 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), 9535 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(),
9509 gfx::PointF(), gfx::Size(30, 30), true, false, 9536 gfx::PointF(), gfx::Size(30, 30), true, false,
9510 true); 9537 true);
9511 9538
9512 hidden->SetHideLayerAndSubtree(true); 9539 hidden->SetHideLayerAndSubtree(true);
9513 ExecuteCalculateDrawProperties(root); 9540 ExecuteCalculateDrawProperties(root);
9514 EXPECT_TRUE(test->LayerIsHidden()); 9541 EXPECT_TRUE(test->IsHidden());
9515 9542
9516 hidden->SetHideLayerAndSubtree(false); 9543 hidden->SetHideLayerAndSubtree(false);
9517 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9544 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9518 ExecuteCalculateDrawProperties(root); 9545 ExecuteCalculateDrawProperties(root);
9519 EXPECT_FALSE(test->LayerIsHidden()); 9546 EXPECT_FALSE(test->IsHidden());
9520 } 9547 }
9521 9548
9522 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { 9549 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) {
9523 LayerImpl* root = root_layer(); 9550 LayerImpl* root = root_layer();
9524 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 9551 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
9525 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 9552 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
9526 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 9553 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
9527 9554
9528 const gfx::Transform identity_matrix; 9555 const gfx::Transform identity_matrix;
9529 clip_child->SetClipParent(root); 9556 clip_child->SetClipParent(root);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
9672 proto::ScrollAndScaleSet proto; 9699 proto::ScrollAndScaleSet proto;
9673 scroll_and_scale_set.ToProtobuf(&proto); 9700 scroll_and_scale_set.ToProtobuf(&proto);
9674 ScrollAndScaleSet new_scroll_and_scale_set; 9701 ScrollAndScaleSet new_scroll_and_scale_set;
9675 new_scroll_and_scale_set.FromProtobuf(proto); 9702 new_scroll_and_scale_set.FromProtobuf(proto);
9676 9703
9677 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); 9704 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set));
9678 } 9705 }
9679 9706
9680 } // namespace 9707 } // namespace
9681 } // namespace cc 9708 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698