| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 template <typename LayerType> | 56 template <typename LayerType> |
| 57 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, | 57 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, |
| 58 LayerType* layer) { | 58 LayerType* layer) { |
| 59 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); | 59 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); |
| 60 const int id = inherits_clip ? data.clip_tree_parent | 60 const int id = inherits_clip ? data.clip_tree_parent |
| 61 : layer->clip_parent()->clip_tree_index(); | 61 : layer->clip_parent()->clip_tree_index(); |
| 62 return data.clip_tree->Node(id); | 62 return data.clip_tree->Node(id); |
| 63 } | 63 } |
| 64 | 64 |
| 65 template <typename LayerType> | 65 template <typename LayerType> |
| 66 static bool HasPotentiallyRunningAnimation(LayerType* layer, | |
| 67 Animation::TargetProperty property) { | |
| 68 if (Animation* animation = | |
| 69 layer->layer_animation_controller()->GetAnimation(property)) { | |
| 70 return !animation->is_finished(); | |
| 71 } | |
| 72 return false; | |
| 73 } | |
| 74 | |
| 75 template <typename LayerType> | |
| 76 static bool RequiresClipNode(LayerType* layer, | 66 static bool RequiresClipNode(LayerType* layer, |
| 77 const DataForRecursion<LayerType>& data, | 67 const DataForRecursion<LayerType>& data, |
| 78 int parent_transform_id, | 68 int parent_transform_id, |
| 79 bool is_clipped) { | 69 bool is_clipped) { |
| 80 const bool render_surface_applies_clip = | 70 const bool render_surface_applies_clip = |
| 81 layer->render_surface() && is_clipped; | 71 layer->render_surface() && is_clipped; |
| 82 const bool render_surface_may_grow_due_to_clip_children = | 72 const bool render_surface_may_grow_due_to_clip_children = |
| 83 layer->render_surface() && layer->num_unclipped_descendants() > 0; | 73 layer->render_surface() && layer->num_unclipped_descendants() > 0; |
| 84 | 74 |
| 85 if (layer->masks_to_bounds() || layer->mask_layer() || | 75 if (layer->masks_to_bounds() || layer->mask_layer() || |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 DataForRecursion<LayerType>* data_for_children) { | 157 DataForRecursion<LayerType>* data_for_children) { |
| 168 const bool is_root = !layer->parent(); | 158 const bool is_root = !layer->parent(); |
| 169 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; | 159 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; |
| 170 const bool is_scrollable = layer->scrollable(); | 160 const bool is_scrollable = layer->scrollable(); |
| 171 const bool is_fixed = layer->position_constraint().is_fixed_position(); | 161 const bool is_fixed = layer->position_constraint().is_fixed_position(); |
| 172 | 162 |
| 173 const bool has_significant_transform = | 163 const bool has_significant_transform = |
| 174 !layer->transform().IsIdentityOr2DTranslation(); | 164 !layer->transform().IsIdentityOr2DTranslation(); |
| 175 | 165 |
| 176 const bool has_potentially_animated_transform = | 166 const bool has_potentially_animated_transform = |
| 177 HasPotentiallyRunningAnimation(layer, Animation::TRANSFORM); | 167 layer->HasPotentiallyRunningTransformAnimation(); |
| 178 | 168 const bool has_animated_transform = layer->TransformIsAnimating(); |
| 179 const bool has_animated_transform = | |
| 180 layer->layer_animation_controller()->IsAnimatingProperty( | |
| 181 Animation::TRANSFORM); | |
| 182 | 169 |
| 183 const bool has_surface = !!layer->render_surface(); | 170 const bool has_surface = !!layer->render_surface(); |
| 184 | 171 |
| 185 bool requires_node = is_root || is_scrollable || has_significant_transform || | 172 bool requires_node = is_root || is_scrollable || has_significant_transform || |
| 186 has_potentially_animated_transform || has_surface || | 173 has_potentially_animated_transform || has_surface || |
| 187 is_fixed || is_page_scale_layer; | 174 is_fixed || is_page_scale_layer; |
| 188 | 175 |
| 189 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); | 176 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); |
| 190 DCHECK_IMPLIES(!is_root, transform_parent); | 177 DCHECK_IMPLIES(!is_root, transform_parent); |
| 191 | 178 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 323 |
| 337 data_for_children->scroll_compensation_adjustment += | 324 data_for_children->scroll_compensation_adjustment += |
| 338 layer->ScrollCompensationAdjustment() - node->data.scroll_snap; | 325 layer->ScrollCompensationAdjustment() - node->data.scroll_snap; |
| 339 | 326 |
| 340 node->owner_id = layer->id(); | 327 node->owner_id = layer->id(); |
| 341 | 328 |
| 342 return true; | 329 return true; |
| 343 } | 330 } |
| 344 | 331 |
| 345 bool IsAnimatingOpacity(Layer* layer) { | 332 bool IsAnimatingOpacity(Layer* layer) { |
| 346 return HasPotentiallyRunningAnimation(layer, Animation::OPACITY) || | 333 return layer->HasPotentiallyRunningOpacityAnimation() || |
| 347 layer->OpacityCanAnimateOnImplThread(); | 334 layer->OpacityCanAnimateOnImplThread(); |
| 348 } | 335 } |
| 349 | 336 |
| 350 bool IsAnimatingOpacity(LayerImpl* layer) { | 337 bool IsAnimatingOpacity(LayerImpl* layer) { |
| 351 return HasPotentiallyRunningAnimation(layer, Animation::OPACITY); | 338 return layer->HasPotentiallyRunningOpacityAnimation(); |
| 352 } | 339 } |
| 353 | 340 |
| 354 template <typename LayerType> | 341 template <typename LayerType> |
| 355 void AddOpacityNodeIfNeeded( | 342 void AddOpacityNodeIfNeeded( |
| 356 const DataForRecursion<LayerType>& data_from_ancestor, | 343 const DataForRecursion<LayerType>& data_from_ancestor, |
| 357 LayerType* layer, | 344 LayerType* layer, |
| 358 DataForRecursion<LayerType>* data_for_children) { | 345 DataForRecursion<LayerType>* data_for_children) { |
| 359 const bool is_root = !layer->parent(); | 346 const bool is_root = !layer->parent(); |
| 360 const bool has_transparency = layer->opacity() != 1.f; | 347 const bool has_transparency = layer->opacity() != 1.f; |
| 361 const bool has_animated_opacity = IsAnimatingOpacity(layer); | 348 const bool has_animated_opacity = IsAnimatingOpacity(layer); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 const gfx::Rect& viewport, | 497 const gfx::Rect& viewport, |
| 511 const gfx::Transform& device_transform, | 498 const gfx::Transform& device_transform, |
| 512 PropertyTrees* property_trees) { | 499 PropertyTrees* property_trees) { |
| 513 BuildPropertyTreesTopLevelInternal( | 500 BuildPropertyTreesTopLevelInternal( |
| 514 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 501 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 515 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 502 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
| 516 viewport, device_transform, property_trees); | 503 viewport, device_transform, property_trees); |
| 517 } | 504 } |
| 518 | 505 |
| 519 } // namespace cc | 506 } // namespace cc |
| OLD | NEW |