| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/property_tree_builder.h" | 5 #include "cc/trees/property_tree_builder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 | 227 |
| 228 static Layer* ReplicaLayer(Layer* layer) { | 228 static Layer* ReplicaLayer(Layer* layer) { |
| 229 return layer->replica_layer(); | 229 return layer->replica_layer(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 static LayerImpl* ReplicaLayer(LayerImpl* layer) { | 232 static LayerImpl* ReplicaLayer(LayerImpl* layer) { |
| 233 return layer->test_properties()->replica_layer; | 233 return layer->test_properties()->replica_layer; |
| 234 } | 234 } |
| 235 | 235 |
| 236 static const gfx::Transform& Transform(Layer* layer) { |
| 237 return layer->transform(); |
| 238 } |
| 239 |
| 240 static const gfx::Transform& Transform(LayerImpl* layer) { |
| 241 return layer->test_properties()->transform; |
| 242 } |
| 243 |
| 236 // Methods to query state from the AnimationHost ---------------------- | 244 // Methods to query state from the AnimationHost ---------------------- |
| 237 template <typename LayerType> | 245 template <typename LayerType> |
| 238 bool OpacityIsAnimating(LayerType* layer) { | 246 bool OpacityIsAnimating(LayerType* layer) { |
| 239 return layer->GetAnimationHost()->IsAnimatingOpacityProperty( | 247 return layer->GetAnimationHost()->IsAnimatingOpacityProperty( |
| 240 layer->element_id(), layer->GetElementTypeForAnimation()); | 248 layer->element_id(), layer->GetElementTypeForAnimation()); |
| 241 } | 249 } |
| 242 | 250 |
| 243 template <typename LayerType> | 251 template <typename LayerType> |
| 244 bool HasPotentiallyRunningOpacityAnimation(LayerType* layer) { | 252 bool HasPotentiallyRunningOpacityAnimation(LayerType* layer) { |
| 245 return layer->GetAnimationHost()->HasPotentiallyRunningOpacityAnimation( | 253 return layer->GetAnimationHost()->HasPotentiallyRunningOpacityAnimation( |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 bool created_render_surface, | 487 bool created_render_surface, |
| 480 DataForRecursion<LayerType>* data_for_children) { | 488 DataForRecursion<LayerType>* data_for_children) { |
| 481 const bool is_root = !Parent(layer); | 489 const bool is_root = !Parent(layer); |
| 482 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; | 490 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; |
| 483 const bool is_overscroll_elasticity_layer = | 491 const bool is_overscroll_elasticity_layer = |
| 484 layer == data_from_ancestor.overscroll_elasticity_layer; | 492 layer == data_from_ancestor.overscroll_elasticity_layer; |
| 485 const bool is_scrollable = layer->scrollable(); | 493 const bool is_scrollable = layer->scrollable(); |
| 486 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); | 494 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); |
| 487 | 495 |
| 488 const bool has_significant_transform = | 496 const bool has_significant_transform = |
| 489 !layer->transform().IsIdentityOr2DTranslation(); | 497 !Transform(layer).IsIdentityOr2DTranslation(); |
| 490 | 498 |
| 491 const bool has_potentially_animated_transform = | 499 const bool has_potentially_animated_transform = |
| 492 HasPotentiallyRunningTransformAnimation(layer); | 500 HasPotentiallyRunningTransformAnimation(layer); |
| 493 | 501 |
| 494 // A transform node is needed even for a finished animation, since differences | 502 // A transform node is needed even for a finished animation, since differences |
| 495 // in the timing of animation state updates can mean that an animation that's | 503 // in the timing of animation state updates can mean that an animation that's |
| 496 // in the Finished state at tree-building time on the main thread is still in | 504 // in the Finished state at tree-building time on the main thread is still in |
| 497 // the Running state right after commit on the compositor thread. | 505 // the Running state right after commit on the compositor thread. |
| 498 const bool has_any_transform_animation = | 506 const bool has_any_transform_animation = |
| 499 HasAnyAnimationTargetingProperty(layer, TargetProperty::TRANSFORM); | 507 HasAnyAnimationTargetingProperty(layer, TargetProperty::TRANSFORM); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 550 } |
| 543 } | 551 } |
| 544 | 552 |
| 545 if (IsContainerForFixedPositionLayers(layer) || is_root) { | 553 if (IsContainerForFixedPositionLayers(layer) || is_root) { |
| 546 data_for_children->affected_by_inner_viewport_bounds_delta = | 554 data_for_children->affected_by_inner_viewport_bounds_delta = |
| 547 layer == data_from_ancestor.inner_viewport_scroll_layer; | 555 layer == data_from_ancestor.inner_viewport_scroll_layer; |
| 548 data_for_children->affected_by_outer_viewport_bounds_delta = | 556 data_for_children->affected_by_outer_viewport_bounds_delta = |
| 549 layer == data_from_ancestor.outer_viewport_scroll_layer; | 557 layer == data_from_ancestor.outer_viewport_scroll_layer; |
| 550 if (is_scrollable) { | 558 if (is_scrollable) { |
| 551 DCHECK(!is_root); | 559 DCHECK(!is_root); |
| 552 DCHECK(layer->transform().IsIdentity()); | 560 DCHECK(Transform(layer).IsIdentity()); |
| 553 data_for_children->transform_fixed_parent = Parent(layer); | 561 data_for_children->transform_fixed_parent = Parent(layer); |
| 554 } else { | 562 } else { |
| 555 data_for_children->transform_fixed_parent = layer; | 563 data_for_children->transform_fixed_parent = layer; |
| 556 } | 564 } |
| 557 } | 565 } |
| 558 data_for_children->transform_tree_parent = layer; | 566 data_for_children->transform_tree_parent = layer; |
| 559 | 567 |
| 560 if (!requires_node) { | 568 if (!requires_node) { |
| 561 data_for_children->should_flatten |= ShouldFlattenTransform(layer); | 569 data_for_children->should_flatten |= ShouldFlattenTransform(layer); |
| 562 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + | 570 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + |
| 563 layer->transform().To2dTranslation(); | 571 Transform(layer).To2dTranslation(); |
| 564 gfx::Vector2dF source_to_parent; | 572 gfx::Vector2dF source_to_parent; |
| 565 if (source_index != parent_index) { | 573 if (source_index != parent_index) { |
| 566 gfx::Transform to_parent; | 574 gfx::Transform to_parent; |
| 567 data_from_ancestor.property_trees->transform_tree.ComputeTranslation( | 575 data_from_ancestor.property_trees->transform_tree.ComputeTranslation( |
| 568 source_index, parent_index, &to_parent); | 576 source_index, parent_index, &to_parent); |
| 569 source_to_parent = to_parent.To2dTranslation(); | 577 source_to_parent = to_parent.To2dTranslation(); |
| 570 } | 578 } |
| 571 layer->set_offset_to_transform_parent(source_offset + source_to_parent + | 579 layer->set_offset_to_transform_parent(source_offset + source_to_parent + |
| 572 local_offset); | 580 local_offset); |
| 573 layer->set_should_flatten_transform_from_property_tree( | 581 layer->set_should_flatten_transform_from_property_tree( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 node->affected_by_outer_viewport_bounds_delta_y = | 679 node->affected_by_outer_viewport_bounds_delta_y = |
| 672 PositionConstraint(layer).is_fixed_to_bottom_edge(); | 680 PositionConstraint(layer).is_fixed_to_bottom_edge(); |
| 673 if (node->affected_by_outer_viewport_bounds_delta_x || | 681 if (node->affected_by_outer_viewport_bounds_delta_x || |
| 674 node->affected_by_outer_viewport_bounds_delta_y) { | 682 node->affected_by_outer_viewport_bounds_delta_y) { |
| 675 data_for_children->property_trees->transform_tree | 683 data_for_children->property_trees->transform_tree |
| 676 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); | 684 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); |
| 677 } | 685 } |
| 678 } | 686 } |
| 679 } | 687 } |
| 680 | 688 |
| 681 node->local = layer->transform(); | 689 node->local = Transform(layer); |
| 682 node->update_pre_local_transform(TransformOrigin(layer)); | 690 node->update_pre_local_transform(TransformOrigin(layer)); |
| 683 | 691 |
| 684 node->needs_local_transform_update = true; | 692 node->needs_local_transform_update = true; |
| 685 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); | 693 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); |
| 686 | 694 |
| 687 layer->set_offset_to_transform_parent(gfx::Vector2dF()); | 695 layer->set_offset_to_transform_parent(gfx::Vector2dF()); |
| 688 | 696 |
| 689 // Flattening (if needed) will be handled by |node|. | 697 // Flattening (if needed) will be handled by |node|. |
| 690 layer->set_should_flatten_transform_from_property_tree(false); | 698 layer->set_should_flatten_transform_from_property_tree(false); |
| 691 | 699 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 814 |
| 807 static inline bool HasCopyRequest(LayerImpl* layer) { | 815 static inline bool HasCopyRequest(LayerImpl* layer) { |
| 808 return !layer->test_properties()->copy_requests.empty(); | 816 return !layer->test_properties()->copy_requests.empty(); |
| 809 } | 817 } |
| 810 | 818 |
| 811 template <typename LayerType> | 819 template <typename LayerType> |
| 812 bool ShouldCreateRenderSurface(LayerType* layer, | 820 bool ShouldCreateRenderSurface(LayerType* layer, |
| 813 gfx::Transform current_transform, | 821 gfx::Transform current_transform, |
| 814 bool axis_aligned) { | 822 bool axis_aligned) { |
| 815 const bool preserves_2d_axis_alignment = | 823 const bool preserves_2d_axis_alignment = |
| 816 (current_transform * layer->transform()).Preserves2dAxisAlignment() && | 824 (current_transform * Transform(layer)).Preserves2dAxisAlignment() && |
| 817 axis_aligned && AnimationsPreserveAxisAlignment(layer); | 825 axis_aligned && AnimationsPreserveAxisAlignment(layer); |
| 818 const bool is_root = !Parent(layer); | 826 const bool is_root = !Parent(layer); |
| 819 if (is_root) | 827 if (is_root) |
| 820 return true; | 828 return true; |
| 821 | 829 |
| 822 // If the layer uses a mask and the layer is not a replica layer. | 830 // If the layer uses a mask and the layer is not a replica layer. |
| 823 // TODO(weiliangc): After slimming paint there won't be replica layers. | 831 // TODO(weiliangc): After slimming paint there won't be replica layers. |
| 824 if (MaskLayer(layer) && ReplicaLayer(Parent(layer)) != layer) { | 832 if (MaskLayer(layer) && ReplicaLayer(Parent(layer)) != layer) { |
| 825 return true; | 833 return true; |
| 826 } | 834 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 bool requires_node = is_root || has_transparency || | 958 bool requires_node = is_root || has_transparency || |
| 951 has_potential_opacity_animation || | 959 has_potential_opacity_animation || |
| 952 should_create_render_surface; | 960 should_create_render_surface; |
| 953 | 961 |
| 954 int parent_id = data_from_ancestor.effect_tree_parent; | 962 int parent_id = data_from_ancestor.effect_tree_parent; |
| 955 | 963 |
| 956 if (!requires_node) { | 964 if (!requires_node) { |
| 957 layer->SetEffectTreeIndex(parent_id); | 965 layer->SetEffectTreeIndex(parent_id); |
| 958 data_for_children->effect_tree_parent = parent_id; | 966 data_for_children->effect_tree_parent = parent_id; |
| 959 data_for_children->compound_transform_since_render_target *= | 967 data_for_children->compound_transform_since_render_target *= |
| 960 layer->transform(); | 968 Transform(layer); |
| 961 return false; | 969 return false; |
| 962 } | 970 } |
| 963 | 971 |
| 964 EffectNode node; | 972 EffectNode node; |
| 965 node.owner_id = layer->id(); | 973 node.owner_id = layer->id(); |
| 966 if (AlwaysUseActiveTreeOpacity(layer)) { | 974 if (AlwaysUseActiveTreeOpacity(layer)) { |
| 967 data_for_children->property_trees->always_use_active_tree_opacity_effect_ids | 975 data_for_children->property_trees->always_use_active_tree_opacity_effect_ids |
| 968 .push_back(node.owner_id); | 976 .push_back(node.owner_id); |
| 969 } | 977 } |
| 970 | 978 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 color = SkColorSetA(color, 255); | 1465 color = SkColorSetA(color, 255); |
| 1458 BuildPropertyTreesTopLevelInternal( | 1466 BuildPropertyTreesTopLevelInternal( |
| 1459 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1467 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 1460 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1468 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 1461 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1469 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 1462 device_transform, property_trees, color); | 1470 device_transform, property_trees, color); |
| 1463 property_trees->ResetCachedData(); | 1471 property_trees->ResetCachedData(); |
| 1464 } | 1472 } |
| 1465 | 1473 |
| 1466 } // namespace cc | 1474 } // namespace cc |
| OLD | NEW |