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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 // Without a new render surface, layer clipping state from ancestors needs | 131 // Without a new render surface, layer clipping state from ancestors needs |
132 // to continue to propagate. | 132 // to continue to propagate. |
133 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; | 133 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; |
134 layers_are_clipped = ancestor_clips_subtree; | 134 layers_are_clipped = ancestor_clips_subtree; |
135 } | 135 } |
136 | 136 |
137 bool layer_clips_subtree = LayerClipsSubtree(layer); | 137 bool layer_clips_subtree = LayerClipsSubtree(layer); |
138 if (layer_clips_subtree) | 138 if (layer_clips_subtree) |
139 layers_are_clipped = true; | 139 layers_are_clipped = true; |
140 | 140 |
141 // Without surfaces, all non-viewport clips have to be applied using layer | |
142 // clipping. | |
143 bool layers_are_clipped_when_surfaces_disabled = | |
144 layer_clips_subtree || | |
145 parent->data.layers_are_clipped_when_surfaces_disabled; | |
146 | |
141 bool applies_clip = | 147 bool applies_clip = |
142 AppliesClip(layer, data_from_ancestor, ancestor_clips_subtree); | 148 AppliesClip(layer, data_from_ancestor, ancestor_clips_subtree); |
143 bool parent_applies_clip = | 149 bool parent_applies_clip = |
144 !parent->data.resets_clip || parent->data.applies_local_clip; | 150 !parent->data.resets_clip || parent->data.applies_local_clip; |
145 | 151 |
146 // When we have an unclipped surface, all ancestor clips no longer apply. | 152 // When we have an unclipped surface, all ancestor clips no longer apply. |
147 // However, if our parent already clears ancestor clips and applies no clip of | 153 // However, if our parent already clears ancestor clips and applies no clip of |
148 // its own, there aren't any ancestor clips that need clearing. | 154 // its own, there aren't any ancestor clips that need clearing. |
149 bool needs_to_clear_ancestor_clips = | 155 bool needs_to_clear_ancestor_clips = |
150 has_unclipped_surface && parent_applies_clip; | 156 has_unclipped_surface && parent_applies_clip; |
151 bool requires_node = applies_clip || needs_to_clear_ancestor_clips; | 157 bool requires_node = applies_clip || needs_to_clear_ancestor_clips; |
152 | 158 |
153 if (!requires_node) { | 159 if (!requires_node) { |
jaydasika
2015/10/16 21:27:09
In the resourceless draw mode case, can we not jus
ajuma
2015/10/16 22:40:41
It's true that these are the only clips we have to
| |
154 data_for_children->clip_tree_parent = parent_id; | 160 data_for_children->clip_tree_parent = parent_id; |
155 DCHECK_EQ(layers_are_clipped, parent->data.layers_are_clipped); | 161 DCHECK_EQ(layers_are_clipped, parent->data.layers_are_clipped); |
162 DCHECK_EQ(layers_are_clipped_when_surfaces_disabled, | |
163 parent->data.layers_are_clipped_when_surfaces_disabled); | |
156 } else { | 164 } else { |
157 LayerType* transform_parent = data_for_children->transform_tree_parent; | 165 LayerType* transform_parent = data_for_children->transform_tree_parent; |
158 if (layer->position_constraint().is_fixed_position() && | 166 if (layer->position_constraint().is_fixed_position() && |
159 !created_transform_node) { | 167 !created_transform_node) { |
160 transform_parent = data_for_children->transform_fixed_parent; | 168 transform_parent = data_for_children->transform_fixed_parent; |
161 } | 169 } |
162 ClipNode node; | 170 ClipNode node; |
163 node.data.clip = | 171 node.data.clip = |
164 gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), | 172 gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), |
165 gfx::SizeF(layer->bounds())); | 173 gfx::SizeF(layer->bounds())); |
(...skipping 27 matching lines...) Expand all Loading... | |
193 // Otherwise, we're either unclipped, or exist only in order to apply our | 201 // Otherwise, we're either unclipped, or exist only in order to apply our |
194 // parent's clips in our space. | 202 // parent's clips in our space. |
195 node.data.applies_local_clip = false; | 203 node.data.applies_local_clip = false; |
196 node.data.layer_clipping_uses_only_local_clip = false; | 204 node.data.layer_clipping_uses_only_local_clip = false; |
197 node.data.layer_visibility_uses_only_local_clip = false; | 205 node.data.layer_visibility_uses_only_local_clip = false; |
198 } | 206 } |
199 | 207 |
200 node.data.resets_clip = has_unclipped_surface || !parent_applies_clip; | 208 node.data.resets_clip = has_unclipped_surface || !parent_applies_clip; |
201 node.data.target_is_clipped = data_for_children->target_is_clipped; | 209 node.data.target_is_clipped = data_for_children->target_is_clipped; |
202 node.data.layers_are_clipped = layers_are_clipped; | 210 node.data.layers_are_clipped = layers_are_clipped; |
211 node.data.layers_are_clipped_when_surfaces_disabled = | |
212 layers_are_clipped_when_surfaces_disabled; | |
203 | 213 |
204 data_for_children->clip_tree_parent = | 214 data_for_children->clip_tree_parent = |
205 data_for_children->clip_tree->Insert(node, parent_id); | 215 data_for_children->clip_tree->Insert(node, parent_id); |
206 } | 216 } |
207 | 217 |
208 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); | 218 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
209 | 219 |
210 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the | 220 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the |
211 // clip for all children since we may need to draw. We need to figure out a | 221 // clip for all children since we may need to draw. We need to figure out a |
212 // better way, since we will need both the clipped and unclipped versions. | 222 // better way, since we will need both the clipped and unclipped versions. |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 const gfx::Rect& viewport, | 629 const gfx::Rect& viewport, |
620 const gfx::Transform& device_transform, | 630 const gfx::Transform& device_transform, |
621 PropertyTrees* property_trees) { | 631 PropertyTrees* property_trees) { |
622 BuildPropertyTreesTopLevelInternal( | 632 BuildPropertyTreesTopLevelInternal( |
623 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 633 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
624 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 634 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
625 viewport, device_transform, property_trees); | 635 viewport, device_transform, property_trees); |
626 } | 636 } |
627 | 637 |
628 } // namespace cc | 638 } // namespace cc |
OLD | NEW |