| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 LayerType* inner_viewport_scroll_layer = nullptr; | 181 LayerType* inner_viewport_scroll_layer = nullptr; |
| 182 LayerType* outer_viewport_scroll_layer = nullptr; | 182 LayerType* outer_viewport_scroll_layer = nullptr; |
| 183 ExecuteCalculateDrawProperties( | 183 ExecuteCalculateDrawProperties( |
| 184 root_layer, device_scale_factor, 1.f, page_scale_application_layer, | 184 root_layer, device_scale_factor, 1.f, page_scale_application_layer, |
| 185 inner_viewport_scroll_layer, outer_viewport_scroll_layer); | 185 inner_viewport_scroll_layer, outer_viewport_scroll_layer); |
| 186 } | 186 } |
| 187 | 187 |
| 188 const LayerList* GetUpdateLayerList() { return &update_layer_list_; } | 188 const LayerList* GetUpdateLayerList() { return &update_layer_list_; } |
| 189 | 189 |
| 190 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(Layer* root_layer) { | 190 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(Layer* root_layer) { |
| 191 DCHECK(root_layer->GetLayerTree()); | 191 DCHECK(root_layer->layer_tree_host()); |
| 192 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); | 192 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); |
| 193 | 193 |
| 194 bool can_render_to_separate_surface = true; | 194 bool can_render_to_separate_surface = true; |
| 195 | 195 |
| 196 const Layer* page_scale_layer = | 196 const Layer* page_scale_layer = |
| 197 root_layer->GetLayerTree()->page_scale_layer(); | 197 root_layer->layer_tree_host()->page_scale_layer(); |
| 198 Layer* inner_viewport_scroll_layer = | 198 Layer* inner_viewport_scroll_layer = |
| 199 root_layer->GetLayerTree()->inner_viewport_scroll_layer(); | 199 root_layer->layer_tree_host()->inner_viewport_scroll_layer(); |
| 200 Layer* outer_viewport_scroll_layer = | 200 Layer* outer_viewport_scroll_layer = |
| 201 root_layer->GetLayerTree()->outer_viewport_scroll_layer(); | 201 root_layer->layer_tree_host()->outer_viewport_scroll_layer(); |
| 202 const Layer* overscroll_elasticity_layer = | 202 const Layer* overscroll_elasticity_layer = |
| 203 root_layer->GetLayerTree()->overscroll_elasticity_layer(); | 203 root_layer->layer_tree_host()->overscroll_elasticity_layer(); |
| 204 gfx::Vector2dF elastic_overscroll = | 204 gfx::Vector2dF elastic_overscroll = |
| 205 root_layer->GetLayerTree()->elastic_overscroll(); | 205 root_layer->layer_tree_host()->elastic_overscroll(); |
| 206 float page_scale_factor = 1.f; | 206 float page_scale_factor = 1.f; |
| 207 float device_scale_factor = 1.f; | 207 float device_scale_factor = 1.f; |
| 208 gfx::Size device_viewport_size = | 208 gfx::Size device_viewport_size = |
| 209 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 209 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 210 root_layer->bounds().height() * device_scale_factor); | 210 root_layer->bounds().height() * device_scale_factor); |
| 211 PropertyTrees* property_trees = | 211 PropertyTrees* property_trees = |
| 212 root_layer->GetLayerTree()->property_trees(); | 212 root_layer->layer_tree_host()->property_trees(); |
| 213 update_layer_list_.clear(); | 213 update_layer_list_.clear(); |
| 214 PropertyTreeBuilder::BuildPropertyTrees( | 214 PropertyTreeBuilder::BuildPropertyTrees( |
| 215 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 215 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 216 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 216 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 217 elastic_overscroll, page_scale_factor, device_scale_factor, | 217 elastic_overscroll, page_scale_factor, device_scale_factor, |
| 218 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); | 218 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); |
| 219 draw_property_utils::UpdatePropertyTrees(property_trees, | 219 draw_property_utils::UpdatePropertyTrees(property_trees, |
| 220 can_render_to_separate_surface); | 220 can_render_to_separate_surface); |
| 221 draw_property_utils::FindLayersThatNeedUpdates( | 221 draw_property_utils::FindLayersThatNeedUpdates( |
| 222 root_layer->GetLayerTree(), property_trees, &update_layer_list_); | 222 root_layer->layer_tree_host(), property_trees, &update_layer_list_); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( | 225 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( |
| 226 LayerImpl* root_layer, | 226 LayerImpl* root_layer, |
| 227 bool skip_verify_visible_rect_calculations = false) { | 227 bool skip_verify_visible_rect_calculations = false) { |
| 228 DCHECK(root_layer->layer_tree_impl()); | 228 DCHECK(root_layer->layer_tree_impl()); |
| 229 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); | 229 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); |
| 230 | 230 |
| 231 bool can_render_to_separate_surface = true; | 231 bool can_render_to_separate_surface = true; |
| 232 | 232 |
| (...skipping 4769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5002 scoped_refptr<Layer> grand_child = Layer::Create(); | 5002 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 5003 scoped_refptr<Layer> mask_layer = Layer::Create(); | 5003 scoped_refptr<Layer> mask_layer = Layer::Create(); |
| 5004 | 5004 |
| 5005 child->AddChild(grand_child.get()); | 5005 child->AddChild(grand_child.get()); |
| 5006 child->SetMaskLayer(mask_layer.get()); | 5006 child->SetMaskLayer(mask_layer.get()); |
| 5007 root->AddChild(child.get()); | 5007 root->AddChild(child.get()); |
| 5008 | 5008 |
| 5009 host()->SetRootLayer(root); | 5009 host()->SetRootLayer(root); |
| 5010 | 5010 |
| 5011 int nonexistent_id = -1; | 5011 int nonexistent_id = -1; |
| 5012 LayerTree* layer_tree = host()->GetLayerTree(); | 5012 EXPECT_EQ(root.get(), host()->LayerById(root->id())); |
| 5013 EXPECT_EQ(root.get(), layer_tree->LayerById(root->id())); | 5013 EXPECT_EQ(child.get(), host()->LayerById(child->id())); |
| 5014 EXPECT_EQ(child.get(), layer_tree->LayerById(child->id())); | 5014 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id())); |
| 5015 EXPECT_EQ(grand_child.get(), layer_tree->LayerById(grand_child->id())); | 5015 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id())); |
| 5016 EXPECT_EQ(mask_layer.get(), layer_tree->LayerById(mask_layer->id())); | 5016 EXPECT_FALSE(host()->LayerById(nonexistent_id)); |
| 5017 EXPECT_FALSE(layer_tree->LayerById(nonexistent_id)); | |
| 5018 } | 5017 } |
| 5019 | 5018 |
| 5020 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { | 5019 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { |
| 5021 LayerImpl* root = root_layer_for_testing(); | 5020 LayerImpl* root = root_layer_for_testing(); |
| 5022 LayerImpl* child = AddChild<LayerImpl>(root); | 5021 LayerImpl* child = AddChild<LayerImpl>(root); |
| 5023 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 5022 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 5024 | 5023 |
| 5025 root->SetBounds(gfx::Size(100, 100)); | 5024 root->SetBounds(gfx::Size(100, 100)); |
| 5026 child->SetBounds(gfx::Size(10, 10)); | 5025 child->SetBounds(gfx::Size(10, 10)); |
| 5027 child->test_properties()->opacity = 0.5f; | 5026 child->test_properties()->opacity = 0.5f; |
| (...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7316 } | 7315 } |
| 7317 | 7316 |
| 7318 TEST_F(LayerTreeHostCommonTest, StickyPositionBottomInnerViewportDelta) { | 7317 TEST_F(LayerTreeHostCommonTest, StickyPositionBottomInnerViewportDelta) { |
| 7319 scoped_refptr<Layer> root = Layer::Create(); | 7318 scoped_refptr<Layer> root = Layer::Create(); |
| 7320 scoped_refptr<Layer> scroller = Layer::Create(); | 7319 scoped_refptr<Layer> scroller = Layer::Create(); |
| 7321 scoped_refptr<Layer> sticky_pos = Layer::Create(); | 7320 scoped_refptr<Layer> sticky_pos = Layer::Create(); |
| 7322 root->AddChild(scroller); | 7321 root->AddChild(scroller); |
| 7323 scroller->AddChild(sticky_pos); | 7322 scroller->AddChild(sticky_pos); |
| 7324 host()->SetRootLayer(root); | 7323 host()->SetRootLayer(root); |
| 7325 scroller->SetScrollClipLayerId(root->id()); | 7324 scroller->SetScrollClipLayerId(root->id()); |
| 7326 host()->GetLayerTree()->RegisterViewportLayers(nullptr, root, scroller, | 7325 host()->RegisterViewportLayers(nullptr, root, scroller, nullptr); |
| 7327 nullptr); | |
| 7328 | 7326 |
| 7329 LayerStickyPositionConstraint sticky_position; | 7327 LayerStickyPositionConstraint sticky_position; |
| 7330 sticky_position.is_sticky = true; | 7328 sticky_position.is_sticky = true; |
| 7331 sticky_position.is_anchored_bottom = true; | 7329 sticky_position.is_anchored_bottom = true; |
| 7332 sticky_position.bottom_offset = 10.0f; | 7330 sticky_position.bottom_offset = 10.0f; |
| 7333 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); | 7331 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); |
| 7334 sticky_position.scroll_container_relative_sticky_box_rect = | 7332 sticky_position.scroll_container_relative_sticky_box_rect = |
| 7335 gfx::Rect(0, 70, 10, 10); | 7333 gfx::Rect(0, 70, 10, 10); |
| 7336 sticky_position.scroll_container_relative_containing_block_rect = | 7334 sticky_position.scroll_container_relative_containing_block_rect = |
| 7337 gfx::Rect(0, 60, 100, 100); | 7335 gfx::Rect(0, 60, 100, 100); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7390 scoped_refptr<Layer> outer_clip = Layer::Create(); | 7388 scoped_refptr<Layer> outer_clip = Layer::Create(); |
| 7391 scoped_refptr<Layer> outer_viewport = Layer::Create(); | 7389 scoped_refptr<Layer> outer_viewport = Layer::Create(); |
| 7392 scoped_refptr<Layer> sticky_pos = Layer::Create(); | 7390 scoped_refptr<Layer> sticky_pos = Layer::Create(); |
| 7393 root->AddChild(scroller); | 7391 root->AddChild(scroller); |
| 7394 scroller->AddChild(outer_clip); | 7392 scroller->AddChild(outer_clip); |
| 7395 outer_clip->AddChild(outer_viewport); | 7393 outer_clip->AddChild(outer_viewport); |
| 7396 outer_viewport->AddChild(sticky_pos); | 7394 outer_viewport->AddChild(sticky_pos); |
| 7397 host()->SetRootLayer(root); | 7395 host()->SetRootLayer(root); |
| 7398 scroller->SetScrollClipLayerId(root->id()); | 7396 scroller->SetScrollClipLayerId(root->id()); |
| 7399 outer_viewport->SetScrollClipLayerId(outer_clip->id()); | 7397 outer_viewport->SetScrollClipLayerId(outer_clip->id()); |
| 7400 host()->GetLayerTree()->RegisterViewportLayers(nullptr, root, scroller, | 7398 host()->RegisterViewportLayers(nullptr, root, scroller, outer_viewport); |
| 7401 outer_viewport); | |
| 7402 | 7399 |
| 7403 LayerStickyPositionConstraint sticky_position; | 7400 LayerStickyPositionConstraint sticky_position; |
| 7404 sticky_position.is_sticky = true; | 7401 sticky_position.is_sticky = true; |
| 7405 sticky_position.is_anchored_bottom = true; | 7402 sticky_position.is_anchored_bottom = true; |
| 7406 sticky_position.bottom_offset = 10.0f; | 7403 sticky_position.bottom_offset = 10.0f; |
| 7407 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); | 7404 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); |
| 7408 sticky_position.scroll_container_relative_sticky_box_rect = | 7405 sticky_position.scroll_container_relative_sticky_box_rect = |
| 7409 gfx::Rect(0, 70, 10, 10); | 7406 gfx::Rect(0, 70, 10, 10); |
| 7410 sticky_position.scroll_container_relative_containing_block_rect = | 7407 sticky_position.scroll_container_relative_containing_block_rect = |
| 7411 gfx::Rect(0, 60, 100, 100); | 7408 gfx::Rect(0, 60, 100, 100); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7936 root->SetBounds(gfx::Size(50, 50)); | 7933 root->SetBounds(gfx::Size(50, 50)); |
| 7937 container->SetBounds(gfx::Size(50, 50)); | 7934 container->SetBounds(gfx::Size(50, 50)); |
| 7938 scroller->SetBounds(gfx::Size(50, 50)); | 7935 scroller->SetBounds(gfx::Size(50, 50)); |
| 7939 fixed_pos->SetBounds(gfx::Size(50, 50)); | 7936 fixed_pos->SetBounds(gfx::Size(50, 50)); |
| 7940 | 7937 |
| 7941 gfx::Transform rotate; | 7938 gfx::Transform rotate; |
| 7942 rotate.RotateAboutXAxis(20); | 7939 rotate.RotateAboutXAxis(20); |
| 7943 container->SetTransform(rotate); | 7940 container->SetTransform(rotate); |
| 7944 | 7941 |
| 7945 ExecuteCalculateDrawProperties(root.get()); | 7942 ExecuteCalculateDrawProperties(root.get()); |
| 7946 TransformTree& tree = root->GetLayerTree()->property_trees()->transform_tree; | 7943 TransformTree& tree = |
| 7944 root->layer_tree_host()->property_trees()->transform_tree; |
| 7947 gfx::Transform transform; | 7945 gfx::Transform transform; |
| 7948 tree.ComputeTranslation(fixed_pos->transform_tree_index(), | 7946 tree.ComputeTranslation(fixed_pos->transform_tree_index(), |
| 7949 container->transform_tree_index(), &transform); | 7947 container->transform_tree_index(), &transform); |
| 7950 EXPECT_TRUE(transform.IsIdentity()); | 7948 EXPECT_TRUE(transform.IsIdentity()); |
| 7951 } | 7949 } |
| 7952 | 7950 |
| 7953 TEST_F(LayerTreeHostCommonTest, ScrollSnappingWithFixedPosChild) { | 7951 TEST_F(LayerTreeHostCommonTest, ScrollSnappingWithFixedPosChild) { |
| 7954 // This test verifies that a fixed pos child of a scrolling layer doesn't get | 7952 // This test verifies that a fixed pos child of a scrolling layer doesn't get |
| 7955 // snapped to integer coordinates. | 7953 // snapped to integer coordinates. |
| 7956 // | 7954 // |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8840 | 8838 |
| 8841 inner_viewport_scroll_layer->SetScrollClipLayerId( | 8839 inner_viewport_scroll_layer->SetScrollClipLayerId( |
| 8842 inner_viewport_container_layer->id()); | 8840 inner_viewport_container_layer->id()); |
| 8843 outer_viewport_scroll_layer->SetScrollClipLayerId( | 8841 outer_viewport_scroll_layer->SetScrollClipLayerId( |
| 8844 outer_viewport_container_layer->id()); | 8842 outer_viewport_container_layer->id()); |
| 8845 | 8843 |
| 8846 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 8844 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 8847 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 8845 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 8848 | 8846 |
| 8849 host()->SetRootLayer(root); | 8847 host()->SetRootLayer(root); |
| 8850 host()->GetLayerTree()->RegisterViewportLayers( | 8848 host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer, |
| 8851 nullptr, root, inner_viewport_scroll_layer, outer_viewport_scroll_layer); | 8849 outer_viewport_scroll_layer); |
| 8852 | 8850 |
| 8853 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); | 8851 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); |
| 8854 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); | 8852 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); |
| 8855 | 8853 |
| 8856 inner_viewport_scroll_layer->AddChild(fixed_to_inner); | 8854 inner_viewport_scroll_layer->AddChild(fixed_to_inner); |
| 8857 outer_viewport_scroll_layer->AddChild(fixed_to_outer); | 8855 outer_viewport_scroll_layer->AddChild(fixed_to_outer); |
| 8858 | 8856 |
| 8859 LayerPositionConstraint fixed_to_right; | 8857 LayerPositionConstraint fixed_to_right; |
| 8860 fixed_to_right.set_is_fixed_position(true); | 8858 fixed_to_right.set_is_fixed_position(true); |
| 8861 fixed_to_right.set_is_fixed_to_right_edge(true); | 8859 fixed_to_right.set_is_fixed_to_right_edge(true); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9325 | 9323 |
| 9326 root->SetBounds(gfx::Size(100, 100)); | 9324 root->SetBounds(gfx::Size(100, 100)); |
| 9327 child->SetBounds(gfx::Size(10, 10)); | 9325 child->SetBounds(gfx::Size(10, 10)); |
| 9328 grandchild->SetBounds(gfx::Size(10, 10)); | 9326 grandchild->SetBounds(gfx::Size(10, 10)); |
| 9329 greatgrandchild->SetBounds(gfx::Size(10, 10)); | 9327 greatgrandchild->SetBounds(gfx::Size(10, 10)); |
| 9330 | 9328 |
| 9331 root->AddChild(child); | 9329 root->AddChild(child); |
| 9332 child->AddChild(grandchild); | 9330 child->AddChild(grandchild); |
| 9333 grandchild->AddChild(greatgrandchild); | 9331 grandchild->AddChild(greatgrandchild); |
| 9334 host()->SetRootLayer(root); | 9332 host()->SetRootLayer(root); |
| 9335 host()->GetLayerTree()->SetElementIdsForTesting(); | 9333 host()->SetElementIdsForTesting(); |
| 9336 | 9334 |
| 9337 // Check the non-skipped case. | 9335 // Check the non-skipped case. |
| 9338 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 9336 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9339 const LayerList* update_list = GetUpdateLayerList(); | 9337 const LayerList* update_list = GetUpdateLayerList(); |
| 9340 EXPECT_TRUE(VerifyLayerInList(grandchild, update_list)); | 9338 EXPECT_TRUE(VerifyLayerInList(grandchild, update_list)); |
| 9341 | 9339 |
| 9342 // Now we will reset the visible rect from property trees for the grandchild, | 9340 // Now we will reset the visible rect from property trees for the grandchild, |
| 9343 // and we will configure |child| in several ways that should force the subtree | 9341 // and we will configure |child| in several ways that should force the subtree |
| 9344 // to be skipped. The visible content rect for |grandchild| should, therefore, | 9342 // to be skipped. The visible content rect for |grandchild| should, therefore, |
| 9345 // remain empty. | 9343 // remain empty. |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10463 EXPECT_EQ(property_trees->layer_id_to_effect_node_index.find(child->id()), | 10461 EXPECT_EQ(property_trees->layer_id_to_effect_node_index.find(child->id()), |
| 10464 property_trees->layer_id_to_effect_node_index.end()); | 10462 property_trees->layer_id_to_effect_node_index.end()); |
| 10465 } | 10463 } |
| 10466 | 10464 |
| 10467 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 10465 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| 10468 scoped_refptr<Layer> root = Layer::Create(); | 10466 scoped_refptr<Layer> root = Layer::Create(); |
| 10469 scoped_refptr<LayerWithForcedDrawsContent> animated = | 10467 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 10470 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10468 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 10471 root->AddChild(animated); | 10469 root->AddChild(animated); |
| 10472 host()->SetRootLayer(root); | 10470 host()->SetRootLayer(root); |
| 10473 host()->GetLayerTree()->SetElementIdsForTesting(); | 10471 host()->SetElementIdsForTesting(); |
| 10474 | 10472 |
| 10475 root->SetBounds(gfx::Size(100, 100)); | 10473 root->SetBounds(gfx::Size(100, 100)); |
| 10476 root->SetForceRenderSurfaceForTesting(true); | 10474 root->SetForceRenderSurfaceForTesting(true); |
| 10477 animated->SetBounds(gfx::Size(20, 20)); | 10475 animated->SetBounds(gfx::Size(20, 20)); |
| 10478 animated->SetOpacity(0.f); | 10476 animated->SetOpacity(0.f); |
| 10479 | 10477 |
| 10480 scoped_refptr<AnimationPlayer> player = | 10478 scoped_refptr<AnimationPlayer> player = |
| 10481 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 10479 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 10482 timeline()->AttachPlayer(player); | 10480 timeline()->AttachPlayer(player); |
| 10483 | 10481 |
| 10484 player->AttachElement(animated->element_id()); | 10482 player->AttachElement(animated->element_id()); |
| 10485 | 10483 |
| 10486 int animation_id = 0; | 10484 int animation_id = 0; |
| 10487 std::unique_ptr<Animation> animation = Animation::Create( | 10485 std::unique_ptr<Animation> animation = Animation::Create( |
| 10488 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 10486 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 10489 animation_id, 1, TargetProperty::OPACITY); | 10487 animation_id, 1, TargetProperty::OPACITY); |
| 10490 animation->set_fill_mode(Animation::FillMode::NONE); | 10488 animation->set_fill_mode(Animation::FillMode::NONE); |
| 10491 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 10489 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 10492 Animation* animation_ptr = animation.get(); | 10490 Animation* animation_ptr = animation.get(); |
| 10493 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), | 10491 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
| 10494 std::move(animation)); | 10492 std::move(animation)); |
| 10495 | 10493 |
| 10496 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10494 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10497 | 10495 |
| 10498 EffectTree& tree = root->GetLayerTree()->property_trees()->effect_tree; | 10496 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; |
| 10499 EffectNode* node = tree.Node(animated->effect_tree_index()); | 10497 EffectNode* node = tree.Node(animated->effect_tree_index()); |
| 10500 EXPECT_FALSE(node->is_currently_animating_opacity); | 10498 EXPECT_FALSE(node->is_currently_animating_opacity); |
| 10501 EXPECT_TRUE(node->has_potential_opacity_animation); | 10499 EXPECT_TRUE(node->has_potential_opacity_animation); |
| 10502 | 10500 |
| 10503 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 10501 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
| 10504 host()->AnimateLayers( | 10502 host()->AnimateLayers( |
| 10505 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); | 10503 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); |
| 10506 node = tree.Node(animated->effect_tree_index()); | 10504 node = tree.Node(animated->effect_tree_index()); |
| 10507 EXPECT_TRUE(node->is_currently_animating_opacity); | 10505 EXPECT_TRUE(node->is_currently_animating_opacity); |
| 10508 EXPECT_TRUE(node->has_potential_opacity_animation); | 10506 EXPECT_TRUE(node->has_potential_opacity_animation); |
| 10509 | 10507 |
| 10510 player->AbortAnimations(TargetProperty::OPACITY, false /*needs_completion*/); | 10508 player->AbortAnimations(TargetProperty::OPACITY, false /*needs_completion*/); |
| 10511 node = tree.Node(animated->effect_tree_index()); | 10509 node = tree.Node(animated->effect_tree_index()); |
| 10512 EXPECT_FALSE(node->is_currently_animating_opacity); | 10510 EXPECT_FALSE(node->is_currently_animating_opacity); |
| 10513 EXPECT_FALSE(node->has_potential_opacity_animation); | 10511 EXPECT_FALSE(node->has_potential_opacity_animation); |
| 10514 } | 10512 } |
| 10515 | 10513 |
| 10516 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 10514 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
| 10517 scoped_refptr<Layer> root = Layer::Create(); | 10515 scoped_refptr<Layer> root = Layer::Create(); |
| 10518 scoped_refptr<LayerWithForcedDrawsContent> animated = | 10516 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 10519 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10517 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 10520 root->AddChild(animated); | 10518 root->AddChild(animated); |
| 10521 host()->SetRootLayer(root); | 10519 host()->SetRootLayer(root); |
| 10522 host()->GetLayerTree()->SetElementIdsForTesting(); | 10520 host()->SetElementIdsForTesting(); |
| 10523 | 10521 |
| 10524 root->SetBounds(gfx::Size(100, 100)); | 10522 root->SetBounds(gfx::Size(100, 100)); |
| 10525 root->SetForceRenderSurfaceForTesting(true); | 10523 root->SetForceRenderSurfaceForTesting(true); |
| 10526 animated->SetBounds(gfx::Size(20, 20)); | 10524 animated->SetBounds(gfx::Size(20, 20)); |
| 10527 | 10525 |
| 10528 scoped_refptr<AnimationPlayer> player = | 10526 scoped_refptr<AnimationPlayer> player = |
| 10529 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 10527 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 10530 timeline()->AttachPlayer(player); | 10528 timeline()->AttachPlayer(player); |
| 10531 player->AttachElement(animated->element_id()); | 10529 player->AttachElement(animated->element_id()); |
| 10532 | 10530 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10545 std::unique_ptr<Animation> animation( | 10543 std::unique_ptr<Animation> animation( |
| 10546 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 10544 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 10547 animation->set_fill_mode(Animation::FillMode::NONE); | 10545 animation->set_fill_mode(Animation::FillMode::NONE); |
| 10548 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 10546 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 10549 Animation* animation_ptr = animation.get(); | 10547 Animation* animation_ptr = animation.get(); |
| 10550 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), | 10548 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
| 10551 std::move(animation)); | 10549 std::move(animation)); |
| 10552 | 10550 |
| 10553 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10551 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10554 | 10552 |
| 10555 TransformTree& tree = root->GetLayerTree()->property_trees()->transform_tree; | 10553 TransformTree& tree = |
| 10554 root->layer_tree_host()->property_trees()->transform_tree; |
| 10556 TransformNode* node = tree.Node(animated->transform_tree_index()); | 10555 TransformNode* node = tree.Node(animated->transform_tree_index()); |
| 10557 EXPECT_FALSE(node->is_currently_animating); | 10556 EXPECT_FALSE(node->is_currently_animating); |
| 10558 EXPECT_TRUE(node->has_potential_animation); | 10557 EXPECT_TRUE(node->has_potential_animation); |
| 10559 | 10558 |
| 10560 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 10559 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
| 10561 host()->AnimateLayers( | 10560 host()->AnimateLayers( |
| 10562 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); | 10561 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); |
| 10563 node = tree.Node(animated->transform_tree_index()); | 10562 node = tree.Node(animated->transform_tree_index()); |
| 10564 EXPECT_TRUE(node->is_currently_animating); | 10563 EXPECT_TRUE(node->is_currently_animating); |
| 10565 EXPECT_TRUE(node->has_potential_animation); | 10564 EXPECT_TRUE(node->has_potential_animation); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10645 MainThreadScrollingReason::kScrollbarScrolling); | 10644 MainThreadScrollingReason::kScrollbarScrolling); |
| 10646 | 10645 |
| 10647 child7->SetScrollClipLayerId(parent3->id()); | 10646 child7->SetScrollClipLayerId(parent3->id()); |
| 10648 | 10647 |
| 10649 child8->SetScrollParent(child7.get()); | 10648 child8->SetScrollParent(child7.get()); |
| 10650 grand_child11->SetScrollClipLayerId(parent3->id()); | 10649 grand_child11->SetScrollClipLayerId(parent3->id()); |
| 10651 | 10650 |
| 10652 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 10651 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 10653 parent5->SetBounds(gfx::Size(10, 10)); | 10652 parent5->SetBounds(gfx::Size(10, 10)); |
| 10654 | 10653 |
| 10655 host()->GetLayerTree()->RegisterViewportLayers(nullptr, page_scale_layer, | 10654 host()->RegisterViewportLayers(nullptr, page_scale_layer, parent2, nullptr); |
| 10656 parent2, nullptr); | |
| 10657 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root1.get()); | 10655 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root1.get()); |
| 10658 | 10656 |
| 10659 const int kRootPropertyTreeNodeId = 0; | 10657 const int kRootPropertyTreeNodeId = 0; |
| 10660 | 10658 |
| 10661 // Property tree root | 10659 // Property tree root |
| 10662 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; | 10660 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; |
| 10663 PropertyTrees property_trees; | 10661 PropertyTrees property_trees; |
| 10664 property_trees.is_main_thread = true; | 10662 property_trees.is_main_thread = true; |
| 10665 property_trees.is_active = false; | 10663 property_trees.is_active = false; |
| 10666 ScrollTree& expected_scroll_tree = property_trees.scroll_tree; | 10664 ScrollTree& expected_scroll_tree = property_trees.scroll_tree; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10758 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10756 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10759 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10757 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10760 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10758 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10761 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10759 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10762 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10760 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10763 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10761 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10764 } | 10762 } |
| 10765 | 10763 |
| 10766 } // namespace | 10764 } // namespace |
| 10767 } // namespace cc | 10765 } // namespace cc |
| OLD | NEW |