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->GetLayerTree()->property_trees(); | 196 root_layer->GetLayerTree()->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 3419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8315 | 8316 |
8316 root->SetBounds(gfx::Size(100, 100)); | 8317 root->SetBounds(gfx::Size(100, 100)); |
8317 child->SetBounds(gfx::Size(10, 10)); | 8318 child->SetBounds(gfx::Size(10, 10)); |
8318 grandchild->SetBounds(gfx::Size(10, 10)); | 8319 grandchild->SetBounds(gfx::Size(10, 10)); |
8319 greatgrandchild->SetBounds(gfx::Size(10, 10)); | 8320 greatgrandchild->SetBounds(gfx::Size(10, 10)); |
8320 | 8321 |
8321 root->AddChild(child); | 8322 root->AddChild(child); |
8322 child->AddChild(grandchild); | 8323 child->AddChild(grandchild); |
8323 grandchild->AddChild(greatgrandchild); | 8324 grandchild->AddChild(greatgrandchild); |
8324 host()->SetRootLayer(root); | 8325 host()->SetRootLayer(root); |
8325 host()->SetElementIdsForTesting(); | 8326 host()->GetLayerTree()->SetElementIdsForTesting(); |
8326 | 8327 |
8327 // Check the non-skipped case. | 8328 // Check the non-skipped case. |
8328 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8329 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8329 const LayerList* update_list = GetUpdateLayerList(); | 8330 const LayerList* update_list = GetUpdateLayerList(); |
8330 EXPECT_TRUE(VerifyLayerInList(grandchild, update_list)); | 8331 EXPECT_TRUE(VerifyLayerInList(grandchild, update_list)); |
8331 | 8332 |
8332 // Now we will reset the visible rect from property trees for the grandchild, | 8333 // Now we will reset the visible rect from property trees for the grandchild, |
8333 // and we will configure |child| in several ways that should force the subtree | 8334 // and we will configure |child| in several ways that should force the subtree |
8334 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8335 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8335 // remain empty. | 8336 // remain empty. |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9426 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), | 9427 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), |
9427 property_trees->effect_id_to_index_map.end()); | 9428 property_trees->effect_id_to_index_map.end()); |
9428 } | 9429 } |
9429 | 9430 |
9430 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9431 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
9431 scoped_refptr<Layer> root = Layer::Create(); | 9432 scoped_refptr<Layer> root = Layer::Create(); |
9432 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9433 scoped_refptr<LayerWithForcedDrawsContent> animated = |
9433 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9434 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
9434 root->AddChild(animated); | 9435 root->AddChild(animated); |
9435 host()->SetRootLayer(root); | 9436 host()->SetRootLayer(root); |
9436 host()->SetElementIdsForTesting(); | 9437 host()->GetLayerTree()->SetElementIdsForTesting(); |
9437 | 9438 |
9438 root->SetBounds(gfx::Size(100, 100)); | 9439 root->SetBounds(gfx::Size(100, 100)); |
9439 root->SetForceRenderSurfaceForTesting(true); | 9440 root->SetForceRenderSurfaceForTesting(true); |
9440 animated->SetBounds(gfx::Size(20, 20)); | 9441 animated->SetBounds(gfx::Size(20, 20)); |
9441 animated->SetOpacity(0.f); | 9442 animated->SetOpacity(0.f); |
9442 | 9443 |
9443 scoped_refptr<AnimationPlayer> player = | 9444 scoped_refptr<AnimationPlayer> player = |
9444 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9445 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
9445 timeline()->AttachPlayer(player); | 9446 timeline()->AttachPlayer(player); |
9446 | 9447 |
(...skipping 28 matching lines...) Expand all Loading... |
9475 EXPECT_FALSE(node->is_currently_animating_opacity); | 9476 EXPECT_FALSE(node->is_currently_animating_opacity); |
9476 EXPECT_FALSE(node->has_potential_opacity_animation); | 9477 EXPECT_FALSE(node->has_potential_opacity_animation); |
9477 } | 9478 } |
9478 | 9479 |
9479 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 9480 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
9480 scoped_refptr<Layer> root = Layer::Create(); | 9481 scoped_refptr<Layer> root = Layer::Create(); |
9481 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9482 scoped_refptr<LayerWithForcedDrawsContent> animated = |
9482 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9483 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
9483 root->AddChild(animated); | 9484 root->AddChild(animated); |
9484 host()->SetRootLayer(root); | 9485 host()->SetRootLayer(root); |
9485 host()->SetElementIdsForTesting(); | 9486 host()->GetLayerTree()->SetElementIdsForTesting(); |
9486 | 9487 |
9487 root->SetBounds(gfx::Size(100, 100)); | 9488 root->SetBounds(gfx::Size(100, 100)); |
9488 root->SetForceRenderSurfaceForTesting(true); | 9489 root->SetForceRenderSurfaceForTesting(true); |
9489 animated->SetBounds(gfx::Size(20, 20)); | 9490 animated->SetBounds(gfx::Size(20, 20)); |
9490 | 9491 |
9491 scoped_refptr<AnimationPlayer> player = | 9492 scoped_refptr<AnimationPlayer> player = |
9492 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9493 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
9493 timeline()->AttachPlayer(player); | 9494 timeline()->AttachPlayer(player); |
9494 player->AttachElement(animated->element_id()); | 9495 player->AttachElement(animated->element_id()); |
9495 | 9496 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9759 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9760 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
9760 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9761 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
9761 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9762 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
9762 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9763 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
9763 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9764 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
9764 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9765 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
9765 } | 9766 } |
9766 | 9767 |
9767 } // namespace | 9768 } // namespace |
9768 } // namespace cc | 9769 } // namespace cc |
OLD | NEW |