Index: cc/trees/draw_property_utils.cc |
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc |
index 175c33415100440aa966860f8d6a576a48d6f30e..26feaf1c0c738c0946962d8f6dbbf87b042eb558 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); |
@@ -388,6 +387,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; |
} |
@@ -409,6 +409,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 |
@@ -417,8 +419,19 @@ 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.ComputeTransformWithDestinationSublayerScale( |
+ transform_node->data.target_id, target_id, |
+ &transform_target_to_target); |
+ } 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( |
@@ -442,25 +455,57 @@ 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) { |
+ if (clip_node->data.inherit_parent_target_space_clip) { |
+ clip_node->data.transform_id = parent_clip_node->data.transform_id; |
ajuma
2015/08/05 13:51:09
I don't think we should be changing the transform
jaydasika
2015/08/05 15:07:20
Ah, I see the problem. But I am still not sure wha
ajuma
2015/08/05 15:21:58
If we reach this point, we have an uninvertible tr
jaydasika
2015/08/05 21:50:11
Done.
|
+ clip_node->data.combined_clip = parent_clip_node->data.combined_clip; |
+ } else { |
+ clip_node->data.combined_clip = clip_node->data.clip; |
+ } |
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 |
+ // doesn't apply any clip. So, we should clip using the clip value |
+ // 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); |
} |