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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2716733007: cc: Rename LayerImpl::render_surface to GetRenderSurface (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 parent->test_properties()->transform = parent_layer_transform; 736 parent->test_properties()->transform = parent_layer_transform;
737 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 30.f, 0.f); 737 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 30.f, 0.f);
738 parent->SetBounds(gfx::Size(100, 120)); 738 parent->SetBounds(gfx::Size(100, 120));
739 child->SetBounds(gfx::Size(16, 18)); 739 child->SetBounds(gfx::Size(16, 18));
740 child->test_properties()->force_render_surface = true; 740 child->test_properties()->force_render_surface = true;
741 grand_child->SetBounds(gfx::Size(8, 10)); 741 grand_child->SetBounds(gfx::Size(8, 10));
742 grand_child->SetDrawsContent(true); 742 grand_child->SetDrawsContent(true);
743 ExecuteCalculateDrawProperties(root); 743 ExecuteCalculateDrawProperties(root);
744 744
745 // Render surface should have been created now. 745 // Render surface should have been created now.
746 ASSERT_TRUE(child->render_surface()); 746 ASSERT_TRUE(child->GetRenderSurface());
747 ASSERT_EQ(child->render_surface(), child->render_target()); 747 ASSERT_EQ(child->GetRenderSurface(), child->render_target());
748 748
749 // The child layer's draw transform should refer to its new render surface. 749 // The child layer's draw transform should refer to its new render surface.
750 // The screen-space transform, however, should still refer to the root. 750 // The screen-space transform, however, should still refer to the root.
751 EXPECT_TRANSFORMATION_MATRIX_EQ(surface_sublayer_transform, 751 EXPECT_TRANSFORMATION_MATRIX_EQ(surface_sublayer_transform,
752 child->DrawTransform()); 752 child->DrawTransform());
753 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform, 753 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform,
754 child->ScreenSpaceTransform()); 754 child->ScreenSpaceTransform());
755 755
756 // Because the grand_child is the only drawable content, the child's render 756 // Because the grand_child is the only drawable content, the child's render
757 // surface will tighten its bounds to the grand_child. The scale at which the 757 // surface will tighten its bounds to the grand_child. The scale at which the
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); 921 grand_child_of_rs1->SetBounds(gfx::Size(10, 10));
922 grand_child_of_rs2->test_properties()->transform_origin = 922 grand_child_of_rs2->test_properties()->transform_origin =
923 gfx::Point3F(2.5f, 0.f, 0.f); 923 gfx::Point3F(2.5f, 0.f, 0.f);
924 grand_child_of_rs2->test_properties()->transform = layer_transform; 924 grand_child_of_rs2->test_properties()->transform = layer_transform;
925 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); 925 grand_child_of_rs2->SetBounds(gfx::Size(10, 10));
926 926
927 ExecuteCalculateDrawProperties(root); 927 ExecuteCalculateDrawProperties(root);
928 928
929 // Only layers that are associated with render surfaces should have an actual 929 // Only layers that are associated with render surfaces should have an actual
930 // RenderSurface() value. 930 // RenderSurface() value.
931 ASSERT_TRUE(root->render_surface()); 931 ASSERT_TRUE(root->GetRenderSurface());
932 ASSERT_FALSE(child_of_root->render_surface()); 932 ASSERT_FALSE(child_of_root->GetRenderSurface());
933 ASSERT_FALSE(grand_child_of_root->render_surface()); 933 ASSERT_FALSE(grand_child_of_root->GetRenderSurface());
934 934
935 ASSERT_TRUE(render_surface1->render_surface()); 935 ASSERT_TRUE(render_surface1->GetRenderSurface());
936 ASSERT_FALSE(child_of_rs1->render_surface()); 936 ASSERT_FALSE(child_of_rs1->GetRenderSurface());
937 ASSERT_FALSE(grand_child_of_rs1->render_surface()); 937 ASSERT_FALSE(grand_child_of_rs1->GetRenderSurface());
938 938
939 ASSERT_TRUE(render_surface2->render_surface()); 939 ASSERT_TRUE(render_surface2->GetRenderSurface());
940 ASSERT_FALSE(child_of_rs2->render_surface()); 940 ASSERT_FALSE(child_of_rs2->GetRenderSurface());
941 ASSERT_FALSE(grand_child_of_rs2->render_surface()); 941 ASSERT_FALSE(grand_child_of_rs2->GetRenderSurface());
942 942
943 // Verify all render target accessors 943 // Verify all render target accessors
944 EXPECT_EQ(root->render_surface(), parent->render_target()); 944 EXPECT_EQ(root->GetRenderSurface(), parent->render_target());
945 EXPECT_EQ(root->render_surface(), child_of_root->render_target()); 945 EXPECT_EQ(root->GetRenderSurface(), child_of_root->render_target());
946 EXPECT_EQ(root->render_surface(), grand_child_of_root->render_target()); 946 EXPECT_EQ(root->GetRenderSurface(), grand_child_of_root->render_target());
947 947
948 EXPECT_EQ(render_surface1->render_surface(), 948 EXPECT_EQ(render_surface1->GetRenderSurface(),
949 render_surface1->render_target()); 949 render_surface1->render_target());
950 EXPECT_EQ(render_surface1->render_surface(), child_of_rs1->render_target()); 950 EXPECT_EQ(render_surface1->GetRenderSurface(), child_of_rs1->render_target());
951 EXPECT_EQ(render_surface1->render_surface(), 951 EXPECT_EQ(render_surface1->GetRenderSurface(),
952 grand_child_of_rs1->render_target()); 952 grand_child_of_rs1->render_target());
953 953
954 EXPECT_EQ(render_surface2->render_surface(), 954 EXPECT_EQ(render_surface2->GetRenderSurface(),
955 render_surface2->render_target()); 955 render_surface2->render_target());
956 EXPECT_EQ(render_surface2->render_surface(), child_of_rs2->render_target()); 956 EXPECT_EQ(render_surface2->GetRenderSurface(), child_of_rs2->render_target());
957 EXPECT_EQ(render_surface2->render_surface(), 957 EXPECT_EQ(render_surface2->GetRenderSurface(),
958 grand_child_of_rs2->render_target()); 958 grand_child_of_rs2->render_target());
959 959
960 // Verify layer draw transforms note that draw transforms are described with 960 // Verify layer draw transforms note that draw transforms are described with
961 // respect to the nearest ancestor render surface but screen space transforms 961 // respect to the nearest ancestor render surface but screen space transforms
962 // are described with respect to the root. 962 // are described with respect to the root.
963 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->DrawTransform()); 963 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->DrawTransform());
964 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A, child_of_root->DrawTransform()); 964 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A, child_of_root->DrawTransform());
965 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A, 965 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A,
966 grand_child_of_root->DrawTransform()); 966 grand_child_of_root->DrawTransform());
967 967
(...skipping 25 matching lines...) Expand all
993 render_surface2->ScreenSpaceTransform()); 993 render_surface2->ScreenSpaceTransform());
994 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A, 994 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A,
995 child_of_rs2->ScreenSpaceTransform()); 995 child_of_rs2->ScreenSpaceTransform());
996 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A * A, 996 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A * A,
997 grand_child_of_rs2->ScreenSpaceTransform()); 997 grand_child_of_rs2->ScreenSpaceTransform());
998 998
999 // Verify render surface transforms. 999 // Verify render surface transforms.
1000 // 1000 //
1001 // Draw transform of render surface 1 is described with respect to root. 1001 // Draw transform of render surface 1 is described with respect to root.
1002 EXPECT_TRANSFORMATION_MATRIX_EQ( 1002 EXPECT_TRANSFORMATION_MATRIX_EQ(
1003 A * A * S1, render_surface1->render_surface()->draw_transform()); 1003 A * A * S1, render_surface1->GetRenderSurface()->draw_transform());
1004 EXPECT_TRANSFORMATION_MATRIX_EQ( 1004 EXPECT_TRANSFORMATION_MATRIX_EQ(
1005 A * A * S1, render_surface1->render_surface()->screen_space_transform()); 1005 A * A * S1,
1006 render_surface1->GetRenderSurface()->screen_space_transform());
1006 // Draw transform of render surface 2 is described with respect to render 1007 // Draw transform of render surface 2 is described with respect to render
1007 // surface 1. 1008 // surface 1.
1008 EXPECT_TRANSFORMATION_MATRIX_EQ( 1009 EXPECT_TRANSFORMATION_MATRIX_EQ(
1009 SS1 * A * S2, render_surface2->render_surface()->draw_transform()); 1010 SS1 * A * S2, render_surface2->GetRenderSurface()->draw_transform());
1010 EXPECT_TRANSFORMATION_MATRIX_EQ( 1011 EXPECT_TRANSFORMATION_MATRIX_EQ(
1011 A * A * A * S2, 1012 A * A * A * S2,
1012 render_surface2->render_surface()->screen_space_transform()); 1013 render_surface2->GetRenderSurface()->screen_space_transform());
1013 1014
1014 // Sanity check. If these fail there is probably a bug in the test itself. It 1015 // Sanity check. If these fail there is probably a bug in the test itself. It
1015 // is expected that we correctly set up transforms so that the y-component of 1016 // is expected that we correctly set up transforms so that the y-component of
1016 // the screen-space transform encodes the "depth" of the layer in the tree. 1017 // the screen-space transform encodes the "depth" of the layer in the tree.
1017 EXPECT_FLOAT_EQ(1.0, parent->ScreenSpaceTransform().matrix().get(1, 3)); 1018 EXPECT_FLOAT_EQ(1.0, parent->ScreenSpaceTransform().matrix().get(1, 3));
1018 EXPECT_FLOAT_EQ(2.0, 1019 EXPECT_FLOAT_EQ(2.0,
1019 child_of_root->ScreenSpaceTransform().matrix().get(1, 3)); 1020 child_of_root->ScreenSpaceTransform().matrix().get(1, 3));
1020 EXPECT_FLOAT_EQ( 1021 EXPECT_FLOAT_EQ(
1021 3.0, grand_child_of_root->ScreenSpaceTransform().matrix().get(1, 3)); 1022 3.0, grand_child_of_root->ScreenSpaceTransform().matrix().get(1, 3));
1022 1023
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 gfx::Transform expected_grand_child_screen_space_transform = 1074 gfx::Transform expected_grand_child_screen_space_transform =
1074 flattened_rotation_about_y * rotation_about_y_axis; 1075 flattened_rotation_about_y * rotation_about_y_axis;
1075 gfx::Transform expected_great_grand_child_draw_transform = 1076 gfx::Transform expected_great_grand_child_draw_transform =
1076 flattened_rotation_about_y; 1077 flattened_rotation_about_y;
1077 gfx::Transform expected_great_grand_child_screen_space_transform = 1078 gfx::Transform expected_great_grand_child_screen_space_transform =
1078 flattened_rotation_about_y * flattened_rotation_about_y; 1079 flattened_rotation_about_y * flattened_rotation_about_y;
1079 1080
1080 ExecuteCalculateDrawProperties(root); 1081 ExecuteCalculateDrawProperties(root);
1081 1082
1082 // The child's draw transform should have been taken by its surface. 1083 // The child's draw transform should have been taken by its surface.
1083 ASSERT_TRUE(child->render_surface()); 1084 ASSERT_TRUE(child->GetRenderSurface());
1084 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_draw_transform, 1085 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_draw_transform,
1085 child->render_surface()->draw_transform()); 1086 child->GetRenderSurface()->draw_transform());
1086 EXPECT_TRANSFORMATION_MATRIX_EQ( 1087 EXPECT_TRANSFORMATION_MATRIX_EQ(
1087 expected_child_screen_space_transform, 1088 expected_child_screen_space_transform,
1088 child->render_surface()->screen_space_transform()); 1089 child->GetRenderSurface()->screen_space_transform());
1089 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); 1090 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform());
1090 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_screen_space_transform, 1091 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_screen_space_transform,
1091 child->ScreenSpaceTransform()); 1092 child->ScreenSpaceTransform());
1092 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_draw_transform, 1093 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_draw_transform,
1093 grand_child->DrawTransform()); 1094 grand_child->DrawTransform());
1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform, 1095 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
1095 grand_child->ScreenSpaceTransform()); 1096 grand_child->ScreenSpaceTransform());
1096 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform, 1097 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform,
1097 great_grand_child->DrawTransform()); 1098 great_grand_child->DrawTransform());
1098 EXPECT_TRANSFORMATION_MATRIX_EQ( 1099 EXPECT_TRANSFORMATION_MATRIX_EQ(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 grand_child->SetDrawsContent(true); 1157 grand_child->SetDrawsContent(true);
1157 1158
1158 root->SetBounds(gfx::Size(100, 100)); 1159 root->SetBounds(gfx::Size(100, 100));
1159 // The child height is zero, but has non-zero width that should be accounted 1160 // The child height is zero, but has non-zero width that should be accounted
1160 // for while computing draw transforms. 1161 // for while computing draw transforms.
1161 child->SetBounds(gfx::Size(10, 0)); 1162 child->SetBounds(gfx::Size(10, 0));
1162 child->test_properties()->force_render_surface = true; 1163 child->test_properties()->force_render_surface = true;
1163 grand_child->SetBounds(gfx::Size(10, 10)); 1164 grand_child->SetBounds(gfx::Size(10, 10));
1164 ExecuteCalculateDrawProperties(root); 1165 ExecuteCalculateDrawProperties(root);
1165 1166
1166 ASSERT_TRUE(child->has_render_surface()); 1167 ASSERT_TRUE(child->GetRenderSurface());
1167 // This is the real test, the rest are sanity checks. 1168 // This is the real test, the rest are sanity checks.
1168 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1169 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1169 child->render_surface()->draw_transform()); 1170 child->GetRenderSurface()->draw_transform());
1170 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); 1171 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform());
1171 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1172 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1172 grand_child->DrawTransform()); 1173 grand_child->DrawTransform());
1173 } 1174 }
1174 1175
1175 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { 1176 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) {
1176 LayerImpl* root = root_layer_for_testing(); 1177 LayerImpl* root = root_layer_for_testing();
1177 LayerImpl* render_surface = AddChild<LayerImpl>(root); 1178 LayerImpl* render_surface = AddChild<LayerImpl>(root);
1178 LayerImpl* child = AddChild<LayerImpl>(render_surface); 1179 LayerImpl* child = AddChild<LayerImpl>(render_surface);
1179 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1180 LayerImpl* grand_child = AddChild<LayerImpl>(child);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 LayerImplList render_surface_layer_list_impl; 1227 LayerImplList render_surface_layer_list_impl;
1227 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1228 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1228 root, root->bounds(), translate, &render_surface_layer_list_impl); 1229 root, root->bounds(), translate, &render_surface_layer_list_impl);
1229 inputs.property_trees->needs_rebuild = true; 1230 inputs.property_trees->needs_rebuild = true;
1230 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1231 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1231 EXPECT_TRANSFORMATION_MATRIX_EQ( 1232 EXPECT_TRANSFORMATION_MATRIX_EQ(
1232 translate, root->draw_properties().target_space_transform); 1233 translate, root->draw_properties().target_space_transform);
1233 EXPECT_TRANSFORMATION_MATRIX_EQ( 1234 EXPECT_TRANSFORMATION_MATRIX_EQ(
1234 translate, child->draw_properties().target_space_transform); 1235 translate, child->draw_properties().target_space_transform);
1235 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1236 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1236 root->render_surface()->draw_transform()); 1237 root->GetRenderSurface()->draw_transform());
1237 EXPECT_TRANSFORMATION_MATRIX_EQ(translate, child->ScreenSpaceTransform()); 1238 EXPECT_TRANSFORMATION_MATRIX_EQ(translate, child->ScreenSpaceTransform());
1238 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), child->clip_rect()); 1239 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), child->clip_rect());
1239 } 1240 }
1240 1241
1241 gfx::Transform scale; 1242 gfx::Transform scale;
1242 scale.Scale(2, 2); 1243 scale.Scale(2, 2);
1243 { 1244 {
1244 LayerImplList render_surface_layer_list_impl; 1245 LayerImplList render_surface_layer_list_impl;
1245 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1246 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1246 root, root->bounds(), scale, &render_surface_layer_list_impl); 1247 root, root->bounds(), scale, &render_surface_layer_list_impl);
1247 inputs.property_trees->needs_rebuild = true; 1248 inputs.property_trees->needs_rebuild = true;
1248 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1249 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1249 EXPECT_TRANSFORMATION_MATRIX_EQ( 1250 EXPECT_TRANSFORMATION_MATRIX_EQ(
1250 scale, root->draw_properties().target_space_transform); 1251 scale, root->draw_properties().target_space_transform);
1251 EXPECT_TRANSFORMATION_MATRIX_EQ( 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(
1252 scale, child->draw_properties().target_space_transform); 1253 scale, child->draw_properties().target_space_transform);
1253 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1254 root->render_surface()->draw_transform()); 1255 root->GetRenderSurface()->draw_transform());
1255 EXPECT_TRANSFORMATION_MATRIX_EQ(scale, child->ScreenSpaceTransform()); 1256 EXPECT_TRANSFORMATION_MATRIX_EQ(scale, child->ScreenSpaceTransform());
1256 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), child->clip_rect()); 1257 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), child->clip_rect());
1257 } 1258 }
1258 1259
1259 gfx::Transform rotate; 1260 gfx::Transform rotate;
1260 rotate.Rotate(2); 1261 rotate.Rotate(2);
1261 { 1262 {
1262 LayerImplList render_surface_layer_list_impl; 1263 LayerImplList render_surface_layer_list_impl;
1263 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1264 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1264 root, root->bounds(), rotate, &render_surface_layer_list_impl); 1265 root, root->bounds(), rotate, &render_surface_layer_list_impl);
1265 inputs.property_trees->needs_rebuild = true; 1266 inputs.property_trees->needs_rebuild = true;
1266 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1267 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1267 EXPECT_TRANSFORMATION_MATRIX_EQ( 1268 EXPECT_TRANSFORMATION_MATRIX_EQ(
1268 rotate, root->draw_properties().target_space_transform); 1269 rotate, root->draw_properties().target_space_transform);
1269 EXPECT_TRANSFORMATION_MATRIX_EQ( 1270 EXPECT_TRANSFORMATION_MATRIX_EQ(
1270 rotate, child->draw_properties().target_space_transform); 1271 rotate, child->draw_properties().target_space_transform);
1271 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1272 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1272 root->render_surface()->draw_transform()); 1273 root->GetRenderSurface()->draw_transform());
1273 EXPECT_TRANSFORMATION_MATRIX_EQ(rotate, child->ScreenSpaceTransform()); 1274 EXPECT_TRANSFORMATION_MATRIX_EQ(rotate, child->ScreenSpaceTransform());
1274 EXPECT_EQ(gfx::Rect(-4, 0, 104, 104), child->clip_rect()); 1275 EXPECT_EQ(gfx::Rect(-4, 0, 104, 104), child->clip_rect());
1275 } 1276 }
1276 1277
1277 gfx::Transform composite; 1278 gfx::Transform composite;
1278 composite.ConcatTransform(translate); 1279 composite.ConcatTransform(translate);
1279 composite.ConcatTransform(scale); 1280 composite.ConcatTransform(scale);
1280 composite.ConcatTransform(rotate); 1281 composite.ConcatTransform(rotate);
1281 { 1282 {
1282 LayerImplList render_surface_layer_list_impl; 1283 LayerImplList render_surface_layer_list_impl;
1283 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1284 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1284 root, root->bounds(), composite, &render_surface_layer_list_impl); 1285 root, root->bounds(), composite, &render_surface_layer_list_impl);
1285 inputs.property_trees->needs_rebuild = true; 1286 inputs.property_trees->needs_rebuild = true;
1286 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1287 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1287 EXPECT_TRANSFORMATION_MATRIX_EQ( 1288 EXPECT_TRANSFORMATION_MATRIX_EQ(
1288 composite, root->draw_properties().target_space_transform); 1289 composite, root->draw_properties().target_space_transform);
1289 EXPECT_TRANSFORMATION_MATRIX_EQ( 1290 EXPECT_TRANSFORMATION_MATRIX_EQ(
1290 composite, child->draw_properties().target_space_transform); 1291 composite, child->draw_properties().target_space_transform);
1291 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1292 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1292 root->render_surface()->draw_transform()); 1293 root->GetRenderSurface()->draw_transform());
1293 EXPECT_TRANSFORMATION_MATRIX_EQ(composite, child->ScreenSpaceTransform()); 1294 EXPECT_TRANSFORMATION_MATRIX_EQ(composite, child->ScreenSpaceTransform());
1294 EXPECT_EQ(gfx::Rect(89, 103, 208, 208), child->clip_rect()); 1295 EXPECT_EQ(gfx::Rect(89, 103, 208, 208), child->clip_rect());
1295 } 1296 }
1296 1297
1297 // Verify it composes correctly with device scale. 1298 // Verify it composes correctly with device scale.
1298 float device_scale_factor = 1.5f; 1299 float device_scale_factor = 1.5f;
1299 1300
1300 { 1301 {
1301 LayerImplList render_surface_layer_list_impl; 1302 LayerImplList render_surface_layer_list_impl;
1302 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1303 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1303 root, root->bounds(), translate, &render_surface_layer_list_impl); 1304 root, root->bounds(), translate, &render_surface_layer_list_impl);
1304 inputs.device_scale_factor = device_scale_factor; 1305 inputs.device_scale_factor = device_scale_factor;
1305 inputs.property_trees->needs_rebuild = true; 1306 inputs.property_trees->needs_rebuild = true;
1306 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1307 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1307 gfx::Transform device_scaled_translate = translate; 1308 gfx::Transform device_scaled_translate = translate;
1308 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); 1309 device_scaled_translate.Scale(device_scale_factor, device_scale_factor);
1309 EXPECT_TRANSFORMATION_MATRIX_EQ( 1310 EXPECT_TRANSFORMATION_MATRIX_EQ(
1310 device_scaled_translate, 1311 device_scaled_translate,
1311 root->draw_properties().target_space_transform); 1312 root->draw_properties().target_space_transform);
1312 EXPECT_TRANSFORMATION_MATRIX_EQ( 1313 EXPECT_TRANSFORMATION_MATRIX_EQ(
1313 device_scaled_translate, 1314 device_scaled_translate,
1314 child->draw_properties().target_space_transform); 1315 child->draw_properties().target_space_transform);
1315 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1316 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1316 root->render_surface()->draw_transform()); 1317 root->GetRenderSurface()->draw_transform());
1317 EXPECT_TRANSFORMATION_MATRIX_EQ(device_scaled_translate, 1318 EXPECT_TRANSFORMATION_MATRIX_EQ(device_scaled_translate,
1318 child->ScreenSpaceTransform()); 1319 child->ScreenSpaceTransform());
1319 EXPECT_EQ(gfx::Rect(50, 50, 150, 150), child->clip_rect()); 1320 EXPECT_EQ(gfx::Rect(50, 50, 150, 150), child->clip_rect());
1320 } 1321 }
1321 1322
1322 // Verify it composes correctly with page scale. 1323 // Verify it composes correctly with page scale.
1323 float page_scale_factor = 2.f; 1324 float page_scale_factor = 2.f;
1324 1325
1325 { 1326 {
1326 LayerImplList render_surface_layer_list_impl; 1327 LayerImplList render_surface_layer_list_impl;
1327 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1328 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1328 root, root->bounds(), translate, &render_surface_layer_list_impl); 1329 root, root->bounds(), translate, &render_surface_layer_list_impl);
1329 inputs.page_scale_factor = page_scale_factor; 1330 inputs.page_scale_factor = page_scale_factor;
1330 inputs.page_scale_layer = root; 1331 inputs.page_scale_layer = root;
1331 inputs.property_trees->needs_rebuild = true; 1332 inputs.property_trees->needs_rebuild = true;
1332 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1333 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1333 gfx::Transform page_scaled_translate = translate; 1334 gfx::Transform page_scaled_translate = translate;
1334 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); 1335 page_scaled_translate.Scale(page_scale_factor, page_scale_factor);
1335 EXPECT_TRANSFORMATION_MATRIX_EQ( 1336 EXPECT_TRANSFORMATION_MATRIX_EQ(
1336 page_scaled_translate, root->draw_properties().target_space_transform); 1337 page_scaled_translate, root->draw_properties().target_space_transform);
1337 EXPECT_TRANSFORMATION_MATRIX_EQ( 1338 EXPECT_TRANSFORMATION_MATRIX_EQ(
1338 page_scaled_translate, child->draw_properties().target_space_transform); 1339 page_scaled_translate, child->draw_properties().target_space_transform);
1339 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1340 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1340 root->render_surface()->draw_transform()); 1341 root->GetRenderSurface()->draw_transform());
1341 EXPECT_TRANSFORMATION_MATRIX_EQ(page_scaled_translate, 1342 EXPECT_TRANSFORMATION_MATRIX_EQ(page_scaled_translate,
1342 child->ScreenSpaceTransform()); 1343 child->ScreenSpaceTransform());
1343 EXPECT_EQ(gfx::Rect(50, 50, 200, 200), child->clip_rect()); 1344 EXPECT_EQ(gfx::Rect(50, 50, 200, 200), child->clip_rect());
1344 } 1345 }
1345 1346
1346 // Verify that it composes correctly with transforms directly on root layer. 1347 // Verify that it composes correctly with transforms directly on root layer.
1347 root->test_properties()->transform = composite; 1348 root->test_properties()->transform = composite;
1348 1349
1349 { 1350 {
1350 LayerImplList render_surface_layer_list_impl; 1351 LayerImplList render_surface_layer_list_impl;
1351 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1352 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1352 root, root->bounds(), composite, &render_surface_layer_list_impl); 1353 root, root->bounds(), composite, &render_surface_layer_list_impl);
1353 inputs.property_trees->needs_rebuild = true; 1354 inputs.property_trees->needs_rebuild = true;
1354 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1355 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1355 gfx::Transform compositeSquared = composite; 1356 gfx::Transform compositeSquared = composite;
1356 compositeSquared.ConcatTransform(composite); 1357 compositeSquared.ConcatTransform(composite);
1357 EXPECT_TRANSFORMATION_MATRIX_EQ( 1358 EXPECT_TRANSFORMATION_MATRIX_EQ(
1358 compositeSquared, root->draw_properties().target_space_transform); 1359 compositeSquared, root->draw_properties().target_space_transform);
1359 EXPECT_TRANSFORMATION_MATRIX_EQ( 1360 EXPECT_TRANSFORMATION_MATRIX_EQ(
1360 compositeSquared, child->draw_properties().target_space_transform); 1361 compositeSquared, child->draw_properties().target_space_transform);
1361 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1362 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1362 root->render_surface()->draw_transform()); 1363 root->GetRenderSurface()->draw_transform());
1363 EXPECT_TRANSFORMATION_MATRIX_EQ(compositeSquared, 1364 EXPECT_TRANSFORMATION_MATRIX_EQ(compositeSquared,
1364 child->ScreenSpaceTransform()); 1365 child->ScreenSpaceTransform());
1365 EXPECT_EQ(gfx::Rect(254, 316, 428, 428), child->clip_rect()); 1366 EXPECT_EQ(gfx::Rect(254, 316, 428, 428), child->clip_rect());
1366 } 1367 }
1367 } 1368 }
1368 1369
1369 TEST_F(LayerTreeHostCommonTest, 1370 TEST_F(LayerTreeHostCommonTest,
1370 RenderSurfaceListForRenderSurfaceWithClippedLayer) { 1371 RenderSurfaceListForRenderSurfaceWithClippedLayer) {
1371 LayerImpl* root = root_layer_for_testing(); 1372 LayerImpl* root = root_layer_for_testing();
1372 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 1373 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
1373 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1374 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1374 1375
1375 root->SetBounds(gfx::Size(10, 10)); 1376 root->SetBounds(gfx::Size(10, 10));
1376 root->SetMasksToBounds(true); 1377 root->SetMasksToBounds(true);
1377 render_surface1->SetBounds(gfx::Size(10, 10)); 1378 render_surface1->SetBounds(gfx::Size(10, 10));
1378 render_surface1->test_properties()->force_render_surface = true; 1379 render_surface1->test_properties()->force_render_surface = true;
1379 child->SetDrawsContent(true); 1380 child->SetDrawsContent(true);
1380 child->SetPosition(gfx::PointF(30.f, 30.f)); 1381 child->SetPosition(gfx::PointF(30.f, 30.f));
1381 child->SetBounds(gfx::Size(10, 10)); 1382 child->SetBounds(gfx::Size(10, 10));
1382 ExecuteCalculateDrawProperties(root); 1383 ExecuteCalculateDrawProperties(root);
1383 1384
1384 // The child layer's content is entirely outside the root's clip rect, so 1385 // The child layer's content is entirely outside the root's clip rect, so
1385 // the intermediate render surface should not be listed here, even if it was 1386 // the intermediate render surface should not be listed here, even if it was
1386 // forced to be created. Render surfaces without children or visible content 1387 // forced to be created. Render surfaces without children or visible content
1387 // are unexpected at draw time (e.g. we might try to create a content texture 1388 // are unexpected at draw time (e.g. we might try to create a content texture
1388 // of size 0). 1389 // of size 0).
1389 ASSERT_TRUE(root->render_surface()); 1390 ASSERT_TRUE(root->GetRenderSurface());
1390 EXPECT_EQ(1U, render_surface_layer_list_impl()->size()); 1391 EXPECT_EQ(1U, render_surface_layer_list_impl()->size());
1391 } 1392 }
1392 1393
1393 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) { 1394 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
1394 LayerImpl* root = root_layer_for_testing(); 1395 LayerImpl* root = root_layer_for_testing();
1395 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 1396 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
1396 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1397 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1397 1398
1398 render_surface1->SetBounds(gfx::Size(10, 10)); 1399 render_surface1->SetBounds(gfx::Size(10, 10));
1399 render_surface1->test_properties()->force_render_surface = true; 1400 render_surface1->test_properties()->force_render_surface = true;
1400 render_surface1->test_properties()->opacity = 0.f; 1401 render_surface1->test_properties()->opacity = 0.f;
1401 child->SetBounds(gfx::Size(10, 10)); 1402 child->SetBounds(gfx::Size(10, 10));
1402 child->SetDrawsContent(true); 1403 child->SetDrawsContent(true);
1403 1404
1404 LayerImplList render_surface_layer_list; 1405 LayerImplList render_surface_layer_list;
1405 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1406 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1406 root, root->bounds(), &render_surface_layer_list); 1407 root, root->bounds(), &render_surface_layer_list);
1407 inputs.can_adjust_raster_scales = true; 1408 inputs.can_adjust_raster_scales = true;
1408 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1409 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1409 1410
1410 // Since the layer is transparent, render_surface1->render_surface() should 1411 // Since the layer is transparent, render_surface1->GetRenderSurface() should
1411 // not have gotten added anywhere. Also, the drawable content rect should not 1412 // not have gotten added anywhere. Also, the drawable content rect should not
1412 // have been extended by the children. 1413 // have been extended by the children.
1413 ASSERT_TRUE(root->render_surface()); 1414 ASSERT_TRUE(root->GetRenderSurface());
1414 EXPECT_EQ(0U, root->render_surface()->layer_list().size()); 1415 EXPECT_EQ(0U, root->GetRenderSurface()->layer_list().size());
1415 EXPECT_EQ(1U, render_surface_layer_list.size()); 1416 EXPECT_EQ(1U, render_surface_layer_list.size());
1416 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); 1417 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id());
1417 EXPECT_EQ(gfx::Rect(), root->drawable_content_rect()); 1418 EXPECT_EQ(gfx::Rect(), root->drawable_content_rect());
1418 } 1419 }
1419 1420
1420 TEST_F(LayerTreeHostCommonTest, 1421 TEST_F(LayerTreeHostCommonTest,
1421 RenderSurfaceListForTransparentChildWithBackgroundFilter) { 1422 RenderSurfaceListForTransparentChildWithBackgroundFilter) {
1422 LayerImpl* root = root_layer_for_testing(); 1423 LayerImpl* root = root_layer_for_testing();
1423 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 1424 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
1424 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1425 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
(...skipping 12 matching lines...) Expand all
1437 { 1438 {
1438 LayerImplList render_surface_layer_list; 1439 LayerImplList render_surface_layer_list;
1439 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1440 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1440 root, root->bounds(), &render_surface_layer_list); 1441 root, root->bounds(), &render_surface_layer_list);
1441 inputs.can_adjust_raster_scales = true; 1442 inputs.can_adjust_raster_scales = true;
1442 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1443 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1443 EXPECT_EQ(2U, render_surface_layer_list.size()); 1444 EXPECT_EQ(2U, render_surface_layer_list.size());
1444 } 1445 }
1445 // The layer is fully transparent, but has a background filter, so it 1446 // The layer is fully transparent, but has a background filter, so it
1446 // shouldn't be skipped and should be drawn. 1447 // shouldn't be skipped and should be drawn.
1447 ASSERT_TRUE(root->render_surface()); 1448 ASSERT_TRUE(root->GetRenderSurface());
1448 EXPECT_EQ(1U, root->render_surface()->layer_list().size()); 1449 EXPECT_EQ(1U, root->GetRenderSurface()->layer_list().size());
1449 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), 1450 EXPECT_EQ(gfx::RectF(0, 0, 10, 10),
1450 root->render_surface()->DrawableContentRect()); 1451 root->GetRenderSurface()->DrawableContentRect());
1451 EffectTree& effect_tree = 1452 EffectTree& effect_tree =
1452 root->layer_tree_impl()->property_trees()->effect_tree; 1453 root->layer_tree_impl()->property_trees()->effect_tree;
1453 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); 1454 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index());
1454 EXPECT_TRUE(node->is_drawn); 1455 EXPECT_TRUE(node->is_drawn);
1455 1456
1456 // When root is transparent, the layer should not be drawn. 1457 // When root is transparent, the layer should not be drawn.
1457 effect_tree.OnOpacityAnimated(0.f, root->effect_tree_index(), 1458 effect_tree.OnOpacityAnimated(0.f, root->effect_tree_index(),
1458 root->layer_tree_impl()); 1459 root->layer_tree_impl());
1459 effect_tree.OnOpacityAnimated(1.f, render_surface1->effect_tree_index(), 1460 effect_tree.OnOpacityAnimated(1.f, render_surface1->effect_tree_index(),
1460 root->layer_tree_impl()); 1461 root->layer_tree_impl());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 child2->SetBounds(gfx::Size(25, 25)); 1495 child2->SetBounds(gfx::Size(25, 25));
1495 child2->SetDrawsContent(true); 1496 child2->SetDrawsContent(true);
1496 child2->test_properties()->force_render_surface = true; 1497 child2->test_properties()->force_render_surface = true;
1497 1498
1498 LayerImplList render_surface_layer_list; 1499 LayerImplList render_surface_layer_list;
1499 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1500 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1500 root, root->bounds(), &render_surface_layer_list); 1501 root, root->bounds(), &render_surface_layer_list);
1501 inputs.can_adjust_raster_scales = true; 1502 inputs.can_adjust_raster_scales = true;
1502 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1503 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1503 1504
1504 ASSERT_TRUE(parent->render_surface()); 1505 ASSERT_TRUE(parent->GetRenderSurface());
1505 EXPECT_EQ(2U, parent->render_surface()->layer_list().size()); 1506 EXPECT_EQ(2U, parent->GetRenderSurface()->layer_list().size());
1506 EXPECT_EQ(4U, render_surface_layer_list.size()); 1507 EXPECT_EQ(4U, render_surface_layer_list.size());
1507 1508
1508 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the 1509 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the
1509 // blur (-30,-30 110x110), and then scaled by the scale matrix 1510 // blur (-30,-30 110x110), and then scaled by the scale matrix
1510 // (-60,-60 220x220). 1511 // (-60,-60 220x220).
1511 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220), 1512 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220),
1512 parent->render_surface()->DrawableContentRect()); 1513 parent->GetRenderSurface()->DrawableContentRect());
1513 } 1514 }
1514 1515
1515 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) { 1516 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) {
1516 LayerImpl* root = root_layer_for_testing(); 1517 LayerImpl* root = root_layer_for_testing();
1517 LayerImpl* child = AddChild<LayerImpl>(root); 1518 LayerImpl* child = AddChild<LayerImpl>(root);
1518 1519
1519 root->SetBounds(gfx::Size(100, 100)); 1520 root->SetBounds(gfx::Size(100, 100));
1520 child->SetBounds(gfx::Size(25, 25)); 1521 child->SetBounds(gfx::Size(25, 25));
1521 child->SetDrawsContent(true); 1522 child->SetDrawsContent(true);
1522 child->test_properties()->force_render_surface = true; 1523 child->test_properties()->force_render_surface = true;
1523 FilterOperations filters; 1524 FilterOperations filters;
1524 filters.Append(FilterOperation::CreateReferenceFilter( 1525 filters.Append(FilterOperation::CreateReferenceFilter(
1525 SkOffsetImageFilter::Make(50, 50, nullptr))); 1526 SkOffsetImageFilter::Make(50, 50, nullptr)));
1526 child->test_properties()->filters = filters; 1527 child->test_properties()->filters = filters;
1527 ExecuteCalculateDrawProperties(root); 1528 ExecuteCalculateDrawProperties(root);
1528 1529
1529 // The render surface's size should be unaffected by the offset image filter; 1530 // The render surface's size should be unaffected by the offset image filter;
1530 // it need only have a drawable content rect large enough to contain the 1531 // it need only have a drawable content rect large enough to contain the
1531 // contents (at the new offset). 1532 // contents (at the new offset).
1532 ASSERT_TRUE(child->render_surface()); 1533 ASSERT_TRUE(child->GetRenderSurface());
1533 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), 1534 EXPECT_EQ(gfx::RectF(50, 50, 25, 25),
1534 child->render_surface()->DrawableContentRect()); 1535 child->GetRenderSurface()->DrawableContentRect());
1535 } 1536 }
1536 1537
1537 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { 1538 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) {
1538 const float device_scale_factor = 2.0f; 1539 const float device_scale_factor = 2.0f;
1539 1540
1540 LayerImpl* root = root_layer_for_testing(); 1541 LayerImpl* root = root_layer_for_testing();
1541 LayerImpl* child = AddChild<LayerImpl>(root); 1542 LayerImpl* child = AddChild<LayerImpl>(root);
1542 1543
1543 root->SetBounds(gfx::Size(100, 100)); 1544 root->SetBounds(gfx::Size(100, 100));
1544 child->SetBounds(gfx::Size(25, 25)); 1545 child->SetBounds(gfx::Size(25, 25));
1545 child->SetDrawsContent(true); 1546 child->SetDrawsContent(true);
1546 child->test_properties()->force_render_surface = true; 1547 child->test_properties()->force_render_surface = true;
1547 1548
1548 FilterOperations filters; 1549 FilterOperations filters;
1549 filters.Append(FilterOperation::CreateReferenceFilter( 1550 filters.Append(FilterOperation::CreateReferenceFilter(
1550 SkOffsetImageFilter::Make(50, 50, nullptr))); 1551 SkOffsetImageFilter::Make(50, 50, nullptr)));
1551 child->test_properties()->filters = filters; 1552 child->test_properties()->filters = filters;
1552 1553
1553 ExecuteCalculateDrawProperties(root, device_scale_factor); 1554 ExecuteCalculateDrawProperties(root, device_scale_factor);
1554 1555
1555 // The render surface's size should be unaffected by the offset image filter; 1556 // The render surface's size should be unaffected by the offset image filter;
1556 // it need only have a drawable content rect large enough to contain the 1557 // it need only have a drawable content rect large enough to contain the
1557 // contents (at the new offset). All coordinates should be scaled by 2, 1558 // contents (at the new offset). All coordinates should be scaled by 2,
1558 // corresponding to the device scale factor. 1559 // corresponding to the device scale factor.
1559 ASSERT_TRUE(child->render_surface()); 1560 ASSERT_TRUE(child->GetRenderSurface());
1560 EXPECT_EQ(gfx::RectF(100, 100, 50, 50), 1561 EXPECT_EQ(gfx::RectF(100, 100, 50, 50),
1561 child->render_surface()->DrawableContentRect()); 1562 child->GetRenderSurface()->DrawableContentRect());
1562 } 1563 }
1563 1564
1564 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1565 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1565 LayerImpl* root = root_layer_for_testing(); 1566 LayerImpl* root = root_layer_for_testing();
1566 LayerImpl* child = AddChild<LayerImpl>(root); 1567 LayerImpl* child = AddChild<LayerImpl>(root);
1567 1568
1568 root->SetBounds(gfx::Size(10, 10)); 1569 root->SetBounds(gfx::Size(10, 10));
1569 child->SetBounds(gfx::Size(10, 10)); 1570 child->SetBounds(gfx::Size(10, 10));
1570 child->SetDrawsContent(true); 1571 child->SetDrawsContent(true);
1571 child->test_properties()->blend_mode = SkBlendMode::kMultiply; 1572 child->test_properties()->blend_mode = SkBlendMode::kMultiply;
1572 child->test_properties()->opacity = 0.5f; 1573 child->test_properties()->opacity = 0.5f;
1573 child->test_properties()->force_render_surface = true; 1574 child->test_properties()->force_render_surface = true;
1574 ExecuteCalculateDrawProperties(root); 1575 ExecuteCalculateDrawProperties(root);
1575 1576
1576 // Since the child layer has a blend mode other than normal, it should get 1577 // Since the child layer has a blend mode other than normal, it should get
1577 // its own render surface. Also, layer's draw_properties should contain the 1578 // its own render surface. Also, layer's draw_properties should contain the
1578 // default blend mode, since the render surface becomes responsible for 1579 // default blend mode, since the render surface becomes responsible for
1579 // applying the blend mode. 1580 // applying the blend mode.
1580 ASSERT_TRUE(child->render_surface()); 1581 ASSERT_TRUE(child->GetRenderSurface());
1581 EXPECT_EQ(1.0f, child->draw_opacity()); 1582 EXPECT_EQ(1.0f, child->draw_opacity());
1582 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity()); 1583 EXPECT_EQ(0.5f, child->GetRenderSurface()->draw_opacity());
1583 EXPECT_EQ(SkBlendMode::kSrcOver, child->draw_blend_mode()); 1584 EXPECT_EQ(SkBlendMode::kSrcOver, child->draw_blend_mode());
1584 } 1585 }
1585 1586
1586 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { 1587 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) {
1587 LayerImpl* root = root_layer_for_testing(); 1588 LayerImpl* root = root_layer_for_testing();
1588 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); 1589 LayerImpl* surface1 = AddChildToRoot<LayerImpl>();
1589 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); 1590 LayerImpl* not_surface = AddChild<LayerImpl>(surface1);
1590 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); 1591 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface);
1591 1592
1592 root->SetBounds(gfx::Size(10, 10)); 1593 root->SetBounds(gfx::Size(10, 10));
1593 surface1->SetBounds(gfx::Size(10, 10)); 1594 surface1->SetBounds(gfx::Size(10, 10));
1594 surface1->SetDrawsContent(true); 1595 surface1->SetDrawsContent(true);
1595 surface1->test_properties()->opacity = 0.5f; 1596 surface1->test_properties()->opacity = 0.5f;
1596 surface1->test_properties()->force_render_surface = true; 1597 surface1->test_properties()->force_render_surface = true;
1597 not_surface->SetBounds(gfx::Size(10, 10)); 1598 not_surface->SetBounds(gfx::Size(10, 10));
1598 not_surface->test_properties()->opacity = 0.5f; 1599 not_surface->test_properties()->opacity = 0.5f;
1599 surface2->SetBounds(gfx::Size(10, 10)); 1600 surface2->SetBounds(gfx::Size(10, 10));
1600 surface2->SetDrawsContent(true); 1601 surface2->SetDrawsContent(true);
1601 surface2->test_properties()->opacity = 0.5f; 1602 surface2->test_properties()->opacity = 0.5f;
1602 surface2->test_properties()->force_render_surface = true; 1603 surface2->test_properties()->force_render_surface = true;
1603 ExecuteCalculateDrawProperties(root); 1604 ExecuteCalculateDrawProperties(root);
1604 1605
1605 ASSERT_TRUE(surface1->render_surface()); 1606 ASSERT_TRUE(surface1->GetRenderSurface());
1606 ASSERT_FALSE(not_surface->render_surface()); 1607 ASSERT_FALSE(not_surface->GetRenderSurface());
1607 ASSERT_TRUE(surface2->render_surface()); 1608 ASSERT_TRUE(surface2->GetRenderSurface());
1608 EXPECT_EQ(0.5f, surface1->render_surface()->draw_opacity()); 1609 EXPECT_EQ(0.5f, surface1->GetRenderSurface()->draw_opacity());
1609 // surface2's draw opacity should include the opacity of not-surface and 1610 // surface2's draw opacity should include the opacity of not-surface and
1610 // itself, but not the opacity of surface1. 1611 // itself, but not the opacity of surface1.
1611 EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity()); 1612 EXPECT_EQ(0.25f, surface2->GetRenderSurface()->draw_opacity());
1612 } 1613 }
1613 1614
1614 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) { 1615 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) {
1615 // Tests that when separate surfaces are disabled, a layer's draw opacity is 1616 // Tests that when separate surfaces are disabled, a layer's draw opacity is
1616 // the product of all ancestor layer opacties and the layer's own opacity. 1617 // the product of all ancestor layer opacties and the layer's own opacity.
1617 // (Rendering will still be incorrect in situations where we really do need 1618 // (Rendering will still be incorrect in situations where we really do need
1618 // surfaces to apply opacity, such as when we have overlapping layers with an 1619 // surfaces to apply opacity, such as when we have overlapping layers with an
1619 // ancestor whose opacity is <1.) 1620 // ancestor whose opacity is <1.)
1620 LayerImpl* root = root_layer_for_testing(); 1621 LayerImpl* root = root_layer_for_testing();
1621 LayerImpl* parent = AddChild<LayerImpl>(root); 1622 LayerImpl* parent = AddChild<LayerImpl>(root);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 root->SetBounds(gfx::Size(10, 10)); 1680 root->SetBounds(gfx::Size(10, 10));
1680 render_surface1->SetBounds(gfx::Size(10, 10)); 1681 render_surface1->SetBounds(gfx::Size(10, 10));
1681 render_surface1->test_properties()->force_render_surface = true; 1682 render_surface1->test_properties()->force_render_surface = true;
1682 child->SetBounds(gfx::Size(10, 10)); 1683 child->SetBounds(gfx::Size(10, 10));
1683 child->SetDrawsContent(true); 1684 child->SetDrawsContent(true);
1684 1685
1685 { 1686 {
1686 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 1687 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
1687 1688
1688 // The root layer always creates a render surface 1689 // The root layer always creates a render surface
1689 EXPECT_TRUE(root->has_render_surface()); 1690 EXPECT_TRUE(root->GetRenderSurface());
1690 EXPECT_TRUE(render_surface1->has_render_surface()); 1691 EXPECT_TRUE(render_surface1->GetRenderSurface());
1691 } 1692 }
1692 1693
1693 { 1694 {
1694 render_surface1->test_properties()->force_render_surface = false; 1695 render_surface1->test_properties()->force_render_surface = false;
1695 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true; 1696 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true;
1696 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 1697 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
1697 EXPECT_TRUE(root->has_render_surface()); 1698 EXPECT_TRUE(root->GetRenderSurface());
1698 EXPECT_FALSE(render_surface1->has_render_surface()); 1699 EXPECT_FALSE(render_surface1->GetRenderSurface());
1699 } 1700 }
1700 } 1701 }
1701 1702
1702 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { 1703 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
1703 // Render surfaces act as a flattening point for their subtree, so should 1704 // Render surfaces act as a flattening point for their subtree, so should
1704 // always flatten the target-to-screen space transform seen by descendants. 1705 // always flatten the target-to-screen space transform seen by descendants.
1705 LayerImpl* root = root_layer_for_testing(); 1706 LayerImpl* root = root_layer_for_testing();
1706 LayerImpl* parent = AddChild<LayerImpl>(root); 1707 LayerImpl* parent = AddChild<LayerImpl>(root);
1707 LayerImpl* child = AddChild<LayerImpl>(parent); 1708 LayerImpl* child = AddChild<LayerImpl>(parent);
1708 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1709 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1709 1710
1710 gfx::Transform rotation_about_y_axis; 1711 gfx::Transform rotation_about_y_axis;
1711 rotation_about_y_axis.RotateAboutYAxis(30.0); 1712 rotation_about_y_axis.RotateAboutYAxis(30.0);
1712 1713
1713 root->SetBounds(gfx::Size(100, 100)); 1714 root->SetBounds(gfx::Size(100, 100));
1714 parent->test_properties()->transform = rotation_about_y_axis; 1715 parent->test_properties()->transform = rotation_about_y_axis;
1715 parent->SetBounds(gfx::Size(10, 10)); 1716 parent->SetBounds(gfx::Size(10, 10));
1716 parent->test_properties()->force_render_surface = true; 1717 parent->test_properties()->force_render_surface = true;
1717 child->SetBounds(gfx::Size(10, 10)); 1718 child->SetBounds(gfx::Size(10, 10));
1718 child->SetDrawsContent(true); 1719 child->SetDrawsContent(true);
1719 grand_child->SetBounds(gfx::Size(10, 10)); 1720 grand_child->SetBounds(gfx::Size(10, 10));
1720 grand_child->SetDrawsContent(true); 1721 grand_child->SetDrawsContent(true);
1721 grand_child->test_properties()->should_flatten_transform = false; 1722 grand_child->test_properties()->should_flatten_transform = false;
1722 ExecuteCalculateDrawProperties(root); 1723 ExecuteCalculateDrawProperties(root);
1723 1724
1724 EXPECT_TRUE(parent->render_surface()); 1725 EXPECT_TRUE(parent->GetRenderSurface());
1725 EXPECT_FALSE(child->render_surface()); 1726 EXPECT_FALSE(child->GetRenderSurface());
1726 EXPECT_FALSE(grand_child->render_surface()); 1727 EXPECT_FALSE(grand_child->GetRenderSurface());
1727 1728
1728 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); 1729 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform());
1729 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1730 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1730 grand_child->DrawTransform()); 1731 grand_child->DrawTransform());
1731 1732
1732 // The screen-space transform inherited by |child| and |grand_child| should 1733 // The screen-space transform inherited by |child| and |grand_child| should
1733 // have been flattened at their render target. In particular, the fact that 1734 // have been flattened at their render target. In particular, the fact that
1734 // |grand_child| happens to preserve 3d shouldn't affect this flattening. 1735 // |grand_child| happens to preserve 3d shouldn't affect this flattening.
1735 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; 1736 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis;
1736 flattened_rotation_about_y.FlattenTo2d(); 1737 flattened_rotation_about_y.FlattenTo2d();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 grand_child->SetBounds(gfx::Size(100, 100)); 1856 grand_child->SetBounds(gfx::Size(100, 100));
1856 grand_child->SetDrawsContent(true); 1857 grand_child->SetDrawsContent(true);
1857 leaf_node1->SetBounds(gfx::Size(100, 100)); 1858 leaf_node1->SetBounds(gfx::Size(100, 100));
1858 leaf_node1->SetDrawsContent(true); 1859 leaf_node1->SetDrawsContent(true);
1859 leaf_node2->SetBounds(gfx::Size(100, 100)); 1860 leaf_node2->SetBounds(gfx::Size(100, 100));
1860 leaf_node2->SetDrawsContent(true); 1861 leaf_node2->SetDrawsContent(true);
1861 1862
1862 // Case 1: nothing is clipped except the root render surface. 1863 // Case 1: nothing is clipped except the root render surface.
1863 ExecuteCalculateDrawProperties(root); 1864 ExecuteCalculateDrawProperties(root);
1864 1865
1865 ASSERT_TRUE(root->render_surface()); 1866 ASSERT_TRUE(root->GetRenderSurface());
1866 ASSERT_TRUE(child2->render_surface()); 1867 ASSERT_TRUE(child2->GetRenderSurface());
1867 1868
1868 EXPECT_FALSE(root->is_clipped()); 1869 EXPECT_FALSE(root->is_clipped());
1869 EXPECT_TRUE(root->render_surface()->is_clipped()); 1870 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
1870 EXPECT_FALSE(parent->is_clipped()); 1871 EXPECT_FALSE(parent->is_clipped());
1871 EXPECT_FALSE(child1->is_clipped()); 1872 EXPECT_FALSE(child1->is_clipped());
1872 EXPECT_FALSE(child2->is_clipped()); 1873 EXPECT_FALSE(child2->is_clipped());
1873 EXPECT_FALSE(child2->render_surface()->is_clipped()); 1874 EXPECT_FALSE(child2->GetRenderSurface()->is_clipped());
1874 EXPECT_FALSE(grand_child->is_clipped()); 1875 EXPECT_FALSE(grand_child->is_clipped());
1875 EXPECT_FALSE(leaf_node1->is_clipped()); 1876 EXPECT_FALSE(leaf_node1->is_clipped());
1876 EXPECT_FALSE(leaf_node2->is_clipped()); 1877 EXPECT_FALSE(leaf_node2->is_clipped());
1877 1878
1878 // Case 2: parent MasksToBounds, so the parent, child1, and child2's 1879 // Case 2: parent MasksToBounds, so the parent, child1, and child2's
1879 // surface are clipped. But layers that contribute to child2's surface are 1880 // surface are clipped. But layers that contribute to child2's surface are
1880 // not clipped explicitly because child2's surface already accounts for 1881 // not clipped explicitly because child2's surface already accounts for
1881 // that clip. 1882 // that clip.
1882 parent->SetMasksToBounds(true); 1883 parent->SetMasksToBounds(true);
1883 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 1884 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
1884 1885
1885 ExecuteCalculateDrawProperties(root); 1886 ExecuteCalculateDrawProperties(root);
1886 1887
1887 ASSERT_TRUE(root->render_surface()); 1888 ASSERT_TRUE(root->GetRenderSurface());
1888 ASSERT_TRUE(child2->render_surface()); 1889 ASSERT_TRUE(child2->GetRenderSurface());
1889 1890
1890 EXPECT_FALSE(root->is_clipped()); 1891 EXPECT_FALSE(root->is_clipped());
1891 EXPECT_TRUE(root->render_surface()->is_clipped()); 1892 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
1892 EXPECT_TRUE(parent->is_clipped()); 1893 EXPECT_TRUE(parent->is_clipped());
1893 EXPECT_TRUE(child1->is_clipped()); 1894 EXPECT_TRUE(child1->is_clipped());
1894 EXPECT_FALSE(child2->is_clipped()); 1895 EXPECT_FALSE(child2->is_clipped());
1895 EXPECT_TRUE(child2->render_surface()->is_clipped()); 1896 EXPECT_TRUE(child2->GetRenderSurface()->is_clipped());
1896 EXPECT_TRUE(grand_child->is_clipped()); 1897 EXPECT_TRUE(grand_child->is_clipped());
1897 EXPECT_TRUE(leaf_node1->is_clipped()); 1898 EXPECT_TRUE(leaf_node1->is_clipped());
1898 EXPECT_FALSE(leaf_node2->is_clipped()); 1899 EXPECT_FALSE(leaf_node2->is_clipped());
1899 1900
1900 parent->SetMasksToBounds(false); 1901 parent->SetMasksToBounds(false);
1901 1902
1902 // Case 3: child2 MasksToBounds. The layer and subtree are clipped, and 1903 // Case 3: child2 MasksToBounds. The layer and subtree are clipped, and
1903 // child2's render surface is not clipped. 1904 // child2's render surface is not clipped.
1904 child2->SetMasksToBounds(true); 1905 child2->SetMasksToBounds(true);
1905 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 1906 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
1906 1907
1907 ExecuteCalculateDrawProperties(root); 1908 ExecuteCalculateDrawProperties(root);
1908 1909
1909 ASSERT_TRUE(root->render_surface()); 1910 ASSERT_TRUE(root->GetRenderSurface());
1910 ASSERT_TRUE(child2->render_surface()); 1911 ASSERT_TRUE(child2->GetRenderSurface());
1911 1912
1912 EXPECT_FALSE(root->is_clipped()); 1913 EXPECT_FALSE(root->is_clipped());
1913 EXPECT_TRUE(root->render_surface()->is_clipped()); 1914 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
1914 EXPECT_FALSE(parent->is_clipped()); 1915 EXPECT_FALSE(parent->is_clipped());
1915 EXPECT_FALSE(child1->is_clipped()); 1916 EXPECT_FALSE(child1->is_clipped());
1916 EXPECT_TRUE(child2->is_clipped()); 1917 EXPECT_TRUE(child2->is_clipped());
1917 EXPECT_FALSE(child2->render_surface()->is_clipped()); 1918 EXPECT_FALSE(child2->GetRenderSurface()->is_clipped());
1918 EXPECT_FALSE(grand_child->is_clipped()); 1919 EXPECT_FALSE(grand_child->is_clipped());
1919 EXPECT_FALSE(leaf_node1->is_clipped()); 1920 EXPECT_FALSE(leaf_node1->is_clipped());
1920 EXPECT_TRUE(leaf_node2->is_clipped()); 1921 EXPECT_TRUE(leaf_node2->is_clipped());
1921 } 1922 }
1922 1923
1923 TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) { 1924 TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) {
1924 // Tests that when as long as layer is clipped, it's clip rect is set to 1925 // Tests that when as long as layer is clipped, it's clip rect is set to
1925 // correct value. 1926 // correct value.
1926 LayerImpl* root = root_layer_for_testing(); 1927 LayerImpl* root = root_layer_for_testing();
1927 LayerImpl* parent = AddChild<LayerImpl>(root); 1928 LayerImpl* parent = AddChild<LayerImpl>(root);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 leaf_node1->SetBounds(gfx::Size(10, 10)); 2191 leaf_node1->SetBounds(gfx::Size(10, 10));
2191 leaf_node1->SetDrawsContent(true); 2192 leaf_node1->SetDrawsContent(true);
2192 leaf_node2->SetBounds(gfx::Size(10, 10)); 2193 leaf_node2->SetBounds(gfx::Size(10, 10));
2193 leaf_node2->SetDrawsContent(true); 2194 leaf_node2->SetDrawsContent(true);
2194 leaf_node3->SetBounds(gfx::Size(10, 10)); 2195 leaf_node3->SetBounds(gfx::Size(10, 10));
2195 leaf_node3->SetDrawsContent(true); 2196 leaf_node3->SetDrawsContent(true);
2196 leaf_node4->SetBounds(gfx::Size(10, 10)); 2197 leaf_node4->SetBounds(gfx::Size(10, 10));
2197 leaf_node4->SetDrawsContent(true); 2198 leaf_node4->SetDrawsContent(true);
2198 ExecuteCalculateDrawProperties(parent); 2199 ExecuteCalculateDrawProperties(parent);
2199 2200
2200 ASSERT_TRUE(grand_child1->render_surface()); 2201 ASSERT_TRUE(grand_child1->GetRenderSurface());
2201 ASSERT_TRUE(grand_child2->render_surface()); 2202 ASSERT_TRUE(grand_child2->GetRenderSurface());
2202 ASSERT_TRUE(grand_child3->render_surface()); 2203 ASSERT_TRUE(grand_child3->GetRenderSurface());
2203 2204
2204 // Surfaces are clipped by their parent, but un-affected by the owning layer's 2205 // Surfaces are clipped by their parent, but un-affected by the owning layer's
2205 // MasksToBounds. 2206 // MasksToBounds.
2206 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2207 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2207 grand_child1->render_surface()->clip_rect()); 2208 grand_child1->GetRenderSurface()->clip_rect());
2208 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2209 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2209 grand_child2->render_surface()->clip_rect()); 2210 grand_child2->GetRenderSurface()->clip_rect());
2210 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2211 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2211 grand_child3->render_surface()->clip_rect()); 2212 grand_child3->GetRenderSurface()->clip_rect());
2212 } 2213 }
2213 2214
2214 TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) { 2215 TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) {
2215 // Tests that when separate surfaces are disabled, a layer's clip_rect is the 2216 // Tests that when separate surfaces are disabled, a layer's clip_rect is the
2216 // intersection of all ancestor clips in screen space; in particular, if a 2217 // intersection of all ancestor clips in screen space; in particular, if a
2217 // layer masks to bounds, it contributes to the clip_rect of all layers in its 2218 // layer masks to bounds, it contributes to the clip_rect of all layers in its
2218 // subtree (since there are no render surfaces that can reset the clip_rect). 2219 // subtree (since there are no render surfaces that can reset the clip_rect).
2219 LayerImpl* root = root_layer_for_testing(); 2220 LayerImpl* root = root_layer_for_testing();
2220 LayerImpl* parent = AddChild<LayerImpl>(root); 2221 LayerImpl* parent = AddChild<LayerImpl>(root);
2221 LayerImpl* child1 = AddChild<LayerImpl>(parent); 2222 LayerImpl* child1 = AddChild<LayerImpl>(parent);
(...skipping 25 matching lines...) Expand all
2247 leaf_node2->SetDrawsContent(true); 2248 leaf_node2->SetDrawsContent(true);
2248 2249
2249 root->test_properties()->force_render_surface = true; 2250 root->test_properties()->force_render_surface = true;
2250 child1->test_properties()->force_render_surface = true; 2251 child1->test_properties()->force_render_surface = true;
2251 grand_child->test_properties()->force_render_surface = true; 2252 grand_child->test_properties()->force_render_surface = true;
2252 2253
2253 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its 2254 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its
2254 // bounds in target space. The only thing that changes when surfaces are 2255 // bounds in target space. The only thing that changes when surfaces are
2255 // disabled is that target space is always screen space. 2256 // disabled is that target space is always screen space.
2256 ExecuteCalculateDrawProperties(root); 2257 ExecuteCalculateDrawProperties(root);
2257 EXPECT_TRUE(root->has_render_surface()); 2258 EXPECT_TRUE(root->GetRenderSurface());
2258 EXPECT_FALSE(parent->has_render_surface()); 2259 EXPECT_FALSE(parent->GetRenderSurface());
2259 EXPECT_TRUE(child1->has_render_surface()); 2260 EXPECT_TRUE(child1->GetRenderSurface());
2260 EXPECT_FALSE(child2->has_render_surface()); 2261 EXPECT_FALSE(child2->GetRenderSurface());
2261 EXPECT_TRUE(grand_child->has_render_surface()); 2262 EXPECT_TRUE(grand_child->GetRenderSurface());
2262 EXPECT_FALSE(leaf_node1->has_render_surface()); 2263 EXPECT_FALSE(leaf_node1->GetRenderSurface());
2263 EXPECT_FALSE(leaf_node2->has_render_surface()); 2264 EXPECT_FALSE(leaf_node2->GetRenderSurface());
2264 EXPECT_FALSE(root->is_clipped()); 2265 EXPECT_FALSE(root->is_clipped());
2265 EXPECT_FALSE(parent->is_clipped()); 2266 EXPECT_FALSE(parent->is_clipped());
2266 EXPECT_FALSE(child1->is_clipped()); 2267 EXPECT_FALSE(child1->is_clipped());
2267 EXPECT_FALSE(child2->is_clipped()); 2268 EXPECT_FALSE(child2->is_clipped());
2268 EXPECT_FALSE(grand_child->is_clipped()); 2269 EXPECT_FALSE(grand_child->is_clipped());
2269 EXPECT_FALSE(leaf_node1->is_clipped()); 2270 EXPECT_FALSE(leaf_node1->is_clipped());
2270 EXPECT_FALSE(leaf_node2->is_clipped()); 2271 EXPECT_FALSE(leaf_node2->is_clipped());
2271 EXPECT_TRUE(root->render_surface()->is_clipped()); 2272 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
2272 EXPECT_FALSE(child1->render_surface()->is_clipped()); 2273 EXPECT_FALSE(child1->GetRenderSurface()->is_clipped());
2273 EXPECT_FALSE(grand_child->render_surface()->is_clipped()); 2274 EXPECT_FALSE(grand_child->GetRenderSurface()->is_clipped());
2274 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2275 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect());
2275 2276
2276 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2277 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2277 EXPECT_FALSE(root->is_clipped()); 2278 EXPECT_FALSE(root->is_clipped());
2278 EXPECT_FALSE(parent->is_clipped()); 2279 EXPECT_FALSE(parent->is_clipped());
2279 EXPECT_FALSE(child1->is_clipped()); 2280 EXPECT_FALSE(child1->is_clipped());
2280 EXPECT_FALSE(child2->is_clipped()); 2281 EXPECT_FALSE(child2->is_clipped());
2281 EXPECT_FALSE(grand_child->is_clipped()); 2282 EXPECT_FALSE(grand_child->is_clipped());
2282 EXPECT_FALSE(leaf_node1->is_clipped()); 2283 EXPECT_FALSE(leaf_node1->is_clipped());
2283 EXPECT_FALSE(leaf_node2->is_clipped()); 2284 EXPECT_FALSE(leaf_node2->is_clipped());
2284 EXPECT_TRUE(root->render_surface()->is_clipped()); 2285 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
2285 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2286 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect());
2286 2287
2287 // Case 2: The root is clipped. In this case, layers that draw into the root 2288 // Case 2: The root is clipped. In this case, layers that draw into the root
2288 // render surface are clipped by the root's bounds. 2289 // render surface are clipped by the root's bounds.
2289 root->SetMasksToBounds(true); 2290 root->SetMasksToBounds(true);
2290 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 2291 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
2291 root->test_properties()->force_render_surface = true; 2292 root->test_properties()->force_render_surface = true;
2292 child1->test_properties()->force_render_surface = true; 2293 child1->test_properties()->force_render_surface = true;
2293 grand_child->test_properties()->force_render_surface = true; 2294 grand_child->test_properties()->force_render_surface = true;
2294 ExecuteCalculateDrawProperties(root); 2295 ExecuteCalculateDrawProperties(root);
2295 EXPECT_TRUE(root->has_render_surface()); 2296 EXPECT_TRUE(root->GetRenderSurface());
2296 EXPECT_FALSE(parent->has_render_surface()); 2297 EXPECT_FALSE(parent->GetRenderSurface());
2297 EXPECT_TRUE(child1->has_render_surface()); 2298 EXPECT_TRUE(child1->GetRenderSurface());
2298 EXPECT_FALSE(child2->has_render_surface()); 2299 EXPECT_FALSE(child2->GetRenderSurface());
2299 EXPECT_TRUE(grand_child->has_render_surface()); 2300 EXPECT_TRUE(grand_child->GetRenderSurface());
2300 EXPECT_FALSE(leaf_node1->has_render_surface()); 2301 EXPECT_FALSE(leaf_node1->GetRenderSurface());
2301 EXPECT_FALSE(leaf_node2->has_render_surface()); 2302 EXPECT_FALSE(leaf_node2->GetRenderSurface());
2302 EXPECT_TRUE(root->is_clipped()); 2303 EXPECT_TRUE(root->is_clipped());
2303 EXPECT_TRUE(parent->is_clipped()); 2304 EXPECT_TRUE(parent->is_clipped());
2304 EXPECT_FALSE(child1->is_clipped()); 2305 EXPECT_FALSE(child1->is_clipped());
2305 EXPECT_TRUE(child1->render_surface()->is_clipped()); 2306 EXPECT_TRUE(child1->GetRenderSurface()->is_clipped());
2306 EXPECT_TRUE(child2->is_clipped()); 2307 EXPECT_TRUE(child2->is_clipped());
2307 EXPECT_FALSE(grand_child->is_clipped()); 2308 EXPECT_FALSE(grand_child->is_clipped());
2308 EXPECT_FALSE(grand_child->render_surface()->is_clipped()); 2309 EXPECT_FALSE(grand_child->GetRenderSurface()->is_clipped());
2309 EXPECT_FALSE(leaf_node1->is_clipped()); 2310 EXPECT_FALSE(leaf_node1->is_clipped());
2310 EXPECT_TRUE(leaf_node2->is_clipped()); 2311 EXPECT_TRUE(leaf_node2->is_clipped());
2311 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2312 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
2312 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); 2313 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect());
2313 EXPECT_EQ(gfx::Rect(100, 100), child1->render_surface()->clip_rect()); 2314 EXPECT_EQ(gfx::Rect(100, 100), child1->GetRenderSurface()->clip_rect());
2314 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); 2315 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect());
2315 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); 2316 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect());
2316 2317
2317 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2318 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2318 EXPECT_TRUE(root->is_clipped()); 2319 EXPECT_TRUE(root->is_clipped());
2319 EXPECT_TRUE(parent->is_clipped()); 2320 EXPECT_TRUE(parent->is_clipped());
2320 EXPECT_TRUE(child1->is_clipped()); 2321 EXPECT_TRUE(child1->is_clipped());
2321 EXPECT_TRUE(child2->is_clipped()); 2322 EXPECT_TRUE(child2->is_clipped());
2322 EXPECT_TRUE(grand_child->is_clipped()); 2323 EXPECT_TRUE(grand_child->is_clipped());
2323 EXPECT_TRUE(leaf_node1->is_clipped()); 2324 EXPECT_TRUE(leaf_node1->is_clipped());
(...skipping 14 matching lines...) Expand all
2338 // child1's clip rect doesn't contribute to its descendants, since its only 2339 // child1's clip rect doesn't contribute to its descendants, since its only
2339 // child is a render surface. However, without surfaces, these clip rects 2340 // child is a render surface. However, without surfaces, these clip rects
2340 // contribute to all descendants. 2341 // contribute to all descendants.
2341 parent->SetMasksToBounds(true); 2342 parent->SetMasksToBounds(true);
2342 child1->SetMasksToBounds(true); 2343 child1->SetMasksToBounds(true);
2343 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 2344 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
2344 root->test_properties()->force_render_surface = true; 2345 root->test_properties()->force_render_surface = true;
2345 child1->test_properties()->force_render_surface = true; 2346 child1->test_properties()->force_render_surface = true;
2346 grand_child->test_properties()->force_render_surface = true; 2347 grand_child->test_properties()->force_render_surface = true;
2347 ExecuteCalculateDrawProperties(root); 2348 ExecuteCalculateDrawProperties(root);
2348 EXPECT_TRUE(root->has_render_surface()); 2349 EXPECT_TRUE(root->GetRenderSurface());
2349 EXPECT_FALSE(parent->has_render_surface()); 2350 EXPECT_FALSE(parent->GetRenderSurface());
2350 EXPECT_TRUE(child1->has_render_surface()); 2351 EXPECT_TRUE(child1->GetRenderSurface());
2351 EXPECT_FALSE(child2->has_render_surface()); 2352 EXPECT_FALSE(child2->GetRenderSurface());
2352 EXPECT_TRUE(grand_child->has_render_surface()); 2353 EXPECT_TRUE(grand_child->GetRenderSurface());
2353 EXPECT_FALSE(leaf_node1->has_render_surface()); 2354 EXPECT_FALSE(leaf_node1->GetRenderSurface());
2354 EXPECT_FALSE(leaf_node2->has_render_surface()); 2355 EXPECT_FALSE(leaf_node2->GetRenderSurface());
2355 EXPECT_FALSE(root->is_clipped()); 2356 EXPECT_FALSE(root->is_clipped());
2356 EXPECT_TRUE(root->render_surface()->is_clipped()); 2357 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
2357 EXPECT_TRUE(parent->is_clipped()); 2358 EXPECT_TRUE(parent->is_clipped());
2358 EXPECT_TRUE(child1->is_clipped()); 2359 EXPECT_TRUE(child1->is_clipped());
2359 EXPECT_TRUE(child2->is_clipped()); 2360 EXPECT_TRUE(child2->is_clipped());
2360 EXPECT_FALSE(grand_child->is_clipped()); 2361 EXPECT_FALSE(grand_child->is_clipped());
2361 EXPECT_TRUE(grand_child->render_surface()->is_clipped()); 2362 EXPECT_TRUE(grand_child->GetRenderSurface()->is_clipped());
2362 EXPECT_FALSE(leaf_node1->is_clipped()); 2363 EXPECT_FALSE(leaf_node1->is_clipped());
2363 EXPECT_TRUE(leaf_node2->is_clipped()); 2364 EXPECT_TRUE(leaf_node2->is_clipped());
2364 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2365 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect());
2365 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2366 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2366 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); 2367 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
2367 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); 2368 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
2368 EXPECT_EQ(gfx::Rect(800, 800), grand_child->render_surface()->clip_rect()); 2369 EXPECT_EQ(gfx::Rect(800, 800), grand_child->GetRenderSurface()->clip_rect());
2369 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); 2370 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
2370 2371
2371 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2372 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2372 EXPECT_FALSE(root->is_clipped()); 2373 EXPECT_FALSE(root->is_clipped());
2373 EXPECT_TRUE(root->render_surface()->is_clipped()); 2374 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
2374 EXPECT_TRUE(parent->is_clipped()); 2375 EXPECT_TRUE(parent->is_clipped());
2375 EXPECT_TRUE(child1->is_clipped()); 2376 EXPECT_TRUE(child1->is_clipped());
2376 EXPECT_TRUE(child2->is_clipped()); 2377 EXPECT_TRUE(child2->is_clipped());
2377 EXPECT_TRUE(grand_child->is_clipped()); 2378 EXPECT_TRUE(grand_child->is_clipped());
2378 EXPECT_TRUE(leaf_node1->is_clipped()); 2379 EXPECT_TRUE(leaf_node1->is_clipped());
2379 EXPECT_TRUE(leaf_node2->is_clipped()); 2380 EXPECT_TRUE(leaf_node2->is_clipped());
2380 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2381 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect());
2381 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2382 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2382 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect()); 2383 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect());
2383 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); 2384 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
2384 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect()); 2385 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect());
2385 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect()); 2386 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect());
2386 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); 2387 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
2387 } 2388 }
2388 2389
2389 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) { 2390 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) {
2390 LayerImpl* root = root_layer_for_testing(); 2391 LayerImpl* root = root_layer_for_testing();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), 2572 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(),
2572 timeline_impl(), 10.0, 30, 0); 2573 timeline_impl(), 10.0, 30, 0);
2573 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), 2574 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(),
2574 timeline_impl(), 10.0, 30, 0); 2575 timeline_impl(), 10.0, 30, 0);
2575 2576
2576 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 2577 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
2577 ExecuteCalculateDrawProperties(root); 2578 ExecuteCalculateDrawProperties(root);
2578 2579
2579 // Only layers that are associated with render surfaces should have an actual 2580 // Only layers that are associated with render surfaces should have an actual
2580 // RenderSurface() value. 2581 // RenderSurface() value.
2581 ASSERT_TRUE(root->render_surface()); 2582 ASSERT_TRUE(root->GetRenderSurface());
2582 ASSERT_FALSE(child_of_root->render_surface()); 2583 ASSERT_FALSE(child_of_root->GetRenderSurface());
2583 ASSERT_FALSE(grand_child_of_root->render_surface()); 2584 ASSERT_FALSE(grand_child_of_root->GetRenderSurface());
2584 2585
2585 ASSERT_TRUE(render_surface1->render_surface()); 2586 ASSERT_TRUE(render_surface1->GetRenderSurface());
2586 ASSERT_FALSE(child_of_rs1->render_surface()); 2587 ASSERT_FALSE(child_of_rs1->GetRenderSurface());
2587 ASSERT_FALSE(grand_child_of_rs1->render_surface()); 2588 ASSERT_FALSE(grand_child_of_rs1->GetRenderSurface());
2588 2589
2589 ASSERT_TRUE(render_surface2->render_surface()); 2590 ASSERT_TRUE(render_surface2->GetRenderSurface());
2590 ASSERT_FALSE(child_of_rs2->render_surface()); 2591 ASSERT_FALSE(child_of_rs2->GetRenderSurface());
2591 ASSERT_FALSE(grand_child_of_rs2->render_surface()); 2592 ASSERT_FALSE(grand_child_of_rs2->GetRenderSurface());
2592 2593
2593 // Verify all render target accessors 2594 // Verify all render target accessors
2594 EXPECT_EQ(root->render_surface(), root->render_target()); 2595 EXPECT_EQ(root->GetRenderSurface(), root->render_target());
2595 EXPECT_EQ(root->render_surface(), child_of_root->render_target()); 2596 EXPECT_EQ(root->GetRenderSurface(), child_of_root->render_target());
2596 EXPECT_EQ(root->render_surface(), grand_child_of_root->render_target()); 2597 EXPECT_EQ(root->GetRenderSurface(), grand_child_of_root->render_target());
2597 2598
2598 EXPECT_EQ(render_surface1->render_surface(), 2599 EXPECT_EQ(render_surface1->GetRenderSurface(),
2599 render_surface1->render_target()); 2600 render_surface1->render_target());
2600 EXPECT_EQ(render_surface1->render_surface(), child_of_rs1->render_target()); 2601 EXPECT_EQ(render_surface1->GetRenderSurface(), child_of_rs1->render_target());
2601 EXPECT_EQ(render_surface1->render_surface(), 2602 EXPECT_EQ(render_surface1->GetRenderSurface(),
2602 grand_child_of_rs1->render_target()); 2603 grand_child_of_rs1->render_target());
2603 2604
2604 EXPECT_EQ(render_surface2->render_surface(), 2605 EXPECT_EQ(render_surface2->GetRenderSurface(),
2605 render_surface2->render_target()); 2606 render_surface2->render_target());
2606 EXPECT_EQ(render_surface2->render_surface(), child_of_rs2->render_target()); 2607 EXPECT_EQ(render_surface2->GetRenderSurface(), child_of_rs2->render_target());
2607 EXPECT_EQ(render_surface2->render_surface(), 2608 EXPECT_EQ(render_surface2->GetRenderSurface(),
2608 grand_child_of_rs2->render_target()); 2609 grand_child_of_rs2->render_target());
2609 2610
2610 // Verify screen_space_transform_is_animating values 2611 // Verify screen_space_transform_is_animating values
2611 EXPECT_FALSE(root->screen_space_transform_is_animating()); 2612 EXPECT_FALSE(root->screen_space_transform_is_animating());
2612 EXPECT_FALSE(child_of_root->screen_space_transform_is_animating()); 2613 EXPECT_FALSE(child_of_root->screen_space_transform_is_animating());
2613 EXPECT_TRUE(grand_child_of_root->screen_space_transform_is_animating()); 2614 EXPECT_TRUE(grand_child_of_root->screen_space_transform_is_animating());
2614 EXPECT_FALSE(render_surface1->screen_space_transform_is_animating()); 2615 EXPECT_FALSE(render_surface1->screen_space_transform_is_animating());
2615 EXPECT_FALSE(child_of_rs1->screen_space_transform_is_animating()); 2616 EXPECT_FALSE(child_of_rs1->screen_space_transform_is_animating());
2616 EXPECT_FALSE(grand_child_of_rs1->screen_space_transform_is_animating()); 2617 EXPECT_FALSE(grand_child_of_rs1->screen_space_transform_is_animating());
2617 EXPECT_TRUE(render_surface2->screen_space_transform_is_animating()); 2618 EXPECT_TRUE(render_surface2->screen_space_transform_is_animating());
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 TEST_F(LayerTreeHostCommonTest, 3010 TEST_F(LayerTreeHostCommonTest,
3010 VisibleRectsForPositionedRootLayerClippedByViewport) { 3011 VisibleRectsForPositionedRootLayerClippedByViewport) {
3011 LayerImpl* root = root_layer_for_testing(); 3012 LayerImpl* root = root_layer_for_testing();
3012 3013
3013 root->SetPosition(gfx::PointF(60, 70)); 3014 root->SetPosition(gfx::PointF(60, 70));
3014 root->SetBounds(gfx::Size(100, 100)); 3015 root->SetBounds(gfx::Size(100, 100));
3015 root->SetDrawsContent(true); 3016 root->SetDrawsContent(true);
3016 ExecuteCalculateDrawProperties(root); 3017 ExecuteCalculateDrawProperties(root);
3017 3018
3018 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3019 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3019 root->render_surface()->DrawableContentRect()); 3020 root->GetRenderSurface()->DrawableContentRect());
3020 // In target space, not clipped. 3021 // In target space, not clipped.
3021 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); 3022 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect());
3022 // In layer space, clipped. 3023 // In layer space, clipped.
3023 EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect()); 3024 EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect());
3024 } 3025 }
3025 3026
3026 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { 3027 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
3027 LayerImpl* root = root_layer_for_testing(); 3028 LayerImpl* root = root_layer_for_testing();
3028 LayerImpl* child1_layer = AddChildToRoot<LayerImpl>(); 3029 LayerImpl* child1_layer = AddChildToRoot<LayerImpl>();
3029 LayerImpl* child2_layer = AddChildToRoot<LayerImpl>(); 3030 LayerImpl* child2_layer = AddChildToRoot<LayerImpl>();
3030 LayerImpl* child3_layer = AddChildToRoot<LayerImpl>(); 3031 LayerImpl* child3_layer = AddChildToRoot<LayerImpl>();
3031 3032
3032 root->SetBounds(gfx::Size(100, 100)); 3033 root->SetBounds(gfx::Size(100, 100));
3033 child1_layer->SetBounds(gfx::Size(50, 50)); 3034 child1_layer->SetBounds(gfx::Size(50, 50));
3034 child1_layer->SetDrawsContent(true); 3035 child1_layer->SetDrawsContent(true);
3035 child2_layer->SetPosition(gfx::PointF(75.f, 75.f)); 3036 child2_layer->SetPosition(gfx::PointF(75.f, 75.f));
3036 child2_layer->SetBounds(gfx::Size(50, 50)); 3037 child2_layer->SetBounds(gfx::Size(50, 50));
3037 child2_layer->SetDrawsContent(true); 3038 child2_layer->SetDrawsContent(true);
3038 child3_layer->SetPosition(gfx::PointF(125.f, 125.f)); 3039 child3_layer->SetPosition(gfx::PointF(125.f, 125.f));
3039 child3_layer->SetBounds(gfx::Size(50, 50)); 3040 child3_layer->SetBounds(gfx::Size(50, 50));
3040 child3_layer->SetDrawsContent(true); 3041 child3_layer->SetDrawsContent(true);
3041 ExecuteCalculateDrawProperties(root); 3042 ExecuteCalculateDrawProperties(root);
3042 3043
3043 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3044 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3044 root->render_surface()->DrawableContentRect()); 3045 root->GetRenderSurface()->DrawableContentRect());
3045 3046
3046 // Layers that do not draw content should have empty visible_layer_rects. 3047 // Layers that do not draw content should have empty visible_layer_rects.
3047 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3048 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3048 3049
3049 // layer visible_layer_rects are clipped by their target surface. 3050 // layer visible_layer_rects are clipped by their target surface.
3050 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->visible_layer_rect()); 3051 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->visible_layer_rect());
3051 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2_layer->visible_layer_rect()); 3052 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2_layer->visible_layer_rect());
3052 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty()); 3053 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty());
3053 3054
3054 // layer drawable_content_rects are not clipped. 3055 // layer drawable_content_rects are not clipped.
(...skipping 18 matching lines...) Expand all
3073 grand_child1->SetDrawsContent(true); 3074 grand_child1->SetDrawsContent(true);
3074 grand_child2->SetPosition(gfx::PointF(75.f, 75.f)); 3075 grand_child2->SetPosition(gfx::PointF(75.f, 75.f));
3075 grand_child2->SetBounds(gfx::Size(50, 50)); 3076 grand_child2->SetBounds(gfx::Size(50, 50));
3076 grand_child2->SetDrawsContent(true); 3077 grand_child2->SetDrawsContent(true);
3077 grand_child3->SetPosition(gfx::PointF(125.f, 125.f)); 3078 grand_child3->SetPosition(gfx::PointF(125.f, 125.f));
3078 grand_child3->SetBounds(gfx::Size(50, 50)); 3079 grand_child3->SetBounds(gfx::Size(50, 50));
3079 grand_child3->SetDrawsContent(true); 3080 grand_child3->SetDrawsContent(true);
3080 ExecuteCalculateDrawProperties(root); 3081 ExecuteCalculateDrawProperties(root);
3081 3082
3082 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3083 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3083 root->render_surface()->DrawableContentRect()); 3084 root->GetRenderSurface()->DrawableContentRect());
3084 3085
3085 // Layers that do not draw content should have empty visible content rects. 3086 // Layers that do not draw content should have empty visible content rects.
3086 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3087 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3087 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect()); 3088 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect());
3088 3089
3089 // All grandchild visible content rects should be clipped by child. 3090 // All grandchild visible content rects should be clipped by child.
3090 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect()); 3091 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect());
3091 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect()); 3092 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect());
3092 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty()); 3093 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty());
3093 3094
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 clip->SetBounds(gfx::Size(10, 10)); 3131 clip->SetBounds(gfx::Size(10, 10));
3131 filter->test_properties()->force_render_surface = true; 3132 filter->test_properties()->force_render_surface = true;
3132 filter_child->SetBounds(gfx::Size(2000, 2000)); 3133 filter_child->SetBounds(gfx::Size(2000, 2000));
3133 filter_child->SetPosition(gfx::PointF(-50, -50)); 3134 filter_child->SetPosition(gfx::PointF(-50, -50));
3134 filter_child->SetDrawsContent(true); 3135 filter_child->SetDrawsContent(true);
3135 3136
3136 clip->SetMasksToBounds(true); 3137 clip->SetMasksToBounds(true);
3137 3138
3138 ExecuteCalculateDrawProperties(root); 3139 ExecuteCalculateDrawProperties(root);
3139 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect()); 3140 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect());
3140 EXPECT_EQ(gfx::Rect(10, 10), filter->render_surface()->content_rect()); 3141 EXPECT_EQ(gfx::Rect(10, 10), filter->GetRenderSurface()->content_rect());
3141 3142
3142 FilterOperations blur_filter; 3143 FilterOperations blur_filter;
3143 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f)); 3144 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f));
3144 filter->test_properties()->filters = blur_filter; 3145 filter->test_properties()->filters = blur_filter;
3145 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 3146 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
3146 3147
3147 ExecuteCalculateDrawProperties(root); 3148 ExecuteCalculateDrawProperties(root);
3148 3149
3149 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect()); 3150 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect());
3150 EXPECT_EQ(gfx::Rect(-12, -12, 34, 34), 3151 EXPECT_EQ(gfx::Rect(-12, -12, 34, 34),
3151 filter->render_surface()->content_rect()); 3152 filter->GetRenderSurface()->content_rect());
3152 3153
3153 gfx::Transform vertical_flip; 3154 gfx::Transform vertical_flip;
3154 vertical_flip.Scale(1, -1); 3155 vertical_flip.Scale(1, -1);
3155 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter( 3156 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter(
3156 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr); 3157 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr);
3157 FilterOperations reflection_filter; 3158 FilterOperations reflection_filter;
3158 reflection_filter.Append( 3159 reflection_filter.Append(
3159 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make( 3160 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make(
3160 SkBlendMode::kSrcOver, std::move(flip_filter)))); 3161 SkBlendMode::kSrcOver, std::move(flip_filter))));
3161 filter->test_properties()->filters = reflection_filter; 3162 filter->test_properties()->filters = reflection_filter;
3162 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 3163 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
3163 3164
3164 ExecuteCalculateDrawProperties(root); 3165 ExecuteCalculateDrawProperties(root);
3165 3166
3166 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect()); 3167 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect());
3167 EXPECT_EQ(gfx::Rect(0, -10, 10, 20), 3168 EXPECT_EQ(gfx::Rect(0, -10, 10, 20),
3168 filter->render_surface()->content_rect()); 3169 filter->GetRenderSurface()->content_rect());
3169 } 3170 }
3170 3171
3171 TEST_F(LayerTreeHostCommonTest, VisibleRectWithScalingClippingAndFilters) { 3172 TEST_F(LayerTreeHostCommonTest, VisibleRectWithScalingClippingAndFilters) {
3172 LayerImpl* root = root_layer_for_testing(); 3173 LayerImpl* root = root_layer_for_testing();
3173 LayerImpl* scale = AddChild<LayerImpl>(root); 3174 LayerImpl* scale = AddChild<LayerImpl>(root);
3174 LayerImpl* clip = AddChild<LayerImpl>(scale); 3175 LayerImpl* clip = AddChild<LayerImpl>(scale);
3175 LayerImpl* filter = AddChild<LayerImpl>(clip); 3176 LayerImpl* filter = AddChild<LayerImpl>(clip);
3176 LayerImpl* filter_child = AddChild<LayerImpl>(filter); 3177 LayerImpl* filter_child = AddChild<LayerImpl>(filter);
3177 3178
3178 root->SetBounds(gfx::Size(100, 100)); 3179 root->SetBounds(gfx::Size(100, 100));
3179 clip->SetBounds(gfx::Size(10, 10)); 3180 clip->SetBounds(gfx::Size(10, 10));
3180 filter->test_properties()->force_render_surface = true; 3181 filter->test_properties()->force_render_surface = true;
3181 filter_child->SetBounds(gfx::Size(2000, 2000)); 3182 filter_child->SetBounds(gfx::Size(2000, 2000));
3182 filter_child->SetPosition(gfx::PointF(-50, -50)); 3183 filter_child->SetPosition(gfx::PointF(-50, -50));
3183 filter_child->SetDrawsContent(true); 3184 filter_child->SetDrawsContent(true);
3184 3185
3185 clip->SetMasksToBounds(true); 3186 clip->SetMasksToBounds(true);
3186 3187
3187 gfx::Transform scale_transform; 3188 gfx::Transform scale_transform;
3188 scale_transform.Scale(3, 3); 3189 scale_transform.Scale(3, 3);
3189 scale->test_properties()->transform = scale_transform; 3190 scale->test_properties()->transform = scale_transform;
3190 3191
3191 ExecuteCalculateDrawProperties(root); 3192 ExecuteCalculateDrawProperties(root);
3192 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect()); 3193 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect());
3193 EXPECT_EQ(gfx::Rect(30, 30), filter->render_surface()->content_rect()); 3194 EXPECT_EQ(gfx::Rect(30, 30), filter->GetRenderSurface()->content_rect());
3194 3195
3195 FilterOperations blur_filter; 3196 FilterOperations blur_filter;
3196 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f)); 3197 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f));
3197 filter->test_properties()->filters = blur_filter; 3198 filter->test_properties()->filters = blur_filter;
3198 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 3199 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
3199 3200
3200 ExecuteCalculateDrawProperties(root); 3201 ExecuteCalculateDrawProperties(root);
3201 3202
3202 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect()); 3203 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect());
3203 EXPECT_EQ(gfx::Rect(-36, -36, 102, 102), 3204 EXPECT_EQ(gfx::Rect(-36, -36, 102, 102),
3204 filter->render_surface()->content_rect()); 3205 filter->GetRenderSurface()->content_rect());
3205 3206
3206 gfx::Transform vertical_flip; 3207 gfx::Transform vertical_flip;
3207 vertical_flip.Scale(1, -1); 3208 vertical_flip.Scale(1, -1);
3208 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter( 3209 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter(
3209 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr); 3210 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr);
3210 FilterOperations reflection_filter; 3211 FilterOperations reflection_filter;
3211 reflection_filter.Append( 3212 reflection_filter.Append(
3212 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make( 3213 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make(
3213 SkBlendMode::kSrcOver, std::move(flip_filter)))); 3214 SkBlendMode::kSrcOver, std::move(flip_filter))));
3214 filter->test_properties()->filters = reflection_filter; 3215 filter->test_properties()->filters = reflection_filter;
3215 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 3216 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
3216 3217
3217 ExecuteCalculateDrawProperties(root); 3218 ExecuteCalculateDrawProperties(root);
3218 3219
3219 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect()); 3220 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect());
3220 EXPECT_EQ(gfx::Rect(0, -30, 30, 60), 3221 EXPECT_EQ(gfx::Rect(0, -30, 30, 60),
3221 filter->render_surface()->content_rect()); 3222 filter->GetRenderSurface()->content_rect());
3222 } 3223 }
3223 3224
3224 TEST_F(LayerTreeHostCommonTest, ClipRectWithClipParentAndFilters) { 3225 TEST_F(LayerTreeHostCommonTest, ClipRectWithClipParentAndFilters) {
3225 LayerImpl* root = root_layer_for_testing(); 3226 LayerImpl* root = root_layer_for_testing();
3226 LayerImpl* clip = AddChild<LayerImpl>(root); 3227 LayerImpl* clip = AddChild<LayerImpl>(root);
3227 LayerImpl* filter = AddChild<LayerImpl>(clip); 3228 LayerImpl* filter = AddChild<LayerImpl>(clip);
3228 LayerImpl* filter_child_1 = AddChild<LayerImpl>(filter); 3229 LayerImpl* filter_child_1 = AddChild<LayerImpl>(filter);
3229 LayerImpl* filter_child_2 = AddChild<LayerImpl>(filter); 3230 LayerImpl* filter_child_2 = AddChild<LayerImpl>(filter);
3230 3231
3231 root->SetBounds(gfx::Size(100, 100)); 3232 root->SetBounds(gfx::Size(100, 100));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 child1->SetBounds(gfx::Size(50, 50)); 3310 child1->SetBounds(gfx::Size(50, 50));
3310 child1->SetDrawsContent(true); 3311 child1->SetDrawsContent(true);
3311 child2->SetPosition(gfx::PointF(75.f, 75.f)); 3312 child2->SetPosition(gfx::PointF(75.f, 75.f));
3312 child2->SetBounds(gfx::Size(50, 50)); 3313 child2->SetBounds(gfx::Size(50, 50));
3313 child2->SetDrawsContent(true); 3314 child2->SetDrawsContent(true);
3314 child3->SetPosition(gfx::PointF(125.f, 125.f)); 3315 child3->SetPosition(gfx::PointF(125.f, 125.f));
3315 child3->SetBounds(gfx::Size(50, 50)); 3316 child3->SetBounds(gfx::Size(50, 50));
3316 child3->SetDrawsContent(true); 3317 child3->SetDrawsContent(true);
3317 ExecuteCalculateDrawProperties(root); 3318 ExecuteCalculateDrawProperties(root);
3318 3319
3319 ASSERT_TRUE(render_surface->render_surface()); 3320 ASSERT_TRUE(render_surface->GetRenderSurface());
3320 3321
3321 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3322 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3322 root->render_surface()->DrawableContentRect()); 3323 root->GetRenderSurface()->DrawableContentRect());
3323 3324
3324 // Layers that do not draw content should have empty visible content rects. 3325 // Layers that do not draw content should have empty visible content rects.
3325 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3326 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3326 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); 3327 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect());
3327 3328
3328 // An unclipped surface grows its DrawableContentRect to include all drawable 3329 // An unclipped surface grows its DrawableContentRect to include all drawable
3329 // regions of the subtree. 3330 // regions of the subtree.
3330 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), 3331 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f),
3331 render_surface->render_surface()->DrawableContentRect()); 3332 render_surface->GetRenderSurface()->DrawableContentRect());
3332 3333
3333 // All layers that draw content into the unclipped surface are also unclipped. 3334 // All layers that draw content into the unclipped surface are also unclipped.
3334 // Only the viewport clip should apply 3335 // Only the viewport clip should apply
3335 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); 3336 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3336 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); 3337 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
3337 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect()); 3338 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect());
3338 3339
3339 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3340 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3340 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3341 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3341 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3342 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 child3->SetPosition(gfx::PointF(125.f, 125.f)); 3537 child3->SetPosition(gfx::PointF(125.f, 125.f));
3537 child3->SetBounds(gfx::Size(50, 50)); 3538 child3->SetBounds(gfx::Size(50, 50));
3538 child3->SetDrawsContent(true); 3539 child3->SetDrawsContent(true);
3539 3540
3540 LayerImplList render_surface_layer_list_impl; 3541 LayerImplList render_surface_layer_list_impl;
3541 // Now set the root render surface an empty clip. 3542 // Now set the root render surface an empty clip.
3542 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 3543 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
3543 root, gfx::Size(), &render_surface_layer_list_impl); 3544 root, gfx::Size(), &render_surface_layer_list_impl);
3544 3545
3545 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 3546 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
3546 ASSERT_TRUE(root->render_surface()); 3547 ASSERT_TRUE(root->GetRenderSurface());
3547 EXPECT_FALSE(root->is_clipped()); 3548 EXPECT_FALSE(root->is_clipped());
3548 3549
3549 gfx::Rect empty; 3550 gfx::Rect empty;
3550 EXPECT_EQ(empty, root->render_surface()->clip_rect()); 3551 EXPECT_EQ(empty, root->GetRenderSurface()->clip_rect());
3551 EXPECT_TRUE(root->render_surface()->is_clipped()); 3552 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
3552 3553
3553 // Visible content rect calculation will check if the target surface is 3554 // Visible content rect calculation will check if the target surface is
3554 // clipped or not. An empty clip rect does not indicate the render surface 3555 // clipped or not. An empty clip rect does not indicate the render surface
3555 // is unclipped. 3556 // is unclipped.
3556 EXPECT_EQ(empty, child1->visible_layer_rect()); 3557 EXPECT_EQ(empty, child1->visible_layer_rect());
3557 EXPECT_EQ(empty, child2->visible_layer_rect()); 3558 EXPECT_EQ(empty, child2->visible_layer_rect());
3558 EXPECT_EQ(empty, child3->visible_layer_rect()); 3559 EXPECT_EQ(empty, child3->visible_layer_rect());
3559 } 3560 }
3560 3561
3561 TEST_F(LayerTreeHostCommonTest, 3562 TEST_F(LayerTreeHostCommonTest,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3695 child->test_properties()->AddChild(std::move(surface_sibling)); 3696 child->test_properties()->AddChild(std::move(surface_sibling));
3696 root->test_properties()->AddChild(std::move(child)); 3697 root->test_properties()->AddChild(std::move(child));
3697 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); 3698 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
3698 host_impl.SetVisible(true); 3699 host_impl.SetVisible(true);
3699 host_impl.InitializeRenderer(compositor_frame_sink.get()); 3700 host_impl.InitializeRenderer(compositor_frame_sink.get());
3700 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 3701 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
3701 bool update_lcd_text = false; 3702 bool update_lcd_text = false;
3702 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); 3703 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3703 3704
3704 EXPECT_TRANSFORMATION_MATRIX_EQ( 3705 EXPECT_TRANSFORMATION_MATRIX_EQ(
3705 surface_ptr->render_surface()->draw_transform(), translate); 3706 surface_ptr->GetRenderSurface()->draw_transform(), translate);
3706 // surface_sibling draws into the root render surface and occludes 3707 // surface_sibling draws into the root render surface and occludes
3707 // surface_child's contents. 3708 // surface_child's contents.
3708 Occlusion actual_occlusion = 3709 Occlusion actual_occlusion =
3709 surface_child_ptr->render_surface()->occlusion_in_content_space(); 3710 surface_child_ptr->GetRenderSurface()->occlusion_in_content_space();
3710 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), 3711 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()),
3711 SimpleEnclosedRegion(gfx::Rect(200, 200))); 3712 SimpleEnclosedRegion(gfx::Rect(200, 200)));
3712 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); 3713 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion));
3713 3714
3714 // Mask layer should have the same occlusion. 3715 // Mask layer should have the same occlusion.
3715 actual_occlusion = 3716 actual_occlusion =
3716 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; 3717 surface_child_mask_ptr->draw_properties().occlusion_in_content_space;
3717 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); 3718 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion));
3718 } 3719 }
3719 3720
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 child1->SetBounds(gfx::Size(50, 50)); 3853 child1->SetBounds(gfx::Size(50, 50));
3853 child1->SetDrawsContent(true); 3854 child1->SetDrawsContent(true);
3854 child2->SetPosition(gfx::PointF(75.f, 75.f)); 3855 child2->SetPosition(gfx::PointF(75.f, 75.f));
3855 child2->SetBounds(gfx::Size(50, 50)); 3856 child2->SetBounds(gfx::Size(50, 50));
3856 child2->SetDrawsContent(true); 3857 child2->SetDrawsContent(true);
3857 child3->SetPosition(gfx::PointF(125.f, 125.f)); 3858 child3->SetPosition(gfx::PointF(125.f, 125.f));
3858 child3->SetBounds(gfx::Size(50, 50)); 3859 child3->SetBounds(gfx::Size(50, 50));
3859 child3->SetDrawsContent(true); 3860 child3->SetDrawsContent(true);
3860 ExecuteCalculateDrawProperties(root); 3861 ExecuteCalculateDrawProperties(root);
3861 3862
3862 ASSERT_TRUE(render_surface->render_surface()); 3863 ASSERT_TRUE(render_surface->GetRenderSurface());
3863 3864
3864 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3865 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3865 root->render_surface()->DrawableContentRect()); 3866 root->GetRenderSurface()->DrawableContentRect());
3866 3867
3867 // Layers that do not draw content should have empty visible content rects. 3868 // Layers that do not draw content should have empty visible content rects.
3868 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3869 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3869 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); 3870 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect());
3870 3871
3871 // A clipped surface grows its DrawableContentRect to include all drawable 3872 // A clipped surface grows its DrawableContentRect to include all drawable
3872 // regions of the subtree, but also gets clamped by the ancestor's clip. 3873 // regions of the subtree, but also gets clamped by the ancestor's clip.
3873 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), 3874 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f),
3874 render_surface->render_surface()->DrawableContentRect()); 3875 render_surface->GetRenderSurface()->DrawableContentRect());
3875 3876
3876 // All layers that draw content into the surface have their visible content 3877 // All layers that draw content into the surface have their visible content
3877 // rect clipped by the surface clip rect. 3878 // rect clipped by the surface clip rect.
3878 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); 3879 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3879 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); 3880 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
3880 EXPECT_TRUE(child3->visible_layer_rect().IsEmpty()); 3881 EXPECT_TRUE(child3->visible_layer_rect().IsEmpty());
3881 3882
3882 // But the DrawableContentRects are unclipped. 3883 // But the DrawableContentRects are unclipped.
3883 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3884 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3884 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3885 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
(...skipping 20 matching lines...) Expand all
3905 child1->SetBounds(gfx::Size(50, 50)); 3906 child1->SetBounds(gfx::Size(50, 50));
3906 child1->SetDrawsContent(true); 3907 child1->SetDrawsContent(true);
3907 child2->SetPosition(gfx::PointF(75.f, 75.f)); 3908 child2->SetPosition(gfx::PointF(75.f, 75.f));
3908 child2->SetBounds(gfx::Size(50, 50)); 3909 child2->SetBounds(gfx::Size(50, 50));
3909 child2->SetDrawsContent(true); 3910 child2->SetDrawsContent(true);
3910 child3->SetPosition(gfx::PointF(125.f, 125.f)); 3911 child3->SetPosition(gfx::PointF(125.f, 125.f));
3911 child3->SetBounds(gfx::Size(50, 50)); 3912 child3->SetBounds(gfx::Size(50, 50));
3912 child3->SetDrawsContent(true); 3913 child3->SetDrawsContent(true);
3913 ExecuteCalculateDrawProperties(root); 3914 ExecuteCalculateDrawProperties(root);
3914 3915
3915 ASSERT_TRUE(render_surface1->render_surface()); 3916 ASSERT_TRUE(render_surface1->GetRenderSurface());
3916 ASSERT_TRUE(render_surface2->render_surface()); 3917 ASSERT_TRUE(render_surface2->GetRenderSurface());
3917 3918
3918 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3919 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3919 root->render_surface()->DrawableContentRect()); 3920 root->GetRenderSurface()->DrawableContentRect());
3920 3921
3921 // Layers that do not draw content should have empty visible content rects. 3922 // Layers that do not draw content should have empty visible content rects.
3922 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3923 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3923 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect()); 3924 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
3924 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect()); 3925 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect());
3925 3926
3926 // A clipped surface grows its DrawableContentRect to include all drawable 3927 // A clipped surface grows its DrawableContentRect to include all drawable
3927 // regions of the subtree, but also gets clamped by the ancestor's clip. 3928 // regions of the subtree, but also gets clamped by the ancestor's clip.
3928 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), 3929 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f),
3929 render_surface1->render_surface()->DrawableContentRect()); 3930 render_surface1->GetRenderSurface()->DrawableContentRect());
3930 3931
3931 // render_surface1 lives in the "unclipped universe" of render_surface1, and 3932 // render_surface1 lives in the "unclipped universe" of render_surface1, and
3932 // is only implicitly clipped by render_surface1's content rect. So, 3933 // is only implicitly clipped by render_surface1's content rect. So,
3933 // render_surface2 grows to enclose all drawable content of its subtree. 3934 // render_surface2 grows to enclose all drawable content of its subtree.
3934 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), 3935 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f),
3935 render_surface2->render_surface()->DrawableContentRect()); 3936 render_surface2->GetRenderSurface()->DrawableContentRect());
3936 3937
3937 // All layers that draw content into render_surface2 think they are unclipped 3938 // All layers that draw content into render_surface2 think they are unclipped
3938 // by the surface. So, only the viewport clip applies. 3939 // by the surface. So, only the viewport clip applies.
3939 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); 3940 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3940 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); 3941 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
3941 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect()); 3942 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect());
3942 3943
3943 // DrawableContentRects are also unclipped. 3944 // DrawableContentRects are also unclipped.
3944 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3945 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3945 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3946 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 clip_child->test_properties()->clip_parent = clip_parent; 4032 clip_child->test_properties()->clip_parent = clip_parent;
4032 4033
4033 render_surface2->SetBounds(gfx::Size(60, 60)); 4034 render_surface2->SetBounds(gfx::Size(60, 60));
4034 render_surface2->SetDrawsContent(true); 4035 render_surface2->SetDrawsContent(true);
4035 render_surface2->test_properties()->force_render_surface = true; 4036 render_surface2->test_properties()->force_render_surface = true;
4036 4037
4037 clip_parent->SetMasksToBounds(true); 4038 clip_parent->SetMasksToBounds(true);
4038 render_surface1->SetMasksToBounds(true); 4039 render_surface1->SetMasksToBounds(true);
4039 4040
4040 ExecuteCalculateDrawProperties(root); 4041 ExecuteCalculateDrawProperties(root);
4041 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->render_surface()->clip_rect()); 4042 EXPECT_EQ(gfx::Rect(50, 50),
4043 render_surface2->GetRenderSurface()->clip_rect());
4042 } 4044 }
4043 4045
4044 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWhenLayerNotDrawn) { 4046 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWhenLayerNotDrawn) {
4045 // Test that only drawn layers contribute to render surface content rect. 4047 // Test that only drawn layers contribute to render surface content rect.
4046 LayerImpl* root = root_layer_for_testing(); 4048 LayerImpl* root = root_layer_for_testing();
4047 LayerImpl* surface = AddChildToRoot<LayerImpl>(); 4049 LayerImpl* surface = AddChildToRoot<LayerImpl>();
4048 LayerImpl* test_layer = AddChild<LayerImpl>(surface); 4050 LayerImpl* test_layer = AddChild<LayerImpl>(surface);
4049 4051
4050 root->SetBounds(gfx::Size(200, 200)); 4052 root->SetBounds(gfx::Size(200, 200));
4051 surface->SetBounds(gfx::Size(100, 100)); 4053 surface->SetBounds(gfx::Size(100, 100));
4052 surface->SetDrawsContent(true); 4054 surface->SetDrawsContent(true);
4053 surface->test_properties()->force_render_surface = true; 4055 surface->test_properties()->force_render_surface = true;
4054 test_layer->SetBounds(gfx::Size(150, 150)); 4056 test_layer->SetBounds(gfx::Size(150, 150));
4055 4057
4056 ExecuteCalculateDrawProperties(root); 4058 ExecuteCalculateDrawProperties(root);
4057 EXPECT_EQ(gfx::Rect(100, 100), surface->render_surface()->content_rect()); 4059 EXPECT_EQ(gfx::Rect(100, 100), surface->GetRenderSurface()->content_rect());
4058 4060
4059 test_layer->SetDrawsContent(true); 4061 test_layer->SetDrawsContent(true);
4060 ExecuteCalculateDrawProperties(root); 4062 ExecuteCalculateDrawProperties(root);
4061 EXPECT_EQ(gfx::Rect(150, 150), surface->render_surface()->content_rect()); 4063 EXPECT_EQ(gfx::Rect(150, 150), surface->GetRenderSurface()->content_rect());
4062 } 4064 }
4063 4065
4064 TEST_F(LayerTreeHostCommonTest, VisibleRectsMultipleSurfaces) { 4066 TEST_F(LayerTreeHostCommonTest, VisibleRectsMultipleSurfaces) {
4065 // Tests visible rects computation when we have unclipped_surface-> 4067 // Tests visible rects computation when we have unclipped_surface->
4066 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds 4068 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds
4067 // of surface_with_unclipped_descendants doesn't propagate to the 4069 // of surface_with_unclipped_descendants doesn't propagate to the
4068 // clipped_surface below it. 4070 // clipped_surface below it.
4069 LayerImpl* root = root_layer_for_testing(); 4071 LayerImpl* root = root_layer_for_testing();
4070 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); 4072 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>();
4071 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); 4073 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 root->SetBounds(gfx::Size(100, 100)); 4161 root->SetBounds(gfx::Size(100, 100));
4160 render_surface->SetBounds(gfx::Size(3, 4)); 4162 render_surface->SetBounds(gfx::Size(3, 4));
4161 render_surface->test_properties()->force_render_surface = true; 4163 render_surface->test_properties()->force_render_surface = true;
4162 child1->test_properties()->transform = child_rotation; 4164 child1->test_properties()->transform = child_rotation;
4163 child1->SetPosition(gfx::PointF(25.f, 25.f)); 4165 child1->SetPosition(gfx::PointF(25.f, 25.f));
4164 child1->SetBounds(gfx::Size(50, 50)); 4166 child1->SetBounds(gfx::Size(50, 50));
4165 child1->SetDrawsContent(true); 4167 child1->SetDrawsContent(true);
4166 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); 4168 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f);
4167 ExecuteCalculateDrawProperties(root); 4169 ExecuteCalculateDrawProperties(root);
4168 4170
4169 ASSERT_TRUE(render_surface->render_surface()); 4171 ASSERT_TRUE(render_surface->GetRenderSurface());
4170 4172
4171 EXPECT_EQ(gfx::RectF(100.f, 100.f), 4173 EXPECT_EQ(gfx::RectF(100.f, 100.f),
4172 root->render_surface()->DrawableContentRect()); 4174 root->GetRenderSurface()->DrawableContentRect());
4173 4175
4174 // Layers that do not draw content should have empty visible content rects. 4176 // Layers that do not draw content should have empty visible content rects.
4175 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 4177 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
4176 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); 4178 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect());
4177 4179
4178 // The unclipped surface grows its DrawableContentRect to include all drawable 4180 // The unclipped surface grows its DrawableContentRect to include all drawable
4179 // regions of the subtree. 4181 // regions of the subtree.
4180 int diagonal_radius = ceil(sqrt(2.0) * 25.0); 4182 int diagonal_radius = ceil(sqrt(2.0) * 25.0);
4181 gfx::Rect expected_surface_drawable_content = 4183 gfx::Rect expected_surface_drawable_content =
4182 gfx::Rect(50 - diagonal_radius, 4184 gfx::Rect(50 - diagonal_radius,
4183 50 - diagonal_radius, 4185 50 - diagonal_radius,
4184 diagonal_radius * 2, 4186 diagonal_radius * 2,
4185 diagonal_radius * 2); 4187 diagonal_radius * 2);
4186 EXPECT_EQ(gfx::RectF(expected_surface_drawable_content), 4188 EXPECT_EQ(gfx::RectF(expected_surface_drawable_content),
4187 render_surface->render_surface()->DrawableContentRect()); 4189 render_surface->GetRenderSurface()->DrawableContentRect());
4188 4190
4189 // All layers that draw content into the unclipped surface are also unclipped. 4191 // All layers that draw content into the unclipped surface are also unclipped.
4190 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); 4192 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
4191 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect()); 4193 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect());
4192 } 4194 }
4193 4195
4194 TEST_F(LayerTreeHostCommonTest, 4196 TEST_F(LayerTreeHostCommonTest,
4195 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { 4197 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) {
4196 // Layers that have non-axis aligned bounds (due to transforms) have an 4198 // Layers that have non-axis aligned bounds (due to transforms) have an
4197 // expanded, axis-aligned DrawableContentRect and visible content rect. 4199 // expanded, axis-aligned DrawableContentRect and visible content rect.
4198 LayerImpl* root = root_layer_for_testing(); 4200 LayerImpl* root = root_layer_for_testing();
4199 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); 4201 LayerImpl* render_surface = AddChildToRoot<LayerImpl>();
4200 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); 4202 LayerImpl* child1 = AddChild<LayerImpl>(render_surface);
4201 4203
4202 gfx::Transform child_rotation; 4204 gfx::Transform child_rotation;
4203 child_rotation.Rotate(45.0); 4205 child_rotation.Rotate(45.0);
4204 4206
4205 root->SetBounds(gfx::Size(50, 50)); 4207 root->SetBounds(gfx::Size(50, 50));
4206 root->SetMasksToBounds(true); 4208 root->SetMasksToBounds(true);
4207 render_surface->SetBounds(gfx::Size(3, 4)); 4209 render_surface->SetBounds(gfx::Size(3, 4));
4208 render_surface->test_properties()->force_render_surface = true; 4210 render_surface->test_properties()->force_render_surface = true;
4209 child1->SetPosition(gfx::PointF(25.f, 25.f)); 4211 child1->SetPosition(gfx::PointF(25.f, 25.f));
4210 child1->SetBounds(gfx::Size(50, 50)); 4212 child1->SetBounds(gfx::Size(50, 50));
4211 child1->SetDrawsContent(true); 4213 child1->SetDrawsContent(true);
4212 child1->test_properties()->transform = child_rotation; 4214 child1->test_properties()->transform = child_rotation;
4213 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); 4215 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f);
4214 ExecuteCalculateDrawProperties(root); 4216 ExecuteCalculateDrawProperties(root);
4215 4217
4216 ASSERT_TRUE(render_surface->render_surface()); 4218 ASSERT_TRUE(render_surface->GetRenderSurface());
4217 4219
4218 // The clipped surface clamps the DrawableContentRect that encloses the 4220 // The clipped surface clamps the DrawableContentRect that encloses the
4219 // rotated layer. 4221 // rotated layer.
4220 int diagonal_radius = ceil(sqrt(2.0) * 25.0); 4222 int diagonal_radius = ceil(sqrt(2.0) * 25.0);
4221 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius, 4223 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius,
4222 50 - diagonal_radius, 4224 50 - diagonal_radius,
4223 diagonal_radius * 2, 4225 diagonal_radius * 2,
4224 diagonal_radius * 2); 4226 diagonal_radius * 2);
4225 gfx::RectF expected_surface_drawable_content( 4227 gfx::RectF expected_surface_drawable_content(
4226 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(50, 50))); 4228 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(50, 50)));
4227 EXPECT_EQ(expected_surface_drawable_content, 4229 EXPECT_EQ(expected_surface_drawable_content,
4228 render_surface->render_surface()->DrawableContentRect()); 4230 render_surface->GetRenderSurface()->DrawableContentRect());
4229 4231
4230 // On the clipped surface, only a quarter of the child1 is visible, but when 4232 // On the clipped surface, only a quarter of the child1 is visible, but when
4231 // rotating it back to child1's content space, the actual enclosing rect ends 4233 // rotating it back to child1's content space, the actual enclosing rect ends
4232 // up covering the full left half of child1. 4234 // up covering the full left half of child1.
4233 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect()); 4235 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect());
4234 4236
4235 // The child's DrawableContentRect is unclipped. 4237 // The child's DrawableContentRect is unclipped.
4236 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); 4238 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect());
4237 } 4239 }
4238 4240
(...skipping 25 matching lines...) Expand all
4264 child1->SetDrawsContent(true); 4266 child1->SetDrawsContent(true);
4265 child2->SetBounds(gfx::Size(50, 50)); 4267 child2->SetBounds(gfx::Size(50, 50));
4266 child2->SetPosition(gfx::PointF(75.f, 75.f)); 4268 child2->SetPosition(gfx::PointF(75.f, 75.f));
4267 child2->SetDrawsContent(true); 4269 child2->SetDrawsContent(true);
4268 child3->SetBounds(gfx::Size(50, 50)); 4270 child3->SetBounds(gfx::Size(50, 50));
4269 child3->SetPosition(gfx::PointF(125.f, 125.f)); 4271 child3->SetPosition(gfx::PointF(125.f, 125.f));
4270 child3->SetDrawsContent(true); 4272 child3->SetDrawsContent(true);
4271 float device_scale_factor = 2.f; 4273 float device_scale_factor = 2.f;
4272 ExecuteCalculateDrawProperties(root, device_scale_factor); 4274 ExecuteCalculateDrawProperties(root, device_scale_factor);
4273 4275
4274 ASSERT_TRUE(render_surface1->render_surface()); 4276 ASSERT_TRUE(render_surface1->GetRenderSurface());
4275 ASSERT_TRUE(render_surface2->render_surface()); 4277 ASSERT_TRUE(render_surface2->GetRenderSurface());
4276 4278
4277 // drawable_content_rects for all layers and surfaces are scaled by 4279 // drawable_content_rects for all layers and surfaces are scaled by
4278 // device_scale_factor. 4280 // device_scale_factor.
4279 EXPECT_EQ(gfx::RectF(200.f, 200.f), 4281 EXPECT_EQ(gfx::RectF(200.f, 200.f),
4280 root->render_surface()->DrawableContentRect()); 4282 root->GetRenderSurface()->DrawableContentRect());
4281 EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f), 4283 EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f),
4282 render_surface1->render_surface()->DrawableContentRect()); 4284 render_surface1->GetRenderSurface()->DrawableContentRect());
4283 4285
4284 // render_surface2 lives in the "unclipped universe" of render_surface1, and 4286 // render_surface2 lives in the "unclipped universe" of render_surface1, and
4285 // is only implicitly clipped by render_surface1. 4287 // is only implicitly clipped by render_surface1.
4286 EXPECT_EQ(gfx::RectF(10.f, 10.f, 350.f, 350.f), 4288 EXPECT_EQ(gfx::RectF(10.f, 10.f, 350.f, 350.f),
4287 render_surface2->render_surface()->DrawableContentRect()); 4289 render_surface2->GetRenderSurface()->DrawableContentRect());
4288 4290
4289 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect()); 4291 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect());
4290 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect()); 4292 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect());
4291 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect()); 4293 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect());
4292 4294
4293 // The root layer does not actually draw content of its own. 4295 // The root layer does not actually draw content of its own.
4294 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 4296 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
4295 4297
4296 // All layer visible content rects are not expressed in content space of each 4298 // All layer visible content rects are not expressed in content space of each
4297 // layer, so they are not scaled by the device_scale_factor. 4299 // layer, so they are not scaled by the device_scale_factor.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4369 backface_matrix; 4371 backface_matrix;
4370 back_facing_child_of_back_facing_surface->test_properties()->transform = 4372 back_facing_child_of_back_facing_surface->test_properties()->transform =
4371 backface_matrix; 4373 backface_matrix;
4372 4374
4373 // Note: No layers preserve 3d. According to current W3C CSS gfx::Transforms 4375 // Note: No layers preserve 3d. According to current W3C CSS gfx::Transforms
4374 // spec, these layers should blindly use their own local transforms to 4376 // spec, these layers should blindly use their own local transforms to
4375 // determine back-face culling. 4377 // determine back-face culling.
4376 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 4378 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
4377 4379
4378 // Verify which render surfaces were created. 4380 // Verify which render surfaces were created.
4379 EXPECT_FALSE(front_facing_child->has_render_surface()); 4381 EXPECT_FALSE(front_facing_child->GetRenderSurface());
4380 EXPECT_FALSE(back_facing_child->has_render_surface()); 4382 EXPECT_FALSE(back_facing_child->GetRenderSurface());
4381 EXPECT_TRUE(front_facing_surface->has_render_surface()); 4383 EXPECT_TRUE(front_facing_surface->GetRenderSurface());
4382 EXPECT_TRUE(back_facing_surface->has_render_surface()); 4384 EXPECT_TRUE(back_facing_surface->GetRenderSurface());
4383 EXPECT_FALSE( 4385 EXPECT_FALSE(front_facing_child_of_front_facing_surface->GetRenderSurface());
4384 front_facing_child_of_front_facing_surface->has_render_surface()); 4386 EXPECT_FALSE(back_facing_child_of_front_facing_surface->GetRenderSurface());
4385 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface()); 4387 EXPECT_FALSE(front_facing_child_of_back_facing_surface->GetRenderSurface());
4386 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface()); 4388 EXPECT_FALSE(back_facing_child_of_back_facing_surface->GetRenderSurface());
4387 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface());
4388 4389
4389 EXPECT_EQ(3u, update_layer_list_impl()->size()); 4390 EXPECT_EQ(3u, update_layer_list_impl()->size());
4390 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); 4391 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id()));
4391 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); 4392 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id()));
4392 EXPECT_TRUE(UpdateLayerListImplContains( 4393 EXPECT_TRUE(UpdateLayerListImplContains(
4393 front_facing_child_of_front_facing_surface->id())); 4394 front_facing_child_of_front_facing_surface->id()));
4394 } 4395 }
4395 4396
4396 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { 4397 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
4397 // Verify the behavior of back-face culling when preserves-3d transform style 4398 // Verify the behavior of back-face culling when preserves-3d transform style
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4478 back_facing_child_of_front_facing_surface->test_properties() 4479 back_facing_child_of_front_facing_surface->test_properties()
4479 ->sorting_context_id = 1; 4480 ->sorting_context_id = 1;
4480 front_facing_child_of_back_facing_surface->test_properties() 4481 front_facing_child_of_back_facing_surface->test_properties()
4481 ->sorting_context_id = 1; 4482 ->sorting_context_id = 1;
4482 back_facing_child_of_back_facing_surface->test_properties() 4483 back_facing_child_of_back_facing_surface->test_properties()
4483 ->sorting_context_id = 1; 4484 ->sorting_context_id = 1;
4484 4485
4485 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 4486 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
4486 4487
4487 // Verify which render surfaces were created and used. 4488 // Verify which render surfaces were created and used.
4488 EXPECT_FALSE(front_facing_child->has_render_surface()); 4489 EXPECT_FALSE(front_facing_child->GetRenderSurface());
4489 EXPECT_FALSE(back_facing_child->has_render_surface()); 4490 EXPECT_FALSE(back_facing_child->GetRenderSurface());
4490 EXPECT_TRUE(front_facing_surface->has_render_surface()); 4491 EXPECT_TRUE(front_facing_surface->GetRenderSurface());
4491 // We expect that a has_render_surface was created but not used. 4492 // We expect that a has_render_surface was created but not used.
4492 EXPECT_TRUE(back_facing_surface->has_render_surface()); 4493 EXPECT_TRUE(back_facing_surface->GetRenderSurface());
4493 EXPECT_FALSE( 4494 EXPECT_FALSE(front_facing_child_of_front_facing_surface->GetRenderSurface());
4494 front_facing_child_of_front_facing_surface->has_render_surface()); 4495 EXPECT_FALSE(back_facing_child_of_front_facing_surface->GetRenderSurface());
4495 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface()); 4496 EXPECT_FALSE(front_facing_child_of_back_facing_surface->GetRenderSurface());
4496 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface()); 4497 EXPECT_FALSE(back_facing_child_of_back_facing_surface->GetRenderSurface());
4497 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface());
4498 4498
4499 EXPECT_EQ(3u, update_layer_list_impl()->size()); 4499 EXPECT_EQ(3u, update_layer_list_impl()->size());
4500 4500
4501 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); 4501 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id()));
4502 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); 4502 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id()));
4503 EXPECT_TRUE(UpdateLayerListImplContains( 4503 EXPECT_TRUE(UpdateLayerListImplContains(
4504 front_facing_child_of_front_facing_surface->id())); 4504 front_facing_child_of_front_facing_surface->id()));
4505 } 4505 }
4506 4506
4507 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { 4507 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4553 animating_surface->test_properties()->transform = backface_matrix; 4553 animating_surface->test_properties()->transform = backface_matrix;
4554 animating_surface->test_properties()->force_render_surface = true; 4554 animating_surface->test_properties()->force_render_surface = true;
4555 child_of_animating_surface->SetBounds(gfx::Size(100, 100)); 4555 child_of_animating_surface->SetBounds(gfx::Size(100, 100));
4556 child_of_animating_surface->test_properties()->transform = backface_matrix; 4556 child_of_animating_surface->test_properties()->transform = backface_matrix;
4557 animating_child->SetBounds(gfx::Size(100, 100)); 4557 animating_child->SetBounds(gfx::Size(100, 100));
4558 animating_child->test_properties()->transform = backface_matrix; 4558 animating_child->test_properties()->transform = backface_matrix;
4559 child2->SetBounds(gfx::Size(100, 100)); 4559 child2->SetBounds(gfx::Size(100, 100));
4560 4560
4561 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 4561 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
4562 4562
4563 EXPECT_FALSE(child->has_render_surface()); 4563 EXPECT_FALSE(child->GetRenderSurface());
4564 EXPECT_TRUE(animating_surface->has_render_surface()); 4564 EXPECT_TRUE(animating_surface->GetRenderSurface());
4565 EXPECT_FALSE(child_of_animating_surface->has_render_surface()); 4565 EXPECT_FALSE(child_of_animating_surface->GetRenderSurface());
4566 EXPECT_FALSE(animating_child->has_render_surface()); 4566 EXPECT_FALSE(animating_child->GetRenderSurface());
4567 EXPECT_FALSE(child2->has_render_surface()); 4567 EXPECT_FALSE(child2->GetRenderSurface());
4568 4568
4569 EXPECT_EQ(1u, update_layer_list_impl()->size()); 4569 EXPECT_EQ(1u, update_layer_list_impl()->size());
4570 4570
4571 // The back facing layers are culled from the layer list, and have an empty 4571 // The back facing layers are culled from the layer list, and have an empty
4572 // visible rect. 4572 // visible rect.
4573 EXPECT_TRUE(UpdateLayerListImplContains(child2->id())); 4573 EXPECT_TRUE(UpdateLayerListImplContains(child2->id()));
4574 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); 4574 EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
4575 EXPECT_TRUE(animating_surface->visible_layer_rect().IsEmpty()); 4575 EXPECT_TRUE(animating_surface->visible_layer_rect().IsEmpty());
4576 EXPECT_TRUE(child_of_animating_surface->visible_layer_rect().IsEmpty()); 4576 EXPECT_TRUE(child_of_animating_surface->visible_layer_rect().IsEmpty());
4577 EXPECT_TRUE(animating_child->visible_layer_rect().IsEmpty()); 4577 EXPECT_TRUE(animating_child->visible_layer_rect().IsEmpty());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4613 back_facing_surface->test_properties()->force_render_surface = true; 4613 back_facing_surface->test_properties()->force_render_surface = true;
4614 child1->SetBounds(gfx::Size(100, 100)); 4614 child1->SetBounds(gfx::Size(100, 100));
4615 child2->SetBounds(gfx::Size(100, 100)); 4615 child2->SetBounds(gfx::Size(100, 100));
4616 4616
4617 front_facing_surface->test_properties()->sorting_context_id = 1; 4617 front_facing_surface->test_properties()->sorting_context_id = 1;
4618 back_facing_surface->test_properties()->sorting_context_id = 1; 4618 back_facing_surface->test_properties()->sorting_context_id = 1;
4619 4619
4620 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 4620 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
4621 4621
4622 // Verify which render surfaces were created and used. 4622 // Verify which render surfaces were created and used.
4623 EXPECT_TRUE(front_facing_surface->has_render_surface()); 4623 EXPECT_TRUE(front_facing_surface->GetRenderSurface());
4624 4624
4625 // We expect the render surface to have been created, but remain unused. 4625 // We expect the render surface to have been created, but remain unused.
4626 EXPECT_TRUE(back_facing_surface->has_render_surface()); 4626 EXPECT_TRUE(back_facing_surface->GetRenderSurface());
4627 EXPECT_FALSE(child1->has_render_surface()); 4627 EXPECT_FALSE(child1->GetRenderSurface());
4628 EXPECT_FALSE(child2->has_render_surface()); 4628 EXPECT_FALSE(child2->GetRenderSurface());
4629 4629
4630 EXPECT_EQ(2u, update_layer_list_impl()->size()); 4630 EXPECT_EQ(2u, update_layer_list_impl()->size());
4631 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); 4631 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id()));
4632 EXPECT_TRUE(UpdateLayerListImplContains(child1->id())); 4632 EXPECT_TRUE(UpdateLayerListImplContains(child1->id()));
4633 } 4633 }
4634 4634
4635 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { 4635 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) {
4636 // Verify draw and screen space transforms of layers not in a surface. 4636 // Verify draw and screen space transforms of layers not in a surface.
4637 LayerImpl* root = root_layer_for_testing(); 4637 LayerImpl* root = root_layer_for_testing();
4638 root->SetBounds(gfx::Size(100, 100)); 4638 root->SetBounds(gfx::Size(100, 100));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
4802 expected_perspective_surface_draw_transform.PreconcatTransform( 4802 expected_perspective_surface_draw_transform.PreconcatTransform(
4803 perspective_matrix); 4803 perspective_matrix);
4804 expected_perspective_surface_draw_transform.PreconcatTransform( 4804 expected_perspective_surface_draw_transform.PreconcatTransform(
4805 scale_small_matrix); 4805 scale_small_matrix);
4806 gfx::Transform expected_perspective_surface_layer_draw_transform; 4806 gfx::Transform expected_perspective_surface_layer_draw_transform;
4807 expected_perspective_surface_layer_draw_transform.Scale( 4807 expected_perspective_surface_layer_draw_transform.Scale(
4808 device_scale_factor * page_scale_factor, 4808 device_scale_factor * page_scale_factor,
4809 device_scale_factor * page_scale_factor); 4809 device_scale_factor * page_scale_factor);
4810 EXPECT_TRANSFORMATION_MATRIX_EQ( 4810 EXPECT_TRANSFORMATION_MATRIX_EQ(
4811 expected_perspective_surface_draw_transform, 4811 expected_perspective_surface_draw_transform,
4812 perspective_surface->render_surface()->draw_transform()); 4812 perspective_surface->GetRenderSurface()->draw_transform());
4813 EXPECT_TRANSFORMATION_MATRIX_EQ( 4813 EXPECT_TRANSFORMATION_MATRIX_EQ(
4814 expected_perspective_surface_layer_draw_transform, 4814 expected_perspective_surface_layer_draw_transform,
4815 perspective_surface->DrawTransform()); 4815 perspective_surface->DrawTransform());
4816 } 4816 }
4817 4817
4818 TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) { 4818 TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) {
4819 gfx::Transform parent_scale_matrix; 4819 gfx::Transform parent_scale_matrix;
4820 SkMScalar initial_parent_scale = 1.75; 4820 SkMScalar initial_parent_scale = 1.75;
4821 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4821 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4822 4822
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
4945 duplicate_child_non_owner->ScreenSpaceTransform()); 4945 duplicate_child_non_owner->ScreenSpaceTransform());
4946 EXPECT_EQ(child->drawable_content_rect(), 4946 EXPECT_EQ(child->drawable_content_rect(),
4947 duplicate_child_non_owner->drawable_content_rect()); 4947 duplicate_child_non_owner->drawable_content_rect());
4948 EXPECT_EQ(child->bounds(), duplicate_child_non_owner->bounds()); 4948 EXPECT_EQ(child->bounds(), duplicate_child_non_owner->bounds());
4949 4949
4950 gfx::Transform expected_render_surface_draw_transform; 4950 gfx::Transform expected_render_surface_draw_transform;
4951 expected_render_surface_draw_transform.Translate( 4951 expected_render_surface_draw_transform.Translate(
4952 device_scale_factor * child->position().x(), 4952 device_scale_factor * child->position().x(),
4953 device_scale_factor * child->position().y()); 4953 device_scale_factor * child->position().y());
4954 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_render_surface_draw_transform, 4954 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_render_surface_draw_transform,
4955 child->render_surface()->draw_transform()); 4955 child->GetRenderSurface()->draw_transform());
4956 4956
4957 gfx::Transform expected_surface_draw_transform; 4957 gfx::Transform expected_surface_draw_transform;
4958 expected_surface_draw_transform.Translate(device_scale_factor * 2.f, 4958 expected_surface_draw_transform.Translate(device_scale_factor * 2.f,
4959 device_scale_factor * 2.f); 4959 device_scale_factor * 2.f);
4960 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_surface_draw_transform, 4960 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_surface_draw_transform,
4961 child->render_surface()->draw_transform()); 4961 child->GetRenderSurface()->draw_transform());
4962 4962
4963 gfx::Transform expected_surface_screen_space_transform; 4963 gfx::Transform expected_surface_screen_space_transform;
4964 expected_surface_screen_space_transform.Translate(device_scale_factor * 2.f, 4964 expected_surface_screen_space_transform.Translate(device_scale_factor * 2.f,
4965 device_scale_factor * 2.f); 4965 device_scale_factor * 2.f);
4966 EXPECT_TRANSFORMATION_MATRIX_EQ( 4966 EXPECT_TRANSFORMATION_MATRIX_EQ(
4967 expected_surface_screen_space_transform, 4967 expected_surface_screen_space_transform,
4968 child->render_surface()->screen_space_transform()); 4968 child->GetRenderSurface()->screen_space_transform());
4969 } 4969 }
4970 4970
4971 TEST_F(LayerTreeHostCommonTest, 4971 TEST_F(LayerTreeHostCommonTest,
4972 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { 4972 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) {
4973 LayerImpl* parent = root_layer_for_testing(); 4973 LayerImpl* parent = root_layer_for_testing();
4974 parent->SetBounds(gfx::Size(33, 31)); 4974 parent->SetBounds(gfx::Size(33, 31));
4975 parent->SetDrawsContent(true); 4975 parent->SetDrawsContent(true);
4976 4976
4977 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4977 LayerImpl* child = AddChildToRoot<LayerImpl>();
4978 child->SetBounds(gfx::Size(13, 11)); 4978 child->SetBounds(gfx::Size(13, 11));
4979 child->SetDrawsContent(true); 4979 child->SetDrawsContent(true);
4980 child->test_properties()->force_render_surface = true; 4980 child->test_properties()->force_render_surface = true;
4981 4981
4982 float device_scale_factor = 1.7f; 4982 float device_scale_factor = 1.7f;
4983 ExecuteCalculateDrawProperties(parent, device_scale_factor); 4983 ExecuteCalculateDrawProperties(parent, device_scale_factor);
4984 4984
4985 // We should have two render surfaces. The root's render surface and child's 4985 // We should have two render surfaces. The root's render surface and child's
4986 // render surface (it needs one because of force_render_surface). 4986 // render surface (it needs one because of force_render_surface).
4987 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 4987 EXPECT_EQ(2u, render_surface_layer_list_impl()->size());
4988 4988
4989 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 4989 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
4990 child->render_surface()->draw_transform()); 4990 child->GetRenderSurface()->draw_transform());
4991 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 4991 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
4992 child->render_surface()->draw_transform()); 4992 child->GetRenderSurface()->draw_transform());
4993 EXPECT_TRANSFORMATION_MATRIX_EQ( 4993 EXPECT_TRANSFORMATION_MATRIX_EQ(
4994 gfx::Transform(), child->render_surface()->screen_space_transform()); 4994 gfx::Transform(), child->GetRenderSurface()->screen_space_transform());
4995 } 4995 }
4996 4996
4997 TEST_F(LayerTreeHostCommonTest, LayerSearch) { 4997 TEST_F(LayerTreeHostCommonTest, LayerSearch) {
4998 scoped_refptr<Layer> root = Layer::Create(); 4998 scoped_refptr<Layer> root = Layer::Create();
4999 scoped_refptr<Layer> child = Layer::Create(); 4999 scoped_refptr<Layer> child = Layer::Create();
5000 scoped_refptr<Layer> grand_child = Layer::Create(); 5000 scoped_refptr<Layer> grand_child = Layer::Create();
5001 scoped_refptr<Layer> mask_layer = Layer::Create(); 5001 scoped_refptr<Layer> mask_layer = Layer::Create();
5002 5002
5003 child->AddChild(grand_child.get()); 5003 child->AddChild(grand_child.get());
5004 child->SetMaskLayer(mask_layer.get()); 5004 child->SetMaskLayer(mask_layer.get());
(...skipping 13 matching lines...) Expand all
5018 LayerImpl* root = root_layer_for_testing(); 5018 LayerImpl* root = root_layer_for_testing();
5019 LayerImpl* child = AddChild<LayerImpl>(root); 5019 LayerImpl* child = AddChild<LayerImpl>(root);
5020 LayerImpl* grand_child = AddChild<LayerImpl>(child); 5020 LayerImpl* grand_child = AddChild<LayerImpl>(child);
5021 5021
5022 root->SetBounds(gfx::Size(100, 100)); 5022 root->SetBounds(gfx::Size(100, 100));
5023 child->SetBounds(gfx::Size(10, 10)); 5023 child->SetBounds(gfx::Size(10, 10));
5024 child->test_properties()->opacity = 0.5f; 5024 child->test_properties()->opacity = 0.5f;
5025 grand_child->SetBounds(gfx::Size(10, 10)); 5025 grand_child->SetBounds(gfx::Size(10, 10));
5026 grand_child->SetDrawsContent(true); 5026 grand_child->SetDrawsContent(true);
5027 ExecuteCalculateDrawProperties(root); 5027 ExecuteCalculateDrawProperties(root);
5028 EXPECT_FALSE(child->has_render_surface()); 5028 EXPECT_FALSE(child->GetRenderSurface());
5029 } 5029 }
5030 5030
5031 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { 5031 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
5032 FakeImplTaskRunnerProvider task_runner_provider; 5032 FakeImplTaskRunnerProvider task_runner_provider;
5033 TestTaskGraphRunner task_graph_runner; 5033 TestTaskGraphRunner task_graph_runner;
5034 FakeLayerTreeHostImpl host_impl(host()->GetSettings(), &task_runner_provider, 5034 FakeLayerTreeHostImpl host_impl(host()->GetSettings(), &task_runner_provider,
5035 &task_graph_runner); 5035 &task_graph_runner);
5036 host_impl.CreatePendingTree(); 5036 host_impl.CreatePendingTree();
5037 std::unique_ptr<LayerImpl> root = 5037 std::unique_ptr<LayerImpl> root =
5038 LayerImpl::Create(host_impl.pending_tree(), 1); 5038 LayerImpl::Create(host_impl.pending_tree(), 1);
(...skipping 26 matching lines...) Expand all
5065 5065
5066 LayerImplList render_surface_layer_list; 5066 LayerImplList render_surface_layer_list;
5067 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5067 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5068 root_layer, root_layer->bounds(), &render_surface_layer_list); 5068 root_layer, root_layer->bounds(), &render_surface_layer_list);
5069 inputs.can_adjust_raster_scales = true; 5069 inputs.can_adjust_raster_scales = true;
5070 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5070 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5071 5071
5072 // We should have one render surface and two layers. The child 5072 // We should have one render surface and two layers. The child
5073 // layer should be included even though it is transparent. 5073 // layer should be included even though it is transparent.
5074 ASSERT_EQ(1u, render_surface_layer_list.size()); 5074 ASSERT_EQ(1u, render_surface_layer_list.size());
5075 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5075 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size());
5076 5076
5077 // If the root itself is hidden, the child should not be drawn even if it has 5077 // If the root itself is hidden, the child should not be drawn even if it has
5078 // an animating opacity. 5078 // an animating opacity.
5079 root_layer->test_properties()->opacity = 0.0f; 5079 root_layer->test_properties()->opacity = 0.0f;
5080 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5080 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5081 LayerImplList render_surface_layer_list2; 5081 LayerImplList render_surface_layer_list2;
5082 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( 5082 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2(
5083 root_layer, root_layer->bounds(), &render_surface_layer_list2); 5083 root_layer, root_layer->bounds(), &render_surface_layer_list2);
5084 inputs2.can_adjust_raster_scales = true; 5084 inputs2.can_adjust_raster_scales = true;
5085 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); 5085 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
5375 5375
5376 LayerImplList render_surface_layer_list; 5376 LayerImplList render_surface_layer_list;
5377 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5377 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5378 root_layer, root_layer->bounds(), &render_surface_layer_list); 5378 root_layer, root_layer->bounds(), &render_surface_layer_list);
5379 inputs.can_adjust_raster_scales = true; 5379 inputs.can_adjust_raster_scales = true;
5380 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5380 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5381 5381
5382 // We should have one render surface and two layers. The grand child has 5382 // We should have one render surface and two layers. The grand child has
5383 // hidden itself. 5383 // hidden itself.
5384 ASSERT_EQ(1u, render_surface_layer_list.size()); 5384 ASSERT_EQ(1u, render_surface_layer_list.size());
5385 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5385 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size());
5386 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id()); 5386 EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id());
5387 EXPECT_EQ(2, root_layer->render_surface()->layer_list().at(1)->id()); 5387 EXPECT_EQ(2, root_layer->GetRenderSurface()->layer_list().at(1)->id());
5388 } 5388 }
5389 5389
5390 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { 5390 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
5391 FakeImplTaskRunnerProvider task_runner_provider; 5391 FakeImplTaskRunnerProvider task_runner_provider;
5392 TestTaskGraphRunner task_graph_runner; 5392 TestTaskGraphRunner task_graph_runner;
5393 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5393 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5394 host_impl.CreatePendingTree(); 5394 host_impl.CreatePendingTree();
5395 5395
5396 std::unique_ptr<LayerImpl> root = 5396 std::unique_ptr<LayerImpl> root =
5397 LayerImpl::Create(host_impl.pending_tree(), 1); 5397 LayerImpl::Create(host_impl.pending_tree(), 1);
(...skipping 18 matching lines...) Expand all
5416 5416
5417 LayerImplList render_surface_layer_list; 5417 LayerImplList render_surface_layer_list;
5418 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5418 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5419 root_layer, root_layer->bounds(), &render_surface_layer_list); 5419 root_layer, root_layer->bounds(), &render_surface_layer_list);
5420 inputs.can_adjust_raster_scales = true; 5420 inputs.can_adjust_raster_scales = true;
5421 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5421 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5422 5422
5423 // We should have one render surface and one layers. The child has 5423 // We should have one render surface and one layers. The child has
5424 // hidden itself and the grand child. 5424 // hidden itself and the grand child.
5425 ASSERT_EQ(1u, render_surface_layer_list.size()); 5425 ASSERT_EQ(1u, render_surface_layer_list.size());
5426 ASSERT_EQ(1u, root_layer->render_surface()->layer_list().size()); 5426 ASSERT_EQ(1u, root_layer->GetRenderSurface()->layer_list().size());
5427 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id()); 5427 EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id());
5428 } 5428 }
5429 5429
5430 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 5430 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
5431 5431
5432 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { 5432 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
5433 FakeImplTaskRunnerProvider task_runner_provider; 5433 FakeImplTaskRunnerProvider task_runner_provider;
5434 TestTaskGraphRunner task_graph_runner; 5434 TestTaskGraphRunner task_graph_runner;
5435 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5435 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5436 host_impl.CreatePendingTree(); 5436 host_impl.CreatePendingTree();
5437 5437
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
5525 // parent since it has opacity and two drawing descendants, one for the parent 5525 // parent since it has opacity and two drawing descendants, one for the parent
5526 // since it owns a surface, and one for the copy_layer. 5526 // since it owns a surface, and one for the copy_layer.
5527 ASSERT_EQ(4u, render_surface_layer_list.size()); 5527 ASSERT_EQ(4u, render_surface_layer_list.size());
5528 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5528 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5529 EXPECT_EQ(copy_grand_parent_layer->id(), 5529 EXPECT_EQ(copy_grand_parent_layer->id(),
5530 render_surface_layer_list.at(1)->id()); 5530 render_surface_layer_list.at(1)->id());
5531 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); 5531 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
5532 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); 5532 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
5533 5533
5534 // The root render surface should have 2 contributing layers. 5534 // The root render surface should have 2 contributing layers.
5535 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5535 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size());
5536 EXPECT_EQ(root_layer->id(), 5536 EXPECT_EQ(root_layer->id(),
5537 root_layer->render_surface()->layer_list().at(0)->id()); 5537 root_layer->GetRenderSurface()->layer_list().at(0)->id());
5538 EXPECT_EQ(copy_grand_parent_layer->id(), 5538 EXPECT_EQ(copy_grand_parent_layer->id(),
5539 root_layer->render_surface()->layer_list().at(1)->id()); 5539 root_layer->GetRenderSurface()->layer_list().at(1)->id());
5540 5540
5541 // Nothing actually draws into the copy parent, so only the copy_layer will 5541 // Nothing actually draws into the copy parent, so only the copy_layer will
5542 // appear in its list, since it needs to be drawn for the copy request. 5542 // appear in its list, since it needs to be drawn for the copy request.
5543 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); 5543 ASSERT_EQ(1u, copy_parent_layer->GetRenderSurface()->layer_list().size());
5544 EXPECT_EQ(copy_layer->id(), 5544 EXPECT_EQ(copy_layer->id(),
5545 copy_parent_layer->render_surface()->layer_list().at(0)->id()); 5545 copy_parent_layer->GetRenderSurface()->layer_list().at(0)->id());
5546 5546
5547 // The copy_layer's render surface should have two contributing layers. 5547 // The copy_layer's render surface should have two contributing layers.
5548 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); 5548 ASSERT_EQ(2u, copy_layer->GetRenderSurface()->layer_list().size());
5549 EXPECT_EQ(copy_layer->id(), 5549 EXPECT_EQ(copy_layer->id(),
5550 copy_layer->render_surface()->layer_list().at(0)->id()); 5550 copy_layer->GetRenderSurface()->layer_list().at(0)->id());
5551 EXPECT_EQ(copy_child_layer->id(), 5551 EXPECT_EQ(copy_child_layer->id(),
5552 copy_layer->render_surface()->layer_list().at(1)->id()); 5552 copy_layer->GetRenderSurface()->layer_list().at(1)->id());
5553 5553
5554 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, 5554 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
5555 // but the copy_layer and copy_child should be drawn for the copy request. 5555 // but the copy_layer and copy_child should be drawn for the copy request.
5556 // copy grand child should not be drawn as its hidden even in the copy 5556 // copy grand child should not be drawn as its hidden even in the copy
5557 // request. 5557 // request.
5558 EffectTree& tree = 5558 EffectTree& tree =
5559 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5559 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5560 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); 5560 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
5561 EXPECT_FALSE(node->is_drawn); 5561 EXPECT_FALSE(node->is_drawn);
5562 node = tree.Node(copy_parent_layer->effect_tree_index()); 5562 node = tree.Node(copy_parent_layer->effect_tree_index());
5563 EXPECT_FALSE(node->is_drawn); 5563 EXPECT_FALSE(node->is_drawn);
5564 node = tree.Node(copy_layer->effect_tree_index()); 5564 node = tree.Node(copy_layer->effect_tree_index());
5565 EXPECT_TRUE(node->is_drawn); 5565 EXPECT_TRUE(node->is_drawn);
5566 node = tree.Node(copy_child_layer->effect_tree_index()); 5566 node = tree.Node(copy_child_layer->effect_tree_index());
5567 EXPECT_TRUE(node->is_drawn); 5567 EXPECT_TRUE(node->is_drawn);
5568 node = tree.Node(copy_grand_child_layer->effect_tree_index()); 5568 node = tree.Node(copy_grand_child_layer->effect_tree_index());
5569 EXPECT_FALSE(node->is_drawn); 5569 EXPECT_FALSE(node->is_drawn);
5570 5570
5571 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its 5571 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its
5572 // actually hidden. 5572 // actually hidden.
5573 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); 5573 EXPECT_FALSE(copy_layer->GetRenderSurface()->contributes_to_drawn_surface());
5574 } 5574 }
5575 5575
5576 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 5576 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
5577 FakeImplTaskRunnerProvider task_runner_provider; 5577 FakeImplTaskRunnerProvider task_runner_provider;
5578 TestTaskGraphRunner task_graph_runner; 5578 TestTaskGraphRunner task_graph_runner;
5579 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5579 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5580 host_impl.CreatePendingTree(); 5580 host_impl.CreatePendingTree();
5581 5581
5582 std::unique_ptr<LayerImpl> root = 5582 std::unique_ptr<LayerImpl> root =
5583 LayerImpl::Create(host_impl.pending_tree(), 1); 5583 LayerImpl::Create(host_impl.pending_tree(), 1);
(...skipping 30 matching lines...) Expand all
5614 root_layer, root_layer->bounds(), &render_surface_layer_list); 5614 root_layer, root_layer->bounds(), &render_surface_layer_list);
5615 inputs.can_adjust_raster_scales = true; 5615 inputs.can_adjust_raster_scales = true;
5616 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5616 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5617 5617
5618 // We should have two render surface, as the others are clipped out. 5618 // We should have two render surface, as the others are clipped out.
5619 ASSERT_EQ(2u, render_surface_layer_list.size()); 5619 ASSERT_EQ(2u, render_surface_layer_list.size());
5620 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5620 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5621 5621
5622 // The root render surface should only have 2 contributing layer, since the 5622 // The root render surface should only have 2 contributing layer, since the
5623 // other layers are empty/clipped away. 5623 // other layers are empty/clipped away.
5624 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5624 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size());
5625 EXPECT_EQ(root_layer->id(), 5625 EXPECT_EQ(root_layer->id(),
5626 root_layer->render_surface()->layer_list().at(0)->id()); 5626 root_layer->GetRenderSurface()->layer_list().at(0)->id());
5627 } 5627 }
5628 5628
5629 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { 5629 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) {
5630 LayerImpl* root = root_layer_for_testing(); 5630 LayerImpl* root = root_layer_for_testing();
5631 root->SetBounds(gfx::Size(50, 50)); 5631 root->SetBounds(gfx::Size(50, 50));
5632 root->SetDrawsContent(true); 5632 root->SetDrawsContent(true);
5633 root->SetMasksToBounds(true); 5633 root->SetMasksToBounds(true);
5634 5634
5635 LayerImpl* copy_layer = AddChild<LayerImpl>(root); 5635 LayerImpl* copy_layer = AddChild<LayerImpl>(root);
5636 copy_layer->SetBounds(gfx::Size(100, 100)); 5636 copy_layer->SetBounds(gfx::Size(100, 100));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
5736 render_surface->test_properties()->force_render_surface = true; 5736 render_surface->test_properties()->force_render_surface = true;
5737 clip_parent->test_properties()->transform = scale_transform; 5737 clip_parent->test_properties()->transform = scale_transform;
5738 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); 5738 clip_parent->SetPosition(gfx::PointF(1.f, 1.f));
5739 clip_parent->SetBounds(gfx::Size(10, 10)); 5739 clip_parent->SetBounds(gfx::Size(10, 10));
5740 intervening->SetPosition(gfx::PointF(1.f, 1.f)); 5740 intervening->SetPosition(gfx::PointF(1.f, 1.f));
5741 intervening->SetBounds(gfx::Size(5, 5)); 5741 intervening->SetBounds(gfx::Size(5, 5));
5742 clip_child->SetPosition(gfx::PointF(1.f, 1.f)); 5742 clip_child->SetPosition(gfx::PointF(1.f, 1.f));
5743 clip_child->SetBounds(gfx::Size(10, 10)); 5743 clip_child->SetBounds(gfx::Size(10, 10));
5744 ExecuteCalculateDrawProperties(root); 5744 ExecuteCalculateDrawProperties(root);
5745 5745
5746 ASSERT_TRUE(root->render_surface()); 5746 ASSERT_TRUE(root->GetRenderSurface());
5747 ASSERT_TRUE(render_surface->render_surface()); 5747 ASSERT_TRUE(render_surface->GetRenderSurface());
5748 5748
5749 // Ensure that we've inherited our clip parent's clip and weren't affected 5749 // Ensure that we've inherited our clip parent's clip and weren't affected
5750 // by the intervening clip layer. 5750 // by the intervening clip layer.
5751 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), clip_parent->clip_rect()); 5751 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), clip_parent->clip_rect());
5752 ASSERT_EQ(clip_parent->clip_rect(), clip_child->clip_rect()); 5752 ASSERT_EQ(clip_parent->clip_rect(), clip_child->clip_rect());
5753 ASSERT_EQ(gfx::Rect(3, 3, 10, 10), intervening->clip_rect()); 5753 ASSERT_EQ(gfx::Rect(3, 3, 10, 10), intervening->clip_rect());
5754 5754
5755 // Ensure that the render surface reports a content rect that has been grown 5755 // Ensure that the render surface reports a content rect that has been grown
5756 // to accomodate for the clip child. 5756 // to accomodate for the clip child.
5757 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), 5757 ASSERT_EQ(gfx::Rect(1, 1, 20, 20),
5758 render_surface->render_surface()->content_rect()); 5758 render_surface->GetRenderSurface()->content_rect());
5759 5759
5760 // The above check implies the two below, but they nicely demonstrate that 5760 // The above check implies the two below, but they nicely demonstrate that
5761 // we've grown, despite the intervening layer's clip. 5761 // we've grown, despite the intervening layer's clip.
5762 ASSERT_TRUE(clip_parent->clip_rect().Contains( 5762 ASSERT_TRUE(clip_parent->clip_rect().Contains(
5763 render_surface->render_surface()->content_rect())); 5763 render_surface->GetRenderSurface()->content_rect()));
5764 ASSERT_FALSE(intervening->clip_rect().Contains( 5764 ASSERT_FALSE(intervening->clip_rect().Contains(
5765 render_surface->render_surface()->content_rect())); 5765 render_surface->GetRenderSurface()->content_rect()));
5766 } 5766 }
5767 5767
5768 TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) { 5768 TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) {
5769 // Ensure that intervening render surfaces are not a problem in the basic 5769 // Ensure that intervening render surfaces are not a problem in the basic
5770 // case. In the following tree, both render surfaces should be resized to 5770 // case. In the following tree, both render surfaces should be resized to
5771 // accomodate for the clip child, despite an intervening clip. 5771 // accomodate for the clip child, despite an intervening clip.
5772 // 5772 //
5773 // root (a render surface) 5773 // root (a render surface)
5774 // + clip_parent (masks to bounds) 5774 // + clip_parent (masks to bounds)
5775 // + render_surface1 (sets opacity) 5775 // + render_surface1 (sets opacity)
(...skipping 25 matching lines...) Expand all
5801 render_surface1->SetBounds(gfx::Size(10, 10)); 5801 render_surface1->SetBounds(gfx::Size(10, 10));
5802 render_surface1->test_properties()->force_render_surface = true; 5802 render_surface1->test_properties()->force_render_surface = true;
5803 intervening->SetPosition(gfx::PointF(1.f, 1.f)); 5803 intervening->SetPosition(gfx::PointF(1.f, 1.f));
5804 intervening->SetBounds(gfx::Size(5, 5)); 5804 intervening->SetBounds(gfx::Size(5, 5));
5805 render_surface2->SetBounds(gfx::Size(10, 10)); 5805 render_surface2->SetBounds(gfx::Size(10, 10));
5806 render_surface2->test_properties()->force_render_surface = true; 5806 render_surface2->test_properties()->force_render_surface = true;
5807 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); 5807 clip_child->SetPosition(gfx::PointF(-10.f, -10.f));
5808 clip_child->SetBounds(gfx::Size(60, 60)); 5808 clip_child->SetBounds(gfx::Size(60, 60));
5809 ExecuteCalculateDrawProperties(root); 5809 ExecuteCalculateDrawProperties(root);
5810 5810
5811 EXPECT_TRUE(root->render_surface()); 5811 EXPECT_TRUE(root->GetRenderSurface());
5812 EXPECT_TRUE(render_surface1->render_surface()); 5812 EXPECT_TRUE(render_surface1->GetRenderSurface());
5813 EXPECT_TRUE(render_surface2->render_surface()); 5813 EXPECT_TRUE(render_surface2->GetRenderSurface());
5814 5814
5815 // Since the render surfaces could have expanded, they should not clip (their 5815 // Since the render surfaces could have expanded, they should not clip (their
5816 // bounds would no longer be reliable). We should resort to layer clipping 5816 // bounds would no longer be reliable). We should resort to layer clipping
5817 // in this case. 5817 // in this case.
5818 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), 5818 EXPECT_EQ(gfx::Rect(0, 0, 0, 0),
5819 render_surface1->render_surface()->clip_rect()); 5819 render_surface1->GetRenderSurface()->clip_rect());
5820 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); 5820 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped());
5821 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), 5821 EXPECT_EQ(gfx::Rect(0, 0, 0, 0),
5822 render_surface2->render_surface()->clip_rect()); 5822 render_surface2->GetRenderSurface()->clip_rect());
5823 EXPECT_FALSE(render_surface2->render_surface()->is_clipped()); 5823 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped());
5824 5824
5825 // NB: clip rects are in target space. 5825 // NB: clip rects are in target space.
5826 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), render_surface1->clip_rect()); 5826 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), render_surface1->clip_rect());
5827 EXPECT_TRUE(render_surface1->is_clipped()); 5827 EXPECT_TRUE(render_surface1->is_clipped());
5828 5828
5829 // This value is inherited from the clipping ancestor layer, 'intervening'. 5829 // This value is inherited from the clipping ancestor layer, 'intervening'.
5830 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); 5830 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect());
5831 EXPECT_TRUE(render_surface2->is_clipped()); 5831 EXPECT_TRUE(render_surface2->is_clipped());
5832 5832
5833 // The content rects of both render surfaces should both have expanded to 5833 // The content rects of both render surfaces should both have expanded to
5834 // contain the clip child. 5834 // contain the clip child.
5835 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), 5835 EXPECT_EQ(gfx::Rect(0, 0, 40, 40),
5836 render_surface1->render_surface()->content_rect()); 5836 render_surface1->GetRenderSurface()->content_rect());
5837 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40), 5837 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40),
5838 render_surface2->render_surface()->content_rect()); 5838 render_surface2->GetRenderSurface()->content_rect());
5839 5839
5840 // The clip child should have inherited the clip parent's clip (projected to 5840 // The clip child should have inherited the clip parent's clip (projected to
5841 // the right space, of course), and should have the correctly sized visible 5841 // the right space, of course), and should have the correctly sized visible
5842 // content rect. 5842 // content rect.
5843 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40), clip_child->clip_rect()); 5843 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40), clip_child->clip_rect());
5844 EXPECT_EQ(gfx::Rect(9, 9, 40, 40), clip_child->visible_layer_rect()); 5844 EXPECT_EQ(gfx::Rect(9, 9, 40, 40), clip_child->visible_layer_rect());
5845 EXPECT_TRUE(clip_child->is_clipped()); 5845 EXPECT_TRUE(clip_child->is_clipped());
5846 } 5846 }
5847 5847
5848 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { 5848 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5884 render_surface1->SetBounds(gfx::Size(10, 10)); 5884 render_surface1->SetBounds(gfx::Size(10, 10));
5885 render_surface1->test_properties()->force_render_surface = true; 5885 render_surface1->test_properties()->force_render_surface = true;
5886 intervening->SetPosition(gfx::PointF(1.f, 1.f)); 5886 intervening->SetPosition(gfx::PointF(1.f, 1.f));
5887 intervening->SetBounds(gfx::Size(5, 5)); 5887 intervening->SetBounds(gfx::Size(5, 5));
5888 render_surface2->SetBounds(gfx::Size(10, 10)); 5888 render_surface2->SetBounds(gfx::Size(10, 10));
5889 render_surface2->test_properties()->force_render_surface = true; 5889 render_surface2->test_properties()->force_render_surface = true;
5890 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); 5890 clip_child->SetPosition(gfx::PointF(-10.f, -10.f));
5891 clip_child->SetBounds(gfx::Size(60, 60)); 5891 clip_child->SetBounds(gfx::Size(60, 60));
5892 ExecuteCalculateDrawProperties(root); 5892 ExecuteCalculateDrawProperties(root);
5893 5893
5894 EXPECT_TRUE(root->render_surface()); 5894 EXPECT_TRUE(root->GetRenderSurface());
5895 EXPECT_TRUE(render_surface1->render_surface()); 5895 EXPECT_TRUE(render_surface1->GetRenderSurface());
5896 EXPECT_TRUE(render_surface2->render_surface()); 5896 EXPECT_TRUE(render_surface2->GetRenderSurface());
5897 5897
5898 // Since the render surfaces could have expanded, they should not clip (their 5898 // Since the render surfaces could have expanded, they should not clip (their
5899 // bounds would no longer be reliable). We should resort to layer clipping 5899 // bounds would no longer be reliable). We should resort to layer clipping
5900 // in this case. 5900 // in this case.
5901 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), 5901 EXPECT_EQ(gfx::Rect(0, 0, 0, 0),
5902 render_surface1->render_surface()->clip_rect()); 5902 render_surface1->GetRenderSurface()->clip_rect());
5903 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); 5903 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped());
5904 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), 5904 EXPECT_EQ(gfx::Rect(0, 0, 0, 0),
5905 render_surface2->render_surface()->clip_rect()); 5905 render_surface2->GetRenderSurface()->clip_rect());
5906 EXPECT_FALSE(render_surface2->render_surface()->is_clipped()); 5906 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped());
5907 5907
5908 // NB: clip rects are in target space. 5908 // NB: clip rects are in target space.
5909 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), render_surface1->clip_rect()); 5909 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), render_surface1->clip_rect());
5910 EXPECT_TRUE(render_surface1->is_clipped()); 5910 EXPECT_TRUE(render_surface1->is_clipped());
5911 5911
5912 // This value is inherited from the clipping ancestor layer, 'intervening'. 5912 // This value is inherited from the clipping ancestor layer, 'intervening'.
5913 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), render_surface2->clip_rect()); 5913 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), render_surface2->clip_rect());
5914 EXPECT_TRUE(render_surface2->is_clipped()); 5914 EXPECT_TRUE(render_surface2->is_clipped());
5915 5915
5916 // The content rects of both render surfaces should both have expanded to 5916 // The content rects of both render surfaces should both have expanded to
5917 // contain the clip child. 5917 // contain the clip child.
5918 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), 5918 EXPECT_EQ(gfx::Rect(0, 0, 40, 40),
5919 render_surface1->render_surface()->content_rect()); 5919 render_surface1->GetRenderSurface()->content_rect());
5920 EXPECT_EQ(gfx::Rect(2, 2, 40, 40), 5920 EXPECT_EQ(gfx::Rect(2, 2, 40, 40),
5921 render_surface2->render_surface()->content_rect()); 5921 render_surface2->GetRenderSurface()->content_rect());
5922 5922
5923 // The clip child should have inherited the clip parent's clip (projected to 5923 // The clip child should have inherited the clip parent's clip (projected to
5924 // the right space, of course), and should have the correctly sized visible 5924 // the right space, of course), and should have the correctly sized visible
5925 // content rect. 5925 // content rect.
5926 EXPECT_EQ(gfx::Rect(2, 2, 40, 40), clip_child->clip_rect()); 5926 EXPECT_EQ(gfx::Rect(2, 2, 40, 40), clip_child->clip_rect());
5927 EXPECT_EQ(gfx::Rect(12, 12, 40, 40), clip_child->visible_layer_rect()); 5927 EXPECT_EQ(gfx::Rect(12, 12, 40, 40), clip_child->visible_layer_rect());
5928 EXPECT_TRUE(clip_child->is_clipped()); 5928 EXPECT_TRUE(clip_child->is_clipped());
5929 } 5929 }
5930 5930
5931 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { 5931 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
(...skipping 21 matching lines...) Expand all
5953 root->SetBounds(gfx::Size(50, 50)); 5953 root->SetBounds(gfx::Size(50, 50));
5954 clip_parent->SetBounds(gfx::Size(40, 40)); 5954 clip_parent->SetBounds(gfx::Size(40, 40));
5955 clip_parent->SetMasksToBounds(true); 5955 clip_parent->SetMasksToBounds(true);
5956 intervening->SetBounds(gfx::Size(5, 5)); 5956 intervening->SetBounds(gfx::Size(5, 5));
5957 intervening->SetMasksToBounds(true); 5957 intervening->SetMasksToBounds(true);
5958 clip_child->SetBounds(gfx::Size(60, 60)); 5958 clip_child->SetBounds(gfx::Size(60, 60));
5959 child->SetBounds(gfx::Size(60, 60)); 5959 child->SetBounds(gfx::Size(60, 60));
5960 5960
5961 ExecuteCalculateDrawProperties(root); 5961 ExecuteCalculateDrawProperties(root);
5962 5962
5963 EXPECT_TRUE(root->render_surface()); 5963 EXPECT_TRUE(root->GetRenderSurface());
5964 5964
5965 // Neither the clip child nor its descendant should have inherited the clip 5965 // Neither the clip child nor its descendant should have inherited the clip
5966 // from |intervening|. 5966 // from |intervening|.
5967 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), clip_child->clip_rect()); 5967 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), clip_child->clip_rect());
5968 EXPECT_TRUE(clip_child->is_clipped()); 5968 EXPECT_TRUE(clip_child->is_clipped());
5969 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), child->visible_layer_rect()); 5969 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), child->visible_layer_rect());
5970 EXPECT_TRUE(child->is_clipped()); 5970 EXPECT_TRUE(child->is_clipped());
5971 } 5971 }
5972 5972
5973 TEST_F(LayerTreeHostCommonTest, 5973 TEST_F(LayerTreeHostCommonTest,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6009 render_surface1->SetBounds(gfx::Size(5, 5)); 6009 render_surface1->SetBounds(gfx::Size(5, 5));
6010 render_surface1->test_properties()->force_render_surface = true; 6010 render_surface1->test_properties()->force_render_surface = true;
6011 render_surface2->SetBounds(gfx::Size(5, 5)); 6011 render_surface2->SetBounds(gfx::Size(5, 5));
6012 render_surface2->test_properties()->force_render_surface = true; 6012 render_surface2->test_properties()->force_render_surface = true;
6013 clip_child->SetPosition(gfx::PointF(-1, 1)); 6013 clip_child->SetPosition(gfx::PointF(-1, 1));
6014 clip_child->SetBounds(gfx::Size(10, 10)); 6014 clip_child->SetBounds(gfx::Size(10, 10));
6015 non_clip_child->SetBounds(gfx::Size(5, 5)); 6015 non_clip_child->SetBounds(gfx::Size(5, 5));
6016 6016
6017 ExecuteCalculateDrawProperties(root); 6017 ExecuteCalculateDrawProperties(root);
6018 6018
6019 EXPECT_TRUE(root->render_surface()); 6019 EXPECT_TRUE(root->GetRenderSurface());
6020 EXPECT_TRUE(render_surface1->render_surface()); 6020 EXPECT_TRUE(render_surface1->GetRenderSurface());
6021 EXPECT_TRUE(render_surface2->render_surface()); 6021 EXPECT_TRUE(render_surface2->GetRenderSurface());
6022 6022
6023 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface1->clip_rect()); 6023 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface1->clip_rect());
6024 EXPECT_TRUE(render_surface1->is_clipped()); 6024 EXPECT_TRUE(render_surface1->is_clipped());
6025 6025
6026 // The render surface should not clip (it has unclipped descendants), instead 6026 // The render surface should not clip (it has unclipped descendants), instead
6027 // it should rely on layer clipping. 6027 // it should rely on layer clipping.
6028 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), 6028 EXPECT_EQ(gfx::Rect(0, 0, 0, 0),
6029 render_surface1->render_surface()->clip_rect()); 6029 render_surface1->GetRenderSurface()->clip_rect());
6030 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); 6030 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped());
6031 6031
6032 // That said, it should have grown to accomodate the unclipped descendant and 6032 // That said, it should have grown to accomodate the unclipped descendant and
6033 // its own size. 6033 // its own size.
6034 EXPECT_EQ(gfx::Rect(-1, 0, 6, 5), 6034 EXPECT_EQ(gfx::Rect(-1, 0, 6, 5),
6035 render_surface1->render_surface()->content_rect()); 6035 render_surface1->GetRenderSurface()->content_rect());
6036 6036
6037 // This render surface should clip. It has no unclipped descendants. 6037 // This render surface should clip. It has no unclipped descendants.
6038 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), 6038 EXPECT_EQ(gfx::Rect(0, 0, 10, 10),
6039 render_surface2->render_surface()->clip_rect()); 6039 render_surface2->GetRenderSurface()->clip_rect());
6040 EXPECT_TRUE(render_surface2->render_surface()->is_clipped()); 6040 EXPECT_TRUE(render_surface2->GetRenderSurface()->is_clipped());
6041 EXPECT_FALSE(render_surface2->is_clipped()); 6041 EXPECT_FALSE(render_surface2->is_clipped());
6042 6042
6043 // It also shouldn't have grown to accomodate the clip child. 6043 // It also shouldn't have grown to accomodate the clip child.
6044 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), 6044 EXPECT_EQ(gfx::Rect(0, 0, 5, 5),
6045 render_surface2->render_surface()->content_rect()); 6045 render_surface2->GetRenderSurface()->content_rect());
6046 6046
6047 // Sanity check our num_unclipped_descendants values. 6047 // Sanity check our num_unclipped_descendants values.
6048 EXPECT_EQ(1u, render_surface1->test_properties()->num_unclipped_descendants); 6048 EXPECT_EQ(1u, render_surface1->test_properties()->num_unclipped_descendants);
6049 EXPECT_EQ(0u, render_surface2->test_properties()->num_unclipped_descendants); 6049 EXPECT_EQ(0u, render_surface2->test_properties()->num_unclipped_descendants);
6050 } 6050 }
6051 6051
6052 TEST_F(LayerTreeHostCommonTest, 6052 TEST_F(LayerTreeHostCommonTest,
6053 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { 6053 CreateRenderSurfaceWhenFlattenInsideRenderingContext) {
6054 // Verifies that Render Surfaces are created at the edge of rendering context. 6054 // Verifies that Render Surfaces are created at the edge of rendering context.
6055 6055
(...skipping 12 matching lines...) Expand all
6068 child1->test_properties()->sorting_context_id = 1; 6068 child1->test_properties()->sorting_context_id = 1;
6069 child2->SetBounds(bounds); 6069 child2->SetBounds(bounds);
6070 child2->SetDrawsContent(true); 6070 child2->SetDrawsContent(true);
6071 child2->test_properties()->sorting_context_id = 1; 6071 child2->test_properties()->sorting_context_id = 1;
6072 child3->SetBounds(bounds); 6072 child3->SetBounds(bounds);
6073 child3->SetDrawsContent(true); 6073 child3->SetDrawsContent(true);
6074 child3->test_properties()->sorting_context_id = 1; 6074 child3->test_properties()->sorting_context_id = 1;
6075 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 6075 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
6076 6076
6077 // Verify which render surfaces were created. 6077 // Verify which render surfaces were created.
6078 EXPECT_TRUE(root->has_render_surface()); 6078 EXPECT_TRUE(root->GetRenderSurface());
6079 EXPECT_FALSE(child1->has_render_surface()); 6079 EXPECT_FALSE(child1->GetRenderSurface());
6080 EXPECT_TRUE(child2->has_render_surface()); 6080 EXPECT_TRUE(child2->GetRenderSurface());
6081 EXPECT_FALSE(child3->has_render_surface()); 6081 EXPECT_FALSE(child3->GetRenderSurface());
6082 } 6082 }
6083 6083
6084 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { 6084 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
6085 FakeImplTaskRunnerProvider task_runner_provider; 6085 FakeImplTaskRunnerProvider task_runner_provider;
6086 TestTaskGraphRunner task_graph_runner; 6086 TestTaskGraphRunner task_graph_runner;
6087 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 6087 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
6088 6088
6089 std::unique_ptr<LayerImpl> root = 6089 std::unique_ptr<LayerImpl> root =
6090 LayerImpl::Create(host_impl.active_tree(), 12345); 6090 LayerImpl::Create(host_impl.active_tree(), 12345);
6091 std::unique_ptr<LayerImpl> child1 = 6091 std::unique_ptr<LayerImpl> child1 =
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
6210 flattener->SetBounds(gfx::Size(30, 30)); 6210 flattener->SetBounds(gfx::Size(30, 30));
6211 render_surface2->SetBounds(gfx::Size(30, 30)); 6211 render_surface2->SetBounds(gfx::Size(30, 30));
6212 render_surface2->test_properties()->should_flatten_transform = false; 6212 render_surface2->test_properties()->should_flatten_transform = false;
6213 render_surface2->test_properties()->force_render_surface = true; 6213 render_surface2->test_properties()->force_render_surface = true;
6214 render_surface2->test_properties()->double_sided = false; 6214 render_surface2->test_properties()->double_sided = false;
6215 child2->SetBounds(gfx::Size(20, 20)); 6215 child2->SetBounds(gfx::Size(20, 20));
6216 6216
6217 ExecuteCalculateDrawProperties(root); 6217 ExecuteCalculateDrawProperties(root);
6218 6218
6219 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6219 EXPECT_EQ(3u, render_surface_layer_list_impl()->size());
6220 EXPECT_EQ(2u, render_surface_layer_list_impl() 6220 EXPECT_EQ(2u,
6221 ->at(0) 6221 render_surface_layer_list_impl()
6222 ->render_surface() 6222 ->at(0)
6223 ->layer_list() 6223 ->GetRenderSurface()
6224 .size()); 6224 ->layer_list()
6225 EXPECT_EQ(1u, render_surface_layer_list_impl() 6225 .size());
6226 ->at(1) 6226 EXPECT_EQ(1u,
6227 ->render_surface() 6227 render_surface_layer_list_impl()
6228 ->layer_list() 6228 ->at(1)
6229 .size()); 6229 ->GetRenderSurface()
6230 ->layer_list()
6231 .size());
6230 6232
6231 gfx::Transform rotation_transform; 6233 gfx::Transform rotation_transform;
6232 rotation_transform.RotateAboutXAxis(180.0); 6234 rotation_transform.RotateAboutXAxis(180.0);
6233 6235
6234 back_facing->test_properties()->transform = rotation_transform; 6236 back_facing->test_properties()->transform = rotation_transform;
6235 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 6237 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6236 6238
6237 ExecuteCalculateDrawProperties(root); 6239 ExecuteCalculateDrawProperties(root);
6238 6240
6239 // render_surface1 is in the same 3d rendering context as back_facing and is 6241 // render_surface1 is in the same 3d rendering context as back_facing and is
6240 // not double sided, so it should not be in RSLL. render_surface2 is also not 6242 // not double sided, so it should not be in RSLL. render_surface2 is also not
6241 // double-sided, but will still be in RSLL as it's in a different 3d rendering 6243 // double-sided, but will still be in RSLL as it's in a different 3d rendering
6242 // context. 6244 // context.
6243 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 6245 EXPECT_EQ(2u, render_surface_layer_list_impl()->size());
6244 EXPECT_EQ(1u, render_surface_layer_list_impl() 6246 EXPECT_EQ(1u,
6245 ->at(0) 6247 render_surface_layer_list_impl()
6246 ->render_surface() 6248 ->at(0)
6247 ->layer_list() 6249 ->GetRenderSurface()
6248 .size()); 6250 ->layer_list()
6251 .size());
6249 } 6252 }
6250 6253
6251 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { 6254 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) {
6252 LayerImpl* root = root_layer_for_testing(); 6255 LayerImpl* root = root_layer_for_testing();
6253 LayerImpl* child = AddChild<LayerImpl>(root); 6256 LayerImpl* child = AddChild<LayerImpl>(root);
6254 LayerImpl* grand_child = AddChild<LayerImpl>(child); 6257 LayerImpl* grand_child = AddChild<LayerImpl>(child);
6255 6258
6256 root->SetBounds(gfx::Size(50, 50)); 6259 root->SetBounds(gfx::Size(50, 50));
6257 root->test_properties()->should_flatten_transform = false; 6260 root->test_properties()->should_flatten_transform = false;
6258 child->SetBounds(gfx::Size(30, 30)); 6261 child->SetBounds(gfx::Size(30, 30));
6259 child->test_properties()->double_sided = false; 6262 child->test_properties()->double_sided = false;
6260 child->test_properties()->should_flatten_transform = false; 6263 child->test_properties()->should_flatten_transform = false;
6261 grand_child->SetBounds(gfx::Size(20, 20)); 6264 grand_child->SetBounds(gfx::Size(20, 20));
6262 grand_child->SetDrawsContent(true); 6265 grand_child->SetDrawsContent(true);
6263 grand_child->SetUseParentBackfaceVisibility(true); 6266 grand_child->SetUseParentBackfaceVisibility(true);
6264 grand_child->test_properties()->should_flatten_transform = false; 6267 grand_child->test_properties()->should_flatten_transform = false;
6265 ExecuteCalculateDrawProperties(root); 6268 ExecuteCalculateDrawProperties(root);
6266 6269
6267 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6270 EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
6268 EXPECT_EQ(grand_child, render_surface_layer_list_impl() 6271 EXPECT_EQ(grand_child,
6269 ->at(0) 6272 render_surface_layer_list_impl()
6270 ->render_surface() 6273 ->at(0)
6271 ->layer_list()[0]); 6274 ->GetRenderSurface()
6275 ->layer_list()[0]);
6272 6276
6273 // As all layers have identity transform, we shouldn't check for backface 6277 // As all layers have identity transform, we shouldn't check for backface
6274 // visibility. 6278 // visibility.
6275 EXPECT_FALSE(root->should_check_backface_visibility()); 6279 EXPECT_FALSE(root->should_check_backface_visibility());
6276 EXPECT_FALSE(child->should_check_backface_visibility()); 6280 EXPECT_FALSE(child->should_check_backface_visibility());
6277 EXPECT_FALSE(grand_child->should_check_backface_visibility()); 6281 EXPECT_FALSE(grand_child->should_check_backface_visibility());
6278 // As there are no 3d rendering contexts, all layers should use their local 6282 // As there are no 3d rendering contexts, all layers should use their local
6279 // transform for backface visibility. 6283 // transform for backface visibility.
6280 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6284 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
6281 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); 6285 EXPECT_TRUE(child->use_local_transform_for_backface_visibility());
6282 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); 6286 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility());
6283 6287
6284 gfx::Transform rotation_transform; 6288 gfx::Transform rotation_transform;
6285 rotation_transform.RotateAboutXAxis(180.0); 6289 rotation_transform.RotateAboutXAxis(180.0);
6286 6290
6287 child->test_properties()->transform = rotation_transform; 6291 child->test_properties()->transform = rotation_transform;
6288 child->test_properties()->sorting_context_id = 1; 6292 child->test_properties()->sorting_context_id = 1;
6289 grand_child->test_properties()->sorting_context_id = 1; 6293 grand_child->test_properties()->sorting_context_id = 1;
6290 child->layer_tree_impl()->property_trees()->needs_rebuild = true; 6294 child->layer_tree_impl()->property_trees()->needs_rebuild = true;
6291 6295
6292 ExecuteCalculateDrawProperties(root); 6296 ExecuteCalculateDrawProperties(root);
6293 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6297 EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
6294 EXPECT_EQ(0u, render_surface_layer_list_impl() 6298 EXPECT_EQ(0u,
6295 ->at(0) 6299 render_surface_layer_list_impl()
6296 ->render_surface() 6300 ->at(0)
6297 ->layer_list() 6301 ->GetRenderSurface()
6298 .size()); 6302 ->layer_list()
6303 .size());
6299 6304
6300 // We should check for backface visibilty of child as it has a rotation 6305 // We should check for backface visibilty of child as it has a rotation
6301 // transform. We should also check for grand_child as it uses the backface 6306 // transform. We should also check for grand_child as it uses the backface
6302 // visibility of its parent. 6307 // visibility of its parent.
6303 EXPECT_FALSE(root->should_check_backface_visibility()); 6308 EXPECT_FALSE(root->should_check_backface_visibility());
6304 EXPECT_TRUE(child->should_check_backface_visibility()); 6309 EXPECT_TRUE(child->should_check_backface_visibility());
6305 EXPECT_TRUE(grand_child->should_check_backface_visibility()); 6310 EXPECT_TRUE(grand_child->should_check_backface_visibility());
6306 // child uses its local transform for backface visibility as it is the root of 6311 // child uses its local transform for backface visibility as it is the root of
6307 // a 3d rendering context. grand_child is in a 3d rendering context and is not 6312 // a 3d rendering context. grand_child is in a 3d rendering context and is not
6308 // the root, but it derives its backface visibility from its parent which uses 6313 // the root, but it derives its backface visibility from its parent which uses
6309 // its local transform. 6314 // its local transform.
6310 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6315 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
6311 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); 6316 EXPECT_TRUE(child->use_local_transform_for_backface_visibility());
6312 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); 6317 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility());
6313 6318
6314 grand_child->SetUseParentBackfaceVisibility(false); 6319 grand_child->SetUseParentBackfaceVisibility(false);
6315 grand_child->test_properties()->double_sided = false; 6320 grand_child->test_properties()->double_sided = false;
6316 grand_child->layer_tree_impl()->property_trees()->needs_rebuild = true; 6321 grand_child->layer_tree_impl()->property_trees()->needs_rebuild = true;
6317 6322
6318 ExecuteCalculateDrawProperties(root); 6323 ExecuteCalculateDrawProperties(root);
6319 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6324 EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
6320 EXPECT_EQ(0u, render_surface_layer_list_impl() 6325 EXPECT_EQ(0u,
6321 ->at(0) 6326 render_surface_layer_list_impl()
6322 ->render_surface() 6327 ->at(0)
6323 ->layer_list() 6328 ->GetRenderSurface()
6324 .size()); 6329 ->layer_list()
6330 .size());
6325 6331
6326 // We should check the backface visibility of child as it has a rotation 6332 // We should check the backface visibility of child as it has a rotation
6327 // transform and for grand_child as it is in a 3d rendering context and not 6333 // transform and for grand_child as it is in a 3d rendering context and not
6328 // the root of it. 6334 // the root of it.
6329 EXPECT_FALSE(root->should_check_backface_visibility()); 6335 EXPECT_FALSE(root->should_check_backface_visibility());
6330 EXPECT_TRUE(child->should_check_backface_visibility()); 6336 EXPECT_TRUE(child->should_check_backface_visibility());
6331 EXPECT_TRUE(grand_child->should_check_backface_visibility()); 6337 EXPECT_TRUE(grand_child->should_check_backface_visibility());
6332 // grand_child is in an existing 3d rendering context, so it should not use 6338 // grand_child is in an existing 3d rendering context, so it should not use
6333 // local transform for backface visibility. 6339 // local transform for backface visibility.
6334 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6340 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
6418 base::MakeUnique<std::set<LayerImpl*>>(); 6424 base::MakeUnique<std::set<LayerImpl*>>();
6419 scroll_parent->test_properties()->scroll_children->insert(scroll_child); 6425 scroll_parent->test_properties()->scroll_children->insert(scroll_child);
6420 6426
6421 root->SetBounds(gfx::Size(50, 50)); 6427 root->SetBounds(gfx::Size(50, 50));
6422 scroll_parent_border->SetBounds(gfx::Size(40, 40)); 6428 scroll_parent_border->SetBounds(gfx::Size(40, 40));
6423 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); 6429 scroll_parent_clip->SetBounds(gfx::Size(30, 30));
6424 scroll_parent->SetBounds(gfx::Size(50, 50)); 6430 scroll_parent->SetBounds(gfx::Size(50, 50));
6425 scroll_child->SetBounds(gfx::Size(50, 50)); 6431 scroll_child->SetBounds(gfx::Size(50, 50));
6426 ExecuteCalculateDrawProperties(root); 6432 ExecuteCalculateDrawProperties(root);
6427 6433
6428 EXPECT_TRUE(root->render_surface()); 6434 EXPECT_TRUE(root->GetRenderSurface());
6429 6435
6430 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); 6436 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect());
6431 EXPECT_TRUE(scroll_child->is_clipped()); 6437 EXPECT_TRUE(scroll_child->is_clipped());
6432 } 6438 }
6433 6439
6434 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { 6440 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) {
6435 // Tests the computation of draw transform for the scroll child when its 6441 // Tests the computation of draw transform for the scroll child when its
6436 // target is different from its scroll parent's target. 6442 // target is different from its scroll parent's target.
6437 LayerImpl* root = root_layer_for_testing(); 6443 LayerImpl* root = root_layer_for_testing();
6438 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); 6444 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
6590 scroll_parent->SetBounds(gfx::Size(50, 50)); 6596 scroll_parent->SetBounds(gfx::Size(50, 50));
6591 scroll_child->SetBounds(gfx::Size(50, 50)); 6597 scroll_child->SetBounds(gfx::Size(50, 50));
6592 6598
6593 scroll_child->test_properties()->scroll_parent = scroll_parent; 6599 scroll_child->test_properties()->scroll_parent = scroll_parent;
6594 scroll_parent->test_properties()->scroll_children = 6600 scroll_parent->test_properties()->scroll_children =
6595 base::MakeUnique<std::set<LayerImpl*>>(); 6601 base::MakeUnique<std::set<LayerImpl*>>();
6596 scroll_parent->test_properties()->scroll_children->insert(scroll_child); 6602 scroll_parent->test_properties()->scroll_children->insert(scroll_child);
6597 6603
6598 ExecuteCalculateDrawProperties(root); 6604 ExecuteCalculateDrawProperties(root);
6599 6605
6600 EXPECT_TRUE(root->render_surface()); 6606 EXPECT_TRUE(root->GetRenderSurface());
6601 6607
6602 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); 6608 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect());
6603 EXPECT_TRUE(scroll_child->is_clipped()); 6609 EXPECT_TRUE(scroll_child->is_clipped());
6604 } 6610 }
6605 6611
6606 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { 6612 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) {
6607 // Checks that clipping by a scroll parent and scroll grandparent that follow 6613 // Checks that clipping by a scroll parent and scroll grandparent that follow
6608 // you in paint order still results in correct clipping. 6614 // you in paint order still results in correct clipping.
6609 // 6615 //
6610 // + root 6616 // + root
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 scroll_grandparent_border->SetBounds(gfx::Size(40, 40)); 6654 scroll_grandparent_border->SetBounds(gfx::Size(40, 40));
6649 scroll_grandparent_clip->SetBounds(gfx::Size(20, 20)); 6655 scroll_grandparent_clip->SetBounds(gfx::Size(20, 20));
6650 scroll_grandparent->SetBounds(gfx::Size(50, 50)); 6656 scroll_grandparent->SetBounds(gfx::Size(50, 50));
6651 scroll_parent_border->SetBounds(gfx::Size(40, 40)); 6657 scroll_parent_border->SetBounds(gfx::Size(40, 40));
6652 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); 6658 scroll_parent_clip->SetBounds(gfx::Size(30, 30));
6653 scroll_parent->SetBounds(gfx::Size(50, 50)); 6659 scroll_parent->SetBounds(gfx::Size(50, 50));
6654 scroll_child->SetBounds(gfx::Size(50, 50)); 6660 scroll_child->SetBounds(gfx::Size(50, 50));
6655 6661
6656 ExecuteCalculateDrawProperties(root); 6662 ExecuteCalculateDrawProperties(root);
6657 6663
6658 EXPECT_TRUE(root->render_surface()); 6664 EXPECT_TRUE(root->GetRenderSurface());
6659 6665
6660 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); 6666 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect());
6661 EXPECT_TRUE(scroll_child->is_clipped()); 6667 EXPECT_TRUE(scroll_child->is_clipped());
6662 6668
6663 // Despite the fact that we visited the above layers out of order to get the 6669 // Despite the fact that we visited the above layers out of order to get the
6664 // correct clip, the layer lists should be unaffected. 6670 // correct clip, the layer lists should be unaffected.
6665 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); 6671 EXPECT_EQ(3u, root->GetRenderSurface()->layer_list().size());
6666 EXPECT_EQ(scroll_child, root->render_surface()->layer_list().at(0)); 6672 EXPECT_EQ(scroll_child, root->GetRenderSurface()->layer_list().at(0));
6667 EXPECT_EQ(scroll_parent, root->render_surface()->layer_list().at(1)); 6673 EXPECT_EQ(scroll_parent, root->GetRenderSurface()->layer_list().at(1));
6668 EXPECT_EQ(scroll_grandparent, root->render_surface()->layer_list().at(2)); 6674 EXPECT_EQ(scroll_grandparent, root->GetRenderSurface()->layer_list().at(2));
6669 } 6675 }
6670 6676
6671 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { 6677 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) {
6672 // Ensures that even if we visit layers out of order, we still produce a 6678 // Ensures that even if we visit layers out of order, we still produce a
6673 // correctly ordered render surface layer list. 6679 // correctly ordered render surface layer list.
6674 // + root 6680 // + root
6675 // + scroll_child 6681 // + scroll_child
6676 // + scroll_parent_border 6682 // + scroll_parent_border
6677 // + scroll_parent_clip 6683 // + scroll_parent_clip
6678 // + scroll_parent 6684 // + scroll_parent
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6725 render_surface1->test_properties()->force_render_surface = true; 6731 render_surface1->test_properties()->force_render_surface = true;
6726 scroll_parent_border->SetBounds(gfx::Size(40, 40)); 6732 scroll_parent_border->SetBounds(gfx::Size(40, 40));
6727 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); 6733 scroll_parent_clip->SetBounds(gfx::Size(30, 30));
6728 scroll_parent->SetBounds(gfx::Size(50, 50)); 6734 scroll_parent->SetBounds(gfx::Size(50, 50));
6729 render_surface2->SetBounds(gfx::Size(50, 50)); 6735 render_surface2->SetBounds(gfx::Size(50, 50));
6730 render_surface2->test_properties()->force_render_surface = true; 6736 render_surface2->test_properties()->force_render_surface = true;
6731 scroll_child->SetBounds(gfx::Size(50, 50)); 6737 scroll_child->SetBounds(gfx::Size(50, 50));
6732 6738
6733 ExecuteCalculateDrawProperties(root); 6739 ExecuteCalculateDrawProperties(root);
6734 6740
6735 EXPECT_TRUE(root->render_surface()); 6741 EXPECT_TRUE(root->GetRenderSurface());
6736 6742
6737 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); 6743 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect());
6738 EXPECT_TRUE(scroll_child->is_clipped()); 6744 EXPECT_TRUE(scroll_child->is_clipped());
6739 6745
6740 // Despite the fact that we had to process the layers out of order to get the 6746 // Despite the fact that we had to process the layers out of order to get the
6741 // right clip, our render_surface_layer_list's order should be unaffected. 6747 // right clip, our render_surface_layer_list's order should be unaffected.
6742 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6748 EXPECT_EQ(3u, render_surface_layer_list_impl()->size());
6743 EXPECT_EQ(root, render_surface_layer_list_impl()->at(0)); 6749 EXPECT_EQ(root, render_surface_layer_list_impl()->at(0));
6744 EXPECT_EQ(render_surface2, render_surface_layer_list_impl()->at(1)); 6750 EXPECT_EQ(render_surface2, render_surface_layer_list_impl()->at(1));
6745 EXPECT_EQ(render_surface1, render_surface_layer_list_impl()->at(2)); 6751 EXPECT_EQ(render_surface1, render_surface_layer_list_impl()->at(2));
6746 EXPECT_TRUE(render_surface_layer_list_impl()->at(0)->render_surface()); 6752 EXPECT_TRUE(render_surface_layer_list_impl()->at(0)->GetRenderSurface());
6747 EXPECT_TRUE(render_surface_layer_list_impl()->at(1)->render_surface()); 6753 EXPECT_TRUE(render_surface_layer_list_impl()->at(1)->GetRenderSurface());
6748 EXPECT_TRUE(render_surface_layer_list_impl()->at(2)->render_surface()); 6754 EXPECT_TRUE(render_surface_layer_list_impl()->at(2)->GetRenderSurface());
6749 } 6755 }
6750 6756
6751 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) { 6757 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) {
6752 // Ensures that when we have a render surface between a fixed position layer 6758 // Ensures that when we have a render surface between a fixed position layer
6753 // and its container, we compute the fixed position layer's draw transform 6759 // and its container, we compute the fixed position layer's draw transform
6754 // with respect to that intervening render surface, not with respect to its 6760 // with respect to that intervening render surface, not with respect to its
6755 // container's render target. 6761 // container's render target.
6756 // 6762 //
6757 // + root 6763 // + root
6758 // + render_surface 6764 // + render_surface
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
8265 for (LayerIterator it = LayerIterator::Begin(rsll), 8271 for (LayerIterator it = LayerIterator::Begin(rsll),
8266 end = LayerIterator::End(rsll); 8272 end = LayerIterator::End(rsll);
8267 it != end; ++it) { 8273 it != end; ++it) {
8268 LayerImpl* layer = *it; 8274 LayerImpl* layer = *it;
8269 if (it.represents_itself()) 8275 if (it.represents_itself())
8270 drawn_layers->insert(layer); 8276 drawn_layers->insert(layer);
8271 8277
8272 if (!it.represents_contributing_render_surface()) 8278 if (!it.represents_contributing_render_surface())
8273 continue; 8279 continue;
8274 8280
8275 if (layer->render_surface()->MaskLayer()) 8281 if (layer->GetRenderSurface()->MaskLayer())
8276 drawn_layers->insert(layer->render_surface()->MaskLayer()); 8282 drawn_layers->insert(layer->GetRenderSurface()->MaskLayer());
8277 } 8283 }
8278 } 8284 }
8279 8285
8280 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { 8286 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
8281 FakeImplTaskRunnerProvider task_runner_provider; 8287 FakeImplTaskRunnerProvider task_runner_provider;
8282 TestTaskGraphRunner task_graph_runner; 8288 TestTaskGraphRunner task_graph_runner;
8283 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 8289 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
8284 8290
8285 std::unique_ptr<LayerImpl> grand_parent = 8291 std::unique_ptr<LayerImpl> grand_parent =
8286 LayerImpl::Create(host_impl.active_tree(), 1); 8292 LayerImpl::Create(host_impl.active_tree(), 1);
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
8993 child->SetDrawsContent(true); 8999 child->SetDrawsContent(true);
8994 grandchild->SetBounds(gfx::Size(50, 50)); 9000 grandchild->SetBounds(gfx::Size(50, 50));
8995 grandchild->SetDrawsContent(true); 9001 grandchild->SetDrawsContent(true);
8996 9002
8997 SetElementIdsForTesting(); 9003 SetElementIdsForTesting();
8998 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), 9004 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(),
8999 10.0, 1.f, 0.2f, false); 9005 10.0, 1.f, 0.2f, false);
9000 ExecuteCalculateDrawProperties(root); 9006 ExecuteCalculateDrawProperties(root);
9001 9007
9002 EXPECT_EQ(1.f, child->Opacity()); 9008 EXPECT_EQ(1.f, child->Opacity());
9003 EXPECT_TRUE(root->has_render_surface()); 9009 EXPECT_TRUE(root->GetRenderSurface());
9004 EXPECT_TRUE(child->has_render_surface()); 9010 EXPECT_TRUE(child->GetRenderSurface());
9005 EXPECT_FALSE(grandchild->has_render_surface()); 9011 EXPECT_FALSE(grandchild->GetRenderSurface());
9006 } 9012 }
9007 9013
9008 // Verify that having an animated filter (but no current filter, as these 9014 // Verify that having an animated filter (but no current filter, as these
9009 // are mutually exclusive) correctly creates a render surface. 9015 // are mutually exclusive) correctly creates a render surface.
9010 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { 9016 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
9011 LayerImpl* root = root_layer_for_testing(); 9017 LayerImpl* root = root_layer_for_testing();
9012 LayerImpl* child = AddChild<LayerImpl>(root); 9018 LayerImpl* child = AddChild<LayerImpl>(root);
9013 LayerImpl* grandchild = AddChild<LayerImpl>(child); 9019 LayerImpl* grandchild = AddChild<LayerImpl>(child);
9014 9020
9015 root->SetBounds(gfx::Size(50, 50)); 9021 root->SetBounds(gfx::Size(50, 50));
9016 child->SetBounds(gfx::Size(50, 50)); 9022 child->SetBounds(gfx::Size(50, 50));
9017 grandchild->SetBounds(gfx::Size(50, 50)); 9023 grandchild->SetBounds(gfx::Size(50, 50));
9018 9024
9019 SetElementIdsForTesting(); 9025 SetElementIdsForTesting();
9020 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), 9026 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(),
9021 10.0, 0.1f, 0.2f); 9027 10.0, 0.1f, 0.2f);
9022 ExecuteCalculateDrawProperties(root); 9028 ExecuteCalculateDrawProperties(root);
9023 9029
9024 EXPECT_TRUE(root->has_render_surface()); 9030 EXPECT_TRUE(root->GetRenderSurface());
9025 EXPECT_TRUE(child->has_render_surface()); 9031 EXPECT_TRUE(child->GetRenderSurface());
9026 EXPECT_FALSE(grandchild->has_render_surface()); 9032 EXPECT_FALSE(grandchild->GetRenderSurface());
9027 9033
9028 EXPECT_TRUE(root->render_surface()->Filters().IsEmpty()); 9034 EXPECT_TRUE(root->GetRenderSurface()->Filters().IsEmpty());
9029 EXPECT_TRUE(child->render_surface()->Filters().IsEmpty()); 9035 EXPECT_TRUE(child->GetRenderSurface()->Filters().IsEmpty());
9030 9036
9031 EXPECT_FALSE(root->FilterIsAnimating()); 9037 EXPECT_FALSE(root->FilterIsAnimating());
9032 EXPECT_TRUE(child->FilterIsAnimating()); 9038 EXPECT_TRUE(child->FilterIsAnimating());
9033 EXPECT_FALSE(grandchild->FilterIsAnimating()); 9039 EXPECT_FALSE(grandchild->FilterIsAnimating());
9034 } 9040 }
9035 9041
9036 // Verify that having a filter animation with a delayed start time creates a 9042 // Verify that having a filter animation with a delayed start time creates a
9037 // render surface. 9043 // render surface.
9038 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { 9044 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) {
9039 LayerImpl* root = root_layer_for_testing(); 9045 LayerImpl* root = root_layer_for_testing();
(...skipping 18 matching lines...) Expand all
9058 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); 9064 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr));
9059 std::unique_ptr<Animation> animation = 9065 std::unique_ptr<Animation> animation =
9060 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); 9066 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER);
9061 animation->set_fill_mode(Animation::FillMode::NONE); 9067 animation->set_fill_mode(Animation::FillMode::NONE);
9062 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 9068 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
9063 9069
9064 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), 9070 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(),
9065 std::move(animation)); 9071 std::move(animation));
9066 ExecuteCalculateDrawProperties(root); 9072 ExecuteCalculateDrawProperties(root);
9067 9073
9068 EXPECT_TRUE(root->has_render_surface()); 9074 EXPECT_TRUE(root->GetRenderSurface());
9069 EXPECT_TRUE(child->has_render_surface()); 9075 EXPECT_TRUE(child->GetRenderSurface());
9070 EXPECT_FALSE(grandchild->has_render_surface()); 9076 EXPECT_FALSE(grandchild->GetRenderSurface());
9071 9077
9072 EXPECT_TRUE(root->render_surface()->Filters().IsEmpty()); 9078 EXPECT_TRUE(root->GetRenderSurface()->Filters().IsEmpty());
9073 EXPECT_TRUE(child->render_surface()->Filters().IsEmpty()); 9079 EXPECT_TRUE(child->GetRenderSurface()->Filters().IsEmpty());
9074 9080
9075 EXPECT_FALSE(root->FilterIsAnimating()); 9081 EXPECT_FALSE(root->FilterIsAnimating());
9076 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); 9082 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation());
9077 EXPECT_FALSE(child->FilterIsAnimating()); 9083 EXPECT_FALSE(child->FilterIsAnimating());
9078 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); 9084 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation());
9079 EXPECT_FALSE(grandchild->FilterIsAnimating()); 9085 EXPECT_FALSE(grandchild->FilterIsAnimating());
9080 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); 9086 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation());
9081 } 9087 }
9082 9088
9083 // Ensures that the property tree code accounts for offsets between fixed 9089 // Ensures that the property tree code accounts for offsets between fixed
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
9783 page_scale_layer, inner_viewport_scroll_layer, 9789 page_scale_layer, inner_viewport_scroll_layer,
9784 outer_viewport_scroll_layer, 9790 outer_viewport_scroll_layer,
9785 skip_verify_visible_rect_calculations); 9791 skip_verify_visible_rect_calculations);
9786 9792
9787 TransformTree& transform_tree = 9793 TransformTree& transform_tree =
9788 root->layer_tree_impl()->property_trees()->transform_tree; 9794 root->layer_tree_impl()->property_trees()->transform_tree;
9789 TransformNode* transform_node = 9795 TransformNode* transform_node =
9790 transform_tree.Node(significant_transform->transform_tree_index()); 9796 transform_tree.Node(significant_transform->transform_tree_index());
9791 EXPECT_EQ(transform_node->owning_layer_id, significant_transform->id()); 9797 EXPECT_EQ(transform_node->owning_layer_id, significant_transform->id());
9792 9798
9793 EXPECT_TRUE(root->has_render_surface()); 9799 EXPECT_TRUE(root->GetRenderSurface());
9794 EXPECT_FALSE(significant_transform->has_render_surface()); 9800 EXPECT_FALSE(significant_transform->GetRenderSurface());
9795 EXPECT_TRUE(layer_clips_subtree->has_render_surface()); 9801 EXPECT_TRUE(layer_clips_subtree->GetRenderSurface());
9796 EXPECT_TRUE(render_surface->has_render_surface()); 9802 EXPECT_TRUE(render_surface->GetRenderSurface());
9797 EXPECT_FALSE(test_layer->has_render_surface()); 9803 EXPECT_FALSE(test_layer->GetRenderSurface());
9798 9804
9799 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; 9805 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree;
9800 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); 9806 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index());
9801 EXPECT_EQ(clip_node->clip_type, ClipNode::ClipType::NONE); 9807 EXPECT_EQ(clip_node->clip_type, ClipNode::ClipType::NONE);
9802 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect()); 9808 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect());
9803 9809
9804 // Also test the visible rects computed by combining clips in root space. 9810 // Also test the visible rects computed by combining clips in root space.
9805 gfx::Rect visible_rect = draw_property_utils::ComputeLayerVisibleRectDynamic( 9811 gfx::Rect visible_rect = draw_property_utils::ComputeLayerVisibleRectDynamic(
9806 root->layer_tree_impl()->property_trees(), test_layer); 9812 root->layer_tree_impl()->property_trees(), test_layer);
9807 EXPECT_EQ(gfx::Rect(30, 20), visible_rect); 9813 EXPECT_EQ(gfx::Rect(30, 20), visible_rect);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
9998 clipped_surface->SetDrawsContent(true); 10004 clipped_surface->SetDrawsContent(true);
9999 clipped_surface->test_properties()->force_render_surface = true; 10005 clipped_surface->test_properties()->force_render_surface = true;
10000 10006
10001 clip_child->test_properties()->clip_parent = clip_parent; 10007 clip_child->test_properties()->clip_parent = clip_parent;
10002 clip_parent->test_properties()->clip_children = 10008 clip_parent->test_properties()->clip_children =
10003 base::MakeUnique<std::set<LayerImpl*>>(); 10009 base::MakeUnique<std::set<LayerImpl*>>();
10004 clip_parent->test_properties()->clip_children->insert(clip_child); 10010 clip_parent->test_properties()->clip_children->insert(clip_child);
10005 10011
10006 ExecuteCalculateDrawProperties(root); 10012 ExecuteCalculateDrawProperties(root);
10007 EXPECT_EQ(gfx::Rect(50, 50), 10013 EXPECT_EQ(gfx::Rect(50, 50),
10008 unclipped_surface->render_surface()->content_rect()); 10014 unclipped_surface->GetRenderSurface()->content_rect());
10009 EXPECT_EQ(gfx::Rect(50, 50), 10015 EXPECT_EQ(gfx::Rect(50, 50),
10010 unclipped_desc_surface->render_surface()->content_rect()); 10016 unclipped_desc_surface->GetRenderSurface()->content_rect());
10011 EXPECT_EQ(gfx::Rect(50, 50), 10017 EXPECT_EQ(gfx::Rect(50, 50),
10012 unclipped_desc_surface2->render_surface()->content_rect()); 10018 unclipped_desc_surface2->GetRenderSurface()->content_rect());
10013 EXPECT_EQ(gfx::Rect(50, 50), 10019 EXPECT_EQ(gfx::Rect(50, 50),
10014 clipped_surface->render_surface()->content_rect()); 10020 clipped_surface->GetRenderSurface()->content_rect());
10015 } 10021 }
10016 10022
10017 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { 10023 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) {
10018 // Tests the value of render surface content rect when we have a layer that 10024 // Tests the value of render surface content rect when we have a layer that
10019 // clips between the clip parent's target and clip child's target. 10025 // clips between the clip parent's target and clip child's target.
10020 LayerImpl* root = root_layer_for_testing(); 10026 LayerImpl* root = root_layer_for_testing();
10021 LayerImpl* surface = AddChildToRoot<LayerImpl>(); 10027 LayerImpl* surface = AddChildToRoot<LayerImpl>();
10022 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); 10028 LayerImpl* clip_layer = AddChild<LayerImpl>(surface);
10023 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); 10029 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer);
10024 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 10030 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
(...skipping 21 matching lines...) Expand all
10046 clip_child->SetDrawsContent(true); 10052 clip_child->SetDrawsContent(true);
10047 10053
10048 clip_child->test_properties()->clip_parent = clip_parent; 10054 clip_child->test_properties()->clip_parent = clip_parent;
10049 clip_parent->test_properties()->clip_children = 10055 clip_parent->test_properties()->clip_children =
10050 base::MakeUnique<std::set<LayerImpl*>>(); 10056 base::MakeUnique<std::set<LayerImpl*>>();
10051 clip_parent->test_properties()->clip_children->insert(clip_child); 10057 clip_parent->test_properties()->clip_children->insert(clip_child);
10052 10058
10053 ExecuteCalculateDrawProperties(root); 10059 ExecuteCalculateDrawProperties(root);
10054 10060
10055 EXPECT_EQ(gfx::Rect(10, 10), 10061 EXPECT_EQ(gfx::Rect(10, 10),
10056 unclipped_desc_surface->render_surface()->content_rect()); 10062 unclipped_desc_surface->GetRenderSurface()->content_rect());
10057 } 10063 }
10058 10064
10059 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) { 10065 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) {
10060 LayerImpl* root = root_layer_for_testing(); 10066 LayerImpl* root = root_layer_for_testing();
10061 LayerImpl* surface = AddChildToRoot<LayerImpl>(); 10067 LayerImpl* surface = AddChildToRoot<LayerImpl>();
10062 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); 10068 LayerImpl* clip_layer = AddChild<LayerImpl>(surface);
10063 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); 10069 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer);
10064 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 10070 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
10065 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); 10071 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface);
10066 10072
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
10394 // child has one, the large transform applied to child will result in NaNs in 10400 // child has one, the large transform applied to child will result in NaNs in
10395 // the draw_transform of the render_surface, thus make draw property updates 10401 // the draw_transform of the render_surface, thus make draw property updates
10396 // skip the child layer. We need further investigation into this to know 10402 // skip the child layer. We need further investigation into this to know
10397 // what exactly happens here. 10403 // what exactly happens here.
10398 child->test_properties()->transform = large_transform; 10404 child->test_properties()->transform = large_transform;
10399 child->SetBounds(gfx::Size(30, 30)); 10405 child->SetBounds(gfx::Size(30, 30));
10400 10406
10401 ExecuteCalculateDrawProperties(root); 10407 ExecuteCalculateDrawProperties(root);
10402 10408
10403 EXPECT_EQ(gfx::RectF(), 10409 EXPECT_EQ(gfx::RectF(),
10404 render_surface1->render_surface()->DrawableContentRect()); 10410 render_surface1->GetRenderSurface()->DrawableContentRect());
10405 10411
10406 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || 10412 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) ||
10407 std::isnan(child->DrawTransform().matrix().get(0, 0)); 10413 std::isnan(child->DrawTransform().matrix().get(0, 0));
10408 EXPECT_TRUE(is_inf_or_nan); 10414 EXPECT_TRUE(is_inf_or_nan);
10409 10415
10410 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || 10416 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) ||
10411 std::isnan(child->DrawTransform().matrix().get(1, 1)); 10417 std::isnan(child->DrawTransform().matrix().get(1, 1));
10412 EXPECT_TRUE(is_inf_or_nan); 10418 EXPECT_TRUE(is_inf_or_nan);
10413 10419
10414 // The root layer should be in the RenderSurfaceLayerListImpl. 10420 // The root layer should be in the RenderSurfaceLayerListImpl.
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
10752 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10758 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10753 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10759 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10754 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10760 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10755 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10761 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10756 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10762 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10757 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10763 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10758 } 10764 }
10759 10765
10760 } // namespace 10766 } // namespace
10761 } // namespace cc 10767 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698