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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1252313004: Add ClipNode when Render Surface Inherits Clip (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test easier to understand Created 5 years, 5 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/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index bc58bfd381f7acb48f857ce785e729516d60c21b..34ca241bcc925a323bc18c820f36638b35dc3045 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -8240,5 +8240,58 @@ TEST_F(LayerTreeHostCommonTest, ResetLayerDrawPropertiestest) {
EXPECT_FALSE(child->sorted_for_recursion());
}
+TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) {
+ // Ensure that a Clip Node is added when a render surface applies clip.
+ LayerImpl* root = root_layer();
+ LayerImpl* significant_transform = AddChildToRoot<LayerImpl>();
+ LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform);
+ LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree);
+ LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
+
+ const gfx::Transform identity_matrix;
+ // This transform should be a significant one so that a transform node is
+ // formed for it.
+ gfx::Transform transform1;
+ transform1.RotateAboutYAxis(45);
+ transform1.RotateAboutXAxis(30);
+ // This transform should be a 3d transform as we want the render surface
+ // to flatten the transform
+ gfx::Transform transform2;
+ transform2.Translate3d(10, 10, 10);
+
+ layer_clips_subtree->SetMasksToBounds(true);
+ test_layer->SetDrawsContent(true);
+
+ SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(30, 30), true, false,
+ true);
+ SetLayerPropertiesForTesting(significant_transform, transform1,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
+ true, false, false);
+ SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
+ true, false, false);
+ SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(30, 30), true, false,
+ true);
+ SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(30, 30), true, false,
+ false);
+
+ ExecuteCalculateDrawProperties(root);
+
+ TransformTree transform_tree =
+ root->layer_tree_impl()->property_trees()->transform_tree;
+ TransformNode* transform_node = transform_tree.Node(2);
+ EXPECT_EQ(transform_node->owner_id, significant_transform->id());
+
+ ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree;
+ ClipNode* clip_node = clip_tree.Node(3);
+ EXPECT_EQ(clip_node->owner_id, render_surface->id());
+ EXPECT_TRUE(clip_node->data.inherit_parent_target_space_clip);
+ EXPECT_EQ(test_layer->visible_rect_from_property_trees().ToString(),
+ test_layer->visible_layer_rect().ToString());
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698