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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 void ExecuteCalculateDrawProperties(LayerType* root_layer, | 165 void ExecuteCalculateDrawProperties(LayerType* root_layer, |
166 float device_scale_factor) { | 166 float device_scale_factor) { |
167 LayerType* page_scale_application_layer = nullptr; | 167 LayerType* page_scale_application_layer = nullptr; |
168 ExecuteCalculateDrawProperties(root_layer, device_scale_factor, 1.f, | 168 ExecuteCalculateDrawProperties(root_layer, device_scale_factor, 1.f, |
169 page_scale_application_layer); | 169 page_scale_application_layer); |
170 } | 170 } |
171 | 171 |
172 const LayerList* GetUpdateLayerList() { return &update_layer_list_; } | 172 const LayerList* GetUpdateLayerList() { return &update_layer_list_; } |
173 | 173 |
174 void ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) { | 174 void ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) { |
175 DCHECK(root_layer->layer_tree_host()); | 175 DCHECK(root_layer->GetLayerTree()); |
176 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); | 176 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); |
177 | 177 |
178 bool can_render_to_separate_surface = true; | 178 bool can_render_to_separate_surface = true; |
179 | 179 |
180 const Layer* page_scale_layer = | 180 const Layer* page_scale_layer = |
181 root_layer->layer_tree_host()->page_scale_layer(); | 181 root_layer->GetLayerTree()->page_scale_layer(); |
182 Layer* inner_viewport_scroll_layer = | 182 Layer* inner_viewport_scroll_layer = |
183 root_layer->layer_tree_host()->inner_viewport_scroll_layer(); | 183 root_layer->GetLayerTree()->inner_viewport_scroll_layer(); |
184 Layer* outer_viewport_scroll_layer = | 184 Layer* outer_viewport_scroll_layer = |
185 root_layer->layer_tree_host()->outer_viewport_scroll_layer(); | 185 root_layer->GetLayerTree()->outer_viewport_scroll_layer(); |
186 const Layer* overscroll_elasticity_layer = | 186 const Layer* overscroll_elasticity_layer = |
187 root_layer->layer_tree_host()->overscroll_elasticity_layer(); | 187 root_layer->GetLayerTree()->overscroll_elasticity_layer(); |
188 gfx::Vector2dF elastic_overscroll = | 188 gfx::Vector2dF elastic_overscroll = |
189 root_layer->layer_tree_host()->elastic_overscroll(); | 189 root_layer->GetLayerTree()->elastic_overscroll(); |
190 float page_scale_factor = 1.f; | 190 float page_scale_factor = 1.f; |
191 float device_scale_factor = 1.f; | 191 float device_scale_factor = 1.f; |
192 gfx::Size device_viewport_size = | 192 gfx::Size device_viewport_size = |
193 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 193 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
194 root_layer->bounds().height() * device_scale_factor); | 194 root_layer->bounds().height() * device_scale_factor); |
195 PropertyTrees* property_trees = | 195 PropertyTrees* property_trees = |
196 root_layer->layer_tree_host()->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->layer_tree_host(), property_trees->transform_tree, |
(...skipping 6715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6922 root->SetBounds(gfx::Size(50, 50)); | 6922 root->SetBounds(gfx::Size(50, 50)); |
6923 container->SetBounds(gfx::Size(50, 50)); | 6923 container->SetBounds(gfx::Size(50, 50)); |
6924 scroller->SetBounds(gfx::Size(50, 50)); | 6924 scroller->SetBounds(gfx::Size(50, 50)); |
6925 fixed_pos->SetBounds(gfx::Size(50, 50)); | 6925 fixed_pos->SetBounds(gfx::Size(50, 50)); |
6926 | 6926 |
6927 gfx::Transform rotate; | 6927 gfx::Transform rotate; |
6928 rotate.RotateAboutXAxis(20); | 6928 rotate.RotateAboutXAxis(20); |
6929 container->SetTransform(rotate); | 6929 container->SetTransform(rotate); |
6930 | 6930 |
6931 ExecuteCalculateDrawProperties(root.get()); | 6931 ExecuteCalculateDrawProperties(root.get()); |
6932 TransformTree& tree = | 6932 TransformTree& tree = root->GetLayerTree()->property_trees()->transform_tree; |
6933 root->layer_tree_host()->property_trees()->transform_tree; | |
6934 gfx::Transform transform; | 6933 gfx::Transform transform; |
6935 tree.ComputeTranslation(fixed_pos->transform_tree_index(), | 6934 tree.ComputeTranslation(fixed_pos->transform_tree_index(), |
6936 container->transform_tree_index(), &transform); | 6935 container->transform_tree_index(), &transform); |
6937 EXPECT_TRUE(transform.IsIdentity()); | 6936 EXPECT_TRUE(transform.IsIdentity()); |
6938 } | 6937 } |
6939 | 6938 |
6940 TEST_F(LayerTreeHostCommonTest, ScrollSnappingWithFixedPosChild) { | 6939 TEST_F(LayerTreeHostCommonTest, ScrollSnappingWithFixedPosChild) { |
6941 // This test verifies that a fixed pos child of a scrolling layer doesn't get | 6940 // This test verifies that a fixed pos child of a scrolling layer doesn't get |
6942 // snapped to integer coordinates. | 6941 // snapped to integer coordinates. |
6943 // | 6942 // |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7845 | 7844 |
7846 inner_viewport_scroll_layer->SetScrollClipLayerId( | 7845 inner_viewport_scroll_layer->SetScrollClipLayerId( |
7847 inner_viewport_container_layer->id()); | 7846 inner_viewport_container_layer->id()); |
7848 outer_viewport_scroll_layer->SetScrollClipLayerId( | 7847 outer_viewport_scroll_layer->SetScrollClipLayerId( |
7849 outer_viewport_container_layer->id()); | 7848 outer_viewport_container_layer->id()); |
7850 | 7849 |
7851 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 7850 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
7852 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 7851 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
7853 | 7852 |
7854 host()->SetRootLayer(root); | 7853 host()->SetRootLayer(root); |
7855 host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer, | 7854 host()->GetLayerTree()->RegisterViewportLayers( |
7856 outer_viewport_scroll_layer); | 7855 nullptr, root, inner_viewport_scroll_layer, outer_viewport_scroll_layer); |
7857 | 7856 |
7858 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); | 7857 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); |
7859 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); | 7858 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); |
7860 | 7859 |
7861 inner_viewport_scroll_layer->AddChild(fixed_to_inner); | 7860 inner_viewport_scroll_layer->AddChild(fixed_to_inner); |
7862 outer_viewport_scroll_layer->AddChild(fixed_to_outer); | 7861 outer_viewport_scroll_layer->AddChild(fixed_to_outer); |
7863 | 7862 |
7864 LayerPositionConstraint fixed_to_right; | 7863 LayerPositionConstraint fixed_to_right; |
7865 fixed_to_right.set_is_fixed_position(true); | 7864 fixed_to_right.set_is_fixed_position(true); |
7866 fixed_to_right.set_is_fixed_to_right_edge(true); | 7865 fixed_to_right.set_is_fixed_to_right_edge(true); |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9452 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 9451 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
9453 animation_id, 1, TargetProperty::OPACITY); | 9452 animation_id, 1, TargetProperty::OPACITY); |
9454 animation->set_fill_mode(Animation::FillMode::NONE); | 9453 animation->set_fill_mode(Animation::FillMode::NONE); |
9455 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9454 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
9456 Animation* animation_ptr = animation.get(); | 9455 Animation* animation_ptr = animation.get(); |
9457 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), | 9456 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
9458 std::move(animation)); | 9457 std::move(animation)); |
9459 | 9458 |
9460 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9459 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
9461 | 9460 |
9462 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; | 9461 EffectTree& tree = root->GetLayerTree()->property_trees()->effect_tree; |
9463 EffectNode* node = tree.Node(animated->effect_tree_index()); | 9462 EffectNode* node = tree.Node(animated->effect_tree_index()); |
9464 EXPECT_FALSE(node->is_currently_animating_opacity); | 9463 EXPECT_FALSE(node->is_currently_animating_opacity); |
9465 EXPECT_TRUE(node->has_potential_opacity_animation); | 9464 EXPECT_TRUE(node->has_potential_opacity_animation); |
9466 | 9465 |
9467 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 9466 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
9468 root->layer_tree_host()->AnimateLayers( | 9467 root->layer_tree_host()->AnimateLayers( |
9469 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); | 9468 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); |
9470 node = tree.Node(animated->effect_tree_index()); | 9469 node = tree.Node(animated->effect_tree_index()); |
9471 EXPECT_TRUE(node->is_currently_animating_opacity); | 9470 EXPECT_TRUE(node->is_currently_animating_opacity); |
9472 EXPECT_TRUE(node->has_potential_opacity_animation); | 9471 EXPECT_TRUE(node->has_potential_opacity_animation); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9509 std::unique_ptr<Animation> animation( | 9508 std::unique_ptr<Animation> animation( |
9510 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 9509 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
9511 animation->set_fill_mode(Animation::FillMode::NONE); | 9510 animation->set_fill_mode(Animation::FillMode::NONE); |
9512 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9511 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
9513 Animation* animation_ptr = animation.get(); | 9512 Animation* animation_ptr = animation.get(); |
9514 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), | 9513 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
9515 std::move(animation)); | 9514 std::move(animation)); |
9516 | 9515 |
9517 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9516 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
9518 | 9517 |
9519 TransformTree& tree = | 9518 TransformTree& tree = root->GetLayerTree()->property_trees()->transform_tree; |
9520 root->layer_tree_host()->property_trees()->transform_tree; | |
9521 TransformNode* node = tree.Node(animated->transform_tree_index()); | 9519 TransformNode* node = tree.Node(animated->transform_tree_index()); |
9522 EXPECT_FALSE(node->is_currently_animating); | 9520 EXPECT_FALSE(node->is_currently_animating); |
9523 EXPECT_TRUE(node->has_potential_animation); | 9521 EXPECT_TRUE(node->has_potential_animation); |
9524 | 9522 |
9525 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 9523 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
9526 root->layer_tree_host()->AnimateLayers( | 9524 root->layer_tree_host()->AnimateLayers( |
9527 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); | 9525 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); |
9528 node = tree.Node(animated->transform_tree_index()); | 9526 node = tree.Node(animated->transform_tree_index()); |
9529 EXPECT_TRUE(node->is_currently_animating); | 9527 EXPECT_TRUE(node->is_currently_animating); |
9530 EXPECT_TRUE(node->has_potential_animation); | 9528 EXPECT_TRUE(node->has_potential_animation); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9647 MainThreadScrollingReason::kScrollbarScrolling); | 9645 MainThreadScrollingReason::kScrollbarScrolling); |
9648 | 9646 |
9649 child7->SetScrollClipLayerId(parent3->id()); | 9647 child7->SetScrollClipLayerId(parent3->id()); |
9650 | 9648 |
9651 child8->SetScrollParent(child7.get()); | 9649 child8->SetScrollParent(child7.get()); |
9652 grand_child11->SetScrollClipLayerId(parent3->id()); | 9650 grand_child11->SetScrollClipLayerId(parent3->id()); |
9653 | 9651 |
9654 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 9652 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
9655 parent5->SetBounds(gfx::Size(10, 10)); | 9653 parent5->SetBounds(gfx::Size(10, 10)); |
9656 | 9654 |
9657 host()->RegisterViewportLayers(nullptr, page_scale_layer, parent2, nullptr); | 9655 host()->GetLayerTree()->RegisterViewportLayers(nullptr, page_scale_layer, |
| 9656 parent2, nullptr); |
9658 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get()); | 9657 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get()); |
9659 | 9658 |
9660 const int kInvalidPropertyTreeNodeId = -1; | 9659 const int kInvalidPropertyTreeNodeId = -1; |
9661 const int kRootPropertyTreeNodeId = 0; | 9660 const int kRootPropertyTreeNodeId = 0; |
9662 | 9661 |
9663 // Property tree root | 9662 // Property tree root |
9664 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; | 9663 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; |
9665 PropertyTrees property_trees; | 9664 PropertyTrees property_trees; |
9666 property_trees.is_main_thread = true; | 9665 property_trees.is_main_thread = true; |
9667 property_trees.is_active = false; | 9666 property_trees.is_active = false; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9760 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9759 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
9761 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9760 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
9762 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9761 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
9763 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9762 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
9764 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9763 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
9765 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9764 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
9766 } | 9765 } |
9767 | 9766 |
9768 } // namespace | 9767 } // namespace |
9769 } // namespace cc | 9768 } // namespace cc |
OLD | NEW |