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 bool axis_aligned_with_respect_to_parent = | 82 return !!layer->parent(); |
83 data.transform_tree->Are2DAxisAligned(layer->transform_tree_index(), | |
84 parent_transform_id); | |
85 | |
86 return !axis_aligned_with_respect_to_parent; | |
87 } | 83 } |
88 | 84 |
89 template <typename LayerType> | 85 template <typename LayerType> |
90 static bool LayerClipsSubtree(LayerType* layer) { | 86 static bool LayerClipsSubtree(LayerType* layer) { |
91 return layer->masks_to_bounds() || layer->mask_layer(); | 87 return layer->masks_to_bounds() || layer->mask_layer(); |
92 } | 88 } |
93 | 89 |
94 template <typename LayerType> | 90 template <typename LayerType> |
95 void AddClipNodeIfNeeded(const DataForRecursion<LayerType>& data_from_ancestor, | 91 void AddClipNodeIfNeeded(const DataForRecursion<LayerType>& data_from_ancestor, |
96 LayerType* layer, | 92 LayerType* layer, |
(...skipping 18 matching lines...) Expand all Loading... |
115 data_for_children->ancestor_clips_subtree = ancestor_clips_subtree; | 111 data_for_children->ancestor_clips_subtree = ancestor_clips_subtree; |
116 } | 112 } |
117 | 113 |
118 if (LayerClipsSubtree(layer)) | 114 if (LayerClipsSubtree(layer)) |
119 data_for_children->ancestor_clips_subtree = true; | 115 data_for_children->ancestor_clips_subtree = true; |
120 | 116 |
121 if (has_unclipped_surface) | 117 if (has_unclipped_surface) |
122 parent_id = 0; | 118 parent_id = 0; |
123 | 119 |
124 if (!RequiresClipNode(layer, data_from_ancestor, parent->data.transform_id, | 120 if (!RequiresClipNode(layer, data_from_ancestor, parent->data.transform_id, |
125 data_for_children->ancestor_clips_subtree)) { | 121 ancestor_clips_subtree)) { |
126 // Unclipped surfaces reset the clip rect. | 122 // Unclipped surfaces reset the clip rect. |
127 data_for_children->clip_tree_parent = parent_id; | 123 data_for_children->clip_tree_parent = parent_id; |
128 } else { | 124 } else { |
129 LayerType* transform_parent = data_for_children->transform_tree_parent; | 125 LayerType* transform_parent = data_for_children->transform_tree_parent; |
130 if (layer->position_constraint().is_fixed_position() && | 126 if (layer->position_constraint().is_fixed_position() && |
131 !created_transform_node) { | 127 !created_transform_node) { |
132 transform_parent = data_for_children->transform_fixed_parent; | 128 transform_parent = data_for_children->transform_fixed_parent; |
133 } | 129 } |
134 ClipNode node; | 130 ClipNode node; |
135 node.data.clip = gfx::RectF( | 131 node.data.clip = gfx::RectF( |
136 gfx::PointF() + layer->offset_to_transform_parent(), layer->bounds()); | 132 gfx::PointF() + layer->offset_to_transform_parent(), layer->bounds()); |
137 node.data.transform_id = transform_parent->transform_tree_index(); | 133 node.data.transform_id = transform_parent->transform_tree_index(); |
138 node.data.target_id = | 134 node.data.target_id = |
139 data_for_children->render_target->transform_tree_index(); | 135 data_for_children->render_target->transform_tree_index(); |
140 node.owner_id = layer->id(); | 136 node.owner_id = layer->id(); |
141 | 137 node.data.inherit_parent_target_space_clip = |
| 138 !data_for_children->ancestor_clips_subtree && |
| 139 layer->has_render_surface() && ancestor_clips_subtree; |
142 data_for_children->clip_tree_parent = | 140 data_for_children->clip_tree_parent = |
143 data_for_children->clip_tree->Insert(node, parent_id); | 141 data_for_children->clip_tree->Insert(node, parent_id); |
144 } | 142 } |
145 | 143 |
146 layer->SetClipTreeIndex( | 144 layer->SetClipTreeIndex( |
147 has_unclipped_surface ? 0 : data_for_children->clip_tree_parent); | 145 has_unclipped_surface ? 0 : data_for_children->clip_tree_parent); |
148 | 146 |
149 layer->set_is_clipped(data_for_children->ancestor_clips_subtree); | 147 layer->set_is_clipped(data_for_children->ancestor_clips_subtree); |
150 | 148 |
151 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the | 149 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 const gfx::Rect& viewport, | 504 const gfx::Rect& viewport, |
507 const gfx::Transform& device_transform, | 505 const gfx::Transform& device_transform, |
508 PropertyTrees* property_trees) { | 506 PropertyTrees* property_trees) { |
509 BuildPropertyTreesTopLevelInternal( | 507 BuildPropertyTreesTopLevelInternal( |
510 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 508 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
511 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 509 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
512 viewport, device_transform, property_trees); | 510 viewport, device_transform, property_trees); |
513 } | 511 } |
514 | 512 |
515 } // namespace cc | 513 } // namespace cc |
OLD | NEW |