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, 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 Loading... | |
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 3823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5177 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5178 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5178 root.get(), root->bounds(), &render_surface_layer_list, | 5179 root.get(), root->bounds(), &render_surface_layer_list, |
5179 root->layer_tree_impl()->current_render_surface_list_id()); | 5180 root->layer_tree_impl()->current_render_surface_list_id()); |
5180 inputs.can_adjust_raster_scales = true; | 5181 inputs.can_adjust_raster_scales = true; |
5181 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5182 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5182 | 5183 |
5183 // We should have one render surface and two layers. The child | 5184 // We should have one render surface and two layers. The child |
5184 // layer should be included even though it is transparent. | 5185 // layer should be included even though it is transparent. |
5185 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5186 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5186 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5187 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5188 | |
5189 // If the root itself is hidden, the child should not be drawn even if it has | |
jaydasika
2016/01/26 23:13:40
Unit test for the new case.
| |
5190 // an animating opacity. | |
5191 root->SetOpacity(0.f); | |
5192 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | |
5193 LayerImplList render_surface_layer_list2; | |
5194 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | |
5195 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( | |
5196 root.get(), root->bounds(), &render_surface_layer_list2, | |
5197 root->layer_tree_impl()->current_render_surface_list_id()); | |
5198 inputs2.can_adjust_raster_scales = true; | |
5199 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); | |
5200 | |
5201 LayerImpl* child_ptr = root->layer_tree_impl()->LayerById(2); | |
5202 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; | |
5203 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); | |
5204 EXPECT_FALSE(node->data.is_drawn); | |
5187 } | 5205 } |
5188 | 5206 |
5189 class LayerTreeSettingsForLCDTextTest : public LayerTreeSettings { | 5207 class LayerTreeSettingsForLCDTextTest : public LayerTreeSettings { |
5190 public: | 5208 public: |
5191 LayerTreeSettingsForLCDTextTest() { | 5209 LayerTreeSettingsForLCDTextTest() { |
5192 use_compositor_animation_timelines = true; | 5210 use_compositor_animation_timelines = true; |
5193 } | 5211 } |
5194 }; | 5212 }; |
5195 | 5213 |
5196 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; | 5214 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5575 LayerImpl* copy_layer = copy_request.get(); | 5593 LayerImpl* copy_layer = copy_request.get(); |
5576 | 5594 |
5577 scoped_ptr<LayerImpl> copy_child = | 5595 scoped_ptr<LayerImpl> copy_child = |
5578 LayerImpl::Create(host_impl.pending_tree(), 5); | 5596 LayerImpl::Create(host_impl.pending_tree(), 5); |
5579 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5597 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
5580 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5598 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
5581 true, false, false); | 5599 true, false, false); |
5582 copy_child->SetDrawsContent(true); | 5600 copy_child->SetDrawsContent(true); |
5583 LayerImpl* copy_child_layer = copy_child.get(); | 5601 LayerImpl* copy_child_layer = copy_child.get(); |
5584 | 5602 |
5603 scoped_ptr<LayerImpl> copy_grand_child = | |
5604 LayerImpl::Create(host_impl.pending_tree(), 6); | |
5605 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, | |
5606 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | |
5607 true, false, false); | |
5608 copy_child->SetDrawsContent(true); | |
5609 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); | |
5610 | |
5585 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = | 5611 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = |
5586 LayerImpl::Create(host_impl.pending_tree(), 6); | 5612 LayerImpl::Create(host_impl.pending_tree(), 7); |
5587 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), | 5613 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), |
5588 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5614 identity_matrix, gfx::Point3F(), gfx::PointF(), |
5589 gfx::Size(40, 40), true, false, false); | 5615 gfx::Size(40, 40), true, false, false); |
5590 copy_grand_parent_sibling_before->SetDrawsContent(true); | 5616 copy_grand_parent_sibling_before->SetDrawsContent(true); |
5591 LayerImpl* copy_grand_parent_sibling_before_layer = | 5617 LayerImpl* copy_grand_parent_sibling_before_layer = |
5592 copy_grand_parent_sibling_before.get(); | 5618 copy_grand_parent_sibling_before.get(); |
5593 | 5619 |
5594 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = | 5620 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = |
5595 LayerImpl::Create(host_impl.pending_tree(), 7); | 5621 LayerImpl::Create(host_impl.pending_tree(), 8); |
5596 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), | 5622 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), |
5597 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5623 identity_matrix, gfx::Point3F(), gfx::PointF(), |
5598 gfx::Size(40, 40), true, false, false); | 5624 gfx::Size(40, 40), true, false, false); |
5599 copy_grand_parent_sibling_after->SetDrawsContent(true); | 5625 copy_grand_parent_sibling_after->SetDrawsContent(true); |
5600 LayerImpl* copy_grand_parent_sibling_after_layer = | 5626 LayerImpl* copy_grand_parent_sibling_after_layer = |
5601 copy_grand_parent_sibling_after.get(); | 5627 copy_grand_parent_sibling_after.get(); |
5602 | 5628 |
5629 copy_child->AddChild(std::move(copy_grand_child)); | |
5603 copy_request->AddChild(std::move(copy_child)); | 5630 copy_request->AddChild(std::move(copy_child)); |
5604 copy_parent->AddChild(std::move(copy_request)); | 5631 copy_parent->AddChild(std::move(copy_request)); |
5605 copy_grand_parent->AddChild(std::move(copy_parent)); | 5632 copy_grand_parent->AddChild(std::move(copy_parent)); |
5606 root->AddChild(std::move(copy_grand_parent_sibling_before)); | 5633 root->AddChild(std::move(copy_grand_parent_sibling_before)); |
5607 root->AddChild(std::move(copy_grand_parent)); | 5634 root->AddChild(std::move(copy_grand_parent)); |
5608 root->AddChild(std::move(copy_grand_parent_sibling_after)); | 5635 root->AddChild(std::move(copy_grand_parent_sibling_after)); |
5609 | 5636 |
5610 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5637 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
5611 // hidden subtree on copy_layer. | 5638 // hidden subtree on copy_layer. Also hide the copy grand child and its |
5639 // subtree. | |
5612 copy_grand_parent_layer->SetHideLayerAndSubtree(true); | 5640 copy_grand_parent_layer->SetHideLayerAndSubtree(true); |
5613 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); | 5641 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); |
5614 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); | 5642 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); |
5643 copy_grand_child_layer->SetHideLayerAndSubtree(true); | |
5615 | 5644 |
5616 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5645 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5617 copy_requests.push_back( | 5646 copy_requests.push_back( |
5618 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5647 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5619 copy_layer->PassCopyRequests(©_requests); | 5648 copy_layer->PassCopyRequests(©_requests); |
5620 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5649 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5621 | 5650 |
5622 LayerImplList render_surface_layer_list; | 5651 LayerImplList render_surface_layer_list; |
5623 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5652 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
5624 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5653 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5625 root.get(), root->bounds(), &render_surface_layer_list, | 5654 root.get(), root->bounds(), &render_surface_layer_list, |
5626 root->layer_tree_impl()->current_render_surface_list_id()); | 5655 root->layer_tree_impl()->current_render_surface_list_id()); |
5627 inputs.can_adjust_raster_scales = true; | 5656 inputs.can_adjust_raster_scales = true; |
5628 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5657 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5629 | 5658 |
5630 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 5659 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
5631 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5660 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); |
5632 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5661 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); |
5633 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); | 5662 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); |
5634 | 5663 |
5635 // We should have three render surfaces, one for the root, one for the parent | 5664 // We should have four render surfaces, one for the root, one for the grand |
5665 // parent since it has opacity and two drawing descendants, one for the parent | |
5636 // since it owns a surface, and one for the copy_layer. | 5666 // since it owns a surface, and one for the copy_layer. |
5637 ASSERT_EQ(3u, render_surface_layer_list.size()); | 5667 ASSERT_EQ(4u, render_surface_layer_list.size()); |
5638 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5668 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
5639 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id()); | 5669 EXPECT_EQ(copy_grand_parent_layer->id(), |
5640 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); | 5670 render_surface_layer_list.at(1)->id()); |
5671 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); | |
5672 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); | |
5641 | 5673 |
5642 // The root render surface should have 2 contributing layers. The | 5674 // The root render surface should have 2 contributing layers. |
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. | |
5646 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5675 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5647 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5676 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
5648 EXPECT_EQ(copy_parent_layer->id(), | 5677 EXPECT_EQ(copy_grand_parent_layer->id(), |
5649 root->render_surface()->layer_list().at(1)->id()); | 5678 root->render_surface()->layer_list().at(1)->id()); |
5650 | 5679 |
5651 // Nothing actually draws into the copy parent, so only the copy_layer will | 5680 // Nothing actually draws into the copy parent, so only the copy_layer will |
5652 // appear in its list, since it needs to be drawn for the copy request. | 5681 // appear in its list, since it needs to be drawn for the copy request. |
5653 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); | 5682 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
5654 EXPECT_EQ(copy_layer->id(), | 5683 EXPECT_EQ(copy_layer->id(), |
5655 copy_parent_layer->render_surface()->layer_list().at(0)->id()); | 5684 copy_layer->render_surface()->layer_list().at(0)->id()); |
5656 | 5685 |
5657 // The copy_layer's render surface should have two contributing layers. | 5686 // The copy_layer's render surface should have two contributing layers. |
5658 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5687 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
5659 EXPECT_EQ(copy_layer->id(), | 5688 EXPECT_EQ(copy_layer->id(), |
5660 copy_layer->render_surface()->layer_list().at(0)->id()); | 5689 copy_layer->render_surface()->layer_list().at(0)->id()); |
5661 EXPECT_EQ(copy_child_layer->id(), | 5690 EXPECT_EQ(copy_child_layer->id(), |
5662 copy_layer->render_surface()->layer_list().at(1)->id()); | 5691 copy_layer->render_surface()->layer_list().at(1)->id()); |
5692 | |
5693 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | |
5694 // but the copy_layer and copy_child should be drawn for the copy request. | |
5695 // copy grand child should not be drawn as its hidden even in the copy | |
5696 // request. | |
5697 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; | |
5698 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | |
5699 EXPECT_FALSE(node->data.is_drawn); | |
5700 node = tree.Node(copy_parent_layer->effect_tree_index()); | |
5701 EXPECT_FALSE(node->data.is_drawn); | |
5702 node = tree.Node(copy_layer->effect_tree_index()); | |
5703 EXPECT_TRUE(node->data.is_drawn); | |
5704 node = tree.Node(copy_child_layer->effect_tree_index()); | |
5705 EXPECT_TRUE(node->data.is_drawn); | |
5706 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | |
5707 EXPECT_FALSE(node->data.is_drawn); | |
5708 | |
5709 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its | |
5710 // actually hidden. | |
5711 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); | |
5663 } | 5712 } |
5664 | 5713 |
5665 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5714 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
5666 FakeImplTaskRunnerProvider task_runner_provider; | 5715 FakeImplTaskRunnerProvider task_runner_provider; |
5667 TestSharedBitmapManager shared_bitmap_manager; | 5716 TestSharedBitmapManager shared_bitmap_manager; |
5668 TestTaskGraphRunner task_graph_runner; | 5717 TestTaskGraphRunner task_graph_runner; |
5669 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5718 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
5670 &task_graph_runner); | 5719 &task_graph_runner); |
5671 host_impl.CreatePendingTree(); | 5720 host_impl.CreatePendingTree(); |
5672 const gfx::Transform identity_matrix; | 5721 const gfx::Transform identity_matrix; |
(...skipping 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8833 child->RemoveAnimation(animation_id); | 8882 child->RemoveAnimation(animation_id); |
8834 } | 8883 } |
8835 child->SetTransform(identity); | 8884 child->SetTransform(identity); |
8836 child->SetOpacity(0.f); | 8885 child->SetOpacity(0.f); |
8837 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8886 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8838 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8887 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
8839 | 8888 |
8840 // Now, even though child has zero opacity, we will configure |grandchild| and | 8889 // Now, even though child has zero opacity, we will configure |grandchild| and |
8841 // |greatgrandchild| in several ways that should force the subtree to be | 8890 // |greatgrandchild| in several ways that should force the subtree to be |
8842 // processed anyhow. | 8891 // processed anyhow. |
8843 greatgrandchild->RequestCopyOfOutput( | 8892 grandchild->RequestCopyOfOutput( |
8844 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8893 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
8845 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8894 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8846 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); | 8895 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); |
8847 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); | 8896 greatgrandchild->set_visible_rect_from_property_trees(gfx::Rect()); |
8848 | 8897 |
8849 // Add an opacity animation with a start delay. | 8898 // Add an opacity animation with a start delay. |
8850 animation_id = 1; | 8899 animation_id = 1; |
8851 animation = Animation::Create( | 8900 animation = Animation::Create( |
8852 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8901 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
8853 animation_id, 1, Animation::OPACITY); | 8902 animation_id, 1, Animation::OPACITY); |
8854 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8903 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
8855 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8904 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8856 if (layer_settings().use_compositor_animation_timelines) { | 8905 if (layer_settings().use_compositor_animation_timelines) { |
8857 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8906 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), |
(...skipping 27 matching lines...) Expand all Loading... | |
8885 | 8934 |
8886 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8935 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
8887 gfx::PointF(), gfx::Size(100, 100), true, false, | 8936 gfx::PointF(), gfx::Size(100, 100), true, false, |
8888 true); | 8937 true); |
8889 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8938 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
8890 gfx::PointF(), gfx::Size(10, 10), true, false, | 8939 gfx::PointF(), gfx::Size(10, 10), true, false, |
8891 false); | 8940 false); |
8892 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | 8941 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), |
8893 gfx::PointF(), gfx::Size(10, 10), true, false, | 8942 gfx::PointF(), gfx::Size(10, 10), true, false, |
8894 false); | 8943 false); |
8895 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | |
8896 gfx::PointF(), gfx::Size(10, 10), true, false, | |
8897 true); | |
8898 | 8944 |
8899 LayerImpl* child_ptr = child.get(); | 8945 LayerImpl* child_ptr = child.get(); |
8900 LayerImpl* grandchild_ptr = grandchild.get(); | 8946 LayerImpl* grandchild_ptr = grandchild.get(); |
8901 LayerImpl* greatgrandchild_ptr = greatgrandchild.get(); | |
8902 | 8947 |
8903 grandchild->AddChild(std::move(greatgrandchild)); | |
8904 child->AddChild(std::move(grandchild)); | 8948 child->AddChild(std::move(grandchild)); |
8905 root->AddChild(std::move(child)); | 8949 root->AddChild(std::move(child)); |
8906 | 8950 |
8907 // Check the non-skipped case. | 8951 // Check the non-skipped case. |
8908 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8952 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8909 EXPECT_EQ(gfx::Rect(10, 10), | 8953 EXPECT_EQ(gfx::Rect(10, 10), |
8910 grandchild_ptr->visible_rect_from_property_trees()); | 8954 grandchild_ptr->visible_rect_from_property_trees()); |
8911 | 8955 |
8912 // Now we will reset the visible rect from property trees for the grandchild, | 8956 // Now we will reset the visible rect from property trees for the grandchild, |
8913 // and we will configure |child| in several ways that should force the subtree | 8957 // and we will configure |child| in several ways that should force the subtree |
(...skipping 19 matching lines...) Expand all Loading... | |
8933 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8977 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8934 EXPECT_EQ(gfx::Rect(0, 0), | 8978 EXPECT_EQ(gfx::Rect(0, 0), |
8935 grandchild_ptr->visible_rect_from_property_trees()); | 8979 grandchild_ptr->visible_rect_from_property_trees()); |
8936 | 8980 |
8937 // Now, even though child has zero opacity, we will configure |grandchild| and | 8981 // Now, even though child has zero opacity, we will configure |grandchild| and |
8938 // |greatgrandchild| in several ways that should force the subtree to be | 8982 // |greatgrandchild| in several ways that should force the subtree to be |
8939 // processed anyhow. | 8983 // processed anyhow. |
8940 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 8984 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
8941 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8985 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
8942 | 8986 |
8943 greatgrandchild_ptr->PassCopyRequests(&requests); | 8987 grandchild_ptr->PassCopyRequests(&requests); |
8944 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8988 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8945 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8989 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8946 EXPECT_EQ(gfx::Rect(10, 10), | 8990 EXPECT_EQ(gfx::Rect(10, 10), |
8947 grandchild_ptr->visible_rect_from_property_trees()); | 8991 grandchild_ptr->visible_rect_from_property_trees()); |
8948 } | 8992 } |
8949 | 8993 |
8950 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8994 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
8951 gfx::Transform identity; | 8995 gfx::Transform identity; |
8952 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 8996 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
8953 FakeContentLayerClient client; | 8997 FakeContentLayerClient client; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9525 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 9569 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
9526 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 9570 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
9527 | 9571 |
9528 const gfx::Transform identity_matrix; | 9572 const gfx::Transform identity_matrix; |
9529 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9573 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
9530 gfx::PointF(), gfx::Size(30, 30), true, false, | 9574 gfx::PointF(), gfx::Size(30, 30), true, false, |
9531 true); | 9575 true); |
9532 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | 9576 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), |
9533 gfx::PointF(), gfx::Size(30, 30), true, false, | 9577 gfx::PointF(), gfx::Size(30, 30), true, false, |
9534 true); | 9578 true); |
9535 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | 9579 gfx::Transform translation; |
9580 translation.Translate(10, 10); | |
9581 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), | |
9536 gfx::PointF(), gfx::Size(20, 20), true, false, | 9582 gfx::PointF(), gfx::Size(20, 20), true, false, |
9537 false); | 9583 false); |
9538 | 9584 |
9539 render_surface->SetMasksToBounds(true); | 9585 render_surface->SetMasksToBounds(true); |
9540 test_layer->SetDrawsContent(true); | 9586 test_layer->SetDrawsContent(true); |
9541 test_layer->SetOpacity(0); | 9587 test_layer->SetOpacity(0); |
9542 test_layer->SetHaveWheelEventHandlers(true); | 9588 test_layer->SetHaveWheelEventHandlers(true); |
9543 | 9589 |
9544 ExecuteCalculateDrawProperties(root); | 9590 ExecuteCalculateDrawProperties(root); |
9545 EXPECT_EQ(gfx::Rect(20, 20), test_layer->drawable_content_rect()); | 9591 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); |
9546 EXPECT_EQ(gfx::RectF(20, 20), | |
9547 render_surface->render_surface()->DrawableContentRect()); | |
9548 } | 9592 } |
9549 | 9593 |
9550 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9594 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
9551 LayerImpl* root = root_layer(); | 9595 LayerImpl* root = root_layer(); |
9552 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9596 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
9553 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9597 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
9554 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9598 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
9555 | 9599 |
9556 const gfx::Transform identity_matrix; | 9600 const gfx::Transform identity_matrix; |
9557 clip_parent->SetMasksToBounds(true); | 9601 clip_parent->SetMasksToBounds(true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9620 true); | 9664 true); |
9621 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), | 9665 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), |
9622 gfx::PointF(10, 10), gfx::Size(30, 30), true, | 9666 gfx::PointF(10, 10), gfx::Size(30, 30), true, |
9623 false, true); | 9667 false, true); |
9624 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), | 9668 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), |
9625 gfx::PointF(), gfx::Size(30, 30), true, false, | 9669 gfx::PointF(), gfx::Size(30, 30), true, false, |
9626 true); | 9670 true); |
9627 | 9671 |
9628 hidden->SetHideLayerAndSubtree(true); | 9672 hidden->SetHideLayerAndSubtree(true); |
9629 ExecuteCalculateDrawProperties(root); | 9673 ExecuteCalculateDrawProperties(root); |
9630 EXPECT_TRUE(test->LayerIsHidden()); | 9674 EXPECT_TRUE(test->IsHidden()); |
9631 | 9675 |
9632 hidden->SetHideLayerAndSubtree(false); | 9676 hidden->SetHideLayerAndSubtree(false); |
9633 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9677 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
9634 ExecuteCalculateDrawProperties(root); | 9678 ExecuteCalculateDrawProperties(root); |
9635 EXPECT_FALSE(test->LayerIsHidden()); | 9679 EXPECT_FALSE(test->IsHidden()); |
9636 } | 9680 } |
9637 | 9681 |
9638 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9682 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
9639 LayerImpl* root = root_layer(); | 9683 LayerImpl* root = root_layer(); |
9640 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9684 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
9641 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9685 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
9642 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9686 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
9643 | 9687 |
9644 const gfx::Transform identity_matrix; | 9688 const gfx::Transform identity_matrix; |
9645 clip_child->SetClipParent(root); | 9689 clip_child->SetClipParent(root); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9788 proto::ScrollAndScaleSet proto; | 9832 proto::ScrollAndScaleSet proto; |
9789 scroll_and_scale_set.ToProtobuf(&proto); | 9833 scroll_and_scale_set.ToProtobuf(&proto); |
9790 ScrollAndScaleSet new_scroll_and_scale_set; | 9834 ScrollAndScaleSet new_scroll_and_scale_set; |
9791 new_scroll_and_scale_set.FromProtobuf(proto); | 9835 new_scroll_and_scale_set.FromProtobuf(proto); |
9792 | 9836 |
9793 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); | 9837 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); |
9794 } | 9838 } |
9795 | 9839 |
9796 } // namespace | 9840 } // namespace |
9797 } // namespace cc | 9841 } // namespace cc |
OLD | NEW |