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