summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorweiliangc <weiliangc@chromium.org>2016-03-16 10:02:52 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-16 17:05:35 +0000
commite3f09a61b829898c3f7d2047d8d88603fef2b4b3 (patch)
tree09981f8c38a71ea8f00112aaaf5b2df823732b35 /cc
parent9616ceea5c37912b01fcef1f67eb3f9871b3f08a (diff)
downloadchromium_src-e3f09a61b829898c3f7d2047d8d88603fef2b4b3.zip
chromium_src-e3f09a61b829898c3f7d2047d8d88603fef2b4b3.tar.gz
chromium_src-e3f09a61b829898c3f7d2047d8d88603fef2b4b3.tar.bz2
cc: Make sure to set clip rect to empty on layers when needed
Accidentally didn't set clip rect to empty on previous clean up patch. Fix that and also add a unittest. R=ajuma BUG= CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1805703003 Cr-Commit-Position: refs/heads/master@{#381477}
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/draw_property_utils.cc2
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc135
2 files changed, 88 insertions, 49 deletions
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index 3849203..d31fb06 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -146,6 +146,8 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
if (!clip_rect_in_target_space.IsEmpty()) {
layer->set_clip_rect(clip_rect_in_target_space);
+ } else {
+ layer->set_clip_rect(gfx::Rect());
}
// The clip rect should be intersected with layer rect in target space.
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 67fa301..69821a3 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -1810,70 +1810,107 @@ TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectlyLayerImpl) {
false);
// Case 1: nothing is clipped except the root render surface.
- {
- ExecuteCalculateDrawProperties(root);
+ ExecuteCalculateDrawProperties(root);
- ASSERT_TRUE(root->render_surface());
- ASSERT_TRUE(child2->render_surface());
-
- EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(root->render_surface()->is_clipped());
- EXPECT_FALSE(parent->is_clipped());
- EXPECT_FALSE(child1->is_clipped());
- EXPECT_FALSE(child2->is_clipped());
- EXPECT_FALSE(child2->render_surface()->is_clipped());
- EXPECT_FALSE(grand_child->is_clipped());
- EXPECT_FALSE(leaf_node1->is_clipped());
- EXPECT_FALSE(leaf_node2->is_clipped());
- }
+ ASSERT_TRUE(root->render_surface());
+ ASSERT_TRUE(child2->render_surface());
+
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_FALSE(child2->is_clipped());
+ EXPECT_FALSE(child2->render_surface()->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_FALSE(leaf_node2->is_clipped());
// Case 2: parent masksToBounds, so the parent, child1, and child2's
// surface are clipped. But layers that contribute to child2's surface are
// not clipped explicitly because child2's surface already accounts for
// that clip.
- {
- parent->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
+ parent->SetMasksToBounds(true);
+ host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
+ ExecuteCalculateDrawProperties(root);
- ASSERT_TRUE(root->render_surface());
- ASSERT_TRUE(child2->render_surface());
+ ASSERT_TRUE(root->render_surface());
+ ASSERT_TRUE(child2->render_surface());
- EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(root->render_surface()->is_clipped());
- EXPECT_TRUE(parent->is_clipped());
- EXPECT_TRUE(child1->is_clipped());
- EXPECT_FALSE(child2->is_clipped());
- EXPECT_TRUE(child2->render_surface()->is_clipped());
- EXPECT_TRUE(grand_child->is_clipped());
- EXPECT_TRUE(leaf_node1->is_clipped());
- EXPECT_FALSE(leaf_node2->is_clipped());
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_TRUE(parent->is_clipped());
+ EXPECT_TRUE(child1->is_clipped());
+ EXPECT_FALSE(child2->is_clipped());
+ EXPECT_TRUE(child2->render_surface()->is_clipped());
+ EXPECT_TRUE(grand_child->is_clipped());
+ EXPECT_TRUE(leaf_node1->is_clipped());
+ EXPECT_FALSE(leaf_node2->is_clipped());
- parent->SetMasksToBounds(false);
- }
+ parent->SetMasksToBounds(false);
// Case 3: child2 masksToBounds. The layer and subtree are clipped, and
// child2's render surface is not clipped.
- {
- child2->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
+ child2->SetMasksToBounds(true);
+ host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
+ ExecuteCalculateDrawProperties(root);
- ASSERT_TRUE(root->render_surface());
- ASSERT_TRUE(child2->render_surface());
-
- EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(root->render_surface()->is_clipped());
- EXPECT_FALSE(parent->is_clipped());
- EXPECT_FALSE(child1->is_clipped());
- EXPECT_TRUE(child2->is_clipped());
- EXPECT_FALSE(child2->render_surface()->is_clipped());
- EXPECT_FALSE(grand_child->is_clipped());
- EXPECT_FALSE(leaf_node1->is_clipped());
- EXPECT_TRUE(leaf_node2->is_clipped());
- }
+ ASSERT_TRUE(root->render_surface());
+ ASSERT_TRUE(child2->render_surface());
+
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_TRUE(child2->is_clipped());
+ EXPECT_FALSE(child2->render_surface()->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_TRUE(leaf_node2->is_clipped());
+}
+
+TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) {
+ // Tests that when as long as layer is clipped, it's clip rect is set to
+ // correct value.
+ LayerImpl* root = root_layer();
+ LayerImpl* parent = AddChild<LayerImpl>(root);
+ LayerImpl* child = AddChild<LayerImpl>(parent);
+
+ root->SetDrawsContent(true);
+ parent->SetDrawsContent(true);
+ child->SetDrawsContent(true);
+
+ const gfx::Transform identity_matrix;
+
+ SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ true);
+ SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+ SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+ child->SetMasksToBounds(true);
+
+ ExecuteCalculateDrawProperties(root);
+
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_TRUE(child->is_clipped());
+ EXPECT_EQ(gfx::Rect(100, 100), child->clip_rect());
+
+ parent->SetMasksToBounds(true);
+ child->SetPosition(gfx::PointF(100, 100));
+ host_impl()->active_tree()->property_trees()->needs_rebuild = true;
+
+ ExecuteCalculateDrawProperties(root);
+
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(parent->is_clipped());
+ EXPECT_TRUE(child->is_clipped());
+ EXPECT_EQ(gfx::Rect(), child->clip_rect());
}
TEST_F(LayerTreeHostCommonTest, IsClippedWhenCannotRenderToSeparateSurface) {