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