From 0b41eafc7e1265b86c8be6f559e1d33a31b3621f Mon Sep 17 00:00:00 2001 From: weiliangc Date: Mon, 14 Mar 2016 14:35:56 -0700 Subject: cc: Correctly inherit clip parent's clip in target space When a clip is created by a render surface, it uses only parent clip. When this render surface doesn't apply clip, this clip node should inherit parent clip's |clip_in_target_space| adjusted to current target space. R=ajuma BUG=594675 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1802753002 Cr-Commit-Position: refs/heads/master@{#381080} --- cc/trees/draw_property_utils.cc | 9 +++++---- cc/trees/layer_tree_host_common_unittest.cc | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc index 85bf5d7..3849203 100644 --- a/cc/trees/draw_property_utils.cc +++ b/cc/trees/draw_property_utils.cc @@ -530,6 +530,8 @@ void ComputeClips(ClipTree* clip_tree, // clip node's target space. gfx::RectF parent_combined_clip_in_target_space = parent_clip_node->data.combined_clip_in_target_space; + gfx::RectF parent_clip_in_target_space = + parent_clip_node->data.clip_in_target_space; if (parent_clip_node->data.target_id != clip_node->data.target_id && non_root_surfaces_enabled) { success &= transform_tree.ComputeTransformWithDestinationSublayerScale( @@ -548,6 +550,8 @@ void ComputeClips(ClipTree* clip_tree, parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( parent_to_current, parent_clip_node->data.combined_clip_in_target_space); + parent_clip_in_target_space = MathUtil::ProjectClippedRect( + parent_to_current, parent_clip_node->data.clip_in_target_space); } // Only nodes affected by ancestor clips will have their clip adjusted due // to intersecting with an ancestor clip. But, we still need to propagate @@ -579,8 +583,7 @@ void ComputeClips(ClipTree* clip_tree, clip_node->data.clip_in_target_space = parent_clip_node->data.clip_in_target_space; } else if (!clip_node->data.target_is_clipped) { - clip_node->data.clip_in_target_space = - parent_combined_clip_in_target_space; + clip_node->data.clip_in_target_space = parent_clip_in_target_space; } else { // Render Surface applies clip and the owning layer itself applies // no clip. So, clip_in_target_space is not used and hence we can set @@ -615,8 +618,6 @@ void ComputeClips(ClipTree* clip_tree, : !parent_clip_node->data .layers_are_clipped_when_surfaces_disabled; if (!layer_clipping_uses_only_local_clip) { - gfx::RectF parent_clip_in_target_space = MathUtil::ProjectClippedRect( - parent_to_current, parent_clip_node->data.clip_in_target_space); clip_node->data.clip_in_target_space = gfx::IntersectRects( parent_clip_in_target_space, source_clip_in_target_space); } else { diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 6ca96ee..19aff44 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -9326,8 +9326,8 @@ TEST_F(LayerTreeHostCommonTest, EXPECT_TRUE(test_layer->is_clipped()); EXPECT_FALSE(test_layer->render_target()->render_surface()->is_clipped()); - EXPECT_EQ(gfx::Rect(-2, -2, 28, 28), test_layer->clip_rect()); - EXPECT_EQ(gfx::Rect(26, 26), test_layer->drawable_content_rect()); + EXPECT_EQ(gfx::Rect(-2, -2, 30, 30), test_layer->clip_rect()); + EXPECT_EQ(gfx::Rect(28, 28), test_layer->drawable_content_rect()); } TEST_F(LayerTreeHostCommonTest, -- cgit v1.1