| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 template <typename LayerType> | 51 template <typename LayerType> |
| 52 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, | 52 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, |
| 53 LayerType* layer) { | 53 LayerType* layer) { |
| 54 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); | 54 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); |
| 55 const int id = inherits_clip ? data.clip_tree_parent | 55 const int id = inherits_clip ? data.clip_tree_parent |
| 56 : layer->clip_parent()->clip_tree_index(); | 56 : layer->clip_parent()->clip_tree_index(); |
| 57 return data.clip_tree->Node(id); | 57 return data.clip_tree->Node(id); |
| 58 } | 58 } |
| 59 | 59 |
| 60 template <typename LayerType> | 60 template <typename LayerType> |
| 61 static bool HasPotentiallyRunningAnimation(LayerType* layer, | |
| 62 Animation::TargetProperty property) { | |
| 63 if (Animation* animation = | |
| 64 layer->layer_animation_controller()->GetAnimation(property)) { | |
| 65 return !animation->is_finished(); | |
| 66 } | |
| 67 return false; | |
| 68 } | |
| 69 | |
| 70 template <typename LayerType> | |
| 71 static bool RequiresClipNode(LayerType* layer, | 61 static bool RequiresClipNode(LayerType* layer, |
| 72 const DataForRecursion<LayerType>& data, | 62 const DataForRecursion<LayerType>& data, |
| 73 int parent_transform_id, | 63 int parent_transform_id, |
| 74 bool is_clipped) { | 64 bool is_clipped) { |
| 75 const bool render_surface_applies_clip = | 65 const bool render_surface_applies_clip = |
| 76 layer->render_surface() && is_clipped; | 66 layer->render_surface() && is_clipped; |
| 77 const bool render_surface_may_grow_due_to_clip_children = | 67 const bool render_surface_may_grow_due_to_clip_children = |
| 78 layer->render_surface() && layer->num_unclipped_descendants() > 0; | 68 layer->render_surface() && layer->num_unclipped_descendants() > 0; |
| 79 | 69 |
| 80 if (!layer->parent() || layer->masks_to_bounds() || layer->mask_layer() || | 70 if (!layer->parent() || layer->masks_to_bounds() || layer->mask_layer() || |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const bool is_root = !layer->parent(); | 154 const bool is_root = !layer->parent(); |
| 165 const bool is_page_scale_application_layer = | 155 const bool is_page_scale_application_layer = |
| 166 layer->parent() && layer->parent() == data_from_ancestor.page_scale_layer; | 156 layer->parent() && layer->parent() == data_from_ancestor.page_scale_layer; |
| 167 const bool is_scrollable = layer->scrollable(); | 157 const bool is_scrollable = layer->scrollable(); |
| 168 const bool is_fixed = layer->position_constraint().is_fixed_position(); | 158 const bool is_fixed = layer->position_constraint().is_fixed_position(); |
| 169 | 159 |
| 170 const bool has_significant_transform = | 160 const bool has_significant_transform = |
| 171 !layer->transform().IsIdentityOr2DTranslation(); | 161 !layer->transform().IsIdentityOr2DTranslation(); |
| 172 | 162 |
| 173 const bool has_potentially_animated_transform = | 163 const bool has_potentially_animated_transform = |
| 174 HasPotentiallyRunningAnimation(layer, Animation::TRANSFORM); | 164 layer->HasPotentiallyRunningTransformAnimation(); |
| 175 | 165 const bool has_animated_transform = layer->TransformIsAnimating(); |
| 176 const bool has_animated_transform = | |
| 177 layer->layer_animation_controller()->IsAnimatingProperty( | |
| 178 Animation::TRANSFORM); | |
| 179 | 166 |
| 180 const bool has_surface = !!layer->render_surface(); | 167 const bool has_surface = !!layer->render_surface(); |
| 181 | 168 |
| 182 bool requires_node = is_root || is_scrollable || has_significant_transform || | 169 bool requires_node = is_root || is_scrollable || has_significant_transform || |
| 183 has_potentially_animated_transform || has_surface || | 170 has_potentially_animated_transform || has_surface || |
| 184 is_page_scale_application_layer; | 171 is_page_scale_application_layer; |
| 185 | 172 |
| 186 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); | 173 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); |
| 187 | 174 |
| 188 int parent_index = 0; | 175 int parent_index = 0; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 287 |
| 301 data_for_children->scroll_compensation_adjustment += | 288 data_for_children->scroll_compensation_adjustment += |
| 302 layer->ScrollCompensationAdjustment() - node->data.scroll_snap; | 289 layer->ScrollCompensationAdjustment() - node->data.scroll_snap; |
| 303 | 290 |
| 304 node->owner_id = layer->id(); | 291 node->owner_id = layer->id(); |
| 305 | 292 |
| 306 return true; | 293 return true; |
| 307 } | 294 } |
| 308 | 295 |
| 309 bool IsAnimatingOpacity(Layer* layer) { | 296 bool IsAnimatingOpacity(Layer* layer) { |
| 310 return HasPotentiallyRunningAnimation(layer, Animation::OPACITY) || | 297 return layer->HasPotentiallyRunningOpacityAnimation() || |
| 311 layer->OpacityCanAnimateOnImplThread(); | 298 layer->OpacityCanAnimateOnImplThread(); |
| 312 } | 299 } |
| 313 | 300 |
| 314 bool IsAnimatingOpacity(LayerImpl* layer) { | 301 bool IsAnimatingOpacity(LayerImpl* layer) { |
| 315 return HasPotentiallyRunningAnimation(layer, Animation::OPACITY); | 302 return layer->HasPotentiallyRunningOpacityAnimation(); |
| 316 } | 303 } |
| 317 | 304 |
| 318 template <typename LayerType> | 305 template <typename LayerType> |
| 319 void AddOpacityNodeIfNeeded( | 306 void AddOpacityNodeIfNeeded( |
| 320 const DataForRecursion<LayerType>& data_from_ancestor, | 307 const DataForRecursion<LayerType>& data_from_ancestor, |
| 321 LayerType* layer, | 308 LayerType* layer, |
| 322 DataForRecursion<LayerType>* data_for_children) { | 309 DataForRecursion<LayerType>* data_for_children) { |
| 323 const bool is_root = !layer->parent(); | 310 const bool is_root = !layer->parent(); |
| 324 const bool has_transparency = layer->opacity() != 1.f; | 311 const bool has_transparency = layer->opacity() != 1.f; |
| 325 const bool has_animated_opacity = IsAnimatingOpacity(layer); | 312 const bool has_animated_opacity = IsAnimatingOpacity(layer); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 float device_scale_factor, | 432 float device_scale_factor, |
| 446 const gfx::Rect& viewport, | 433 const gfx::Rect& viewport, |
| 447 const gfx::Transform& device_transform, | 434 const gfx::Transform& device_transform, |
| 448 PropertyTrees* property_trees) { | 435 PropertyTrees* property_trees) { |
| 449 BuildPropertyTreesTopLevelInternal( | 436 BuildPropertyTreesTopLevelInternal( |
| 450 root_layer, page_scale_layer, page_scale_factor, device_scale_factor, | 437 root_layer, page_scale_layer, page_scale_factor, device_scale_factor, |
| 451 viewport, device_transform, property_trees); | 438 viewport, device_transform, property_trees); |
| 452 } | 439 } |
| 453 | 440 |
| 454 } // namespace cc | 441 } // namespace cc |
| OLD | NEW |