Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 const EffectTree& effect_tree) { | 82 const EffectTree& effect_tree) { |
| 83 const EffectNode* effect_node = effect_tree.Node(effect_tree_index); | 83 const EffectNode* effect_node = effect_tree.Node(effect_tree_index); |
| 84 return effect_node->render_surface ? effect_node | 84 return effect_node->render_surface ? effect_node |
| 85 : effect_tree.Node(effect_node->target_id); | 85 : effect_tree.Node(effect_node->target_id); |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool ComputeClipRectInTargetSpace(const LayerImpl* layer, | 88 bool ComputeClipRectInTargetSpace(const LayerImpl* layer, |
| 89 const ClipNode* clip_node, | 89 const ClipNode* clip_node, |
| 90 const PropertyTrees* property_trees, | 90 const PropertyTrees* property_trees, |
| 91 int target_node_id, | 91 int target_node_id, |
| 92 gfx::RectF* clip_rect_in_target_space) { | 92 gfx::RectF* clip_rect_in_target_space, |
| 93 bool use_combined_clip) { | |
|
weiliangc
2016/09/13 15:44:14
clip_rect_in_target_space is output of this functi
jaydasika
2016/09/13 17:17:56
Done.
| |
| 93 DCHECK(layer->clip_tree_index() == clip_node->id); | 94 DCHECK(layer->clip_tree_index() == clip_node->id); |
| 94 DCHECK(clip_node->target_transform_id != target_node_id); | 95 DCHECK(clip_node->target_transform_id != target_node_id); |
| 95 | 96 |
| 96 const EffectTree& effect_tree = property_trees->effect_tree; | 97 const EffectTree& effect_tree = property_trees->effect_tree; |
| 97 const EffectNode* target_effect_node = | 98 const EffectNode* target_effect_node = |
| 98 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); | 99 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); |
| 99 gfx::Transform clip_to_target; | 100 gfx::Transform clip_to_target; |
| 101 gfx::RectF clip_from_clip_node = | |
| 102 use_combined_clip ? clip_node->combined_clip_in_target_space | |
| 103 : clip_node->clip_in_target_space; | |
| 104 | |
| 100 if (clip_node->target_transform_id > target_node_id) { | 105 if (clip_node->target_transform_id > target_node_id) { |
| 101 // In this case, layer has a scroll parent. We need to keep the scale | 106 // In this case, layer has a scroll parent. We need to keep the scale |
| 102 // at the layer's target but remove the scale at the scroll parent's | 107 // at the layer's target but remove the scale at the scroll parent's |
| 103 // target. | 108 // target. |
| 104 if (property_trees->ComputeTransformToTarget(clip_node->target_transform_id, | 109 if (property_trees->ComputeTransformToTarget(clip_node->target_transform_id, |
| 105 target_effect_node->id, | 110 target_effect_node->id, |
| 106 &clip_to_target)) { | 111 &clip_to_target)) { |
| 107 // We don't have to apply surface contents scale when target is root. | 112 // We don't have to apply surface contents scale when target is root. |
| 108 if (target_effect_node->id != EffectTree::kContentsRootNodeId) { | 113 if (target_effect_node->id != EffectTree::kContentsRootNodeId) { |
| 109 PostConcatSurfaceContentsScale(target_effect_node, &clip_to_target); | 114 PostConcatSurfaceContentsScale(target_effect_node, &clip_to_target); |
| 110 #if DCHECK_IS_ON() | 115 #if DCHECK_IS_ON() |
| 111 const TransformTree& transform_tree = property_trees->transform_tree; | 116 const TransformTree& transform_tree = property_trees->transform_tree; |
| 112 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), | 117 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), |
| 113 target_node_id, effect_tree, | 118 target_node_id, effect_tree, |
| 114 transform_tree); | 119 transform_tree); |
| 115 #endif | 120 #endif |
| 116 } | 121 } |
| 117 | 122 |
| 118 const EffectNode* source_node = | 123 const EffectNode* source_node = |
| 119 effect_tree.Node(clip_node->target_effect_id); | 124 effect_tree.Node(clip_node->target_effect_id); |
| 120 ConcatInverseSurfaceContentsScale(source_node, &clip_to_target); | 125 ConcatInverseSurfaceContentsScale(source_node, &clip_to_target); |
| 121 #if DCHECK_IS_ON() | 126 #if DCHECK_IS_ON() |
| 122 const TransformTree& transform_tree = property_trees->transform_tree; | 127 const TransformTree& transform_tree = property_trees->transform_tree; |
| 123 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, | 128 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, |
| 124 clip_node->target_transform_id, | 129 clip_node->target_transform_id, |
| 125 effect_tree, transform_tree); | 130 effect_tree, transform_tree); |
| 126 #endif | 131 #endif |
| 127 *clip_rect_in_target_space = MathUtil::MapClippedRect( | 132 *clip_rect_in_target_space = |
| 128 clip_to_target, clip_node->clip_in_target_space); | 133 MathUtil::MapClippedRect(clip_to_target, clip_from_clip_node); |
| 129 } else { | 134 } else { |
| 130 return false; | 135 return false; |
| 131 } | 136 } |
| 132 } else { | 137 } else { |
| 133 if (property_trees->ComputeTransformFromTarget( | 138 if (property_trees->ComputeTransformFromTarget( |
| 134 target_node_id, clip_node->target_effect_id, &clip_to_target)) { | 139 target_node_id, clip_node->target_effect_id, &clip_to_target)) { |
| 135 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( | 140 *clip_rect_in_target_space = |
| 136 clip_to_target, clip_node->clip_in_target_space); | 141 MathUtil::ProjectClippedRect(clip_to_target, clip_from_clip_node); |
| 137 } else { | 142 } else { |
| 138 return false; | 143 return false; |
| 139 } | 144 } |
| 140 } | 145 } |
| 141 return true; | 146 return true; |
| 142 } | 147 } |
| 143 | 148 |
| 144 struct ConditionalClip { | 149 struct ConditionalClip { |
| 145 bool is_clipped; | 150 bool is_clipped; |
| 146 gfx::RectF clip_rect; | 151 gfx::RectF clip_rect; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 // If required, this clip rect should be mapped to the current layer's | 332 // If required, this clip rect should be mapped to the current layer's |
| 328 // target space. | 333 // target space. |
| 329 if (clip_node->target_transform_id != target_node_id) { | 334 if (clip_node->target_transform_id != target_node_id) { |
| 330 // In this case, layer has a clip parent or scroll parent (or shares the | 335 // In this case, layer has a clip parent or scroll parent (or shares the |
| 331 // target with an ancestor layer that has clip parent) and the clip | 336 // target with an ancestor layer that has clip parent) and the clip |
| 332 // parent's target is different from the layer's target. As the layer's | 337 // parent's target is different from the layer's target. As the layer's |
| 333 // target has unclippped descendants, it is unclippped. | 338 // target has unclippped descendants, it is unclippped. |
| 334 if (!clip_node->layers_are_clipped) | 339 if (!clip_node->layers_are_clipped) |
| 335 continue; | 340 continue; |
| 336 | 341 |
| 337 // Compute the clip rect in target space and store it. | 342 // Compute the clip rect in target space and store it. We don't use the |
| 338 if (!ComputeClipRectInTargetSpace(layer, clip_node, property_trees, | 343 // combined clip for calculating clip rects as we don't want to reapply |
| 339 target_node_id, | 344 // clips. |
| 340 &clip_rect_in_target_space)) | 345 bool use_combined_clip = false; |
|
weiliangc
2016/09/13 15:44:14
nit: I think this name might not be easy to unders
jaydasika
2016/09/13 17:17:56
Done.
| |
| 346 if (!ComputeClipRectInTargetSpace( | |
| 347 layer, clip_node, property_trees, target_node_id, | |
| 348 &clip_rect_in_target_space, use_combined_clip)) | |
| 341 continue; | 349 continue; |
| 342 } | 350 } |
| 343 | 351 |
| 344 if (!clip_rect_in_target_space.IsEmpty()) { | 352 if (!clip_rect_in_target_space.IsEmpty()) { |
| 345 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space)); | 353 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space)); |
| 346 } else { | 354 } else { |
| 347 layer->set_clip_rect(gfx::Rect()); | 355 layer->set_clip_rect(gfx::Rect()); |
| 348 } | 356 } |
| 349 } | 357 } |
| 350 } | 358 } |
| 351 } | 359 } |
| 352 | 360 |
| 353 bool GetLayerClipRect(const LayerImpl* layer, | |
| 354 const ClipNode* clip_node, | |
| 355 const PropertyTrees* property_trees, | |
| 356 int target_node_id, | |
| 357 gfx::RectF* clip_rect_in_target_space) { | |
| 358 // This is equivalent of calling ComputeClipRectInTargetSpace. | |
| 359 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect()); | |
| 360 return property_trees->transform_tree.Node(target_node_id) | |
| 361 ->ancestors_are_invertible; | |
| 362 } | |
| 363 | |
| 364 void CalculateVisibleRects(const LayerImplList& visible_layer_list, | 361 void CalculateVisibleRects(const LayerImplList& visible_layer_list, |
| 365 const PropertyTrees* property_trees, | 362 const PropertyTrees* property_trees, |
| 366 bool non_root_surfaces_enabled) { | 363 bool non_root_surfaces_enabled) { |
| 367 const EffectTree& effect_tree = property_trees->effect_tree; | 364 const EffectTree& effect_tree = property_trees->effect_tree; |
| 368 const TransformTree& transform_tree = property_trees->transform_tree; | 365 const TransformTree& transform_tree = property_trees->transform_tree; |
| 369 const ClipTree& clip_tree = property_trees->clip_tree; | 366 const ClipTree& clip_tree = property_trees->clip_tree; |
| 370 for (auto& layer : visible_layer_list) { | 367 for (auto& layer : visible_layer_list) { |
| 371 gfx::Size layer_bounds = layer->bounds(); | 368 gfx::Size layer_bounds = layer->bounds(); |
| 372 | 369 |
| 373 int effect_ancestor_with_copy_request = | 370 int effect_ancestor_with_copy_request = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 if (clip_node->target_transform_id != target_node_id) { | 446 if (clip_node->target_transform_id != target_node_id) { |
| 450 // In this case, layer has a clip parent or scroll parent (or shares the | 447 // In this case, layer has a clip parent or scroll parent (or shares the |
| 451 // target with an ancestor layer that has clip parent) and the clip | 448 // target with an ancestor layer that has clip parent) and the clip |
| 452 // parent's target is different from the layer's target. As the layer's | 449 // parent's target is different from the layer's target. As the layer's |
| 453 // target has unclippped descendants, it is unclippped. | 450 // target has unclippped descendants, it is unclippped. |
| 454 if (!clip_node->layers_are_clipped) { | 451 if (!clip_node->layers_are_clipped) { |
| 455 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 452 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 456 continue; | 453 continue; |
| 457 } | 454 } |
| 458 | 455 |
| 459 // We use the clip node's clip_in_target_space (and not | 456 bool use_combined_clip = true; |
| 460 // combined_clip_in_target_space) here because we want to clip | 457 if (!ComputeClipRectInTargetSpace( |
| 461 // with respect to clip parent's local clip and not its combined clip as | 458 layer, clip_node, property_trees, target_node_id, |
| 462 // the combined clip has even the clip parent's target's clip baked into | 459 &combined_clip_rect_in_target_space, use_combined_clip)) { |
| 463 // it and as our target is different, we don't want to use it in our | |
| 464 // visible rect computation. | |
| 465 if (!GetLayerClipRect(layer, clip_node, property_trees, target_node_id, | |
| 466 &combined_clip_rect_in_target_space)) { | |
| 467 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 460 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 468 continue; | 461 continue; |
| 469 } | 462 } |
| 470 } else { | 463 } else { |
| 471 combined_clip_rect_in_target_space = | 464 combined_clip_rect_in_target_space = |
| 472 clip_node->combined_clip_in_target_space; | 465 clip_node->combined_clip_in_target_space; |
| 473 } | 466 } |
| 474 | 467 |
| 475 // The clip rect should be intersected with layer rect in target space. | 468 // The clip rect should be intersected with layer rect in target space. |
| 476 gfx::Transform content_to_target = transform_tree.ToTarget( | 469 gfx::Transform content_to_target = transform_tree.ToTarget( |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1591 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1584 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1592 const Layer* overscroll_elasticity_layer, | 1585 const Layer* overscroll_elasticity_layer, |
| 1593 const gfx::Vector2dF& elastic_overscroll) { | 1586 const gfx::Vector2dF& elastic_overscroll) { |
| 1594 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1587 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1595 elastic_overscroll); | 1588 elastic_overscroll); |
| 1596 } | 1589 } |
| 1597 | 1590 |
| 1598 } // namespace draw_property_utils | 1591 } // namespace draw_property_utils |
| 1599 | 1592 |
| 1600 } // namespace cc | 1593 } // namespace cc |
| OLD | NEW |