Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3175)

Unified Diff: cc/trees/draw_property_utils.cc

Issue 1252313004: Add ClipNode when Render Surface Inherits Clip (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Layout tests pass , unit test added , comments on patch 11 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..876645e1eed0e19221621dc02c8ef96682953546 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,22 @@ 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(
+ transform_node->data.target_id, target_id,
+ &transform_target_to_target);
+ transform_target_to_target.matrix().postScale(
+ transform_node->data.sublayer_scale.x(),
+ transform_node->data.sublayer_scale.y(), 1.0);
+ } 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 +460,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 inherits its parent target space clip, the layer
+ // that created the clip node doesn't apply any clip. So, we shouldn't 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);
}
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | cc/trees/layer_tree_host_common_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698