| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Without a new render surface, layer clipping state from ancestors needs | 132 // Without a new render surface, layer clipping state from ancestors needs |
| 133 // to continue to propagate. | 133 // to continue to propagate. |
| 134 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; | 134 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; |
| 135 layers_are_clipped = ancestor_clips_subtree; | 135 layers_are_clipped = ancestor_clips_subtree; |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool layer_clips_subtree = LayerClipsSubtree(layer); | 138 bool layer_clips_subtree = LayerClipsSubtree(layer); |
| 139 if (layer_clips_subtree) | 139 if (layer_clips_subtree) |
| 140 layers_are_clipped = true; | 140 layers_are_clipped = true; |
| 141 | 141 |
| 142 // Without surfaces, all non-viewport clips have to be applied using layer |
| 143 // clipping. |
| 144 bool layers_are_clipped_when_surfaces_disabled = |
| 145 layer_clips_subtree || |
| 146 parent->data.layers_are_clipped_when_surfaces_disabled; |
| 147 |
| 142 bool applies_clip = | 148 bool applies_clip = |
| 143 AppliesClip(layer, data_from_ancestor, ancestor_clips_subtree); | 149 AppliesClip(layer, data_from_ancestor, ancestor_clips_subtree); |
| 144 bool parent_applies_clip = !parent->data.resets_clip; | 150 bool parent_applies_clip = !parent->data.resets_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) { |
| 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 17 matching lines...) Expand all Loading... |
| 183 } else { | 191 } else { |
| 184 // Otherwise, we're either unclipped, or exist only in order to apply our | 192 // Otherwise, we're either unclipped, or exist only in order to apply our |
| 185 // parent's clips in our space. | 193 // parent's clips in our space. |
| 186 node.data.layer_clipping_uses_only_local_clip = false; | 194 node.data.layer_clipping_uses_only_local_clip = false; |
| 187 } | 195 } |
| 188 | 196 |
| 189 node.data.applies_local_clip = layer_clips_subtree; | 197 node.data.applies_local_clip = layer_clips_subtree; |
| 190 node.data.resets_clip = has_unclipped_surface; | 198 node.data.resets_clip = has_unclipped_surface; |
| 191 node.data.target_is_clipped = data_for_children->target_is_clipped; | 199 node.data.target_is_clipped = data_for_children->target_is_clipped; |
| 192 node.data.layers_are_clipped = layers_are_clipped; | 200 node.data.layers_are_clipped = layers_are_clipped; |
| 201 node.data.layers_are_clipped_when_surfaces_disabled = |
| 202 layers_are_clipped_when_surfaces_disabled; |
| 193 | 203 |
| 194 data_for_children->clip_tree_parent = | 204 data_for_children->clip_tree_parent = |
| 195 data_for_children->clip_tree->Insert(node, parent_id); | 205 data_for_children->clip_tree->Insert(node, parent_id); |
| 196 } | 206 } |
| 197 | 207 |
| 198 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); | 208 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
| 199 | 209 |
| 200 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the | 210 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the |
| 201 // clip for all children since we may need to draw. We need to figure out a | 211 // clip for all children since we may need to draw. We need to figure out a |
| 202 // better way, since we will need both the clipped and unclipped versions. | 212 // 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... |
| 609 const gfx::Rect& viewport, | 619 const gfx::Rect& viewport, |
| 610 const gfx::Transform& device_transform, | 620 const gfx::Transform& device_transform, |
| 611 PropertyTrees* property_trees) { | 621 PropertyTrees* property_trees) { |
| 612 BuildPropertyTreesTopLevelInternal( | 622 BuildPropertyTreesTopLevelInternal( |
| 613 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 623 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 614 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 624 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
| 615 viewport, device_transform, property_trees); | 625 viewport, device_transform, property_trees); |
| 616 } | 626 } |
| 617 | 627 |
| 618 } // namespace cc | 628 } // namespace cc |
| OLD | NEW |