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

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: Rebase 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/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 b808d71295a5cbd06470b8e6f8b7c2aced032265..2c859973114fd15a3a74db4e9b3f03a6800d5a22 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -6954,9 +6954,9 @@ TEST_F(LayerTreeHostCommonTest,
// This time, flattening does not make |animated|'s transform invertible. This
// means the clip cannot be projected into |surface|'s space, so we treat
- // |surface| and layers that draw into it as fully visible.
- EXPECT_EQ(gfx::Rect(100, 100), surface->visible_rect_from_property_trees());
- EXPECT_EQ(gfx::Rect(200, 200),
+ // |surface| and layers have empty visible rect.
ajuma 2015/08/06 14:25:46 "|surface| and layers that draw into it as having
jaydasika 2015/08/06 16:39:34 Done.
+ EXPECT_EQ(gfx::Rect(), surface->visible_rect_from_property_trees());
+ EXPECT_EQ(gfx::Rect(),
descendant_of_animation->visible_rect_from_property_trees());
}
@@ -7781,5 +7781,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());
ajuma 2015/08/06 14:25:45 Please compare to an actual value rather than to C
jaydasika 2015/08/06 16:39:34 Done.
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698