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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 217313003: Stop displaying layers with non-invertible transforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests. Created 6 years, 8 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 8d48cd69a658b0ebd1e53f1262b64c95428bd72a..241f020f554470cebfa374de842a3b802af69134 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -2942,6 +2942,9 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_TRUE(child->visible_content_rect().IsEmpty());
EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
+ // TODO(avallee): Cases 2, 3 comments no longer accurate. CSS spec days to
avallee 2014/04/15 18:53:26 What do you think of deleting these cases entirely
ajuma 2014/04/15 19:45:11 They're probably still worth keeping (with correct
+ // never draw objects with uninvertible transforms.
+
// Case 2: a matrix with flattened z, technically uninvertible but still
// drawable and visible. In this case, we must assume that the entire layer
// bounds are visible since there is no way to inverse-project the surface
@@ -2960,8 +2963,8 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root.get());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child->visible_content_rect());
- EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child->drawable_content_rect());
+ EXPECT_TRUE(child->visible_content_rect().IsEmpty());
+ EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
// Case 3: a matrix with flattened z, technically uninvertible but still
// drawable, but not visible. In this case, we don't need to conservatively
@@ -2982,7 +2985,7 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root.get());
EXPECT_TRUE(child->visible_content_rect().IsEmpty());
- EXPECT_RECT_EQ(gfx::Rect(505, 5, 50, 50), child->drawable_content_rect());
+ EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
}
TEST_F(LayerTreeHostCommonTest,
@@ -9138,6 +9141,70 @@ TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
EXPECT_TRUE(scroll_child->is_clipped());
}
+TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) {
+ scoped_refptr<LayerWithForcedDrawsContent> root =
+ make_scoped_refptr(new LayerWithForcedDrawsContent);
+ scoped_refptr<LayerWithForcedDrawsContent> parent =
+ make_scoped_refptr(new LayerWithForcedDrawsContent);
+ scoped_refptr<LayerWithForcedDrawsContent> child =
+ make_scoped_refptr(new LayerWithForcedDrawsContent);
+
+ root->AddChild(parent);
+ parent->AddChild(child);
+
+ gfx::Transform identity_transform;
+ SetLayerPropertiesForTesting(root.get(),
+ identity_transform,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(50, 50),
+ true,
+ true);
+ root->SetForceRenderSurface(true);
+ SetLayerPropertiesForTesting(parent.get(),
+ identity_transform,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(30, 30),
+ true,
+ true);
+ parent->SetForceRenderSurface(true);
+ SetLayerPropertiesForTesting(child.get(),
+ identity_transform,
+ gfx::PointF(),
+ gfx::PointF(),
+ gfx::Size(20, 20),
+ true,
+ true);
+ child->SetForceRenderSurface(true);
+
+ scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
+ host->SetRootLayer(root);
+
+ ExecuteCalculateDrawProperties(root.get());
+
+ EXPECT_EQ(3u, render_surface_layer_list()->size());
+
+ gfx::Transform singular_transform;
+ singular_transform.Scale3d(
+ SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0));
+
+ child->SetTransform(singular_transform);
+
+ ExecuteCalculateDrawProperties(root.get());
+
+ EXPECT_EQ(2u, render_surface_layer_list()->size());
+
+ // Ensure that the entire subtree under an layer with singular transform does
ajuma 2014/04/15 19:45:11 s/an/a
avallee 2014/04/16 18:20:56 Done.
+ // not get rendered.
+ parent->SetTransform(singular_transform);
+ child->SetTransform(identity_transform);
+
+ ExecuteCalculateDrawProperties(root.get());
+
+ EXPECT_EQ(1u, render_surface_layer_list()->size());
+}
+
TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) {
// Checks that clipping by a scroll parent that follows you in paint order
// still results in correct clipping.

Powered by Google App Engine
This is Rietveld 408576698