| 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/draw_property_utils.h" | 5 #include "cc/trees/draw_property_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 return ConditionalClip{false, gfx::RectF()}; | 259 return ConditionalClip{false, gfx::RectF()}; |
| 260 } | 260 } |
| 261 | 261 |
| 262 if (!include_clip_applied_by_target) { | 262 if (!include_clip_applied_by_target) { |
| 263 clip_node = parent_chain.top(); | 263 clip_node = parent_chain.top(); |
| 264 parent_chain.pop(); | 264 parent_chain.pop(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 // TODO(weiliangc): If we don't create clip for render surface, we don't need | 267 // TODO(weiliangc): If we don't create clip for render surface, we don't need |
| 268 // to check applies_local_clip. | 268 // to check applies_local_clip. |
| 269 while (!clip_node->applies_local_clip && parent_chain.size() > 0) { | 269 while (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP && |
| 270 parent_chain.size() > 0) { |
| 270 clip_node = parent_chain.top(); | 271 clip_node = parent_chain.top(); |
| 271 parent_chain.pop(); | 272 parent_chain.pop(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 if (!clip_node->applies_local_clip) | 275 if (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP) |
| 275 // No clip node applying clip in between. | 276 // No clip node applying clip in between. |
| 276 return ConditionalClip{false, gfx::RectF()}; | 277 return ConditionalClip{false, gfx::RectF()}; |
| 277 | 278 |
| 278 ConditionalClip current_clip = ComputeCurrentClip( | 279 ConditionalClip current_clip = ComputeCurrentClip( |
| 279 clip_node, property_trees, target_transform_id, target_id); | 280 clip_node, property_trees, target_transform_id, target_id); |
| 280 is_clipped = current_clip.is_clipped; | 281 is_clipped = current_clip.is_clipped; |
| 281 gfx::RectF accumulated_clip = current_clip.clip_rect; | 282 gfx::RectF accumulated_clip = current_clip.clip_rect; |
| 282 | 283 |
| 283 while (parent_chain.size() > 0) { | 284 while (parent_chain.size() > 0) { |
| 284 clip_node = parent_chain.top(); | 285 clip_node = parent_chain.top(); |
| 285 parent_chain.pop(); | 286 parent_chain.pop(); |
| 286 if (!clip_node->applies_local_clip) { | 287 if (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP) { |
| 287 continue; | 288 continue; |
| 288 } | 289 } |
| 289 ConditionalClip current_clip = ComputeCurrentClip( | 290 ConditionalClip current_clip = ComputeCurrentClip( |
| 290 clip_node, property_trees, target_transform_id, target_id); | 291 clip_node, property_trees, target_transform_id, target_id); |
| 291 | 292 |
| 292 // If transform is not invertible, no clip will be applied. | 293 // If transform is not invertible, no clip will be applied. |
| 293 if (!current_clip.is_clipped) | 294 if (!current_clip.is_clipped) |
| 294 return ConditionalClip{false, gfx::RectF()}; | 295 return ConditionalClip{false, gfx::RectF()}; |
| 295 | 296 |
| 296 is_clipped = true; | 297 is_clipped = true; |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 parent_to_current, parent_clip_node->combined_clip_in_target_space); | 850 parent_to_current, parent_clip_node->combined_clip_in_target_space); |
| 850 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 851 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 851 parent_to_current, parent_clip_node->clip_in_target_space); | 852 parent_to_current, parent_clip_node->clip_in_target_space); |
| 852 } | 853 } |
| 853 // Only nodes affected by ancestor clips will have their clip adjusted due | 854 // Only nodes affected by ancestor clips will have their clip adjusted due |
| 854 // to intersecting with an ancestor clip. But, we still need to propagate | 855 // to intersecting with an ancestor clip. But, we still need to propagate |
| 855 // the combined clip to our children because if they are clipped, they may | 856 // the combined clip to our children because if they are clipped, they may |
| 856 // need to clip using our parent clip and if we don't propagate it here, | 857 // need to clip using our parent clip and if we don't propagate it here, |
| 857 // it will be lost. | 858 // it will be lost. |
| 858 if (clip_node->resets_clip && non_root_surfaces_enabled) { | 859 if (clip_node->resets_clip && non_root_surfaces_enabled) { |
| 859 if (clip_node->applies_local_clip) { | 860 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) { |
| 860 clip_node->clip_in_target_space = MathUtil::MapClippedRect( | 861 clip_node->clip_in_target_space = MathUtil::MapClippedRect( |
| 861 transform_tree.ToTarget(clip_node->transform_id, | 862 transform_tree.ToTarget(clip_node->transform_id, |
| 862 clip_node->target_effect_id), | 863 clip_node->target_effect_id), |
| 863 clip_node->clip); | 864 clip_node->clip); |
| 864 ResetIfHasNanCoordinate(&clip_node->clip_in_target_space); | 865 ResetIfHasNanCoordinate(&clip_node->clip_in_target_space); |
| 865 clip_node->combined_clip_in_target_space = | 866 clip_node->combined_clip_in_target_space = |
| 866 gfx::IntersectRects(clip_node->clip_in_target_space, | 867 gfx::IntersectRects(clip_node->clip_in_target_space, |
| 867 parent_combined_clip_in_target_space); | 868 parent_combined_clip_in_target_space); |
| 868 } else { | 869 } else { |
| 869 DCHECK(!clip_node->target_is_clipped); | 870 DCHECK(!clip_node->target_is_clipped); |
| 870 DCHECK(!clip_node->layers_are_clipped); | 871 DCHECK(!clip_node->layers_are_clipped); |
| 871 clip_node->combined_clip_in_target_space = | 872 clip_node->combined_clip_in_target_space = |
| 872 parent_combined_clip_in_target_space; | 873 parent_combined_clip_in_target_space; |
| 873 } | 874 } |
| 874 ResetIfHasNanCoordinate(&clip_node->combined_clip_in_target_space); | 875 ResetIfHasNanCoordinate(&clip_node->combined_clip_in_target_space); |
| 875 continue; | 876 continue; |
| 876 } | 877 } |
| 877 bool use_only_parent_clip = !clip_node->applies_local_clip; | 878 bool use_only_parent_clip = |
| 879 clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP; |
| 878 if (use_only_parent_clip) { | 880 if (use_only_parent_clip) { |
| 879 clip_node->combined_clip_in_target_space = | 881 clip_node->combined_clip_in_target_space = |
| 880 parent_combined_clip_in_target_space; | 882 parent_combined_clip_in_target_space; |
| 881 if (!non_root_surfaces_enabled) { | 883 if (!non_root_surfaces_enabled) { |
| 882 clip_node->clip_in_target_space = | 884 clip_node->clip_in_target_space = |
| 883 parent_clip_node->clip_in_target_space; | 885 parent_clip_node->clip_in_target_space; |
| 884 } else if (!clip_node->target_is_clipped) { | 886 } else if (!clip_node->target_is_clipped) { |
| 885 clip_node->clip_in_target_space = parent_clip_in_target_space; | 887 clip_node->clip_in_target_space = parent_clip_in_target_space; |
| 886 } else { | 888 } else { |
| 887 // Render Surface applies clip and the owning layer itself applies | 889 // Render Surface applies clip and the owning layer itself applies |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1604 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1603 const Layer* overscroll_elasticity_layer, | 1605 const Layer* overscroll_elasticity_layer, |
| 1604 const gfx::Vector2dF& elastic_overscroll) { | 1606 const gfx::Vector2dF& elastic_overscroll) { |
| 1605 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1607 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1606 elastic_overscroll); | 1608 elastic_overscroll); |
| 1607 } | 1609 } |
| 1608 | 1610 |
| 1609 } // namespace draw_property_utils | 1611 } // namespace draw_property_utils |
| 1610 | 1612 |
| 1611 } // namespace cc | 1613 } // namespace cc |
| OLD | NEW |