Chromium Code Reviews| Index: cc/trees/draw_property_utils.cc |
| diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc |
| index 39456bc83bad09fa3d57a8c91b645147a4f29e5d..fe464365fb6d2922de0cdf514273bf721fd265c9 100644 |
| --- a/cc/trees/draw_property_utils.cc |
| +++ b/cc/trees/draw_property_utils.cc |
| @@ -57,7 +57,6 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list, |
| success = transform_tree.ComputeTransformWithDestinationSublayerScale( |
| clip_transform_node->id, target_node->id, &clip_to_target); |
| } |
| - |
| if (target_node->id > clip_node->data.transform_id) { |
| if (!success) { |
| DCHECK(target_node->data.to_screen_is_animated); |
| @@ -390,6 +389,7 @@ void ComputeClips(ClipTree* clip_tree, const TransformTree& transform_tree) { |
| // clip adjusted due to intersecting with an ancestor clip. |
| const bool is_clipped = clip_node->parent_id > 0; |
| if (!is_clipped) { |
| + DCHECK(!clip_node->data.inherit_parent_target_space_clip); |
| clip_node->data.combined_clip = clip_node->data.clip; |
| continue; |
| } |
| @@ -411,6 +411,8 @@ void ComputeClips(ClipTree* clip_tree, const TransformTree& transform_tree) { |
| gfx::Transform parent_to_target; |
| gfx::Transform clip_to_target; |
| gfx::Transform target_to_clip; |
| + gfx::Transform parent_to_transform_target; |
| + gfx::Transform transform_target_to_target; |
| const bool target_is_root_surface = clip_node->data.target_id == 1; |
| // When the target is the root surface, we need to include the root |
| @@ -419,8 +421,21 @@ void ComputeClips(ClipTree* clip_tree, const TransformTree& transform_tree) { |
| target_is_root_surface ? 0 : clip_node->data.target_id; |
| bool success = true; |
| - if (parent_transform_node->data.content_target_id == |
| - clip_node->data.target_id) { |
| + // When render surface applies clip, we need the clip from the target's |
| + // target space. But, as the combined clip is in parent clip's target |
| + // space, we need to first transform it from parent's target space to |
| + // target's target space. |
| + if (clip_node->data.inherit_parent_target_space_clip) { |
| + success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| + parent_transform_node->id, transform_node->data.target_id, |
| + &parent_to_transform_target); |
| + success &= transform_tree.ComputeTransformWithSourceSublayerScale( |
|
ajuma
2015/08/06 14:25:45
ComputeTransformWithSourceSublayerScale can divide
jaydasika
2015/08/06 16:39:34
Done.
|
| + transform_node->data.target_id, target_id, |
| + &transform_target_to_target); |
| + transform_target_to_target.Scale(transform_node->data.sublayer_scale.x(), |
| + transform_node->data.sublayer_scale.y()); |
| + } else if (parent_transform_node->data.content_target_id == |
| + clip_node->data.target_id) { |
| parent_to_target = parent_transform_node->data.to_target; |
| } else { |
| success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| @@ -444,25 +459,51 @@ void ComputeClips(ClipTree* clip_tree, const TransformTree& transform_tree) { |
| // If we can't compute a transform, it's because we had to use the inverse |
| // of a singular transform. We won't draw in this case, so there's no need |
| // to compute clips. |
| - if (!success) |
| + if (!success) { |
| continue; |
| + } |
| // In order to intersect with as small a rect as possible, we do a |
| // preliminary clip in target space so that when we project back, there's |
| // less likelihood of intersecting the view plane. |
| - gfx::RectF inherited_clip_in_target_space = MathUtil::MapClippedRect( |
| - parent_to_target, parent_clip_node->data.combined_clip); |
| + gfx::RectF inherited_clip_in_target_space; |
| + if (clip_node->data.inherit_parent_target_space_clip) { |
| + gfx::RectF combined_clip_in_transform_target_space; |
| + if (parent_transform_node->id > transform_node->data.target_id) |
| + combined_clip_in_transform_target_space = MathUtil::MapClippedRect( |
| + parent_to_transform_target, parent_clip_node->data.combined_clip); |
| + else |
| + combined_clip_in_transform_target_space = MathUtil::ProjectClippedRect( |
| + parent_to_transform_target, parent_clip_node->data.combined_clip); |
| + inherited_clip_in_target_space = MathUtil::ProjectClippedRect( |
| + transform_target_to_target, combined_clip_in_transform_target_space); |
| + } else if (parent_transform_node->id > target_id) { |
| + inherited_clip_in_target_space = MathUtil::MapClippedRect( |
| + parent_to_target, parent_clip_node->data.combined_clip); |
| + } else { |
| + inherited_clip_in_target_space = MathUtil::ProjectClippedRect( |
| + parent_to_target, parent_clip_node->data.combined_clip); |
| + } |
| - gfx::RectF clip_in_target_space = |
| - MathUtil::MapClippedRect(clip_to_target, clip_node->data.clip); |
| + // When render surface applies clip, the layer that created the clip node |
|
ajuma
2015/08/06 14:25:45
s/applies clip/inherits its parent's target space
jaydasika
2015/08/06 16:39:34
Done.
|
| + // doesn't apply any clip. So, we should clip using the clip value |
|
ajuma
2015/08/06 14:25:45
Do you mean "we shouldn't clip" instead? (Since in
jaydasika
2015/08/06 16:39:34
Done.
|
| + // stored in the clip node. |
| + gfx::RectF intersected_in_target_space; |
| + if (!clip_node->data.inherit_parent_target_space_clip) { |
| + gfx::RectF clip_in_target_space = |
| + MathUtil::MapClippedRect(clip_to_target, clip_node->data.clip); |
| - gfx::RectF intersected_in_target_space = gfx::IntersectRects( |
| - inherited_clip_in_target_space, clip_in_target_space); |
| + intersected_in_target_space = gfx::IntersectRects( |
| + inherited_clip_in_target_space, clip_in_target_space); |
| + } else { |
| + intersected_in_target_space = inherited_clip_in_target_space; |
| + } |
| clip_node->data.combined_clip = MathUtil::ProjectClippedRect( |
| target_to_clip, intersected_in_target_space); |
| - clip_node->data.combined_clip.Intersect(clip_node->data.clip); |
| + if (!clip_node->data.inherit_parent_target_space_clip) |
| + clip_node->data.combined_clip.Intersect(clip_node->data.clip); |
| } |
| clip_tree->set_needs_update(false); |
| } |