| 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 29 matching lines...) Expand all Loading... |
| 40 const LayerType* overscroll_elasticity_layer; | 40 const LayerType* overscroll_elasticity_layer; |
| 41 gfx::Vector2dF elastic_overscroll; | 41 gfx::Vector2dF elastic_overscroll; |
| 42 float page_scale_factor; | 42 float page_scale_factor; |
| 43 bool in_subtree_of_page_scale_layer; | 43 bool in_subtree_of_page_scale_layer; |
| 44 bool affected_by_inner_viewport_bounds_delta; | 44 bool affected_by_inner_viewport_bounds_delta; |
| 45 bool affected_by_outer_viewport_bounds_delta; | 45 bool affected_by_outer_viewport_bounds_delta; |
| 46 bool should_flatten; | 46 bool should_flatten; |
| 47 bool target_is_clipped; | 47 bool target_is_clipped; |
| 48 const gfx::Transform* device_transform; | 48 const gfx::Transform* device_transform; |
| 49 gfx::Vector2dF scroll_compensation_adjustment; | 49 gfx::Vector2dF scroll_compensation_adjustment; |
| 50 gfx::Transform compound_transform_since_render_target; | |
| 51 bool axis_align_since_render_target; | |
| 52 int sequence_number; | 50 int sequence_number; |
| 53 }; | 51 }; |
| 54 | 52 |
| 55 template <typename LayerType> | 53 template <typename LayerType> |
| 56 static LayerType* GetTransformParent(const DataForRecursion<LayerType>& data, | 54 static LayerType* GetTransformParent(const DataForRecursion<LayerType>& data, |
| 57 LayerType* layer) { | 55 LayerType* layer) { |
| 58 return layer->position_constraint().is_fixed_position() | 56 return layer->position_constraint().is_fixed_position() |
| 59 ? data.transform_fixed_parent | 57 ? data.transform_fixed_parent |
| 60 : data.transform_tree_parent; | 58 : data.transform_tree_parent; |
| 61 } | 59 } |
| 62 | 60 |
| 63 template <typename LayerType> | 61 template <typename LayerType> |
| 64 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, | 62 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, |
| 65 LayerType* layer) { | 63 LayerType* layer) { |
| 66 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); | 64 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); |
| 67 const int id = inherits_clip ? data.clip_tree_parent | 65 const int id = inherits_clip ? data.clip_tree_parent |
| 68 : layer->clip_parent()->clip_tree_index(); | 66 : layer->clip_parent()->clip_tree_index(); |
| 69 return data.clip_tree->Node(id); | 67 return data.clip_tree->Node(id); |
| 70 } | 68 } |
| 71 | 69 |
| 72 template <typename LayerType> | 70 template <typename LayerType> |
| 73 static bool AppliesClip(LayerType* layer, | 71 static bool AppliesClip(LayerType* layer, |
| 74 const DataForRecursion<LayerType>& data, | 72 const DataForRecursion<LayerType>& data, |
| 75 bool created_render_surface, | |
| 76 bool is_clipped) { | 73 bool is_clipped) { |
| 77 const bool render_surface_applies_clip = created_render_surface && is_clipped; | 74 const bool render_surface_applies_clip = |
| 75 layer->has_render_surface() && is_clipped; |
| 78 const bool render_surface_may_grow_due_to_clip_children = | 76 const bool render_surface_may_grow_due_to_clip_children = |
| 79 created_render_surface && layer->num_unclipped_descendants() > 0; | 77 layer->has_render_surface() && layer->num_unclipped_descendants() > 0; |
| 80 | 78 |
| 81 if (layer->masks_to_bounds() || layer->mask_layer() || | 79 if (layer->masks_to_bounds() || layer->mask_layer() || |
| 82 render_surface_may_grow_due_to_clip_children) | 80 render_surface_may_grow_due_to_clip_children) |
| 83 return true; | 81 return true; |
| 84 | 82 |
| 85 if (!render_surface_applies_clip) | 83 if (!render_surface_applies_clip) |
| 86 return false; | 84 return false; |
| 87 | 85 |
| 88 return true; | 86 return true; |
| 89 } | 87 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 int parent_id = parent->id; | 101 int parent_id = parent->id; |
| 104 | 102 |
| 105 bool is_root = !layer->parent(); | 103 bool is_root = !layer->parent(); |
| 106 | 104 |
| 107 // Whether we have an ancestor clip that we might need to apply. | 105 // Whether we have an ancestor clip that we might need to apply. |
| 108 bool ancestor_clips_subtree = is_root || parent->data.layers_are_clipped; | 106 bool ancestor_clips_subtree = is_root || parent->data.layers_are_clipped; |
| 109 | 107 |
| 110 bool layers_are_clipped = false; | 108 bool layers_are_clipped = false; |
| 111 bool has_unclipped_surface = false; | 109 bool has_unclipped_surface = false; |
| 112 | 110 |
| 113 if (created_render_surface) { | 111 if (layer->has_render_surface()) { |
| 114 // Clips can usually be applied to a surface's descendants simply by | 112 // Clips can usually be applied to a surface's descendants simply by |
| 115 // clipping the surface (or applied implicitly by the surface's bounds). | 113 // clipping the surface (or applied implicitly by the surface's bounds). |
| 116 // However, if the surface has unclipped descendants (layers that aren't | 114 // However, if the surface has unclipped descendants (layers that aren't |
| 117 // affected by the ancestor clip), we cannot clip the surface itself, and | 115 // affected by the ancestor clip), we cannot clip the surface itself, and |
| 118 // must instead apply clips to the clipped descendants. | 116 // must instead apply clips to the clipped descendants. |
| 119 if (ancestor_clips_subtree && layer->num_unclipped_descendants() > 0) { | 117 if (ancestor_clips_subtree && layer->num_unclipped_descendants() > 0) { |
| 120 layers_are_clipped = true; | 118 layers_are_clipped = true; |
| 121 } else if (!ancestor_clips_subtree) { | 119 } else if (!ancestor_clips_subtree) { |
| 122 // When there are no ancestor clips that need to be applied to a render | 120 // When there are no ancestor clips that need to be applied to a render |
| 123 // surface, we reset clipping state. The surface might contribute a clip | 121 // surface, we reset clipping state. The surface might contribute a clip |
| (...skipping 18 matching lines...) Expand all Loading... |
| 142 if (layer_clips_subtree) | 140 if (layer_clips_subtree) |
| 143 layers_are_clipped = true; | 141 layers_are_clipped = true; |
| 144 | 142 |
| 145 // Without surfaces, all non-viewport clips have to be applied using layer | 143 // Without surfaces, all non-viewport clips have to be applied using layer |
| 146 // clipping. | 144 // clipping. |
| 147 bool layers_are_clipped_when_surfaces_disabled = | 145 bool layers_are_clipped_when_surfaces_disabled = |
| 148 layer_clips_subtree || | 146 layer_clips_subtree || |
| 149 parent->data.layers_are_clipped_when_surfaces_disabled; | 147 parent->data.layers_are_clipped_when_surfaces_disabled; |
| 150 | 148 |
| 151 bool applies_clip = | 149 bool applies_clip = |
| 152 AppliesClip(layer, data_from_ancestor, created_render_surface, | 150 AppliesClip(layer, data_from_ancestor, ancestor_clips_subtree); |
| 153 ancestor_clips_subtree); | |
| 154 bool parent_applies_clip = !parent->data.resets_clip; | 151 bool parent_applies_clip = !parent->data.resets_clip; |
| 155 | 152 |
| 156 // When we have an unclipped surface, all ancestor clips no longer apply. | 153 // When we have an unclipped surface, all ancestor clips no longer apply. |
| 157 // However, if our parent already clears ancestor clips and applies no clip of | 154 // However, if our parent already clears ancestor clips and applies no clip of |
| 158 // its own, there aren't any ancestor clips that need clearing. | 155 // its own, there aren't any ancestor clips that need clearing. |
| 159 bool needs_to_clear_ancestor_clips = | 156 bool needs_to_clear_ancestor_clips = |
| 160 has_unclipped_surface && parent_applies_clip; | 157 has_unclipped_surface && parent_applies_clip; |
| 161 bool requires_node = applies_clip || needs_to_clear_ancestor_clips; | 158 bool requires_node = applies_clip || needs_to_clear_ancestor_clips; |
| 162 | 159 |
| 163 if (!requires_node) { | 160 if (!requires_node) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 178 node.data.transform_id = transform_parent->transform_tree_index(); | 175 node.data.transform_id = transform_parent->transform_tree_index(); |
| 179 node.data.target_id = | 176 node.data.target_id = |
| 180 data_for_children->effect_tree->Node(data_for_children->render_target) | 177 data_for_children->effect_tree->Node(data_for_children->render_target) |
| 181 ->data.transform_id; | 178 ->data.transform_id; |
| 182 node.owner_id = layer->id(); | 179 node.owner_id = layer->id(); |
| 183 | 180 |
| 184 if (ancestor_clips_subtree || layer_clips_subtree) { | 181 if (ancestor_clips_subtree || layer_clips_subtree) { |
| 185 // Surfaces reset the rect used for layer clipping. At other nodes, layer | 182 // Surfaces reset the rect used for layer clipping. At other nodes, layer |
| 186 // clipping state from ancestors must continue to get propagated. | 183 // clipping state from ancestors must continue to get propagated. |
| 187 node.data.layer_clipping_uses_only_local_clip = | 184 node.data.layer_clipping_uses_only_local_clip = |
| 188 created_render_surface || !ancestor_clips_subtree; | 185 layer->has_render_surface() || !ancestor_clips_subtree; |
| 189 } else { | 186 } else { |
| 190 // Otherwise, we're either unclipped, or exist only in order to apply our | 187 // Otherwise, we're either unclipped, or exist only in order to apply our |
| 191 // parent's clips in our space. | 188 // parent's clips in our space. |
| 192 node.data.layer_clipping_uses_only_local_clip = false; | 189 node.data.layer_clipping_uses_only_local_clip = false; |
| 193 } | 190 } |
| 194 | 191 |
| 195 node.data.applies_local_clip = layer_clips_subtree; | 192 node.data.applies_local_clip = layer_clips_subtree; |
| 196 node.data.resets_clip = has_unclipped_surface; | 193 node.data.resets_clip = has_unclipped_surface; |
| 197 node.data.target_is_clipped = data_for_children->target_is_clipped; | 194 node.data.target_is_clipped = data_for_children->target_is_clipped; |
| 198 node.data.layers_are_clipped = layers_are_clipped; | 195 node.data.layers_are_clipped = layers_are_clipped; |
| 199 node.data.layers_are_clipped_when_surfaces_disabled = | 196 node.data.layers_are_clipped_when_surfaces_disabled = |
| 200 layers_are_clipped_when_surfaces_disabled; | 197 layers_are_clipped_when_surfaces_disabled; |
| 201 | 198 |
| 202 data_for_children->clip_tree_parent = | 199 data_for_children->clip_tree_parent = |
| 203 data_for_children->clip_tree->Insert(node, parent_id); | 200 data_for_children->clip_tree->Insert(node, parent_id); |
| 204 } | 201 } |
| 205 | 202 |
| 206 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); | 203 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
| 204 |
| 207 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the | 205 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the |
| 208 // clip for all children since we may need to draw. We need to figure out a | 206 // clip for all children since we may need to draw. We need to figure out a |
| 209 // better way, since we will need both the clipped and unclipped versions. | 207 // better way, since we will need both the clipped and unclipped versions. |
| 210 } | 208 } |
| 211 | 209 |
| 212 template <typename LayerType> | 210 template <typename LayerType> |
| 213 bool AddTransformNodeIfNeeded( | 211 bool AddTransformNodeIfNeeded( |
| 214 const DataForRecursion<LayerType>& data_from_ancestor, | 212 const DataForRecursion<LayerType>& data_from_ancestor, |
| 215 LayerType* layer, | 213 LayerType* layer, |
| 216 bool created_render_surface, | 214 bool created_render_surface, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 228 const bool has_potentially_animated_transform = | 226 const bool has_potentially_animated_transform = |
| 229 layer->HasPotentiallyRunningTransformAnimation(); | 227 layer->HasPotentiallyRunningTransformAnimation(); |
| 230 | 228 |
| 231 // A transform node is needed even for a finished animation, since differences | 229 // A transform node is needed even for a finished animation, since differences |
| 232 // in the timing of animation state updates can mean that an animation that's | 230 // in the timing of animation state updates can mean that an animation that's |
| 233 // in the Finished state at tree-building time on the main thread is still in | 231 // in the Finished state at tree-building time on the main thread is still in |
| 234 // the Running state right after commit on the compositor thread. | 232 // the Running state right after commit on the compositor thread. |
| 235 const bool has_any_transform_animation = | 233 const bool has_any_transform_animation = |
| 236 layer->HasAnyAnimationTargetingProperty(Animation::TRANSFORM); | 234 layer->HasAnyAnimationTargetingProperty(Animation::TRANSFORM); |
| 237 | 235 |
| 238 const bool has_surface = created_render_surface; | 236 const bool has_surface = layer->has_render_surface(); |
| 239 | 237 |
| 240 bool requires_node = is_root || is_scrollable || has_significant_transform || | 238 bool requires_node = is_root || is_scrollable || has_significant_transform || |
| 241 has_any_transform_animation || has_surface || is_fixed || | 239 has_any_transform_animation || has_surface || is_fixed || |
| 242 is_page_scale_layer || is_overscroll_elasticity_layer; | 240 is_page_scale_layer || is_overscroll_elasticity_layer; |
| 243 | 241 |
| 244 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); | 242 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); |
| 245 DCHECK(is_root || transform_parent); | 243 DCHECK(is_root || transform_parent); |
| 246 | 244 |
| 247 int parent_index = kRootPropertyTreeNodeId; | 245 int parent_index = kRootPropertyTreeNodeId; |
| 248 if (transform_parent) | 246 if (transform_parent) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 bool IsAnimatingOpacity(Layer* layer) { | 424 bool IsAnimatingOpacity(Layer* layer) { |
| 427 return layer->HasPotentiallyRunningOpacityAnimation() || | 425 return layer->HasPotentiallyRunningOpacityAnimation() || |
| 428 layer->OpacityCanAnimateOnImplThread(); | 426 layer->OpacityCanAnimateOnImplThread(); |
| 429 } | 427 } |
| 430 | 428 |
| 431 bool IsAnimatingOpacity(LayerImpl* layer) { | 429 bool IsAnimatingOpacity(LayerImpl* layer) { |
| 432 return layer->HasPotentiallyRunningOpacityAnimation(); | 430 return layer->HasPotentiallyRunningOpacityAnimation(); |
| 433 } | 431 } |
| 434 | 432 |
| 435 template <typename LayerType> | 433 template <typename LayerType> |
| 436 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | |
| 437 return layer->Is3dSorted() && layer->parent() && | |
| 438 layer->parent()->Is3dSorted() && | |
| 439 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); | |
| 440 } | |
| 441 | |
| 442 template <typename LayerType> | |
| 443 bool ShouldCreateRenderSurface(LayerType* layer, | |
| 444 gfx::Transform current_transform, | |
| 445 bool axis_aligned) { | |
| 446 const bool preserves_2d_axis_alignment = | |
| 447 (current_transform * layer->transform()).Preserves2dAxisAlignment() && | |
| 448 axis_aligned && layer->AnimationsPreserveAxisAlignment(); | |
| 449 const bool is_root = !layer->parent(); | |
| 450 if (is_root) | |
| 451 return true; | |
| 452 | |
| 453 // If the layer uses a mask and the layer is not a replica layer. | |
| 454 // TODO(weiliangc): After slimming paint there won't be replica layers. | |
| 455 if (layer->mask_layer() && layer->parent()->replica_layer() != layer) { | |
| 456 return true; | |
| 457 } | |
| 458 | |
| 459 // If the layer has a reflection. | |
| 460 if (layer->replica_layer()) { | |
| 461 return true; | |
| 462 } | |
| 463 | |
| 464 // If the layer uses a CSS filter. | |
| 465 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { | |
| 466 return true; | |
| 467 } | |
| 468 | |
| 469 // If the layer will use a CSS filter. In this case, the animation | |
| 470 // will start and add a filter to this layer, so it needs a surface. | |
| 471 if (layer->HasPotentiallyRunningFilterAnimation()) { | |
| 472 return true; | |
| 473 } | |
| 474 | |
| 475 int num_descendants_that_draw_content = | |
| 476 layer->NumDescendantsThatDrawContent(); | |
| 477 | |
| 478 // If the layer flattens its subtree, but it is treated as a 3D object by its | |
| 479 // parent (i.e. parent participates in a 3D rendering context). | |
| 480 if (LayerIsInExisting3DRenderingContext(layer) && | |
| 481 layer->should_flatten_transform() && | |
| 482 num_descendants_that_draw_content > 0) { | |
| 483 TRACE_EVENT_INSTANT0( | |
| 484 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface flattening", | |
| 485 TRACE_EVENT_SCOPE_THREAD); | |
| 486 return true; | |
| 487 } | |
| 488 | |
| 489 // If the layer has blending. | |
| 490 // TODO(rosca): this is temporary, until blending is implemented for other | |
| 491 // types of quads than RenderPassDrawQuad. Layers having descendants that draw | |
| 492 // content will still create a separate rendering surface. | |
| 493 if (!layer->uses_default_blend_mode()) { | |
| 494 TRACE_EVENT_INSTANT0( | |
| 495 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface blending", | |
| 496 TRACE_EVENT_SCOPE_THREAD); | |
| 497 return true; | |
| 498 } | |
| 499 // If the layer clips its descendants but it is not axis-aligned with respect | |
| 500 // to its parent. | |
| 501 bool layer_clips_external_content = | |
| 502 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); | |
| 503 if (layer_clips_external_content && !preserves_2d_axis_alignment && | |
| 504 num_descendants_that_draw_content > 0) { | |
| 505 TRACE_EVENT_INSTANT0( | |
| 506 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface clipping", | |
| 507 TRACE_EVENT_SCOPE_THREAD); | |
| 508 return true; | |
| 509 } | |
| 510 | |
| 511 // If the layer has some translucency and does not have a preserves-3d | |
| 512 // transform style. This condition only needs a render surface if two or more | |
| 513 // layers in the subtree overlap. But checking layer overlaps is unnecessarily | |
| 514 // costly so instead we conservatively create a surface whenever at least two | |
| 515 // layers draw content for this subtree. | |
| 516 bool at_least_two_layers_in_subtree_draw_content = | |
| 517 num_descendants_that_draw_content > 0 && | |
| 518 (layer->DrawsContent() || num_descendants_that_draw_content > 1); | |
| 519 | |
| 520 if (layer->opacity() != 1.f && layer->should_flatten_transform() && | |
| 521 at_least_two_layers_in_subtree_draw_content) { | |
| 522 TRACE_EVENT_INSTANT0( | |
| 523 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface opacity", | |
| 524 TRACE_EVENT_SCOPE_THREAD); | |
| 525 DCHECK(!is_root); | |
| 526 return true; | |
| 527 } | |
| 528 // If the layer has isolation. | |
| 529 // TODO(rosca): to be optimized - create separate rendering surface only when | |
| 530 // the blending descendants might have access to the content behind this layer | |
| 531 // (layer has transparent background or descendants overflow). | |
| 532 // https://code.google.com/p/chromium/issues/detail?id=301738 | |
| 533 if (layer->is_root_for_isolated_group()) { | |
| 534 TRACE_EVENT_INSTANT0( | |
| 535 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation", | |
| 536 TRACE_EVENT_SCOPE_THREAD); | |
| 537 return true; | |
| 538 } | |
| 539 | |
| 540 // If we force it. | |
| 541 if (layer->force_render_surface()) | |
| 542 return true; | |
| 543 | |
| 544 // If we'll make a copy of the layer's contents. | |
| 545 if (layer->HasCopyRequest()) | |
| 546 return true; | |
| 547 | |
| 548 return false; | |
| 549 } | |
| 550 | |
| 551 template <typename LayerType> | |
| 552 bool AddEffectNodeIfNeeded( | 434 bool AddEffectNodeIfNeeded( |
| 553 const DataForRecursion<LayerType>& data_from_ancestor, | 435 const DataForRecursion<LayerType>& data_from_ancestor, |
| 554 LayerType* layer, | 436 LayerType* layer, |
| 555 DataForRecursion<LayerType>* data_for_children) { | 437 DataForRecursion<LayerType>* data_for_children) { |
| 556 const bool is_root = !layer->parent(); | 438 const bool is_root = !layer->parent(); |
| 557 const bool has_transparency = layer->opacity() != 1.f; | 439 const bool has_transparency = layer->opacity() != 1.f; |
| 558 const bool has_animated_opacity = IsAnimatingOpacity(layer); | 440 const bool has_animated_opacity = IsAnimatingOpacity(layer); |
| 559 const bool should_create_render_surface = ShouldCreateRenderSurface( | 441 const bool has_render_surface = layer->has_render_surface(); |
| 560 layer, data_from_ancestor.compound_transform_since_render_target, | 442 bool requires_node = |
| 561 data_from_ancestor.axis_align_since_render_target); | 443 is_root || has_transparency || has_animated_opacity || has_render_surface; |
| 562 data_for_children->axis_align_since_render_target &= | |
| 563 layer->AnimationsPreserveAxisAlignment(); | |
| 564 | |
| 565 bool requires_node = is_root || has_transparency || has_animated_opacity || | |
| 566 should_create_render_surface; | |
| 567 | 444 |
| 568 int parent_id = data_from_ancestor.effect_tree_parent; | 445 int parent_id = data_from_ancestor.effect_tree_parent; |
| 569 | 446 |
| 570 if (!requires_node) { | 447 if (!requires_node) { |
| 571 layer->SetEffectTreeIndex(parent_id); | 448 layer->SetEffectTreeIndex(parent_id); |
| 572 data_for_children->effect_tree_parent = parent_id; | 449 data_for_children->effect_tree_parent = parent_id; |
| 573 data_for_children->compound_transform_since_render_target *= | |
| 574 layer->transform(); | |
| 575 return false; | 450 return false; |
| 576 } | 451 } |
| 577 | 452 |
| 578 EffectNode node; | 453 EffectNode node; |
| 579 node.owner_id = layer->id(); | 454 node.owner_id = layer->id(); |
| 580 node.data.opacity = layer->opacity(); | 455 node.data.opacity = layer->opacity(); |
| 581 node.data.screen_space_opacity = layer->opacity(); | 456 node.data.screen_space_opacity = layer->opacity(); |
| 582 node.data.has_render_surface = should_create_render_surface; | 457 node.data.has_render_surface = has_render_surface; |
| 583 | |
| 584 if (!is_root) { | 458 if (!is_root) { |
| 585 // For every effect node, we create a transform node, so it's safe to use | 459 // For every effect node, we create a transform node, so it's safe to use |
| 586 // the next available id from the transform tree as this effect node's | 460 // the next available id from the transform tree as this effect node's |
| 587 // transform id. | 461 // transform id. |
| 588 node.data.transform_id = | 462 node.data.transform_id = |
| 589 data_from_ancestor.transform_tree->next_available_id(); | 463 data_from_ancestor.transform_tree->next_available_id(); |
| 590 node.data.clip_id = data_from_ancestor.clip_tree_parent; | 464 node.data.clip_id = data_from_ancestor.clip_tree_parent; |
| 591 | 465 |
| 592 node.data.screen_space_opacity *= | 466 node.data.screen_space_opacity *= |
| 593 data_from_ancestor.effect_tree->Node(parent_id) | 467 data_from_ancestor.effect_tree->Node(parent_id) |
| 594 ->data.screen_space_opacity; | 468 ->data.screen_space_opacity; |
| 595 } else { | 469 } else { |
| 596 // Root render surface acts the unbounded and untransformed to draw content | 470 // Root render surface acts the unbounded and untransformed to draw content |
| 597 // into. Transform node created from root layer (includes device scale | 471 // into. Transform node created from root layer (includes device scale |
| 598 // factor) and clip node created from root layer (include viewports) applies | 472 // factor) and clip node created from root layer (include viewports) applies |
| 599 // to root render surface's content, but not root render surface itself. | 473 // to root render surface's content, but not root render surface itself. |
| 600 node.data.transform_id = kRootPropertyTreeNodeId; | 474 node.data.transform_id = kRootPropertyTreeNodeId; |
| 601 node.data.clip_id = kRootPropertyTreeNodeId; | 475 node.data.clip_id = kRootPropertyTreeNodeId; |
| 602 } | 476 } |
| 603 data_for_children->effect_tree_parent = | 477 data_for_children->effect_tree_parent = |
| 604 data_for_children->effect_tree->Insert(node, parent_id); | 478 data_for_children->effect_tree->Insert(node, parent_id); |
| 605 layer->SetEffectTreeIndex(data_for_children->effect_tree_parent); | 479 layer->SetEffectTreeIndex(data_for_children->effect_tree_parent); |
| 606 if (should_create_render_surface) { | 480 return has_render_surface; |
| 607 data_for_children->compound_transform_since_render_target = | |
| 608 gfx::Transform(); | |
| 609 data_for_children->axis_align_since_render_target = true; | |
| 610 } | |
| 611 return should_create_render_surface; | |
| 612 } | 481 } |
| 613 | 482 |
| 614 template <typename LayerType> | 483 template <typename LayerType> |
| 615 void BuildPropertyTreesInternal( | 484 void BuildPropertyTreesInternal( |
| 616 LayerType* layer, | 485 LayerType* layer, |
| 617 const DataForRecursion<LayerType>& data_from_parent) { | 486 const DataForRecursion<LayerType>& data_from_parent) { |
| 618 layer->set_property_tree_sequence_number(data_from_parent.sequence_number); | 487 layer->set_property_tree_sequence_number(data_from_parent.sequence_number); |
| 619 DataForRecursion<LayerType> data_for_children(data_from_parent); | 488 DataForRecursion<LayerType> data_for_children(data_from_parent); |
| 620 | 489 |
| 621 bool created_render_surface = | 490 bool created_render_surface = |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 data_for_recursion.in_subtree_of_page_scale_layer = false; | 574 data_for_recursion.in_subtree_of_page_scale_layer = false; |
| 706 data_for_recursion.affected_by_inner_viewport_bounds_delta = false; | 575 data_for_recursion.affected_by_inner_viewport_bounds_delta = false; |
| 707 data_for_recursion.affected_by_outer_viewport_bounds_delta = false; | 576 data_for_recursion.affected_by_outer_viewport_bounds_delta = false; |
| 708 data_for_recursion.should_flatten = false; | 577 data_for_recursion.should_flatten = false; |
| 709 data_for_recursion.target_is_clipped = false; | 578 data_for_recursion.target_is_clipped = false; |
| 710 data_for_recursion.device_transform = &device_transform; | 579 data_for_recursion.device_transform = &device_transform; |
| 711 | 580 |
| 712 data_for_recursion.transform_tree->clear(); | 581 data_for_recursion.transform_tree->clear(); |
| 713 data_for_recursion.clip_tree->clear(); | 582 data_for_recursion.clip_tree->clear(); |
| 714 data_for_recursion.effect_tree->clear(); | 583 data_for_recursion.effect_tree->clear(); |
| 715 data_for_recursion.compound_transform_since_render_target = gfx::Transform(); | |
| 716 data_for_recursion.axis_align_since_render_target = true; | |
| 717 data_for_recursion.sequence_number = property_trees->sequence_number; | 584 data_for_recursion.sequence_number = property_trees->sequence_number; |
| 718 data_for_recursion.transform_tree->set_device_scale_factor( | 585 data_for_recursion.transform_tree->set_device_scale_factor( |
| 719 device_scale_factor); | 586 device_scale_factor); |
| 720 | 587 |
| 721 ClipNode root_clip; | 588 ClipNode root_clip; |
| 722 root_clip.data.resets_clip = true; | 589 root_clip.data.resets_clip = true; |
| 723 root_clip.data.applies_local_clip = true; | 590 root_clip.data.applies_local_clip = true; |
| 724 root_clip.data.clip = gfx::RectF(viewport); | 591 root_clip.data.clip = gfx::RectF(viewport); |
| 725 root_clip.data.transform_id = kRootPropertyTreeNodeId; | 592 root_clip.data.transform_id = kRootPropertyTreeNodeId; |
| 726 data_for_recursion.clip_tree_parent = | 593 data_for_recursion.clip_tree_parent = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 const gfx::Transform& device_transform, | 635 const gfx::Transform& device_transform, |
| 769 PropertyTrees* property_trees) { | 636 PropertyTrees* property_trees) { |
| 770 BuildPropertyTreesTopLevelInternal( | 637 BuildPropertyTreesTopLevelInternal( |
| 771 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 638 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 772 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 639 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 773 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 640 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 774 device_transform, property_trees); | 641 device_transform, property_trees); |
| 775 } | 642 } |
| 776 | 643 |
| 777 } // namespace cc | 644 } // namespace cc |
| OLD | NEW |