OLD | NEW |
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 Loading... |
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, | 153 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { |
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. | |
157 LayerImpl* parent = root_layer(); | 154 LayerImpl* parent = root_layer(); |
158 LayerImpl* child = AddChild<LayerImpl>(parent); | 155 LayerImpl* child = AddChild<LayerImpl>(parent); |
159 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 156 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
160 child->SetDrawsContent(true); | 157 child->SetDrawsContent(true); |
161 grand_child->SetDrawsContent(true); | 158 grand_child->SetDrawsContent(true); |
162 | 159 |
163 gfx::Transform identity_matrix; | 160 gfx::Transform identity_matrix; |
164 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 161 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
165 gfx::PointF(), gfx::Size(100, 100), true, false); | 162 gfx::PointF(), gfx::Size(100, 100), true, false); |
166 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 163 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
167 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 164 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
168 false); | 165 false); |
169 // This will cause the subtree to be skipped. | 166 // This would have previously caused us to skip our subtree, but this would be |
| 167 // wrong; we need up-to-date draw properties to do hit testing on the layers |
| 168 // with handlers. |
170 child->SetOpacity(0.f); | 169 child->SetOpacity(0.f); |
171 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 170 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
172 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 171 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
173 false); | 172 false); |
174 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 173 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
175 | 174 |
176 ExecuteCalculateDrawProperties(parent); | 175 ExecuteCalculateDrawProperties(parent); |
177 | 176 |
178 EXPECT_TRUE(child->has_render_surface()); | 177 EXPECT_TRUE(child->has_render_surface()); |
179 EXPECT_FALSE(grand_child->has_render_surface()); | 178 EXPECT_FALSE(grand_child->has_render_surface()); |
180 // Check that we've computed draw properties for the subtree rooted at | 179 // Check that we've computed draw properties for the subtree rooted at |
181 // |child|. | 180 // |child|. |
182 EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity()); | 181 EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity()); |
183 EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity()); | 182 EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity()); |
| 183 EXPECT_FALSE( |
| 184 grand_child->draw_properties().target_space_transform.IsIdentity()); |
184 } | 185 } |
185 | 186 |
186 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { | 187 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { |
187 // Tests that effect tree node gets a valid transform id when a layer | 188 // Tests that effect tree node gets a valid transform id when a layer |
188 // has opacity but doesn't create a render surface. | 189 // has opacity but doesn't create a render surface. |
189 LayerImpl* parent = root_layer(); | 190 LayerImpl* parent = root_layer(); |
190 LayerImpl* child = AddChild<LayerImpl>(parent); | 191 LayerImpl* child = AddChild<LayerImpl>(parent); |
191 child->SetDrawsContent(true); | 192 child->SetDrawsContent(true); |
192 | 193 |
193 gfx::Transform identity_matrix; | 194 gfx::Transform identity_matrix; |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 1334 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
1334 gfx::PointF(), gfx::Size(10, 10), true, false, | 1335 gfx::PointF(), gfx::Size(10, 10), true, false, |
1335 true); | 1336 true); |
1336 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), | 1337 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), |
1337 gfx::PointF(), gfx::Size(10, 10), true, false, | 1338 gfx::PointF(), gfx::Size(10, 10), true, false, |
1338 true); | 1339 true); |
1339 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 1340 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
1340 gfx::PointF(), gfx::Size(10, 10), true, false, | 1341 gfx::PointF(), gfx::Size(10, 10), true, false, |
1341 false); | 1342 false); |
1342 render_surface1->SetOpacity(0.f); | 1343 render_surface1->SetOpacity(0.f); |
1343 render_surface1->SetDrawsContent(true); | |
1344 child->SetDrawsContent(true); | |
1345 FilterOperations filters; | 1344 FilterOperations filters; |
1346 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); | 1345 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); |
1347 render_surface1->SetBackgroundFilters(filters); | 1346 render_surface1->SetBackgroundFilters(filters); |
1348 | 1347 |
1349 LayerImplList render_surface_layer_list; | 1348 LayerImplList render_surface_layer_list; |
1350 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 1349 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
1351 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1350 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1352 parent, parent->bounds(), &render_surface_layer_list, | 1351 parent, parent->bounds(), &render_surface_layer_list, |
1353 parent->layer_tree_impl()->current_render_surface_list_id()); | 1352 parent->layer_tree_impl()->current_render_surface_list_id()); |
1354 inputs.can_adjust_raster_scales = true; | 1353 inputs.can_adjust_raster_scales = true; |
(...skipping 4221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5576 LayerImpl* copy_layer = copy_request.get(); | 5575 LayerImpl* copy_layer = copy_request.get(); |
5577 | 5576 |
5578 scoped_ptr<LayerImpl> copy_child = | 5577 scoped_ptr<LayerImpl> copy_child = |
5579 LayerImpl::Create(host_impl.pending_tree(), 5); | 5578 LayerImpl::Create(host_impl.pending_tree(), 5); |
5580 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5579 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
5581 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5580 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
5582 true, false, false); | 5581 true, false, false); |
5583 copy_child->SetDrawsContent(true); | 5582 copy_child->SetDrawsContent(true); |
5584 LayerImpl* copy_child_layer = copy_child.get(); | 5583 LayerImpl* copy_child_layer = copy_child.get(); |
5585 | 5584 |
5586 scoped_ptr<LayerImpl> copy_grand_child = | 5585 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = |
5587 LayerImpl::Create(host_impl.pending_tree(), 6); | 5586 LayerImpl::Create(host_impl.pending_tree(), 6); |
5588 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, | |
5589 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | |
5590 true, false, false); | |
5591 copy_child->SetDrawsContent(true); | |
5592 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); | |
5593 | |
5594 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = | |
5595 LayerImpl::Create(host_impl.pending_tree(), 7); | |
5596 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), | 5587 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), |
5597 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5588 identity_matrix, gfx::Point3F(), gfx::PointF(), |
5598 gfx::Size(40, 40), true, false, false); | 5589 gfx::Size(40, 40), true, false, false); |
5599 copy_grand_parent_sibling_before->SetDrawsContent(true); | 5590 copy_grand_parent_sibling_before->SetDrawsContent(true); |
5600 LayerImpl* copy_grand_parent_sibling_before_layer = | 5591 LayerImpl* copy_grand_parent_sibling_before_layer = |
5601 copy_grand_parent_sibling_before.get(); | 5592 copy_grand_parent_sibling_before.get(); |
5602 | 5593 |
5603 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = | 5594 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = |
5604 LayerImpl::Create(host_impl.pending_tree(), 8); | 5595 LayerImpl::Create(host_impl.pending_tree(), 7); |
5605 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), | 5596 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), |
5606 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5597 identity_matrix, gfx::Point3F(), gfx::PointF(), |
5607 gfx::Size(40, 40), true, false, false); | 5598 gfx::Size(40, 40), true, false, false); |
5608 copy_grand_parent_sibling_after->SetDrawsContent(true); | 5599 copy_grand_parent_sibling_after->SetDrawsContent(true); |
5609 LayerImpl* copy_grand_parent_sibling_after_layer = | 5600 LayerImpl* copy_grand_parent_sibling_after_layer = |
5610 copy_grand_parent_sibling_after.get(); | 5601 copy_grand_parent_sibling_after.get(); |
5611 | 5602 |
5612 copy_child->AddChild(std::move(copy_grand_child)); | |
5613 copy_request->AddChild(std::move(copy_child)); | 5603 copy_request->AddChild(std::move(copy_child)); |
5614 copy_parent->AddChild(std::move(copy_request)); | 5604 copy_parent->AddChild(std::move(copy_request)); |
5615 copy_grand_parent->AddChild(std::move(copy_parent)); | 5605 copy_grand_parent->AddChild(std::move(copy_parent)); |
5616 root->AddChild(std::move(copy_grand_parent_sibling_before)); | 5606 root->AddChild(std::move(copy_grand_parent_sibling_before)); |
5617 root->AddChild(std::move(copy_grand_parent)); | 5607 root->AddChild(std::move(copy_grand_parent)); |
5618 root->AddChild(std::move(copy_grand_parent_sibling_after)); | 5608 root->AddChild(std::move(copy_grand_parent_sibling_after)); |
5619 | 5609 |
5620 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5610 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
5621 // hidden subtree on copy_layer. Also hide the copy grand child and its | 5611 // hidden subtree on copy_layer. |
5622 // subtree. | |
5623 copy_grand_parent_layer->SetHideLayerAndSubtree(true); | 5612 copy_grand_parent_layer->SetHideLayerAndSubtree(true); |
5624 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); | 5613 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); |
5625 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); | 5614 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); |
5626 copy_grand_child_layer->SetHideLayerAndSubtree(true); | |
5627 | 5615 |
5628 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5616 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5629 copy_requests.push_back( | 5617 copy_requests.push_back( |
5630 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5618 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5631 copy_layer->PassCopyRequests(©_requests); | 5619 copy_layer->PassCopyRequests(©_requests); |
5632 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5620 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5633 | 5621 |
5634 LayerImplList render_surface_layer_list; | 5622 LayerImplList render_surface_layer_list; |
5635 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5623 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
5636 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5624 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5637 root.get(), root->bounds(), &render_surface_layer_list, | 5625 root.get(), root->bounds(), &render_surface_layer_list, |
5638 root->layer_tree_impl()->current_render_surface_list_id()); | 5626 root->layer_tree_impl()->current_render_surface_list_id()); |
5639 inputs.can_adjust_raster_scales = true; | 5627 inputs.can_adjust_raster_scales = true; |
5640 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5628 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5641 | 5629 |
5642 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 5630 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
5643 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5631 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); |
5644 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5632 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); |
5645 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); | 5633 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); |
5646 | 5634 |
5647 // We should have four render surfaces, one for the root, one for the grand | 5635 // We should have three render surfaces, one for the root, one for the parent |
5648 // parent since it has opacity and two drawing descendants, one for the parent | |
5649 // since it owns a surface, and one for the copy_layer. | 5636 // since it owns a surface, and one for the copy_layer. |
5650 ASSERT_EQ(4u, render_surface_layer_list.size()); | 5637 ASSERT_EQ(3u, render_surface_layer_list.size()); |
5651 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5638 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
5652 EXPECT_EQ(copy_grand_parent_layer->id(), | 5639 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id()); |
5653 render_surface_layer_list.at(1)->id()); | 5640 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); |
5654 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); | |
5655 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); | |
5656 | 5641 |
5657 // The root render surface should have 2 contributing layers. | 5642 // The root render surface should have 2 contributing layers. The |
| 5643 // copy_grand_parent is hidden along with its siblings, but the copy_parent |
| 5644 // will appear since something in its subtree needs to be drawn for a copy |
| 5645 // request. |
5658 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5646 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5659 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5647 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
5660 EXPECT_EQ(copy_grand_parent_layer->id(), | 5648 EXPECT_EQ(copy_parent_layer->id(), |
5661 root->render_surface()->layer_list().at(1)->id()); | 5649 root->render_surface()->layer_list().at(1)->id()); |
5662 | 5650 |
5663 // Nothing actually draws into the copy parent, so only the copy_layer will | 5651 // Nothing actually draws into the copy parent, so only the copy_layer will |
5664 // appear in its list, since it needs to be drawn for the copy request. | 5652 // appear in its list, since it needs to be drawn for the copy request. |
5665 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); | 5653 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
5666 EXPECT_EQ(copy_layer->id(), | 5654 EXPECT_EQ(copy_layer->id(), |
5667 copy_layer->render_surface()->layer_list().at(0)->id()); | 5655 copy_parent_layer->render_surface()->layer_list().at(0)->id()); |
5668 | 5656 |
5669 // The copy_layer's render surface should have two contributing layers. | 5657 // The copy_layer's render surface should have two contributing layers. |
5670 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5658 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
5671 EXPECT_EQ(copy_layer->id(), | 5659 EXPECT_EQ(copy_layer->id(), |
5672 copy_layer->render_surface()->layer_list().at(0)->id()); | 5660 copy_layer->render_surface()->layer_list().at(0)->id()); |
5673 EXPECT_EQ(copy_child_layer->id(), | 5661 EXPECT_EQ(copy_child_layer->id(), |
5674 copy_layer->render_surface()->layer_list().at(1)->id()); | 5662 copy_layer->render_surface()->layer_list().at(1)->id()); |
5675 | |
5676 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | |
5677 // but the copy_layer and copy_child should be drawn for the copy request. | |
5678 // copy grand child should not be drawn as its hidden even in the copy | |
5679 // request. | |
5680 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; | |
5681 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | |
5682 EXPECT_FALSE(node->data.is_drawn); | |
5683 node = tree.Node(copy_parent_layer->effect_tree_index()); | |
5684 EXPECT_FALSE(node->data.is_drawn); | |
5685 node = tree.Node(copy_layer->effect_tree_index()); | |
5686 EXPECT_TRUE(node->data.is_drawn); | |
5687 node = tree.Node(copy_child_layer->effect_tree_index()); | |
5688 EXPECT_TRUE(node->data.is_drawn); | |
5689 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | |
5690 EXPECT_FALSE(node->data.is_drawn); | |
5691 | |
5692 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its | |
5693 // actually hidden. | |
5694 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); | |
5695 } | 5663 } |
5696 | 5664 |
5697 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5665 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
5698 FakeImplTaskRunnerProvider task_runner_provider; | 5666 FakeImplTaskRunnerProvider task_runner_provider; |
5699 TestSharedBitmapManager shared_bitmap_manager; | 5667 TestSharedBitmapManager shared_bitmap_manager; |
5700 TestTaskGraphRunner task_graph_runner; | 5668 TestTaskGraphRunner task_graph_runner; |
5701 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5669 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
5702 &task_graph_runner); | 5670 &task_graph_runner); |
5703 host_impl.CreatePendingTree(); | 5671 host_impl.CreatePendingTree(); |
5704 const gfx::Transform identity_matrix; | 5672 const gfx::Transform identity_matrix; |
(...skipping 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8865 child->RemoveAnimation(animation_id); | 8833 child->RemoveAnimation(animation_id); |
8866 } | 8834 } |
8867 child->SetTransform(identity); | 8835 child->SetTransform(identity); |
8868 child->SetOpacity(0.f); | 8836 child->SetOpacity(0.f); |
8869 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8837 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8870 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8838 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
8871 | 8839 |
8872 // Now, even though child has zero opacity, we will configure |grandchild| and | 8840 // Now, even though child has zero opacity, we will configure |grandchild| and |
8873 // |greatgrandchild| in several ways that should force the subtree to be | 8841 // |greatgrandchild| in several ways that should force the subtree to be |
8874 // processed anyhow. | 8842 // processed anyhow. |
8875 grandchild->RequestCopyOfOutput( | 8843 greatgrandchild->RequestCopyOfOutput( |
8876 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8844 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
8877 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8845 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8878 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); | 8846 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); |
8879 greatgrandchild->set_visible_rect_from_property_trees(gfx::Rect()); | 8847 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); |
8880 | 8848 |
8881 // Add an opacity animation with a start delay. | 8849 // Add an opacity animation with a start delay. |
8882 animation_id = 1; | 8850 animation_id = 1; |
8883 animation = Animation::Create( | 8851 animation = Animation::Create( |
8884 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8852 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
8885 animation_id, 1, Animation::OPACITY); | 8853 animation_id, 1, Animation::OPACITY); |
8886 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8854 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
8887 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8855 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8888 if (layer_settings().use_compositor_animation_timelines) { | 8856 if (layer_settings().use_compositor_animation_timelines) { |
8889 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8857 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), |
(...skipping 27 matching lines...) Expand all Loading... |
8917 | 8885 |
8918 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8886 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
8919 gfx::PointF(), gfx::Size(100, 100), true, false, | 8887 gfx::PointF(), gfx::Size(100, 100), true, false, |
8920 true); | 8888 true); |
8921 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8889 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
8922 gfx::PointF(), gfx::Size(10, 10), true, false, | 8890 gfx::PointF(), gfx::Size(10, 10), true, false, |
8923 false); | 8891 false); |
8924 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | 8892 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), |
8925 gfx::PointF(), gfx::Size(10, 10), true, false, | 8893 gfx::PointF(), gfx::Size(10, 10), true, false, |
8926 false); | 8894 false); |
| 8895 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), |
| 8896 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 8897 true); |
8927 | 8898 |
8928 LayerImpl* child_ptr = child.get(); | 8899 LayerImpl* child_ptr = child.get(); |
8929 LayerImpl* grandchild_ptr = grandchild.get(); | 8900 LayerImpl* grandchild_ptr = grandchild.get(); |
| 8901 LayerImpl* greatgrandchild_ptr = greatgrandchild.get(); |
8930 | 8902 |
| 8903 grandchild->AddChild(std::move(greatgrandchild)); |
8931 child->AddChild(std::move(grandchild)); | 8904 child->AddChild(std::move(grandchild)); |
8932 root->AddChild(std::move(child)); | 8905 root->AddChild(std::move(child)); |
8933 | 8906 |
8934 // Check the non-skipped case. | 8907 // Check the non-skipped case. |
8935 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8908 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8936 EXPECT_EQ(gfx::Rect(10, 10), | 8909 EXPECT_EQ(gfx::Rect(10, 10), |
8937 grandchild_ptr->visible_rect_from_property_trees()); | 8910 grandchild_ptr->visible_rect_from_property_trees()); |
8938 | 8911 |
8939 // Now we will reset the visible rect from property trees for the grandchild, | 8912 // Now we will reset the visible rect from property trees for the grandchild, |
8940 // and we will configure |child| in several ways that should force the subtree | 8913 // and we will configure |child| in several ways that should force the subtree |
(...skipping 19 matching lines...) Expand all Loading... |
8960 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8933 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8961 EXPECT_EQ(gfx::Rect(0, 0), | 8934 EXPECT_EQ(gfx::Rect(0, 0), |
8962 grandchild_ptr->visible_rect_from_property_trees()); | 8935 grandchild_ptr->visible_rect_from_property_trees()); |
8963 | 8936 |
8964 // Now, even though child has zero opacity, we will configure |grandchild| and | 8937 // Now, even though child has zero opacity, we will configure |grandchild| and |
8965 // |greatgrandchild| in several ways that should force the subtree to be | 8938 // |greatgrandchild| in several ways that should force the subtree to be |
8966 // processed anyhow. | 8939 // processed anyhow. |
8967 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 8940 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
8968 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8941 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
8969 | 8942 |
8970 grandchild_ptr->PassCopyRequests(&requests); | 8943 greatgrandchild_ptr->PassCopyRequests(&requests); |
8971 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8944 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8972 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8945 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8973 EXPECT_EQ(gfx::Rect(10, 10), | 8946 EXPECT_EQ(gfx::Rect(10, 10), |
8974 grandchild_ptr->visible_rect_from_property_trees()); | 8947 grandchild_ptr->visible_rect_from_property_trees()); |
8975 } | 8948 } |
8976 | 8949 |
8977 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8950 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
8978 gfx::Transform identity; | 8951 gfx::Transform identity; |
8979 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 8952 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
8980 FakeContentLayerClient client; | 8953 FakeContentLayerClient client; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9552 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 9525 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
9553 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 9526 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
9554 | 9527 |
9555 const gfx::Transform identity_matrix; | 9528 const gfx::Transform identity_matrix; |
9556 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9529 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
9557 gfx::PointF(), gfx::Size(30, 30), true, false, | 9530 gfx::PointF(), gfx::Size(30, 30), true, false, |
9558 true); | 9531 true); |
9559 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | 9532 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), |
9560 gfx::PointF(), gfx::Size(30, 30), true, false, | 9533 gfx::PointF(), gfx::Size(30, 30), true, false, |
9561 true); | 9534 true); |
9562 gfx::Transform translation; | 9535 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
9563 translation.Translate(10, 10); | |
9564 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), | |
9565 gfx::PointF(), gfx::Size(20, 20), true, false, | 9536 gfx::PointF(), gfx::Size(20, 20), true, false, |
9566 false); | 9537 false); |
9567 | 9538 |
9568 render_surface->SetMasksToBounds(true); | 9539 render_surface->SetMasksToBounds(true); |
9569 test_layer->SetDrawsContent(true); | 9540 test_layer->SetDrawsContent(true); |
9570 test_layer->SetOpacity(0); | 9541 test_layer->SetOpacity(0); |
9571 test_layer->SetHaveWheelEventHandlers(true); | 9542 test_layer->SetHaveWheelEventHandlers(true); |
9572 | 9543 |
9573 ExecuteCalculateDrawProperties(root); | 9544 ExecuteCalculateDrawProperties(root); |
9574 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); | 9545 EXPECT_EQ(gfx::Rect(20, 20), test_layer->drawable_content_rect()); |
| 9546 EXPECT_EQ(gfx::RectF(20, 20), |
| 9547 render_surface->render_surface()->DrawableContentRect()); |
9575 } | 9548 } |
9576 | 9549 |
9577 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9550 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
9578 LayerImpl* root = root_layer(); | 9551 LayerImpl* root = root_layer(); |
9579 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9552 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
9580 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9553 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
9581 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9554 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
9582 | 9555 |
9583 const gfx::Transform identity_matrix; | 9556 const gfx::Transform identity_matrix; |
9584 clip_parent->SetMasksToBounds(true); | 9557 clip_parent->SetMasksToBounds(true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9647 true); | 9620 true); |
9648 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), | 9621 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), |
9649 gfx::PointF(10, 10), gfx::Size(30, 30), true, | 9622 gfx::PointF(10, 10), gfx::Size(30, 30), true, |
9650 false, true); | 9623 false, true); |
9651 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), | 9624 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), |
9652 gfx::PointF(), gfx::Size(30, 30), true, false, | 9625 gfx::PointF(), gfx::Size(30, 30), true, false, |
9653 true); | 9626 true); |
9654 | 9627 |
9655 hidden->SetHideLayerAndSubtree(true); | 9628 hidden->SetHideLayerAndSubtree(true); |
9656 ExecuteCalculateDrawProperties(root); | 9629 ExecuteCalculateDrawProperties(root); |
9657 EXPECT_TRUE(test->IsHidden()); | 9630 EXPECT_TRUE(test->LayerIsHidden()); |
9658 | 9631 |
9659 hidden->SetHideLayerAndSubtree(false); | 9632 hidden->SetHideLayerAndSubtree(false); |
9660 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9633 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
9661 ExecuteCalculateDrawProperties(root); | 9634 ExecuteCalculateDrawProperties(root); |
9662 EXPECT_FALSE(test->IsHidden()); | 9635 EXPECT_FALSE(test->LayerIsHidden()); |
9663 } | 9636 } |
9664 | 9637 |
9665 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9638 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
9666 LayerImpl* root = root_layer(); | 9639 LayerImpl* root = root_layer(); |
9667 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9640 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
9668 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9641 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
9669 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9642 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
9670 | 9643 |
9671 const gfx::Transform identity_matrix; | 9644 const gfx::Transform identity_matrix; |
9672 clip_child->SetClipParent(root); | 9645 clip_child->SetClipParent(root); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9815 proto::ScrollAndScaleSet proto; | 9788 proto::ScrollAndScaleSet proto; |
9816 scroll_and_scale_set.ToProtobuf(&proto); | 9789 scroll_and_scale_set.ToProtobuf(&proto); |
9817 ScrollAndScaleSet new_scroll_and_scale_set; | 9790 ScrollAndScaleSet new_scroll_and_scale_set; |
9818 new_scroll_and_scale_set.FromProtobuf(proto); | 9791 new_scroll_and_scale_set.FromProtobuf(proto); |
9819 | 9792 |
9820 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); | 9793 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); |
9821 } | 9794 } |
9822 | 9795 |
9823 } // namespace | 9796 } // namespace |
9824 } // namespace cc | 9797 } // namespace cc |
OLD | NEW |