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 <memory> | 10 #include <memory> |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 root_layer->layer_tree_host()->property_trees(); | 196 root_layer->layer_tree_host()->property_trees(); |
197 update_layer_list_.clear(); | 197 update_layer_list_.clear(); |
198 PropertyTreeBuilder::BuildPropertyTrees( | 198 PropertyTreeBuilder::BuildPropertyTrees( |
199 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 199 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
200 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 200 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
201 elastic_overscroll, page_scale_factor, device_scale_factor, | 201 elastic_overscroll, page_scale_factor, device_scale_factor, |
202 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); | 202 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); |
203 draw_property_utils::UpdatePropertyTrees(property_trees, | 203 draw_property_utils::UpdatePropertyTrees(property_trees, |
204 can_render_to_separate_surface); | 204 can_render_to_separate_surface); |
205 draw_property_utils::FindLayersThatNeedUpdates( | 205 draw_property_utils::FindLayersThatNeedUpdates( |
206 root_layer->layer_tree_host(), property_trees->transform_tree, | 206 root_layer->GetLayerTree(), property_trees->transform_tree, |
207 property_trees->effect_tree, &update_layer_list_); | 207 property_trees->effect_tree, &update_layer_list_); |
208 } | 208 } |
209 | 209 |
210 void ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) { | 210 void ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) { |
211 DCHECK(root_layer->layer_tree_impl()); | 211 DCHECK(root_layer->layer_tree_impl()); |
212 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); | 212 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); |
213 | 213 |
214 bool can_render_to_separate_surface = true; | 214 bool can_render_to_separate_surface = true; |
215 | 215 |
216 LayerImpl* page_scale_layer = nullptr; | 216 LayerImpl* page_scale_layer = nullptr; |
(...skipping 4653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4870 scoped_refptr<Layer> replica_layer = Layer::Create(); | 4870 scoped_refptr<Layer> replica_layer = Layer::Create(); |
4871 | 4871 |
4872 grand_child->SetReplicaLayer(replica_layer.get()); | 4872 grand_child->SetReplicaLayer(replica_layer.get()); |
4873 child->AddChild(grand_child.get()); | 4873 child->AddChild(grand_child.get()); |
4874 child->SetMaskLayer(mask_layer.get()); | 4874 child->SetMaskLayer(mask_layer.get()); |
4875 root->AddChild(child.get()); | 4875 root->AddChild(child.get()); |
4876 | 4876 |
4877 host()->SetRootLayer(root); | 4877 host()->SetRootLayer(root); |
4878 | 4878 |
4879 int nonexistent_id = -1; | 4879 int nonexistent_id = -1; |
4880 EXPECT_EQ(root.get(), host()->LayerById(root->id())); | 4880 LayerTree* layer_tree = host()->GetLayerTree(); |
4881 EXPECT_EQ(child.get(), host()->LayerById(child->id())); | 4881 EXPECT_EQ(root.get(), layer_tree->LayerById(root->id())); |
4882 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id())); | 4882 EXPECT_EQ(child.get(), layer_tree->LayerById(child->id())); |
4883 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id())); | 4883 EXPECT_EQ(grand_child.get(), layer_tree->LayerById(grand_child->id())); |
4884 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id())); | 4884 EXPECT_EQ(mask_layer.get(), layer_tree->LayerById(mask_layer->id())); |
4885 EXPECT_FALSE(host()->LayerById(nonexistent_id)); | 4885 EXPECT_EQ(replica_layer.get(), layer_tree->LayerById(replica_layer->id())); |
| 4886 EXPECT_FALSE(layer_tree->LayerById(nonexistent_id)); |
4886 } | 4887 } |
4887 | 4888 |
4888 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { | 4889 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { |
4889 LayerImpl* root = root_layer_for_testing(); | 4890 LayerImpl* root = root_layer_for_testing(); |
4890 LayerImpl* child = AddChild<LayerImpl>(root); | 4891 LayerImpl* child = AddChild<LayerImpl>(root); |
4891 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 4892 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
4892 | 4893 |
4893 root->SetBounds(gfx::Size(100, 100)); | 4894 root->SetBounds(gfx::Size(100, 100)); |
4894 child->SetBounds(gfx::Size(10, 10)); | 4895 child->SetBounds(gfx::Size(10, 10)); |
4895 child->test_properties()->opacity = 0.5f; | 4896 child->test_properties()->opacity = 0.5f; |
(...skipping 3420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8316 | 8317 |
8317 root->SetBounds(gfx::Size(100, 100)); | 8318 root->SetBounds(gfx::Size(100, 100)); |
8318 child->SetBounds(gfx::Size(10, 10)); | 8319 child->SetBounds(gfx::Size(10, 10)); |
8319 grandchild->SetBounds(gfx::Size(10, 10)); | 8320 grandchild->SetBounds(gfx::Size(10, 10)); |
8320 greatgrandchild->SetBounds(gfx::Size(10, 10)); | 8321 greatgrandchild->SetBounds(gfx::Size(10, 10)); |
8321 | 8322 |
8322 root->AddChild(child); | 8323 root->AddChild(child); |
8323 child->AddChild(grandchild); | 8324 child->AddChild(grandchild); |
8324 grandchild->AddChild(greatgrandchild); | 8325 grandchild->AddChild(greatgrandchild); |
8325 host()->SetRootLayer(root); | 8326 host()->SetRootLayer(root); |
8326 host()->SetElementIdsForTesting(); | 8327 host()->GetLayerTree()->SetElementIdsForTesting(); |
8327 | 8328 |
8328 // Check the non-skipped case. | 8329 // Check the non-skipped case. |
8329 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8330 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8330 const LayerList* update_list = GetUpdateLayerList(); | 8331 const LayerList* update_list = GetUpdateLayerList(); |
8331 EXPECT_TRUE(VerifyLayerInList(grandchild, update_list)); | 8332 EXPECT_TRUE(VerifyLayerInList(grandchild, update_list)); |
8332 | 8333 |
8333 // Now we will reset the visible rect from property trees for the grandchild, | 8334 // Now we will reset the visible rect from property trees for the grandchild, |
8334 // and we will configure |child| in several ways that should force the subtree | 8335 // and we will configure |child| in several ways that should force the subtree |
8335 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8336 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8336 // remain empty. | 8337 // remain empty. |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9423 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), | 9424 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), |
9424 property_trees->effect_id_to_index_map.end()); | 9425 property_trees->effect_id_to_index_map.end()); |
9425 } | 9426 } |
9426 | 9427 |
9427 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9428 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
9428 scoped_refptr<Layer> root = Layer::Create(); | 9429 scoped_refptr<Layer> root = Layer::Create(); |
9429 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9430 scoped_refptr<LayerWithForcedDrawsContent> animated = |
9430 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9431 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
9431 root->AddChild(animated); | 9432 root->AddChild(animated); |
9432 host()->SetRootLayer(root); | 9433 host()->SetRootLayer(root); |
9433 host()->SetElementIdsForTesting(); | 9434 host()->GetLayerTree()->SetElementIdsForTesting(); |
9434 | 9435 |
9435 root->SetBounds(gfx::Size(100, 100)); | 9436 root->SetBounds(gfx::Size(100, 100)); |
9436 root->SetForceRenderSurfaceForTesting(true); | 9437 root->SetForceRenderSurfaceForTesting(true); |
9437 animated->SetBounds(gfx::Size(20, 20)); | 9438 animated->SetBounds(gfx::Size(20, 20)); |
9438 animated->SetOpacity(0.f); | 9439 animated->SetOpacity(0.f); |
9439 | 9440 |
9440 scoped_refptr<AnimationPlayer> player = | 9441 scoped_refptr<AnimationPlayer> player = |
9441 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9442 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
9442 timeline()->AttachPlayer(player); | 9443 timeline()->AttachPlayer(player); |
9443 | 9444 |
(...skipping 28 matching lines...) Expand all Loading... |
9472 EXPECT_FALSE(node->is_currently_animating_opacity); | 9473 EXPECT_FALSE(node->is_currently_animating_opacity); |
9473 EXPECT_FALSE(node->has_potential_opacity_animation); | 9474 EXPECT_FALSE(node->has_potential_opacity_animation); |
9474 } | 9475 } |
9475 | 9476 |
9476 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 9477 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
9477 scoped_refptr<Layer> root = Layer::Create(); | 9478 scoped_refptr<Layer> root = Layer::Create(); |
9478 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9479 scoped_refptr<LayerWithForcedDrawsContent> animated = |
9479 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9480 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
9480 root->AddChild(animated); | 9481 root->AddChild(animated); |
9481 host()->SetRootLayer(root); | 9482 host()->SetRootLayer(root); |
9482 host()->SetElementIdsForTesting(); | 9483 host()->GetLayerTree()->SetElementIdsForTesting(); |
9483 | 9484 |
9484 root->SetBounds(gfx::Size(100, 100)); | 9485 root->SetBounds(gfx::Size(100, 100)); |
9485 root->SetForceRenderSurfaceForTesting(true); | 9486 root->SetForceRenderSurfaceForTesting(true); |
9486 animated->SetBounds(gfx::Size(20, 20)); | 9487 animated->SetBounds(gfx::Size(20, 20)); |
9487 | 9488 |
9488 scoped_refptr<AnimationPlayer> player = | 9489 scoped_refptr<AnimationPlayer> player = |
9489 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9490 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
9490 timeline()->AttachPlayer(player); | 9491 timeline()->AttachPlayer(player); |
9491 player->AttachElement(animated->element_id()); | 9492 player->AttachElement(animated->element_id()); |
9492 | 9493 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9756 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9757 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
9757 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9758 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
9758 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9759 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
9759 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9760 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
9760 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9761 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
9761 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9762 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
9762 } | 9763 } |
9763 | 9764 |
9764 } // namespace | 9765 } // namespace |
9765 } // namespace cc | 9766 } // namespace cc |
OLD | NEW |