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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 995953002: cc: Fix screen-space transform flattening in CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows build Created 5 years, 9 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
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0a51cccfc0b61706e26f37be82fb7f6ffd2afc85..6c0d1ae7117bb868fc983c44a7fea75f0e9fb1be 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -1478,6 +1478,74 @@ TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) {
}
}
+TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
+ // Render surfaces act as a flattening point for their subtree, so should
+ // always flatten the target-to-screen space transform seen by descendants.
+
+ scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> parent = Layer::Create();
+ scoped_refptr<LayerWithForcedDrawsContent> child =
+ make_scoped_refptr(new LayerWithForcedDrawsContent());
+ scoped_refptr<LayerWithForcedDrawsContent> grand_child =
+ make_scoped_refptr(new LayerWithForcedDrawsContent());
+
+ gfx::Transform rotation_about_y_axis;
+ rotation_about_y_axis.RotateAboutYAxis(30.0);
+ // Make |parent| have a render surface.
+ parent->SetOpacity(0.9f);
+
+ const gfx::Transform identity_matrix;
+ SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false);
+ SetLayerPropertiesForTesting(parent.get(), rotation_about_y_axis,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10),
+ true, false);
+ SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(10, 10), true, false);
+ SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10),
+ true, false);
+
+ root->AddChild(parent);
+ parent->AddChild(child);
+ child->AddChild(grand_child);
+
+ grand_child->SetShouldFlattenTransform(false);
+
+ scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
+ host->SetRootLayer(root);
+
+ // Only grand_child should preserve 3d.
+ EXPECT_TRUE(root->should_flatten_transform());
+ EXPECT_TRUE(parent->should_flatten_transform());
+ EXPECT_TRUE(child->should_flatten_transform());
+ EXPECT_FALSE(grand_child->should_flatten_transform());
+
+ gfx::Transform expected_child_draw_transform = identity_matrix;
+ gfx::Transform expected_grand_child_draw_transform = identity_matrix;
+
+ gfx::Transform flattened_rotation_about_y = rotation_about_y_axis;
+ flattened_rotation_about_y.FlattenTo2d();
+
+ ExecuteCalculateDrawProperties(root.get());
+
+ EXPECT_TRUE(parent->render_surface());
+ EXPECT_FALSE(child->render_surface());
+ EXPECT_FALSE(grand_child->render_surface());
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
+ grand_child->draw_transform());
+
+ // The screen-space transform inherited by |child| and |grand_child| should
+ // have been flattened at their render target. In particular, the fact that
+ // |grand_child| happens to preserve 3d shouldn't affect this flattening.
+ EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y,
+ child->screen_space_transform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y,
+ grand_child->screen_space_transform());
+}
+
TEST_F(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) {
// The entire subtree of layers that are outside the clip rect should be
// culled away, and should not affect the render_surface_layer_list.
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698