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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 const bool render_surface_may_grow_due_to_clip_children = | 72 const bool render_surface_may_grow_due_to_clip_children = |
| 73 layer->render_surface() && layer->num_unclipped_descendants() > 0; | 73 layer->render_surface() && layer->num_unclipped_descendants() > 0; |
| 74 | 74 |
| 75 if (layer->masks_to_bounds() || layer->mask_layer() || | 75 if (layer->masks_to_bounds() || layer->mask_layer() || |
| 76 render_surface_may_grow_due_to_clip_children) | 76 render_surface_may_grow_due_to_clip_children) |
| 77 return true; | 77 return true; |
| 78 | 78 |
| 79 if (!render_surface_applies_clip) | 79 if (!render_surface_applies_clip) |
| 80 return false; | 80 return false; |
| 81 | 81 |
| 82 if (layer->parent()) | |
| 83 return true; | |
| 84 | |
| 82 bool axis_aligned_with_respect_to_parent = | 85 bool axis_aligned_with_respect_to_parent = |
|
ajuma
2015/08/05 13:51:09
Will this ever be true now? If we reach this point
jaydasika
2015/08/05 15:07:20
Done.
| |
| 83 data.transform_tree->Are2DAxisAligned(layer->transform_tree_index(), | 86 data.transform_tree->Are2DAxisAligned(layer->transform_tree_index(), |
| 84 parent_transform_id); | 87 parent_transform_id); |
| 85 | 88 |
| 86 return !axis_aligned_with_respect_to_parent; | 89 return !axis_aligned_with_respect_to_parent; |
| 87 } | 90 } |
| 88 | 91 |
| 89 template <typename LayerType> | 92 template <typename LayerType> |
| 90 static bool LayerClipsSubtree(LayerType* layer) { | 93 static bool LayerClipsSubtree(LayerType* layer) { |
| 91 return layer->masks_to_bounds() || layer->mask_layer(); | 94 return layer->masks_to_bounds() || layer->mask_layer(); |
| 92 } | 95 } |
| 93 | 96 |
| 94 template <typename LayerType> | 97 template <typename LayerType> |
| 95 void AddClipNodeIfNeeded(const DataForRecursion<LayerType>& data_from_ancestor, | 98 void AddClipNodeIfNeeded(const DataForRecursion<LayerType>& data_from_ancestor, |
| 96 LayerType* layer, | 99 LayerType* layer, |
| 97 bool created_transform_node, | 100 bool created_transform_node, |
| 98 DataForRecursion<LayerType>* data_for_children) { | 101 DataForRecursion<LayerType>* data_for_children) { |
| 99 ClipNode* parent = GetClipParent(data_from_ancestor, layer); | 102 ClipNode* parent = GetClipParent(data_from_ancestor, layer); |
| 100 int parent_id = parent->id; | 103 int parent_id = parent->id; |
| 101 | 104 |
| 102 bool ancestor_clips_subtree = | 105 bool ancestor_clips_subtree = |
| 103 data_from_ancestor.ancestor_clips_subtree || | 106 data_from_ancestor.ancestor_clips_subtree || |
| 104 (layer->clip_parent() && layer->clip_parent()->is_clipped()); | 107 (layer->clip_parent() && layer->clip_parent()->is_clipped()); |
| 105 | 108 |
| 106 data_for_children->ancestor_clips_subtree = false; | 109 data_for_children->ancestor_clips_subtree = false; |
| 107 bool has_unclipped_surface = false; | 110 bool has_unclipped_surface = false; |
| 111 bool use_clip_parent_for_layer = false; | |
| 108 | 112 |
| 109 if (layer->has_render_surface()) { | 113 if (layer->has_render_surface()) { |
| 110 if (ancestor_clips_subtree && layer->num_unclipped_descendants() > 0) | 114 if (ancestor_clips_subtree && layer->num_unclipped_descendants() > 0) |
| 111 data_for_children->ancestor_clips_subtree = true; | 115 data_for_children->ancestor_clips_subtree = true; |
| 112 else if (!ancestor_clips_subtree && !layer->num_unclipped_descendants()) | 116 else if (!ancestor_clips_subtree && !layer->num_unclipped_descendants()) |
| 113 has_unclipped_surface = true; | 117 has_unclipped_surface = true; |
| 114 } else { | 118 } else { |
| 115 data_for_children->ancestor_clips_subtree = ancestor_clips_subtree; | 119 data_for_children->ancestor_clips_subtree = ancestor_clips_subtree; |
| 116 } | 120 } |
| 117 | 121 |
| 118 if (LayerClipsSubtree(layer)) | 122 if (LayerClipsSubtree(layer)) |
| 119 data_for_children->ancestor_clips_subtree = true; | 123 data_for_children->ancestor_clips_subtree = true; |
| 120 | 124 |
| 121 if (has_unclipped_surface) | 125 if (has_unclipped_surface) |
| 122 parent_id = 0; | 126 parent_id = 0; |
| 123 | 127 |
| 124 if (!RequiresClipNode(layer, data_from_ancestor, parent->data.transform_id, | 128 if (!RequiresClipNode(layer, data_from_ancestor, parent->data.transform_id, |
| 125 data_for_children->ancestor_clips_subtree)) { | 129 ancestor_clips_subtree)) { |
| 126 // Unclipped surfaces reset the clip rect. | 130 // Unclipped surfaces reset the clip rect. |
| 127 data_for_children->clip_tree_parent = parent_id; | 131 data_for_children->clip_tree_parent = parent_id; |
| 128 } else { | 132 } else { |
| 129 LayerType* transform_parent = data_for_children->transform_tree_parent; | 133 LayerType* transform_parent = data_for_children->transform_tree_parent; |
| 130 if (layer->position_constraint().is_fixed_position() && | 134 if (layer->position_constraint().is_fixed_position() && |
| 131 !created_transform_node) { | 135 !created_transform_node) { |
| 132 transform_parent = data_for_children->transform_fixed_parent; | 136 transform_parent = data_for_children->transform_fixed_parent; |
| 133 } | 137 } |
| 134 ClipNode node; | 138 ClipNode node; |
| 135 node.data.clip = gfx::RectF( | 139 node.data.clip = gfx::RectF( |
| 136 gfx::PointF() + layer->offset_to_transform_parent(), layer->bounds()); | 140 gfx::PointF() + layer->offset_to_transform_parent(), layer->bounds()); |
| 137 node.data.transform_id = transform_parent->transform_tree_index(); | 141 node.data.transform_id = transform_parent->transform_tree_index(); |
| 138 node.data.target_id = | 142 node.data.target_id = |
| 139 data_for_children->render_target->transform_tree_index(); | 143 data_for_children->render_target->transform_tree_index(); |
| 140 node.owner_id = layer->id(); | 144 node.owner_id = layer->id(); |
| 141 | 145 node.data.inherit_parent_target_space_clip = |
| 146 !data_for_children->ancestor_clips_subtree && | |
| 147 layer->has_render_surface() && ancestor_clips_subtree; | |
| 148 if (node.data.inherit_parent_target_space_clip) | |
| 149 use_clip_parent_for_layer = true; | |
| 142 data_for_children->clip_tree_parent = | 150 data_for_children->clip_tree_parent = |
| 143 data_for_children->clip_tree->Insert(node, parent_id); | 151 data_for_children->clip_tree->Insert(node, parent_id); |
| 144 } | 152 } |
| 145 | 153 |
| 146 layer->SetClipTreeIndex( | 154 layer->SetClipTreeIndex( |
| 147 has_unclipped_surface ? 0 : data_for_children->clip_tree_parent); | 155 has_unclipped_surface ? 0 : data_for_children->clip_tree_parent); |
| 156 if (use_clip_parent_for_layer) | |
| 157 layer->SetClipTreeIndex(data_from_ancestor.clip_tree_parent); | |
| 148 | 158 |
| 149 layer->set_is_clipped(data_for_children->ancestor_clips_subtree); | 159 layer->set_is_clipped(data_for_children->ancestor_clips_subtree); |
| 150 | 160 |
| 151 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the | 161 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the |
| 152 // clip for all children since we may need to draw. We need to figure out a | 162 // clip for all children since we may need to draw. We need to figure out a |
| 153 // better way, since we will need both the clipped and unclipped versions. | 163 // better way, since we will need both the clipped and unclipped versions. |
| 154 } | 164 } |
| 155 | 165 |
| 156 template <typename LayerType> | 166 template <typename LayerType> |
| 157 bool AddTransformNodeIfNeeded( | 167 bool AddTransformNodeIfNeeded( |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 const gfx::Rect& viewport, | 510 const gfx::Rect& viewport, |
| 501 const gfx::Transform& device_transform, | 511 const gfx::Transform& device_transform, |
| 502 PropertyTrees* property_trees) { | 512 PropertyTrees* property_trees) { |
| 503 BuildPropertyTreesTopLevelInternal( | 513 BuildPropertyTreesTopLevelInternal( |
| 504 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 514 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 505 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 515 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
| 506 viewport, device_transform, property_trees); | 516 viewport, device_transform, property_trees); |
| 507 } | 517 } |
| 508 | 518 |
| 509 } // namespace cc | 519 } // namespace cc |
| OLD | NEW |