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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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') | cc/trees/layer_tree_host_impl.h » ('j') | 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 d2c473e23d155fb143cda9b20cec2da08ba2a8f3..dd797d5b68ed09ac30015992a85dc7d74c9c465d 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -1006,6 +1006,8 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
scoped_refptr<Layer> child = Layer::Create();
scoped_refptr<LayerWithForcedDrawsContent> grand_child =
make_scoped_refptr(new LayerWithForcedDrawsContent());
+ scoped_refptr<LayerWithForcedDrawsContent> great_grand_child =
+ make_scoped_refptr(new LayerWithForcedDrawsContent());
gfx::Transform rotation_about_y_axis;
rotation_about_y_axis.RotateAboutYAxis(30.0);
@@ -1032,9 +1034,13 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
gfx::Size(10, 10),
true,
false);
+ SetLayerPropertiesForTesting(great_grand_child.get(), identity_matrix,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10),
+ true, false);
root->AddChild(child);
child->AddChild(grand_child);
+ grand_child->AddChild(great_grand_child);
child->SetForceRenderSurface(true);
scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
@@ -1044,6 +1050,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
ASSERT_TRUE(root->should_flatten_transform());
ASSERT_TRUE(child->should_flatten_transform());
ASSERT_TRUE(grand_child->should_flatten_transform());
+ ASSERT_TRUE(great_grand_child->should_flatten_transform());
gfx::Transform expected_child_draw_transform = rotation_about_y_axis;
gfx::Transform expected_child_screen_space_transform = rotation_about_y_axis;
@@ -1053,6 +1060,10 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
flattened_rotation_about_y.FlattenTo2d();
gfx::Transform expected_grand_child_screen_space_transform =
flattened_rotation_about_y * rotation_about_y_axis;
+ gfx::Transform expected_great_grand_child_draw_transform =
+ flattened_rotation_about_y;
+ gfx::Transform expected_great_grand_child_screen_space_transform =
+ flattened_rotation_about_y * flattened_rotation_about_y;
ExecuteCalculateDrawProperties(root.get());
@@ -1070,6 +1081,11 @@ TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
grand_child->draw_transform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
grand_child->screen_space_transform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform,
+ great_grand_child->draw_transform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ expected_great_grand_child_screen_space_transform,
+ great_grand_child->screen_space_transform());
}
TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) {
@@ -7015,6 +7031,27 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
EXPECT_EQ(2u, render_surface_layer_list.size());
+
+ int count_represents_target_render_surface = 0;
+ int count_represents_contributing_render_surface = 0;
+ int count_represents_itself = 0;
+ auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list);
+ for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list);
+ it != end; ++it) {
+ if (it.represents_target_render_surface())
+ count_represents_target_render_surface++;
+ if (it.represents_contributing_render_surface())
+ count_represents_contributing_render_surface++;
+ if (it.represents_itself())
+ count_represents_itself++;
+ }
+
+ // Two render surfaces.
+ EXPECT_EQ(2, count_represents_target_render_surface);
+ // Second render surface contributes to root render surface.
+ EXPECT_EQ(1, count_represents_contributing_render_surface);
+ // All 4 layers represent itself.
+ EXPECT_EQ(4, count_represents_itself);
}
{
@@ -7025,6 +7062,27 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
EXPECT_EQ(1u, render_surface_layer_list.size());
+
+ int count_represents_target_render_surface = 0;
+ int count_represents_contributing_render_surface = 0;
+ int count_represents_itself = 0;
+ auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list);
+ for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list);
+ it != end; ++it) {
+ if (it.represents_target_render_surface())
+ count_represents_target_render_surface++;
+ if (it.represents_contributing_render_surface())
+ count_represents_contributing_render_surface++;
+ if (it.represents_itself())
+ count_represents_itself++;
+ }
+
+ // Only root layer has a render surface.
+ EXPECT_EQ(1, count_represents_target_render_surface);
+ // No layer contributes a render surface to root render surface.
+ EXPECT_EQ(0, count_represents_contributing_render_surface);
+ // All 4 layers represent itself.
+ EXPECT_EQ(4, count_represents_itself);
}
}
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698