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