| OLD | NEW |
| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 parent->test_properties()->transform = parent_layer_transform; | 740 parent->test_properties()->transform = parent_layer_transform; |
| 741 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 30.f, 0.f); | 741 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 30.f, 0.f); |
| 742 parent->SetBounds(gfx::Size(100, 120)); | 742 parent->SetBounds(gfx::Size(100, 120)); |
| 743 child->SetBounds(gfx::Size(16, 18)); | 743 child->SetBounds(gfx::Size(16, 18)); |
| 744 child->test_properties()->force_render_surface = true; | 744 child->test_properties()->force_render_surface = true; |
| 745 grand_child->SetBounds(gfx::Size(8, 10)); | 745 grand_child->SetBounds(gfx::Size(8, 10)); |
| 746 grand_child->SetDrawsContent(true); | 746 grand_child->SetDrawsContent(true); |
| 747 ExecuteCalculateDrawProperties(root); | 747 ExecuteCalculateDrawProperties(root); |
| 748 | 748 |
| 749 // Render surface should have been created now. | 749 // Render surface should have been created now. |
| 750 ASSERT_TRUE(child->GetRenderSurface()); | 750 ASSERT_TRUE(GetRenderSurface(child)); |
| 751 ASSERT_EQ(child->GetRenderSurface(), child->render_target()); | 751 ASSERT_EQ(GetRenderSurface(child), child->render_target()); |
| 752 | 752 |
| 753 // The child layer's draw transform should refer to its new render surface. | 753 // The child layer's draw transform should refer to its new render surface. |
| 754 // The screen-space transform, however, should still refer to the root. | 754 // The screen-space transform, however, should still refer to the root. |
| 755 EXPECT_TRANSFORMATION_MATRIX_EQ(surface_sublayer_transform, | 755 EXPECT_TRANSFORMATION_MATRIX_EQ(surface_sublayer_transform, |
| 756 child->DrawTransform()); | 756 child->DrawTransform()); |
| 757 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform, | 757 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform, |
| 758 child->ScreenSpaceTransform()); | 758 child->ScreenSpaceTransform()); |
| 759 | 759 |
| 760 // Because the grand_child is the only drawable content, the child's render | 760 // Because the grand_child is the only drawable content, the child's render |
| 761 // surface will tighten its bounds to the grand_child. The scale at which the | 761 // 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 Loading... |
| 925 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); | 925 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); |
| 926 grand_child_of_rs2->test_properties()->transform_origin = | 926 grand_child_of_rs2->test_properties()->transform_origin = |
| 927 gfx::Point3F(2.5f, 0.f, 0.f); | 927 gfx::Point3F(2.5f, 0.f, 0.f); |
| 928 grand_child_of_rs2->test_properties()->transform = layer_transform; | 928 grand_child_of_rs2->test_properties()->transform = layer_transform; |
| 929 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); | 929 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); |
| 930 | 930 |
| 931 ExecuteCalculateDrawProperties(root); | 931 ExecuteCalculateDrawProperties(root); |
| 932 | 932 |
| 933 // Only layers that are associated with render surfaces should have an actual | 933 // Only layers that are associated with render surfaces should have an actual |
| 934 // RenderSurface() value. | 934 // RenderSurface() value. |
| 935 ASSERT_TRUE(root->GetRenderSurface()); | 935 ASSERT_TRUE(GetRenderSurface(root)); |
| 936 ASSERT_FALSE(child_of_root->GetRenderSurface()); | 936 ASSERT_FALSE(GetRenderSurface(child_of_root)); |
| 937 ASSERT_FALSE(grand_child_of_root->GetRenderSurface()); | 937 ASSERT_FALSE(GetRenderSurface(grand_child_of_root)); |
| 938 | 938 |
| 939 ASSERT_TRUE(render_surface1->GetRenderSurface()); | 939 ASSERT_TRUE(GetRenderSurface(render_surface1)); |
| 940 ASSERT_FALSE(child_of_rs1->GetRenderSurface()); | 940 ASSERT_FALSE(GetRenderSurface(child_of_rs1)); |
| 941 ASSERT_FALSE(grand_child_of_rs1->GetRenderSurface()); | 941 ASSERT_FALSE(GetRenderSurface(grand_child_of_rs1)); |
| 942 | 942 |
| 943 ASSERT_TRUE(render_surface2->GetRenderSurface()); | 943 ASSERT_TRUE(GetRenderSurface(render_surface2)); |
| 944 ASSERT_FALSE(child_of_rs2->GetRenderSurface()); | 944 ASSERT_FALSE(GetRenderSurface(child_of_rs2)); |
| 945 ASSERT_FALSE(grand_child_of_rs2->GetRenderSurface()); | 945 ASSERT_FALSE(GetRenderSurface(grand_child_of_rs2)); |
| 946 | 946 |
| 947 // Verify all render target accessors | 947 // Verify all render target accessors |
| 948 EXPECT_EQ(root->GetRenderSurface(), parent->render_target()); | 948 EXPECT_EQ(GetRenderSurface(root), parent->render_target()); |
| 949 EXPECT_EQ(root->GetRenderSurface(), child_of_root->render_target()); | 949 EXPECT_EQ(GetRenderSurface(root), child_of_root->render_target()); |
| 950 EXPECT_EQ(root->GetRenderSurface(), grand_child_of_root->render_target()); | 950 EXPECT_EQ(GetRenderSurface(root), grand_child_of_root->render_target()); |
| 951 | 951 |
| 952 EXPECT_EQ(render_surface1->GetRenderSurface(), | 952 EXPECT_EQ(GetRenderSurface(render_surface1), |
| 953 render_surface1->render_target()); | 953 render_surface1->render_target()); |
| 954 EXPECT_EQ(render_surface1->GetRenderSurface(), child_of_rs1->render_target()); | 954 EXPECT_EQ(GetRenderSurface(render_surface1), child_of_rs1->render_target()); |
| 955 EXPECT_EQ(render_surface1->GetRenderSurface(), | 955 EXPECT_EQ(GetRenderSurface(render_surface1), |
| 956 grand_child_of_rs1->render_target()); | 956 grand_child_of_rs1->render_target()); |
| 957 | 957 |
| 958 EXPECT_EQ(render_surface2->GetRenderSurface(), | 958 EXPECT_EQ(GetRenderSurface(render_surface2), |
| 959 render_surface2->render_target()); | 959 render_surface2->render_target()); |
| 960 EXPECT_EQ(render_surface2->GetRenderSurface(), child_of_rs2->render_target()); | 960 EXPECT_EQ(GetRenderSurface(render_surface2), child_of_rs2->render_target()); |
| 961 EXPECT_EQ(render_surface2->GetRenderSurface(), | 961 EXPECT_EQ(GetRenderSurface(render_surface2), |
| 962 grand_child_of_rs2->render_target()); | 962 grand_child_of_rs2->render_target()); |
| 963 | 963 |
| 964 // Verify layer draw transforms note that draw transforms are described with | 964 // Verify layer draw transforms note that draw transforms are described with |
| 965 // respect to the nearest ancestor render surface but screen space transforms | 965 // respect to the nearest ancestor render surface but screen space transforms |
| 966 // are described with respect to the root. | 966 // are described with respect to the root. |
| 967 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->DrawTransform()); | 967 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->DrawTransform()); |
| 968 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A, child_of_root->DrawTransform()); | 968 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A, child_of_root->DrawTransform()); |
| 969 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A, | 969 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A, |
| 970 grand_child_of_root->DrawTransform()); | 970 grand_child_of_root->DrawTransform()); |
| 971 | 971 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 997 render_surface2->ScreenSpaceTransform()); | 997 render_surface2->ScreenSpaceTransform()); |
| 998 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A, | 998 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A, |
| 999 child_of_rs2->ScreenSpaceTransform()); | 999 child_of_rs2->ScreenSpaceTransform()); |
| 1000 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A * A, | 1000 EXPECT_TRANSFORMATION_MATRIX_EQ(A * A * A * A * A, |
| 1001 grand_child_of_rs2->ScreenSpaceTransform()); | 1001 grand_child_of_rs2->ScreenSpaceTransform()); |
| 1002 | 1002 |
| 1003 // Verify render surface transforms. | 1003 // Verify render surface transforms. |
| 1004 // | 1004 // |
| 1005 // Draw transform of render surface 1 is described with respect to root. | 1005 // Draw transform of render surface 1 is described with respect to root. |
| 1006 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1006 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1007 A * A * S1, render_surface1->GetRenderSurface()->draw_transform()); | 1007 A * A * S1, GetRenderSurface(render_surface1)->draw_transform()); |
| 1008 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1008 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1009 A * A * S1, | 1009 A * A * S1, GetRenderSurface(render_surface1)->screen_space_transform()); |
| 1010 render_surface1->GetRenderSurface()->screen_space_transform()); | |
| 1011 // Draw transform of render surface 2 is described with respect to render | 1010 // Draw transform of render surface 2 is described with respect to render |
| 1012 // surface 1. | 1011 // surface 1. |
| 1013 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1012 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1014 SS1 * A * S2, render_surface2->GetRenderSurface()->draw_transform()); | 1013 SS1 * A * S2, GetRenderSurface(render_surface2)->draw_transform()); |
| 1015 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1014 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1016 A * A * A * S2, | 1015 A * A * A * S2, |
| 1017 render_surface2->GetRenderSurface()->screen_space_transform()); | 1016 GetRenderSurface(render_surface2)->screen_space_transform()); |
| 1018 | 1017 |
| 1019 // Sanity check. If these fail there is probably a bug in the test itself. It | 1018 // Sanity check. If these fail there is probably a bug in the test itself. It |
| 1020 // is expected that we correctly set up transforms so that the y-component of | 1019 // is expected that we correctly set up transforms so that the y-component of |
| 1021 // the screen-space transform encodes the "depth" of the layer in the tree. | 1020 // the screen-space transform encodes the "depth" of the layer in the tree. |
| 1022 EXPECT_FLOAT_EQ(1.0, parent->ScreenSpaceTransform().matrix().get(1, 3)); | 1021 EXPECT_FLOAT_EQ(1.0, parent->ScreenSpaceTransform().matrix().get(1, 3)); |
| 1023 EXPECT_FLOAT_EQ(2.0, | 1022 EXPECT_FLOAT_EQ(2.0, |
| 1024 child_of_root->ScreenSpaceTransform().matrix().get(1, 3)); | 1023 child_of_root->ScreenSpaceTransform().matrix().get(1, 3)); |
| 1025 EXPECT_FLOAT_EQ( | 1024 EXPECT_FLOAT_EQ( |
| 1026 3.0, grand_child_of_root->ScreenSpaceTransform().matrix().get(1, 3)); | 1025 3.0, grand_child_of_root->ScreenSpaceTransform().matrix().get(1, 3)); |
| 1027 | 1026 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 gfx::Transform expected_grand_child_screen_space_transform = | 1077 gfx::Transform expected_grand_child_screen_space_transform = |
| 1079 flattened_rotation_about_y * rotation_about_y_axis; | 1078 flattened_rotation_about_y * rotation_about_y_axis; |
| 1080 gfx::Transform expected_great_grand_child_draw_transform = | 1079 gfx::Transform expected_great_grand_child_draw_transform = |
| 1081 flattened_rotation_about_y; | 1080 flattened_rotation_about_y; |
| 1082 gfx::Transform expected_great_grand_child_screen_space_transform = | 1081 gfx::Transform expected_great_grand_child_screen_space_transform = |
| 1083 flattened_rotation_about_y * flattened_rotation_about_y; | 1082 flattened_rotation_about_y * flattened_rotation_about_y; |
| 1084 | 1083 |
| 1085 ExecuteCalculateDrawProperties(root); | 1084 ExecuteCalculateDrawProperties(root); |
| 1086 | 1085 |
| 1087 // The child's draw transform should have been taken by its surface. | 1086 // The child's draw transform should have been taken by its surface. |
| 1088 ASSERT_TRUE(child->GetRenderSurface()); | 1087 ASSERT_TRUE(GetRenderSurface(child)); |
| 1089 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_draw_transform, | 1088 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_draw_transform, |
| 1090 child->GetRenderSurface()->draw_transform()); | 1089 GetRenderSurface(child)->draw_transform()); |
| 1091 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1090 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1092 expected_child_screen_space_transform, | 1091 expected_child_screen_space_transform, |
| 1093 child->GetRenderSurface()->screen_space_transform()); | 1092 GetRenderSurface(child)->screen_space_transform()); |
| 1094 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); | 1093 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); |
| 1095 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_screen_space_transform, | 1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_screen_space_transform, |
| 1096 child->ScreenSpaceTransform()); | 1095 child->ScreenSpaceTransform()); |
| 1097 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_draw_transform, | 1096 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_draw_transform, |
| 1098 grand_child->DrawTransform()); | 1097 grand_child->DrawTransform()); |
| 1099 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform, | 1098 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform, |
| 1100 grand_child->ScreenSpaceTransform()); | 1099 grand_child->ScreenSpaceTransform()); |
| 1101 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform, | 1100 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform, |
| 1102 great_grand_child->DrawTransform()); | 1101 great_grand_child->DrawTransform()); |
| 1103 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1102 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 grand_child->SetDrawsContent(true); | 1158 grand_child->SetDrawsContent(true); |
| 1160 | 1159 |
| 1161 root->SetBounds(gfx::Size(100, 100)); | 1160 root->SetBounds(gfx::Size(100, 100)); |
| 1162 // The child height is zero, but has non-zero width that should be accounted | 1161 // The child height is zero, but has non-zero width that should be accounted |
| 1163 // for while computing draw transforms. | 1162 // for while computing draw transforms. |
| 1164 child->SetBounds(gfx::Size(10, 0)); | 1163 child->SetBounds(gfx::Size(10, 0)); |
| 1165 child->test_properties()->force_render_surface = true; | 1164 child->test_properties()->force_render_surface = true; |
| 1166 grand_child->SetBounds(gfx::Size(10, 10)); | 1165 grand_child->SetBounds(gfx::Size(10, 10)); |
| 1167 ExecuteCalculateDrawProperties(root); | 1166 ExecuteCalculateDrawProperties(root); |
| 1168 | 1167 |
| 1169 ASSERT_TRUE(child->GetRenderSurface()); | 1168 ASSERT_TRUE(GetRenderSurface(child)); |
| 1170 // This is the real test, the rest are sanity checks. | 1169 // This is the real test, the rest are sanity checks. |
| 1171 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1170 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1172 child->GetRenderSurface()->draw_transform()); | 1171 GetRenderSurface(child)->draw_transform()); |
| 1173 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); | 1172 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); |
| 1174 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1173 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1175 grand_child->DrawTransform()); | 1174 grand_child->DrawTransform()); |
| 1176 } | 1175 } |
| 1177 | 1176 |
| 1178 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { | 1177 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { |
| 1179 LayerImpl* root = root_layer_for_testing(); | 1178 LayerImpl* root = root_layer_for_testing(); |
| 1180 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 1179 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 1181 LayerImpl* child = AddChild<LayerImpl>(render_surface); | 1180 LayerImpl* child = AddChild<LayerImpl>(render_surface); |
| 1182 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1181 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 RenderSurfaceList render_surface_list_impl; | 1228 RenderSurfaceList render_surface_list_impl; |
| 1230 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1229 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1231 root, root->bounds(), translate, &render_surface_list_impl); | 1230 root, root->bounds(), translate, &render_surface_list_impl); |
| 1232 inputs.property_trees->needs_rebuild = true; | 1231 inputs.property_trees->needs_rebuild = true; |
| 1233 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1232 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1234 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1233 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1235 translate, root->draw_properties().target_space_transform); | 1234 translate, root->draw_properties().target_space_transform); |
| 1236 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1235 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1237 translate, child->draw_properties().target_space_transform); | 1236 translate, child->draw_properties().target_space_transform); |
| 1238 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1237 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1239 root->GetRenderSurface()->draw_transform()); | 1238 GetRenderSurface(root)->draw_transform()); |
| 1240 EXPECT_TRANSFORMATION_MATRIX_EQ(translate, child->ScreenSpaceTransform()); | 1239 EXPECT_TRANSFORMATION_MATRIX_EQ(translate, child->ScreenSpaceTransform()); |
| 1241 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), child->clip_rect()); | 1240 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), child->clip_rect()); |
| 1242 } | 1241 } |
| 1243 | 1242 |
| 1244 gfx::Transform scale; | 1243 gfx::Transform scale; |
| 1245 scale.Scale(2, 2); | 1244 scale.Scale(2, 2); |
| 1246 { | 1245 { |
| 1247 RenderSurfaceList render_surface_list_impl; | 1246 RenderSurfaceList render_surface_list_impl; |
| 1248 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1247 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1249 root, root->bounds(), scale, &render_surface_list_impl); | 1248 root, root->bounds(), scale, &render_surface_list_impl); |
| 1250 inputs.property_trees->needs_rebuild = true; | 1249 inputs.property_trees->needs_rebuild = true; |
| 1251 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1250 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1252 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1251 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1253 scale, root->draw_properties().target_space_transform); | 1252 scale, root->draw_properties().target_space_transform); |
| 1254 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1253 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1255 scale, child->draw_properties().target_space_transform); | 1254 scale, child->draw_properties().target_space_transform); |
| 1256 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1255 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1257 root->GetRenderSurface()->draw_transform()); | 1256 GetRenderSurface(root)->draw_transform()); |
| 1258 EXPECT_TRANSFORMATION_MATRIX_EQ(scale, child->ScreenSpaceTransform()); | 1257 EXPECT_TRANSFORMATION_MATRIX_EQ(scale, child->ScreenSpaceTransform()); |
| 1259 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), child->clip_rect()); | 1258 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), child->clip_rect()); |
| 1260 } | 1259 } |
| 1261 | 1260 |
| 1262 gfx::Transform rotate; | 1261 gfx::Transform rotate; |
| 1263 rotate.Rotate(2); | 1262 rotate.Rotate(2); |
| 1264 { | 1263 { |
| 1265 RenderSurfaceList render_surface_list_impl; | 1264 RenderSurfaceList render_surface_list_impl; |
| 1266 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1265 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1267 root, root->bounds(), rotate, &render_surface_list_impl); | 1266 root, root->bounds(), rotate, &render_surface_list_impl); |
| 1268 inputs.property_trees->needs_rebuild = true; | 1267 inputs.property_trees->needs_rebuild = true; |
| 1269 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1268 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1270 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1269 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1271 rotate, root->draw_properties().target_space_transform); | 1270 rotate, root->draw_properties().target_space_transform); |
| 1272 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1271 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1273 rotate, child->draw_properties().target_space_transform); | 1272 rotate, child->draw_properties().target_space_transform); |
| 1274 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1273 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1275 root->GetRenderSurface()->draw_transform()); | 1274 GetRenderSurface(root)->draw_transform()); |
| 1276 EXPECT_TRANSFORMATION_MATRIX_EQ(rotate, child->ScreenSpaceTransform()); | 1275 EXPECT_TRANSFORMATION_MATRIX_EQ(rotate, child->ScreenSpaceTransform()); |
| 1277 EXPECT_EQ(gfx::Rect(-4, 0, 104, 104), child->clip_rect()); | 1276 EXPECT_EQ(gfx::Rect(-4, 0, 104, 104), child->clip_rect()); |
| 1278 } | 1277 } |
| 1279 | 1278 |
| 1280 gfx::Transform composite; | 1279 gfx::Transform composite; |
| 1281 composite.ConcatTransform(translate); | 1280 composite.ConcatTransform(translate); |
| 1282 composite.ConcatTransform(scale); | 1281 composite.ConcatTransform(scale); |
| 1283 composite.ConcatTransform(rotate); | 1282 composite.ConcatTransform(rotate); |
| 1284 { | 1283 { |
| 1285 RenderSurfaceList render_surface_list_impl; | 1284 RenderSurfaceList render_surface_list_impl; |
| 1286 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1285 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1287 root, root->bounds(), composite, &render_surface_list_impl); | 1286 root, root->bounds(), composite, &render_surface_list_impl); |
| 1288 inputs.property_trees->needs_rebuild = true; | 1287 inputs.property_trees->needs_rebuild = true; |
| 1289 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1288 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1290 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1289 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1291 composite, root->draw_properties().target_space_transform); | 1290 composite, root->draw_properties().target_space_transform); |
| 1292 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1291 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1293 composite, child->draw_properties().target_space_transform); | 1292 composite, child->draw_properties().target_space_transform); |
| 1294 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1293 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1295 root->GetRenderSurface()->draw_transform()); | 1294 GetRenderSurface(root)->draw_transform()); |
| 1296 EXPECT_TRANSFORMATION_MATRIX_EQ(composite, child->ScreenSpaceTransform()); | 1295 EXPECT_TRANSFORMATION_MATRIX_EQ(composite, child->ScreenSpaceTransform()); |
| 1297 EXPECT_EQ(gfx::Rect(89, 103, 208, 208), child->clip_rect()); | 1296 EXPECT_EQ(gfx::Rect(89, 103, 208, 208), child->clip_rect()); |
| 1298 } | 1297 } |
| 1299 | 1298 |
| 1300 // Verify it composes correctly with device scale. | 1299 // Verify it composes correctly with device scale. |
| 1301 float device_scale_factor = 1.5f; | 1300 float device_scale_factor = 1.5f; |
| 1302 | 1301 |
| 1303 { | 1302 { |
| 1304 RenderSurfaceList render_surface_list_impl; | 1303 RenderSurfaceList render_surface_list_impl; |
| 1305 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1304 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1306 root, root->bounds(), translate, &render_surface_list_impl); | 1305 root, root->bounds(), translate, &render_surface_list_impl); |
| 1307 inputs.device_scale_factor = device_scale_factor; | 1306 inputs.device_scale_factor = device_scale_factor; |
| 1308 inputs.property_trees->needs_rebuild = true; | 1307 inputs.property_trees->needs_rebuild = true; |
| 1309 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1308 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1310 gfx::Transform device_scaled_translate = translate; | 1309 gfx::Transform device_scaled_translate = translate; |
| 1311 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); | 1310 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); |
| 1312 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1311 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1313 device_scaled_translate, | 1312 device_scaled_translate, |
| 1314 root->draw_properties().target_space_transform); | 1313 root->draw_properties().target_space_transform); |
| 1315 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1314 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1316 device_scaled_translate, | 1315 device_scaled_translate, |
| 1317 child->draw_properties().target_space_transform); | 1316 child->draw_properties().target_space_transform); |
| 1318 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1317 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1319 root->GetRenderSurface()->draw_transform()); | 1318 GetRenderSurface(root)->draw_transform()); |
| 1320 EXPECT_TRANSFORMATION_MATRIX_EQ(device_scaled_translate, | 1319 EXPECT_TRANSFORMATION_MATRIX_EQ(device_scaled_translate, |
| 1321 child->ScreenSpaceTransform()); | 1320 child->ScreenSpaceTransform()); |
| 1322 EXPECT_EQ(gfx::Rect(50, 50, 150, 150), child->clip_rect()); | 1321 EXPECT_EQ(gfx::Rect(50, 50, 150, 150), child->clip_rect()); |
| 1323 } | 1322 } |
| 1324 | 1323 |
| 1325 // Verify it composes correctly with page scale. | 1324 // Verify it composes correctly with page scale. |
| 1326 float page_scale_factor = 2.f; | 1325 float page_scale_factor = 2.f; |
| 1327 | 1326 |
| 1328 { | 1327 { |
| 1329 RenderSurfaceList render_surface_list_impl; | 1328 RenderSurfaceList render_surface_list_impl; |
| 1330 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1329 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1331 root, root->bounds(), translate, &render_surface_list_impl); | 1330 root, root->bounds(), translate, &render_surface_list_impl); |
| 1332 inputs.page_scale_factor = page_scale_factor; | 1331 inputs.page_scale_factor = page_scale_factor; |
| 1333 inputs.page_scale_layer = root; | 1332 inputs.page_scale_layer = root; |
| 1334 inputs.property_trees->needs_rebuild = true; | 1333 inputs.property_trees->needs_rebuild = true; |
| 1335 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1334 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1336 gfx::Transform page_scaled_translate = translate; | 1335 gfx::Transform page_scaled_translate = translate; |
| 1337 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); | 1336 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); |
| 1338 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1337 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1339 page_scaled_translate, root->draw_properties().target_space_transform); | 1338 page_scaled_translate, root->draw_properties().target_space_transform); |
| 1340 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1339 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1341 page_scaled_translate, child->draw_properties().target_space_transform); | 1340 page_scaled_translate, child->draw_properties().target_space_transform); |
| 1342 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1341 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1343 root->GetRenderSurface()->draw_transform()); | 1342 GetRenderSurface(root)->draw_transform()); |
| 1344 EXPECT_TRANSFORMATION_MATRIX_EQ(page_scaled_translate, | 1343 EXPECT_TRANSFORMATION_MATRIX_EQ(page_scaled_translate, |
| 1345 child->ScreenSpaceTransform()); | 1344 child->ScreenSpaceTransform()); |
| 1346 EXPECT_EQ(gfx::Rect(50, 50, 200, 200), child->clip_rect()); | 1345 EXPECT_EQ(gfx::Rect(50, 50, 200, 200), child->clip_rect()); |
| 1347 } | 1346 } |
| 1348 | 1347 |
| 1349 // Verify that it composes correctly with transforms directly on root layer. | 1348 // Verify that it composes correctly with transforms directly on root layer. |
| 1350 root->test_properties()->transform = composite; | 1349 root->test_properties()->transform = composite; |
| 1351 | 1350 |
| 1352 { | 1351 { |
| 1353 RenderSurfaceList render_surface_list_impl; | 1352 RenderSurfaceList render_surface_list_impl; |
| 1354 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1353 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1355 root, root->bounds(), composite, &render_surface_list_impl); | 1354 root, root->bounds(), composite, &render_surface_list_impl); |
| 1356 inputs.property_trees->needs_rebuild = true; | 1355 inputs.property_trees->needs_rebuild = true; |
| 1357 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1356 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1358 gfx::Transform compositeSquared = composite; | 1357 gfx::Transform compositeSquared = composite; |
| 1359 compositeSquared.ConcatTransform(composite); | 1358 compositeSquared.ConcatTransform(composite); |
| 1360 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1359 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1361 compositeSquared, root->draw_properties().target_space_transform); | 1360 compositeSquared, root->draw_properties().target_space_transform); |
| 1362 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1361 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1363 compositeSquared, child->draw_properties().target_space_transform); | 1362 compositeSquared, child->draw_properties().target_space_transform); |
| 1364 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1363 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1365 root->GetRenderSurface()->draw_transform()); | 1364 GetRenderSurface(root)->draw_transform()); |
| 1366 EXPECT_TRANSFORMATION_MATRIX_EQ(compositeSquared, | 1365 EXPECT_TRANSFORMATION_MATRIX_EQ(compositeSquared, |
| 1367 child->ScreenSpaceTransform()); | 1366 child->ScreenSpaceTransform()); |
| 1368 EXPECT_EQ(gfx::Rect(254, 316, 428, 428), child->clip_rect()); | 1367 EXPECT_EQ(gfx::Rect(254, 316, 428, 428), child->clip_rect()); |
| 1369 } | 1368 } |
| 1370 } | 1369 } |
| 1371 | 1370 |
| 1372 TEST_F(LayerTreeHostCommonTest, | 1371 TEST_F(LayerTreeHostCommonTest, |
| 1373 RenderSurfaceListForRenderSurfaceWithClippedLayer) { | 1372 RenderSurfaceListForRenderSurfaceWithClippedLayer) { |
| 1374 LayerImpl* root = root_layer_for_testing(); | 1373 LayerImpl* root = root_layer_for_testing(); |
| 1375 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); | 1374 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); |
| 1376 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 1375 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| 1377 | 1376 |
| 1378 root->SetBounds(gfx::Size(10, 10)); | 1377 root->SetBounds(gfx::Size(10, 10)); |
| 1379 root->SetMasksToBounds(true); | 1378 root->SetMasksToBounds(true); |
| 1380 render_surface1->SetBounds(gfx::Size(10, 10)); | 1379 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 1381 render_surface1->test_properties()->force_render_surface = true; | 1380 render_surface1->test_properties()->force_render_surface = true; |
| 1382 child->SetDrawsContent(true); | 1381 child->SetDrawsContent(true); |
| 1383 child->SetPosition(gfx::PointF(30.f, 30.f)); | 1382 child->SetPosition(gfx::PointF(30.f, 30.f)); |
| 1384 child->SetBounds(gfx::Size(10, 10)); | 1383 child->SetBounds(gfx::Size(10, 10)); |
| 1385 ExecuteCalculateDrawProperties(root); | 1384 ExecuteCalculateDrawProperties(root); |
| 1386 | 1385 |
| 1387 // The child layer's content is entirely outside the root's clip rect, so | 1386 // The child layer's content is entirely outside the root's clip rect, so |
| 1388 // the intermediate render surface should not be listed here, even if it was | 1387 // the intermediate render surface should not be listed here, even if it was |
| 1389 // forced to be created. Render surfaces without children or visible content | 1388 // forced to be created. Render surfaces without children or visible content |
| 1390 // are unexpected at draw time (e.g. we might try to create a content texture | 1389 // are unexpected at draw time (e.g. we might try to create a content texture |
| 1391 // of size 0). | 1390 // of size 0). |
| 1392 ASSERT_TRUE(root->GetRenderSurface()); | 1391 ASSERT_TRUE(GetRenderSurface(root)); |
| 1393 EXPECT_EQ(1U, render_surface_list_impl()->size()); | 1392 EXPECT_EQ(1U, render_surface_list_impl()->size()); |
| 1394 } | 1393 } |
| 1395 | 1394 |
| 1396 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) { | 1395 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) { |
| 1397 LayerImpl* root = root_layer_for_testing(); | 1396 LayerImpl* root = root_layer_for_testing(); |
| 1398 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 1397 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 1399 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 1398 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| 1400 | 1399 |
| 1401 render_surface1->SetBounds(gfx::Size(10, 10)); | 1400 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 1402 render_surface1->test_properties()->force_render_surface = true; | 1401 render_surface1->test_properties()->force_render_surface = true; |
| 1403 render_surface1->test_properties()->opacity = 0.f; | 1402 render_surface1->test_properties()->opacity = 0.f; |
| 1404 child->SetBounds(gfx::Size(10, 10)); | 1403 child->SetBounds(gfx::Size(10, 10)); |
| 1405 child->SetDrawsContent(true); | 1404 child->SetDrawsContent(true); |
| 1406 | 1405 |
| 1407 RenderSurfaceList render_surface_list; | 1406 RenderSurfaceList render_surface_list; |
| 1408 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1407 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1409 root, root->bounds(), &render_surface_list); | 1408 root, root->bounds(), &render_surface_list); |
| 1410 inputs.can_adjust_raster_scales = true; | 1409 inputs.can_adjust_raster_scales = true; |
| 1411 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1410 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1412 | 1411 |
| 1413 // Since the layer is transparent, render_surface1->GetRenderSurface() should | 1412 // Since the layer is transparent, render_surface1->GetRenderSurface() should |
| 1414 // not have gotten added anywhere. Also, the drawable content rect should not | 1413 // not have gotten added anywhere. Also, the drawable content rect should not |
| 1415 // have been extended by the children. | 1414 // have been extended by the children. |
| 1416 ASSERT_TRUE(root->GetRenderSurface()); | 1415 ASSERT_TRUE(GetRenderSurface(root)); |
| 1417 EXPECT_EQ(0, root->GetRenderSurface()->num_contributors()); | 1416 EXPECT_EQ(0, GetRenderSurface(root)->num_contributors()); |
| 1418 EXPECT_EQ(1U, render_surface_list.size()); | 1417 EXPECT_EQ(1U, render_surface_list.size()); |
| 1419 EXPECT_EQ(root->id(), render_surface_list.at(0)->id()); | 1418 EXPECT_EQ(root->id(), render_surface_list.at(0)->id()); |
| 1420 EXPECT_EQ(gfx::Rect(), root->drawable_content_rect()); | 1419 EXPECT_EQ(gfx::Rect(), root->drawable_content_rect()); |
| 1421 } | 1420 } |
| 1422 | 1421 |
| 1423 TEST_F(LayerTreeHostCommonTest, | 1422 TEST_F(LayerTreeHostCommonTest, |
| 1424 RenderSurfaceListForTransparentChildWithBackgroundFilter) { | 1423 RenderSurfaceListForTransparentChildWithBackgroundFilter) { |
| 1425 LayerImpl* root = root_layer_for_testing(); | 1424 LayerImpl* root = root_layer_for_testing(); |
| 1426 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 1425 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 1427 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 1426 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1441 { | 1440 { |
| 1442 RenderSurfaceList render_surface_list; | 1441 RenderSurfaceList render_surface_list; |
| 1443 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1442 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1444 root, root->bounds(), &render_surface_list); | 1443 root, root->bounds(), &render_surface_list); |
| 1445 inputs.can_adjust_raster_scales = true; | 1444 inputs.can_adjust_raster_scales = true; |
| 1446 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1445 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1447 EXPECT_EQ(2U, render_surface_list.size()); | 1446 EXPECT_EQ(2U, render_surface_list.size()); |
| 1448 } | 1447 } |
| 1449 // The layer is fully transparent, but has a background filter, so it | 1448 // The layer is fully transparent, but has a background filter, so it |
| 1450 // shouldn't be skipped and should be drawn. | 1449 // shouldn't be skipped and should be drawn. |
| 1451 ASSERT_TRUE(root->GetRenderSurface()); | 1450 ASSERT_TRUE(GetRenderSurface(root)); |
| 1452 EXPECT_EQ(1, root->GetRenderSurface()->num_contributors()); | 1451 EXPECT_EQ(1, GetRenderSurface(root)->num_contributors()); |
| 1453 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), | 1452 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), |
| 1454 root->GetRenderSurface()->DrawableContentRect()); | 1453 GetRenderSurface(root)->DrawableContentRect()); |
| 1455 EffectTree& effect_tree = | 1454 EffectTree& effect_tree = |
| 1456 root->layer_tree_impl()->property_trees()->effect_tree; | 1455 root->layer_tree_impl()->property_trees()->effect_tree; |
| 1457 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); | 1456 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); |
| 1458 EXPECT_TRUE(node->is_drawn); | 1457 EXPECT_TRUE(node->is_drawn); |
| 1459 | 1458 |
| 1460 // When root is transparent, the layer should not be drawn. | 1459 // When root is transparent, the layer should not be drawn. |
| 1461 root->layer_tree_impl()->SetOpacityMutated(root->element_id(), 0.f); | 1460 root->layer_tree_impl()->SetOpacityMutated(root->element_id(), 0.f); |
| 1462 root->layer_tree_impl()->SetOpacityMutated(render_surface1->element_id(), | 1461 root->layer_tree_impl()->SetOpacityMutated(render_surface1->element_id(), |
| 1463 1.f); | 1462 1.f); |
| 1464 render_surface1->set_visible_layer_rect(gfx::Rect()); | 1463 render_surface1->set_visible_layer_rect(gfx::Rect()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 child2->SetBounds(gfx::Size(25, 25)); | 1496 child2->SetBounds(gfx::Size(25, 25)); |
| 1498 child2->SetDrawsContent(true); | 1497 child2->SetDrawsContent(true); |
| 1499 child2->test_properties()->force_render_surface = true; | 1498 child2->test_properties()->force_render_surface = true; |
| 1500 | 1499 |
| 1501 RenderSurfaceList render_surface_list; | 1500 RenderSurfaceList render_surface_list; |
| 1502 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1501 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1503 root, root->bounds(), &render_surface_list); | 1502 root, root->bounds(), &render_surface_list); |
| 1504 inputs.can_adjust_raster_scales = true; | 1503 inputs.can_adjust_raster_scales = true; |
| 1505 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1504 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1506 | 1505 |
| 1507 ASSERT_TRUE(parent->GetRenderSurface()); | 1506 ASSERT_TRUE(GetRenderSurface(parent)); |
| 1508 EXPECT_EQ(2, parent->GetRenderSurface()->num_contributors()); | 1507 EXPECT_EQ(2, GetRenderSurface(parent)->num_contributors()); |
| 1509 EXPECT_EQ(4U, render_surface_list.size()); | 1508 EXPECT_EQ(4U, render_surface_list.size()); |
| 1510 | 1509 |
| 1511 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the | 1510 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the |
| 1512 // blur (-30,-30 110x110), and then scaled by the scale matrix | 1511 // blur (-30,-30 110x110), and then scaled by the scale matrix |
| 1513 // (-60,-60 220x220). | 1512 // (-60,-60 220x220). |
| 1514 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220), | 1513 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220), |
| 1515 parent->GetRenderSurface()->DrawableContentRect()); | 1514 GetRenderSurface(parent)->DrawableContentRect()); |
| 1516 } | 1515 } |
| 1517 | 1516 |
| 1518 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) { | 1517 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) { |
| 1519 LayerImpl* root = root_layer_for_testing(); | 1518 LayerImpl* root = root_layer_for_testing(); |
| 1520 LayerImpl* child = AddChild<LayerImpl>(root); | 1519 LayerImpl* child = AddChild<LayerImpl>(root); |
| 1521 | 1520 |
| 1522 root->SetBounds(gfx::Size(100, 100)); | 1521 root->SetBounds(gfx::Size(100, 100)); |
| 1523 child->SetBounds(gfx::Size(25, 25)); | 1522 child->SetBounds(gfx::Size(25, 25)); |
| 1524 child->SetDrawsContent(true); | 1523 child->SetDrawsContent(true); |
| 1525 child->test_properties()->force_render_surface = true; | 1524 child->test_properties()->force_render_surface = true; |
| 1526 FilterOperations filters; | 1525 FilterOperations filters; |
| 1527 filters.Append(FilterOperation::CreateReferenceFilter( | 1526 filters.Append(FilterOperation::CreateReferenceFilter( |
| 1528 SkOffsetImageFilter::Make(50, 50, nullptr))); | 1527 SkOffsetImageFilter::Make(50, 50, nullptr))); |
| 1529 child->test_properties()->filters = filters; | 1528 child->test_properties()->filters = filters; |
| 1530 ExecuteCalculateDrawProperties(root); | 1529 ExecuteCalculateDrawProperties(root); |
| 1531 | 1530 |
| 1532 // The render surface's size should be unaffected by the offset image filter; | 1531 // The render surface's size should be unaffected by the offset image filter; |
| 1533 // it need only have a drawable content rect large enough to contain the | 1532 // it need only have a drawable content rect large enough to contain the |
| 1534 // contents (at the new offset). | 1533 // contents (at the new offset). |
| 1535 ASSERT_TRUE(child->GetRenderSurface()); | 1534 ASSERT_TRUE(GetRenderSurface(child)); |
| 1536 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), | 1535 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), |
| 1537 child->GetRenderSurface()->DrawableContentRect()); | 1536 GetRenderSurface(child)->DrawableContentRect()); |
| 1538 } | 1537 } |
| 1539 | 1538 |
| 1540 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { | 1539 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { |
| 1541 const float device_scale_factor = 2.0f; | 1540 const float device_scale_factor = 2.0f; |
| 1542 | 1541 |
| 1543 LayerImpl* root = root_layer_for_testing(); | 1542 LayerImpl* root = root_layer_for_testing(); |
| 1544 LayerImpl* child = AddChild<LayerImpl>(root); | 1543 LayerImpl* child = AddChild<LayerImpl>(root); |
| 1545 | 1544 |
| 1546 root->SetBounds(gfx::Size(100, 100)); | 1545 root->SetBounds(gfx::Size(100, 100)); |
| 1547 child->SetBounds(gfx::Size(25, 25)); | 1546 child->SetBounds(gfx::Size(25, 25)); |
| 1548 child->SetDrawsContent(true); | 1547 child->SetDrawsContent(true); |
| 1549 child->test_properties()->force_render_surface = true; | 1548 child->test_properties()->force_render_surface = true; |
| 1550 | 1549 |
| 1551 FilterOperations filters; | 1550 FilterOperations filters; |
| 1552 filters.Append(FilterOperation::CreateReferenceFilter( | 1551 filters.Append(FilterOperation::CreateReferenceFilter( |
| 1553 SkOffsetImageFilter::Make(50, 50, nullptr))); | 1552 SkOffsetImageFilter::Make(50, 50, nullptr))); |
| 1554 child->test_properties()->filters = filters; | 1553 child->test_properties()->filters = filters; |
| 1555 | 1554 |
| 1556 ExecuteCalculateDrawProperties(root, device_scale_factor); | 1555 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 1557 | 1556 |
| 1558 // The render surface's size should be unaffected by the offset image filter; | 1557 // The render surface's size should be unaffected by the offset image filter; |
| 1559 // it need only have a drawable content rect large enough to contain the | 1558 // it need only have a drawable content rect large enough to contain the |
| 1560 // contents (at the new offset). All coordinates should be scaled by 2, | 1559 // contents (at the new offset). All coordinates should be scaled by 2, |
| 1561 // corresponding to the device scale factor. | 1560 // corresponding to the device scale factor. |
| 1562 ASSERT_TRUE(child->GetRenderSurface()); | 1561 ASSERT_TRUE(GetRenderSurface(child)); |
| 1563 EXPECT_EQ(gfx::RectF(100, 100, 50, 50), | 1562 EXPECT_EQ(gfx::RectF(100, 100, 50, 50), |
| 1564 child->GetRenderSurface()->DrawableContentRect()); | 1563 GetRenderSurface(child)->DrawableContentRect()); |
| 1565 } | 1564 } |
| 1566 | 1565 |
| 1567 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { | 1566 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { |
| 1568 LayerImpl* root = root_layer_for_testing(); | 1567 LayerImpl* root = root_layer_for_testing(); |
| 1569 LayerImpl* child = AddChild<LayerImpl>(root); | 1568 LayerImpl* child = AddChild<LayerImpl>(root); |
| 1570 | 1569 |
| 1571 root->SetBounds(gfx::Size(10, 10)); | 1570 root->SetBounds(gfx::Size(10, 10)); |
| 1572 child->SetBounds(gfx::Size(10, 10)); | 1571 child->SetBounds(gfx::Size(10, 10)); |
| 1573 child->SetDrawsContent(true); | 1572 child->SetDrawsContent(true); |
| 1574 child->test_properties()->blend_mode = SkBlendMode::kMultiply; | 1573 child->test_properties()->blend_mode = SkBlendMode::kMultiply; |
| 1575 child->test_properties()->opacity = 0.5f; | 1574 child->test_properties()->opacity = 0.5f; |
| 1576 child->test_properties()->force_render_surface = true; | 1575 child->test_properties()->force_render_surface = true; |
| 1577 ExecuteCalculateDrawProperties(root); | 1576 ExecuteCalculateDrawProperties(root); |
| 1578 | 1577 |
| 1579 // Since the child layer has a blend mode other than normal, it should get | 1578 // Since the child layer has a blend mode other than normal, it should get |
| 1580 // its own render surface. | 1579 // its own render surface. |
| 1581 ASSERT_TRUE(child->GetRenderSurface()); | 1580 ASSERT_TRUE(GetRenderSurface(child)); |
| 1582 EXPECT_EQ(1.0f, child->draw_opacity()); | 1581 EXPECT_EQ(1.0f, child->draw_opacity()); |
| 1583 EXPECT_EQ(0.5f, child->GetRenderSurface()->draw_opacity()); | 1582 EXPECT_EQ(0.5f, GetRenderSurface(child)->draw_opacity()); |
| 1584 EXPECT_EQ(SkBlendMode::kMultiply, child->GetRenderSurface()->BlendMode()); | 1583 EXPECT_EQ(SkBlendMode::kMultiply, GetRenderSurface(child)->BlendMode()); |
| 1585 } | 1584 } |
| 1586 | 1585 |
| 1587 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { | 1586 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { |
| 1588 LayerImpl* root = root_layer_for_testing(); | 1587 LayerImpl* root = root_layer_for_testing(); |
| 1589 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); | 1588 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); |
| 1590 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); | 1589 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); |
| 1591 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); | 1590 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); |
| 1592 | 1591 |
| 1593 root->SetBounds(gfx::Size(10, 10)); | 1592 root->SetBounds(gfx::Size(10, 10)); |
| 1594 surface1->SetBounds(gfx::Size(10, 10)); | 1593 surface1->SetBounds(gfx::Size(10, 10)); |
| 1595 surface1->SetDrawsContent(true); | 1594 surface1->SetDrawsContent(true); |
| 1596 surface1->test_properties()->opacity = 0.5f; | 1595 surface1->test_properties()->opacity = 0.5f; |
| 1597 surface1->test_properties()->force_render_surface = true; | 1596 surface1->test_properties()->force_render_surface = true; |
| 1598 not_surface->SetBounds(gfx::Size(10, 10)); | 1597 not_surface->SetBounds(gfx::Size(10, 10)); |
| 1599 not_surface->test_properties()->opacity = 0.5f; | 1598 not_surface->test_properties()->opacity = 0.5f; |
| 1600 surface2->SetBounds(gfx::Size(10, 10)); | 1599 surface2->SetBounds(gfx::Size(10, 10)); |
| 1601 surface2->SetDrawsContent(true); | 1600 surface2->SetDrawsContent(true); |
| 1602 surface2->test_properties()->opacity = 0.5f; | 1601 surface2->test_properties()->opacity = 0.5f; |
| 1603 surface2->test_properties()->force_render_surface = true; | 1602 surface2->test_properties()->force_render_surface = true; |
| 1604 ExecuteCalculateDrawProperties(root); | 1603 ExecuteCalculateDrawProperties(root); |
| 1605 | 1604 |
| 1606 ASSERT_TRUE(surface1->GetRenderSurface()); | 1605 ASSERT_TRUE(GetRenderSurface(surface1)); |
| 1607 ASSERT_FALSE(not_surface->GetRenderSurface()); | 1606 ASSERT_FALSE(GetRenderSurface(not_surface)); |
| 1608 ASSERT_TRUE(surface2->GetRenderSurface()); | 1607 ASSERT_TRUE(GetRenderSurface(surface2)); |
| 1609 EXPECT_EQ(0.5f, surface1->GetRenderSurface()->draw_opacity()); | 1608 EXPECT_EQ(0.5f, GetRenderSurface(surface1)->draw_opacity()); |
| 1610 // surface2's draw opacity should include the opacity of not-surface and | 1609 // surface2's draw opacity should include the opacity of not-surface and |
| 1611 // itself, but not the opacity of surface1. | 1610 // itself, but not the opacity of surface1. |
| 1612 EXPECT_EQ(0.25f, surface2->GetRenderSurface()->draw_opacity()); | 1611 EXPECT_EQ(0.25f, GetRenderSurface(surface2)->draw_opacity()); |
| 1613 } | 1612 } |
| 1614 | 1613 |
| 1615 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) { | 1614 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) { |
| 1616 // Tests that when separate surfaces are disabled, a layer's draw opacity is | 1615 // Tests that when separate surfaces are disabled, a layer's draw opacity is |
| 1617 // the product of all ancestor layer opacties and the layer's own opacity. | 1616 // the product of all ancestor layer opacties and the layer's own opacity. |
| 1618 // (Rendering will still be incorrect in situations where we really do need | 1617 // (Rendering will still be incorrect in situations where we really do need |
| 1619 // surfaces to apply opacity, such as when we have overlapping layers with an | 1618 // surfaces to apply opacity, such as when we have overlapping layers with an |
| 1620 // ancestor whose opacity is <1.) | 1619 // ancestor whose opacity is <1.) |
| 1621 LayerImpl* root = root_layer_for_testing(); | 1620 LayerImpl* root = root_layer_for_testing(); |
| 1622 LayerImpl* parent = AddChild<LayerImpl>(root); | 1621 LayerImpl* parent = AddChild<LayerImpl>(root); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 root->SetBounds(gfx::Size(10, 10)); | 1679 root->SetBounds(gfx::Size(10, 10)); |
| 1681 render_surface1->SetBounds(gfx::Size(10, 10)); | 1680 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 1682 render_surface1->test_properties()->force_render_surface = true; | 1681 render_surface1->test_properties()->force_render_surface = true; |
| 1683 child->SetBounds(gfx::Size(10, 10)); | 1682 child->SetBounds(gfx::Size(10, 10)); |
| 1684 child->SetDrawsContent(true); | 1683 child->SetDrawsContent(true); |
| 1685 | 1684 |
| 1686 { | 1685 { |
| 1687 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 1686 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 1688 | 1687 |
| 1689 // The root layer always creates a render surface | 1688 // The root layer always creates a render surface |
| 1690 EXPECT_TRUE(root->GetRenderSurface()); | 1689 EXPECT_TRUE(GetRenderSurface(root)); |
| 1691 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 1690 EXPECT_TRUE(GetRenderSurface(render_surface1)); |
| 1692 } | 1691 } |
| 1693 | 1692 |
| 1694 { | 1693 { |
| 1695 render_surface1->test_properties()->force_render_surface = false; | 1694 render_surface1->test_properties()->force_render_surface = false; |
| 1696 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1695 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1697 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 1696 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 1698 EXPECT_TRUE(root->GetRenderSurface()); | 1697 EXPECT_TRUE(GetRenderSurface(root)); |
| 1699 EXPECT_FALSE(render_surface1->GetRenderSurface()); | 1698 EXPECT_FALSE(GetRenderSurface(render_surface1)); |
| 1700 } | 1699 } |
| 1701 } | 1700 } |
| 1702 | 1701 |
| 1703 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { | 1702 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { |
| 1704 // Render surfaces act as a flattening point for their subtree, so should | 1703 // Render surfaces act as a flattening point for their subtree, so should |
| 1705 // always flatten the target-to-screen space transform seen by descendants. | 1704 // always flatten the target-to-screen space transform seen by descendants. |
| 1706 LayerImpl* root = root_layer_for_testing(); | 1705 LayerImpl* root = root_layer_for_testing(); |
| 1707 LayerImpl* parent = AddChild<LayerImpl>(root); | 1706 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 1708 LayerImpl* child = AddChild<LayerImpl>(parent); | 1707 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 1709 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1708 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1710 | 1709 |
| 1711 gfx::Transform rotation_about_y_axis; | 1710 gfx::Transform rotation_about_y_axis; |
| 1712 rotation_about_y_axis.RotateAboutYAxis(30.0); | 1711 rotation_about_y_axis.RotateAboutYAxis(30.0); |
| 1713 | 1712 |
| 1714 root->SetBounds(gfx::Size(100, 100)); | 1713 root->SetBounds(gfx::Size(100, 100)); |
| 1715 parent->test_properties()->transform = rotation_about_y_axis; | 1714 parent->test_properties()->transform = rotation_about_y_axis; |
| 1716 parent->SetBounds(gfx::Size(10, 10)); | 1715 parent->SetBounds(gfx::Size(10, 10)); |
| 1717 parent->test_properties()->force_render_surface = true; | 1716 parent->test_properties()->force_render_surface = true; |
| 1718 child->SetBounds(gfx::Size(10, 10)); | 1717 child->SetBounds(gfx::Size(10, 10)); |
| 1719 child->SetDrawsContent(true); | 1718 child->SetDrawsContent(true); |
| 1720 grand_child->SetBounds(gfx::Size(10, 10)); | 1719 grand_child->SetBounds(gfx::Size(10, 10)); |
| 1721 grand_child->SetDrawsContent(true); | 1720 grand_child->SetDrawsContent(true); |
| 1722 grand_child->test_properties()->should_flatten_transform = false; | 1721 grand_child->test_properties()->should_flatten_transform = false; |
| 1723 ExecuteCalculateDrawProperties(root); | 1722 ExecuteCalculateDrawProperties(root); |
| 1724 | 1723 |
| 1725 EXPECT_TRUE(parent->GetRenderSurface()); | 1724 EXPECT_TRUE(GetRenderSurface(parent)); |
| 1726 EXPECT_FALSE(child->GetRenderSurface()); | 1725 EXPECT_FALSE(GetRenderSurface(child)); |
| 1727 EXPECT_FALSE(grand_child->GetRenderSurface()); | 1726 EXPECT_FALSE(GetRenderSurface(grand_child)); |
| 1728 | 1727 |
| 1729 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); | 1728 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); |
| 1730 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1729 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1731 grand_child->DrawTransform()); | 1730 grand_child->DrawTransform()); |
| 1732 | 1731 |
| 1733 // The screen-space transform inherited by |child| and |grand_child| should | 1732 // The screen-space transform inherited by |child| and |grand_child| should |
| 1734 // have been flattened at their render target. In particular, the fact that | 1733 // have been flattened at their render target. In particular, the fact that |
| 1735 // |grand_child| happens to preserve 3d shouldn't affect this flattening. | 1734 // |grand_child| happens to preserve 3d shouldn't affect this flattening. |
| 1736 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; | 1735 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; |
| 1737 flattened_rotation_about_y.FlattenTo2d(); | 1736 flattened_rotation_about_y.FlattenTo2d(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 grand_child->SetBounds(gfx::Size(100, 100)); | 1854 grand_child->SetBounds(gfx::Size(100, 100)); |
| 1856 grand_child->SetDrawsContent(true); | 1855 grand_child->SetDrawsContent(true); |
| 1857 leaf_node1->SetBounds(gfx::Size(100, 100)); | 1856 leaf_node1->SetBounds(gfx::Size(100, 100)); |
| 1858 leaf_node1->SetDrawsContent(true); | 1857 leaf_node1->SetDrawsContent(true); |
| 1859 leaf_node2->SetBounds(gfx::Size(100, 100)); | 1858 leaf_node2->SetBounds(gfx::Size(100, 100)); |
| 1860 leaf_node2->SetDrawsContent(true); | 1859 leaf_node2->SetDrawsContent(true); |
| 1861 | 1860 |
| 1862 // Case 1: nothing is clipped except the root render surface. | 1861 // Case 1: nothing is clipped except the root render surface. |
| 1863 ExecuteCalculateDrawProperties(root); | 1862 ExecuteCalculateDrawProperties(root); |
| 1864 | 1863 |
| 1865 ASSERT_TRUE(root->GetRenderSurface()); | 1864 ASSERT_TRUE(GetRenderSurface(root)); |
| 1866 ASSERT_TRUE(child2->GetRenderSurface()); | 1865 ASSERT_TRUE(GetRenderSurface(child2)); |
| 1867 | 1866 |
| 1868 EXPECT_FALSE(root->is_clipped()); | 1867 EXPECT_FALSE(root->is_clipped()); |
| 1869 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 1868 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 1870 EXPECT_FALSE(parent->is_clipped()); | 1869 EXPECT_FALSE(parent->is_clipped()); |
| 1871 EXPECT_FALSE(child1->is_clipped()); | 1870 EXPECT_FALSE(child1->is_clipped()); |
| 1872 EXPECT_FALSE(child2->is_clipped()); | 1871 EXPECT_FALSE(child2->is_clipped()); |
| 1873 EXPECT_FALSE(child2->GetRenderSurface()->is_clipped()); | 1872 EXPECT_FALSE(GetRenderSurface(child2)->is_clipped()); |
| 1874 EXPECT_FALSE(grand_child->is_clipped()); | 1873 EXPECT_FALSE(grand_child->is_clipped()); |
| 1875 EXPECT_FALSE(leaf_node1->is_clipped()); | 1874 EXPECT_FALSE(leaf_node1->is_clipped()); |
| 1876 EXPECT_FALSE(leaf_node2->is_clipped()); | 1875 EXPECT_FALSE(leaf_node2->is_clipped()); |
| 1877 | 1876 |
| 1878 // Case 2: parent MasksToBounds, so the parent, child1, and child2's | 1877 // Case 2: parent MasksToBounds, so the parent, child1, and child2's |
| 1879 // surface are clipped. But layers that contribute to child2's surface are | 1878 // surface are clipped. But layers that contribute to child2's surface are |
| 1880 // not clipped explicitly because child2's surface already accounts for | 1879 // not clipped explicitly because child2's surface already accounts for |
| 1881 // that clip. | 1880 // that clip. |
| 1882 parent->SetMasksToBounds(true); | 1881 parent->SetMasksToBounds(true); |
| 1883 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 1882 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 1884 | 1883 |
| 1885 ExecuteCalculateDrawProperties(root); | 1884 ExecuteCalculateDrawProperties(root); |
| 1886 | 1885 |
| 1887 ASSERT_TRUE(root->GetRenderSurface()); | 1886 ASSERT_TRUE(GetRenderSurface(root)); |
| 1888 ASSERT_TRUE(child2->GetRenderSurface()); | 1887 ASSERT_TRUE(GetRenderSurface(child2)); |
| 1889 | 1888 |
| 1890 EXPECT_FALSE(root->is_clipped()); | 1889 EXPECT_FALSE(root->is_clipped()); |
| 1891 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 1890 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 1892 EXPECT_TRUE(parent->is_clipped()); | 1891 EXPECT_TRUE(parent->is_clipped()); |
| 1893 EXPECT_TRUE(child1->is_clipped()); | 1892 EXPECT_TRUE(child1->is_clipped()); |
| 1894 EXPECT_FALSE(child2->is_clipped()); | 1893 EXPECT_FALSE(child2->is_clipped()); |
| 1895 EXPECT_TRUE(child2->GetRenderSurface()->is_clipped()); | 1894 EXPECT_TRUE(GetRenderSurface(child2)->is_clipped()); |
| 1896 EXPECT_TRUE(grand_child->is_clipped()); | 1895 EXPECT_TRUE(grand_child->is_clipped()); |
| 1897 EXPECT_TRUE(leaf_node1->is_clipped()); | 1896 EXPECT_TRUE(leaf_node1->is_clipped()); |
| 1898 EXPECT_FALSE(leaf_node2->is_clipped()); | 1897 EXPECT_FALSE(leaf_node2->is_clipped()); |
| 1899 | 1898 |
| 1900 parent->SetMasksToBounds(false); | 1899 parent->SetMasksToBounds(false); |
| 1901 | 1900 |
| 1902 // Case 3: child2 MasksToBounds. The layer and subtree are clipped, and | 1901 // Case 3: child2 MasksToBounds. The layer and subtree are clipped, and |
| 1903 // child2's render surface is not clipped. | 1902 // child2's render surface is not clipped. |
| 1904 child2->SetMasksToBounds(true); | 1903 child2->SetMasksToBounds(true); |
| 1905 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 1904 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 1906 | 1905 |
| 1907 ExecuteCalculateDrawProperties(root); | 1906 ExecuteCalculateDrawProperties(root); |
| 1908 | 1907 |
| 1909 ASSERT_TRUE(root->GetRenderSurface()); | 1908 ASSERT_TRUE(GetRenderSurface(root)); |
| 1910 ASSERT_TRUE(child2->GetRenderSurface()); | 1909 ASSERT_TRUE(GetRenderSurface(child2)); |
| 1911 | 1910 |
| 1912 EXPECT_FALSE(root->is_clipped()); | 1911 EXPECT_FALSE(root->is_clipped()); |
| 1913 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 1912 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 1914 EXPECT_FALSE(parent->is_clipped()); | 1913 EXPECT_FALSE(parent->is_clipped()); |
| 1915 EXPECT_FALSE(child1->is_clipped()); | 1914 EXPECT_FALSE(child1->is_clipped()); |
| 1916 EXPECT_TRUE(child2->is_clipped()); | 1915 EXPECT_TRUE(child2->is_clipped()); |
| 1917 EXPECT_FALSE(child2->GetRenderSurface()->is_clipped()); | 1916 EXPECT_FALSE(GetRenderSurface(child2)->is_clipped()); |
| 1918 EXPECT_FALSE(grand_child->is_clipped()); | 1917 EXPECT_FALSE(grand_child->is_clipped()); |
| 1919 EXPECT_FALSE(leaf_node1->is_clipped()); | 1918 EXPECT_FALSE(leaf_node1->is_clipped()); |
| 1920 EXPECT_TRUE(leaf_node2->is_clipped()); | 1919 EXPECT_TRUE(leaf_node2->is_clipped()); |
| 1921 } | 1920 } |
| 1922 | 1921 |
| 1923 TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) { | 1922 TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) { |
| 1924 // Tests that when as long as layer is clipped, it's clip rect is set to | 1923 // Tests that when as long as layer is clipped, it's clip rect is set to |
| 1925 // correct value. | 1924 // correct value. |
| 1926 LayerImpl* root = root_layer_for_testing(); | 1925 LayerImpl* root = root_layer_for_testing(); |
| 1927 LayerImpl* parent = AddChild<LayerImpl>(root); | 1926 LayerImpl* parent = AddChild<LayerImpl>(root); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 leaf_node1->SetBounds(gfx::Size(10, 10)); | 2189 leaf_node1->SetBounds(gfx::Size(10, 10)); |
| 2191 leaf_node1->SetDrawsContent(true); | 2190 leaf_node1->SetDrawsContent(true); |
| 2192 leaf_node2->SetBounds(gfx::Size(10, 10)); | 2191 leaf_node2->SetBounds(gfx::Size(10, 10)); |
| 2193 leaf_node2->SetDrawsContent(true); | 2192 leaf_node2->SetDrawsContent(true); |
| 2194 leaf_node3->SetBounds(gfx::Size(10, 10)); | 2193 leaf_node3->SetBounds(gfx::Size(10, 10)); |
| 2195 leaf_node3->SetDrawsContent(true); | 2194 leaf_node3->SetDrawsContent(true); |
| 2196 leaf_node4->SetBounds(gfx::Size(10, 10)); | 2195 leaf_node4->SetBounds(gfx::Size(10, 10)); |
| 2197 leaf_node4->SetDrawsContent(true); | 2196 leaf_node4->SetDrawsContent(true); |
| 2198 ExecuteCalculateDrawProperties(parent); | 2197 ExecuteCalculateDrawProperties(parent); |
| 2199 | 2198 |
| 2200 ASSERT_TRUE(grand_child1->GetRenderSurface()); | 2199 ASSERT_TRUE(GetRenderSurface(grand_child1)); |
| 2201 ASSERT_TRUE(grand_child2->GetRenderSurface()); | 2200 ASSERT_TRUE(GetRenderSurface(grand_child2)); |
| 2202 ASSERT_TRUE(grand_child3->GetRenderSurface()); | 2201 ASSERT_TRUE(GetRenderSurface(grand_child3)); |
| 2203 | 2202 |
| 2204 // Surfaces are clipped by their parent, but un-affected by the owning layer's | 2203 // Surfaces are clipped by their parent, but un-affected by the owning layer's |
| 2205 // MasksToBounds. | 2204 // MasksToBounds. |
| 2206 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), | 2205 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), |
| 2207 grand_child1->GetRenderSurface()->clip_rect()); | 2206 GetRenderSurface(grand_child1)->clip_rect()); |
| 2208 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), | 2207 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), |
| 2209 grand_child2->GetRenderSurface()->clip_rect()); | 2208 GetRenderSurface(grand_child2)->clip_rect()); |
| 2210 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), | 2209 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), |
| 2211 grand_child3->GetRenderSurface()->clip_rect()); | 2210 GetRenderSurface(grand_child3)->clip_rect()); |
| 2212 } | 2211 } |
| 2213 | 2212 |
| 2214 TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) { | 2213 TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) { |
| 2215 // Tests that when separate surfaces are disabled, a layer's clip_rect is the | 2214 // 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 | 2215 // 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 | 2216 // 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). | 2217 // subtree (since there are no render surfaces that can reset the clip_rect). |
| 2219 LayerImpl* root = root_layer_for_testing(); | 2218 LayerImpl* root = root_layer_for_testing(); |
| 2220 LayerImpl* parent = AddChild<LayerImpl>(root); | 2219 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 2221 LayerImpl* child1 = AddChild<LayerImpl>(parent); | 2220 LayerImpl* child1 = AddChild<LayerImpl>(parent); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2247 leaf_node2->SetDrawsContent(true); | 2246 leaf_node2->SetDrawsContent(true); |
| 2248 | 2247 |
| 2249 root->test_properties()->force_render_surface = true; | 2248 root->test_properties()->force_render_surface = true; |
| 2250 child1->test_properties()->force_render_surface = true; | 2249 child1->test_properties()->force_render_surface = true; |
| 2251 grand_child->test_properties()->force_render_surface = true; | 2250 grand_child->test_properties()->force_render_surface = true; |
| 2252 | 2251 |
| 2253 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its | 2252 // 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 | 2253 // bounds in target space. The only thing that changes when surfaces are |
| 2255 // disabled is that target space is always screen space. | 2254 // disabled is that target space is always screen space. |
| 2256 ExecuteCalculateDrawProperties(root); | 2255 ExecuteCalculateDrawProperties(root); |
| 2257 EXPECT_TRUE(root->GetRenderSurface()); | 2256 EXPECT_TRUE(GetRenderSurface(root)); |
| 2258 EXPECT_FALSE(parent->GetRenderSurface()); | 2257 EXPECT_FALSE(GetRenderSurface(parent)); |
| 2259 EXPECT_TRUE(child1->GetRenderSurface()); | 2258 EXPECT_TRUE(GetRenderSurface(child1)); |
| 2260 EXPECT_FALSE(child2->GetRenderSurface()); | 2259 EXPECT_FALSE(GetRenderSurface(child2)); |
| 2261 EXPECT_TRUE(grand_child->GetRenderSurface()); | 2260 EXPECT_TRUE(GetRenderSurface(grand_child)); |
| 2262 EXPECT_FALSE(leaf_node1->GetRenderSurface()); | 2261 EXPECT_FALSE(GetRenderSurface(leaf_node1)); |
| 2263 EXPECT_FALSE(leaf_node2->GetRenderSurface()); | 2262 EXPECT_FALSE(GetRenderSurface(leaf_node2)); |
| 2264 EXPECT_FALSE(root->is_clipped()); | 2263 EXPECT_FALSE(root->is_clipped()); |
| 2265 EXPECT_FALSE(parent->is_clipped()); | 2264 EXPECT_FALSE(parent->is_clipped()); |
| 2266 EXPECT_FALSE(child1->is_clipped()); | 2265 EXPECT_FALSE(child1->is_clipped()); |
| 2267 EXPECT_FALSE(child2->is_clipped()); | 2266 EXPECT_FALSE(child2->is_clipped()); |
| 2268 EXPECT_FALSE(grand_child->is_clipped()); | 2267 EXPECT_FALSE(grand_child->is_clipped()); |
| 2269 EXPECT_FALSE(leaf_node1->is_clipped()); | 2268 EXPECT_FALSE(leaf_node1->is_clipped()); |
| 2270 EXPECT_FALSE(leaf_node2->is_clipped()); | 2269 EXPECT_FALSE(leaf_node2->is_clipped()); |
| 2271 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 2270 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 2272 EXPECT_FALSE(child1->GetRenderSurface()->is_clipped()); | 2271 EXPECT_FALSE(GetRenderSurface(child1)->is_clipped()); |
| 2273 EXPECT_FALSE(grand_child->GetRenderSurface()->is_clipped()); | 2272 EXPECT_FALSE(GetRenderSurface(grand_child)->is_clipped()); |
| 2274 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect()); | 2273 EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(root)->clip_rect()); |
| 2275 | 2274 |
| 2276 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2275 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
| 2277 EXPECT_FALSE(root->is_clipped()); | 2276 EXPECT_FALSE(root->is_clipped()); |
| 2278 EXPECT_FALSE(parent->is_clipped()); | 2277 EXPECT_FALSE(parent->is_clipped()); |
| 2279 EXPECT_FALSE(child1->is_clipped()); | 2278 EXPECT_FALSE(child1->is_clipped()); |
| 2280 EXPECT_FALSE(child2->is_clipped()); | 2279 EXPECT_FALSE(child2->is_clipped()); |
| 2281 EXPECT_FALSE(grand_child->is_clipped()); | 2280 EXPECT_FALSE(grand_child->is_clipped()); |
| 2282 EXPECT_FALSE(leaf_node1->is_clipped()); | 2281 EXPECT_FALSE(leaf_node1->is_clipped()); |
| 2283 EXPECT_FALSE(leaf_node2->is_clipped()); | 2282 EXPECT_FALSE(leaf_node2->is_clipped()); |
| 2284 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 2283 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 2285 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect()); | 2284 EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(root)->clip_rect()); |
| 2286 | 2285 |
| 2287 // Case 2: The root is clipped. In this case, layers that draw into the root | 2286 // 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. | 2287 // render surface are clipped by the root's bounds. |
| 2289 root->SetMasksToBounds(true); | 2288 root->SetMasksToBounds(true); |
| 2290 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 2289 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 2291 root->test_properties()->force_render_surface = true; | 2290 root->test_properties()->force_render_surface = true; |
| 2292 child1->test_properties()->force_render_surface = true; | 2291 child1->test_properties()->force_render_surface = true; |
| 2293 grand_child->test_properties()->force_render_surface = true; | 2292 grand_child->test_properties()->force_render_surface = true; |
| 2294 ExecuteCalculateDrawProperties(root); | 2293 ExecuteCalculateDrawProperties(root); |
| 2295 EXPECT_TRUE(root->GetRenderSurface()); | 2294 EXPECT_TRUE(GetRenderSurface(root)); |
| 2296 EXPECT_FALSE(parent->GetRenderSurface()); | 2295 EXPECT_FALSE(GetRenderSurface(parent)); |
| 2297 EXPECT_TRUE(child1->GetRenderSurface()); | 2296 EXPECT_TRUE(GetRenderSurface(child1)); |
| 2298 EXPECT_FALSE(child2->GetRenderSurface()); | 2297 EXPECT_FALSE(GetRenderSurface(child2)); |
| 2299 EXPECT_TRUE(grand_child->GetRenderSurface()); | 2298 EXPECT_TRUE(GetRenderSurface(grand_child)); |
| 2300 EXPECT_FALSE(leaf_node1->GetRenderSurface()); | 2299 EXPECT_FALSE(GetRenderSurface(leaf_node1)); |
| 2301 EXPECT_FALSE(leaf_node2->GetRenderSurface()); | 2300 EXPECT_FALSE(GetRenderSurface(leaf_node2)); |
| 2302 EXPECT_TRUE(root->is_clipped()); | 2301 EXPECT_TRUE(root->is_clipped()); |
| 2303 EXPECT_TRUE(parent->is_clipped()); | 2302 EXPECT_TRUE(parent->is_clipped()); |
| 2304 EXPECT_FALSE(child1->is_clipped()); | 2303 EXPECT_FALSE(child1->is_clipped()); |
| 2305 EXPECT_TRUE(child1->GetRenderSurface()->is_clipped()); | 2304 EXPECT_TRUE(GetRenderSurface(child1)->is_clipped()); |
| 2306 EXPECT_TRUE(child2->is_clipped()); | 2305 EXPECT_TRUE(child2->is_clipped()); |
| 2307 EXPECT_FALSE(grand_child->is_clipped()); | 2306 EXPECT_FALSE(grand_child->is_clipped()); |
| 2308 EXPECT_FALSE(grand_child->GetRenderSurface()->is_clipped()); | 2307 EXPECT_FALSE(GetRenderSurface(grand_child)->is_clipped()); |
| 2309 EXPECT_FALSE(leaf_node1->is_clipped()); | 2308 EXPECT_FALSE(leaf_node1->is_clipped()); |
| 2310 EXPECT_TRUE(leaf_node2->is_clipped()); | 2309 EXPECT_TRUE(leaf_node2->is_clipped()); |
| 2311 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2310 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
| 2312 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); | 2311 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); |
| 2313 EXPECT_EQ(gfx::Rect(100, 100), child1->GetRenderSurface()->clip_rect()); | 2312 EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(child1)->clip_rect()); |
| 2314 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); | 2313 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); |
| 2315 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); | 2314 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); |
| 2316 | 2315 |
| 2317 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2316 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
| 2318 EXPECT_TRUE(root->is_clipped()); | 2317 EXPECT_TRUE(root->is_clipped()); |
| 2319 EXPECT_TRUE(parent->is_clipped()); | 2318 EXPECT_TRUE(parent->is_clipped()); |
| 2320 EXPECT_TRUE(child1->is_clipped()); | 2319 EXPECT_TRUE(child1->is_clipped()); |
| 2321 EXPECT_TRUE(child2->is_clipped()); | 2320 EXPECT_TRUE(child2->is_clipped()); |
| 2322 EXPECT_TRUE(grand_child->is_clipped()); | 2321 EXPECT_TRUE(grand_child->is_clipped()); |
| 2323 EXPECT_TRUE(leaf_node1->is_clipped()); | 2322 EXPECT_TRUE(leaf_node1->is_clipped()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2338 // child1's clip rect doesn't contribute to its descendants, since its only | 2337 // 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 | 2338 // child is a render surface. However, without surfaces, these clip rects |
| 2340 // contribute to all descendants. | 2339 // contribute to all descendants. |
| 2341 parent->SetMasksToBounds(true); | 2340 parent->SetMasksToBounds(true); |
| 2342 child1->SetMasksToBounds(true); | 2341 child1->SetMasksToBounds(true); |
| 2343 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 2342 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 2344 root->test_properties()->force_render_surface = true; | 2343 root->test_properties()->force_render_surface = true; |
| 2345 child1->test_properties()->force_render_surface = true; | 2344 child1->test_properties()->force_render_surface = true; |
| 2346 grand_child->test_properties()->force_render_surface = true; | 2345 grand_child->test_properties()->force_render_surface = true; |
| 2347 ExecuteCalculateDrawProperties(root); | 2346 ExecuteCalculateDrawProperties(root); |
| 2348 EXPECT_TRUE(root->GetRenderSurface()); | 2347 EXPECT_TRUE(GetRenderSurface(root)); |
| 2349 EXPECT_FALSE(parent->GetRenderSurface()); | 2348 EXPECT_FALSE(GetRenderSurface(parent)); |
| 2350 EXPECT_TRUE(child1->GetRenderSurface()); | 2349 EXPECT_TRUE(GetRenderSurface(child1)); |
| 2351 EXPECT_FALSE(child2->GetRenderSurface()); | 2350 EXPECT_FALSE(GetRenderSurface(child2)); |
| 2352 EXPECT_TRUE(grand_child->GetRenderSurface()); | 2351 EXPECT_TRUE(GetRenderSurface(grand_child)); |
| 2353 EXPECT_FALSE(leaf_node1->GetRenderSurface()); | 2352 EXPECT_FALSE(GetRenderSurface(leaf_node1)); |
| 2354 EXPECT_FALSE(leaf_node2->GetRenderSurface()); | 2353 EXPECT_FALSE(GetRenderSurface(leaf_node2)); |
| 2355 EXPECT_FALSE(root->is_clipped()); | 2354 EXPECT_FALSE(root->is_clipped()); |
| 2356 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 2355 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 2357 EXPECT_TRUE(parent->is_clipped()); | 2356 EXPECT_TRUE(parent->is_clipped()); |
| 2358 EXPECT_TRUE(child1->is_clipped()); | 2357 EXPECT_TRUE(child1->is_clipped()); |
| 2359 EXPECT_TRUE(child2->is_clipped()); | 2358 EXPECT_TRUE(child2->is_clipped()); |
| 2360 EXPECT_FALSE(grand_child->is_clipped()); | 2359 EXPECT_FALSE(grand_child->is_clipped()); |
| 2361 EXPECT_TRUE(grand_child->GetRenderSurface()->is_clipped()); | 2360 EXPECT_TRUE(GetRenderSurface(grand_child)->is_clipped()); |
| 2362 EXPECT_FALSE(leaf_node1->is_clipped()); | 2361 EXPECT_FALSE(leaf_node1->is_clipped()); |
| 2363 EXPECT_TRUE(leaf_node2->is_clipped()); | 2362 EXPECT_TRUE(leaf_node2->is_clipped()); |
| 2364 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect()); | 2363 EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(root)->clip_rect()); |
| 2365 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); | 2364 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); |
| 2366 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); | 2365 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); |
| 2367 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); | 2366 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); |
| 2368 EXPECT_EQ(gfx::Rect(800, 800), grand_child->GetRenderSurface()->clip_rect()); | 2367 EXPECT_EQ(gfx::Rect(800, 800), GetRenderSurface(grand_child)->clip_rect()); |
| 2369 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); | 2368 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); |
| 2370 | 2369 |
| 2371 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2370 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
| 2372 EXPECT_FALSE(root->is_clipped()); | 2371 EXPECT_FALSE(root->is_clipped()); |
| 2373 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 2372 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 2374 EXPECT_TRUE(parent->is_clipped()); | 2373 EXPECT_TRUE(parent->is_clipped()); |
| 2375 EXPECT_TRUE(child1->is_clipped()); | 2374 EXPECT_TRUE(child1->is_clipped()); |
| 2376 EXPECT_TRUE(child2->is_clipped()); | 2375 EXPECT_TRUE(child2->is_clipped()); |
| 2377 EXPECT_TRUE(grand_child->is_clipped()); | 2376 EXPECT_TRUE(grand_child->is_clipped()); |
| 2378 EXPECT_TRUE(leaf_node1->is_clipped()); | 2377 EXPECT_TRUE(leaf_node1->is_clipped()); |
| 2379 EXPECT_TRUE(leaf_node2->is_clipped()); | 2378 EXPECT_TRUE(leaf_node2->is_clipped()); |
| 2380 EXPECT_EQ(gfx::Rect(100, 100), root->GetRenderSurface()->clip_rect()); | 2379 EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(root)->clip_rect()); |
| 2381 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); | 2380 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); |
| 2382 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect()); | 2381 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect()); |
| 2383 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); | 2382 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); |
| 2384 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect()); | 2383 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()); | 2384 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()); | 2385 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); |
| 2387 } | 2386 } |
| 2388 | 2387 |
| 2389 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) { | 2388 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) { |
| 2390 LayerImpl* root = root_layer_for_testing(); | 2389 LayerImpl* root = root_layer_for_testing(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), | 2569 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), |
| 2571 timeline_impl(), 10.0, 30, 0); | 2570 timeline_impl(), 10.0, 30, 0); |
| 2572 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), | 2571 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), |
| 2573 timeline_impl(), 10.0, 30, 0); | 2572 timeline_impl(), 10.0, 30, 0); |
| 2574 | 2573 |
| 2575 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 2574 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 2576 ExecuteCalculateDrawProperties(root); | 2575 ExecuteCalculateDrawProperties(root); |
| 2577 | 2576 |
| 2578 // Only layers that are associated with render surfaces should have an actual | 2577 // Only layers that are associated with render surfaces should have an actual |
| 2579 // RenderSurface() value. | 2578 // RenderSurface() value. |
| 2580 ASSERT_TRUE(root->GetRenderSurface()); | 2579 ASSERT_TRUE(GetRenderSurface(root)); |
| 2581 ASSERT_FALSE(child_of_root->GetRenderSurface()); | 2580 ASSERT_FALSE(GetRenderSurface(child_of_root)); |
| 2582 ASSERT_FALSE(grand_child_of_root->GetRenderSurface()); | 2581 ASSERT_FALSE(GetRenderSurface(grand_child_of_root)); |
| 2583 | 2582 |
| 2584 ASSERT_TRUE(render_surface1->GetRenderSurface()); | 2583 ASSERT_TRUE(GetRenderSurface(render_surface1)); |
| 2585 ASSERT_FALSE(child_of_rs1->GetRenderSurface()); | 2584 ASSERT_FALSE(GetRenderSurface(child_of_rs1)); |
| 2586 ASSERT_FALSE(grand_child_of_rs1->GetRenderSurface()); | 2585 ASSERT_FALSE(GetRenderSurface(grand_child_of_rs1)); |
| 2587 | 2586 |
| 2588 ASSERT_TRUE(render_surface2->GetRenderSurface()); | 2587 ASSERT_TRUE(GetRenderSurface(render_surface2)); |
| 2589 ASSERT_FALSE(child_of_rs2->GetRenderSurface()); | 2588 ASSERT_FALSE(GetRenderSurface(child_of_rs2)); |
| 2590 ASSERT_FALSE(grand_child_of_rs2->GetRenderSurface()); | 2589 ASSERT_FALSE(GetRenderSurface(grand_child_of_rs2)); |
| 2591 | 2590 |
| 2592 // Verify all render target accessors | 2591 // Verify all render target accessors |
| 2593 EXPECT_EQ(root->GetRenderSurface(), root->render_target()); | 2592 EXPECT_EQ(GetRenderSurface(root), root->render_target()); |
| 2594 EXPECT_EQ(root->GetRenderSurface(), child_of_root->render_target()); | 2593 EXPECT_EQ(GetRenderSurface(root), child_of_root->render_target()); |
| 2595 EXPECT_EQ(root->GetRenderSurface(), grand_child_of_root->render_target()); | 2594 EXPECT_EQ(GetRenderSurface(root), grand_child_of_root->render_target()); |
| 2596 | 2595 |
| 2597 EXPECT_EQ(render_surface1->GetRenderSurface(), | 2596 EXPECT_EQ(GetRenderSurface(render_surface1), |
| 2598 render_surface1->render_target()); | 2597 render_surface1->render_target()); |
| 2599 EXPECT_EQ(render_surface1->GetRenderSurface(), child_of_rs1->render_target()); | 2598 EXPECT_EQ(GetRenderSurface(render_surface1), child_of_rs1->render_target()); |
| 2600 EXPECT_EQ(render_surface1->GetRenderSurface(), | 2599 EXPECT_EQ(GetRenderSurface(render_surface1), |
| 2601 grand_child_of_rs1->render_target()); | 2600 grand_child_of_rs1->render_target()); |
| 2602 | 2601 |
| 2603 EXPECT_EQ(render_surface2->GetRenderSurface(), | 2602 EXPECT_EQ(GetRenderSurface(render_surface2), |
| 2604 render_surface2->render_target()); | 2603 render_surface2->render_target()); |
| 2605 EXPECT_EQ(render_surface2->GetRenderSurface(), child_of_rs2->render_target()); | 2604 EXPECT_EQ(GetRenderSurface(render_surface2), child_of_rs2->render_target()); |
| 2606 EXPECT_EQ(render_surface2->GetRenderSurface(), | 2605 EXPECT_EQ(GetRenderSurface(render_surface2), |
| 2607 grand_child_of_rs2->render_target()); | 2606 grand_child_of_rs2->render_target()); |
| 2608 | 2607 |
| 2609 // Verify screen_space_transform_is_animating values | 2608 // Verify screen_space_transform_is_animating values |
| 2610 EXPECT_FALSE(root->screen_space_transform_is_animating()); | 2609 EXPECT_FALSE(root->screen_space_transform_is_animating()); |
| 2611 EXPECT_FALSE(child_of_root->screen_space_transform_is_animating()); | 2610 EXPECT_FALSE(child_of_root->screen_space_transform_is_animating()); |
| 2612 EXPECT_TRUE(grand_child_of_root->screen_space_transform_is_animating()); | 2611 EXPECT_TRUE(grand_child_of_root->screen_space_transform_is_animating()); |
| 2613 EXPECT_FALSE(render_surface1->screen_space_transform_is_animating()); | 2612 EXPECT_FALSE(render_surface1->screen_space_transform_is_animating()); |
| 2614 EXPECT_FALSE(child_of_rs1->screen_space_transform_is_animating()); | 2613 EXPECT_FALSE(child_of_rs1->screen_space_transform_is_animating()); |
| 2615 EXPECT_FALSE(grand_child_of_rs1->screen_space_transform_is_animating()); | 2614 EXPECT_FALSE(grand_child_of_rs1->screen_space_transform_is_animating()); |
| 2616 EXPECT_TRUE(render_surface2->screen_space_transform_is_animating()); | 2615 EXPECT_TRUE(render_surface2->screen_space_transform_is_animating()); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 TEST_F(LayerTreeHostCommonTest, | 3019 TEST_F(LayerTreeHostCommonTest, |
| 3021 VisibleRectsForPositionedRootLayerClippedByViewport) { | 3020 VisibleRectsForPositionedRootLayerClippedByViewport) { |
| 3022 LayerImpl* root = root_layer_for_testing(); | 3021 LayerImpl* root = root_layer_for_testing(); |
| 3023 | 3022 |
| 3024 root->SetPosition(gfx::PointF(60, 70)); | 3023 root->SetPosition(gfx::PointF(60, 70)); |
| 3025 root->SetBounds(gfx::Size(100, 100)); | 3024 root->SetBounds(gfx::Size(100, 100)); |
| 3026 root->SetDrawsContent(true); | 3025 root->SetDrawsContent(true); |
| 3027 ExecuteCalculateDrawProperties(root); | 3026 ExecuteCalculateDrawProperties(root); |
| 3028 | 3027 |
| 3029 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3028 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3030 root->GetRenderSurface()->DrawableContentRect()); | 3029 GetRenderSurface(root)->DrawableContentRect()); |
| 3031 // In target space, not clipped. | 3030 // In target space, not clipped. |
| 3032 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); | 3031 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); |
| 3033 // In layer space, clipped. | 3032 // In layer space, clipped. |
| 3034 EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect()); | 3033 EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect()); |
| 3035 } | 3034 } |
| 3036 | 3035 |
| 3037 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { | 3036 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { |
| 3038 LayerImpl* root = root_layer_for_testing(); | 3037 LayerImpl* root = root_layer_for_testing(); |
| 3039 LayerImpl* child1_layer = AddChildToRoot<LayerImpl>(); | 3038 LayerImpl* child1_layer = AddChildToRoot<LayerImpl>(); |
| 3040 LayerImpl* child2_layer = AddChildToRoot<LayerImpl>(); | 3039 LayerImpl* child2_layer = AddChildToRoot<LayerImpl>(); |
| 3041 LayerImpl* child3_layer = AddChildToRoot<LayerImpl>(); | 3040 LayerImpl* child3_layer = AddChildToRoot<LayerImpl>(); |
| 3042 | 3041 |
| 3043 root->SetBounds(gfx::Size(100, 100)); | 3042 root->SetBounds(gfx::Size(100, 100)); |
| 3044 child1_layer->SetBounds(gfx::Size(50, 50)); | 3043 child1_layer->SetBounds(gfx::Size(50, 50)); |
| 3045 child1_layer->SetDrawsContent(true); | 3044 child1_layer->SetDrawsContent(true); |
| 3046 child2_layer->SetPosition(gfx::PointF(75.f, 75.f)); | 3045 child2_layer->SetPosition(gfx::PointF(75.f, 75.f)); |
| 3047 child2_layer->SetBounds(gfx::Size(50, 50)); | 3046 child2_layer->SetBounds(gfx::Size(50, 50)); |
| 3048 child2_layer->SetDrawsContent(true); | 3047 child2_layer->SetDrawsContent(true); |
| 3049 child3_layer->SetPosition(gfx::PointF(125.f, 125.f)); | 3048 child3_layer->SetPosition(gfx::PointF(125.f, 125.f)); |
| 3050 child3_layer->SetBounds(gfx::Size(50, 50)); | 3049 child3_layer->SetBounds(gfx::Size(50, 50)); |
| 3051 child3_layer->SetDrawsContent(true); | 3050 child3_layer->SetDrawsContent(true); |
| 3052 ExecuteCalculateDrawProperties(root); | 3051 ExecuteCalculateDrawProperties(root); |
| 3053 | 3052 |
| 3054 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3053 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3055 root->GetRenderSurface()->DrawableContentRect()); | 3054 GetRenderSurface(root)->DrawableContentRect()); |
| 3056 | 3055 |
| 3057 // Layers that do not draw content should have empty visible_layer_rects. | 3056 // Layers that do not draw content should have empty visible_layer_rects. |
| 3058 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 3057 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 3059 | 3058 |
| 3060 // layer visible_layer_rects are clipped by their target surface. | 3059 // layer visible_layer_rects are clipped by their target surface. |
| 3061 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->visible_layer_rect()); | 3060 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->visible_layer_rect()); |
| 3062 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2_layer->visible_layer_rect()); | 3061 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2_layer->visible_layer_rect()); |
| 3063 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty()); | 3062 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty()); |
| 3064 | 3063 |
| 3065 // layer drawable_content_rects are not clipped. | 3064 // layer drawable_content_rects are not clipped. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3084 grand_child1->SetDrawsContent(true); | 3083 grand_child1->SetDrawsContent(true); |
| 3085 grand_child2->SetPosition(gfx::PointF(75.f, 75.f)); | 3084 grand_child2->SetPosition(gfx::PointF(75.f, 75.f)); |
| 3086 grand_child2->SetBounds(gfx::Size(50, 50)); | 3085 grand_child2->SetBounds(gfx::Size(50, 50)); |
| 3087 grand_child2->SetDrawsContent(true); | 3086 grand_child2->SetDrawsContent(true); |
| 3088 grand_child3->SetPosition(gfx::PointF(125.f, 125.f)); | 3087 grand_child3->SetPosition(gfx::PointF(125.f, 125.f)); |
| 3089 grand_child3->SetBounds(gfx::Size(50, 50)); | 3088 grand_child3->SetBounds(gfx::Size(50, 50)); |
| 3090 grand_child3->SetDrawsContent(true); | 3089 grand_child3->SetDrawsContent(true); |
| 3091 ExecuteCalculateDrawProperties(root); | 3090 ExecuteCalculateDrawProperties(root); |
| 3092 | 3091 |
| 3093 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3092 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3094 root->GetRenderSurface()->DrawableContentRect()); | 3093 GetRenderSurface(root)->DrawableContentRect()); |
| 3095 | 3094 |
| 3096 // Layers that do not draw content should have empty visible content rects. | 3095 // Layers that do not draw content should have empty visible content rects. |
| 3097 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 3096 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 3098 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect()); | 3097 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect()); |
| 3099 | 3098 |
| 3100 // All grandchild visible content rects should be clipped by child. | 3099 // All grandchild visible content rects should be clipped by child. |
| 3101 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect()); | 3100 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect()); |
| 3102 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect()); | 3101 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect()); |
| 3103 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty()); | 3102 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty()); |
| 3104 | 3103 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3141 clip->SetBounds(gfx::Size(10, 10)); | 3140 clip->SetBounds(gfx::Size(10, 10)); |
| 3142 filter->test_properties()->force_render_surface = true; | 3141 filter->test_properties()->force_render_surface = true; |
| 3143 filter_child->SetBounds(gfx::Size(2000, 2000)); | 3142 filter_child->SetBounds(gfx::Size(2000, 2000)); |
| 3144 filter_child->SetPosition(gfx::PointF(-50, -50)); | 3143 filter_child->SetPosition(gfx::PointF(-50, -50)); |
| 3145 filter_child->SetDrawsContent(true); | 3144 filter_child->SetDrawsContent(true); |
| 3146 | 3145 |
| 3147 clip->SetMasksToBounds(true); | 3146 clip->SetMasksToBounds(true); |
| 3148 | 3147 |
| 3149 ExecuteCalculateDrawProperties(root); | 3148 ExecuteCalculateDrawProperties(root); |
| 3150 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect()); | 3149 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect()); |
| 3151 EXPECT_EQ(gfx::Rect(10, 10), filter->GetRenderSurface()->content_rect()); | 3150 EXPECT_EQ(gfx::Rect(10, 10), GetRenderSurface(filter)->content_rect()); |
| 3152 | 3151 |
| 3153 FilterOperations blur_filter; | 3152 FilterOperations blur_filter; |
| 3154 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f)); | 3153 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f)); |
| 3155 filter->test_properties()->filters = blur_filter; | 3154 filter->test_properties()->filters = blur_filter; |
| 3156 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3155 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 3157 | 3156 |
| 3158 ExecuteCalculateDrawProperties(root); | 3157 ExecuteCalculateDrawProperties(root); |
| 3159 | 3158 |
| 3160 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect()); | 3159 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect()); |
| 3161 EXPECT_EQ(gfx::Rect(-12, -12, 34, 34), | 3160 EXPECT_EQ(gfx::Rect(-12, -12, 34, 34), |
| 3162 filter->GetRenderSurface()->content_rect()); | 3161 GetRenderSurface(filter)->content_rect()); |
| 3163 | 3162 |
| 3164 gfx::Transform vertical_flip; | 3163 gfx::Transform vertical_flip; |
| 3165 vertical_flip.Scale(1, -1); | 3164 vertical_flip.Scale(1, -1); |
| 3166 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter( | 3165 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter( |
| 3167 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr); | 3166 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr); |
| 3168 FilterOperations reflection_filter; | 3167 FilterOperations reflection_filter; |
| 3169 reflection_filter.Append( | 3168 reflection_filter.Append( |
| 3170 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make( | 3169 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make( |
| 3171 SkBlendMode::kSrcOver, std::move(flip_filter)))); | 3170 SkBlendMode::kSrcOver, std::move(flip_filter)))); |
| 3172 filter->test_properties()->filters = reflection_filter; | 3171 filter->test_properties()->filters = reflection_filter; |
| 3173 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3172 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 3174 | 3173 |
| 3175 ExecuteCalculateDrawProperties(root); | 3174 ExecuteCalculateDrawProperties(root); |
| 3176 | 3175 |
| 3177 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect()); | 3176 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect()); |
| 3178 EXPECT_EQ(gfx::Rect(0, -10, 10, 20), | 3177 EXPECT_EQ(gfx::Rect(0, -10, 10, 20), |
| 3179 filter->GetRenderSurface()->content_rect()); | 3178 GetRenderSurface(filter)->content_rect()); |
| 3180 } | 3179 } |
| 3181 | 3180 |
| 3182 TEST_F(LayerTreeHostCommonTest, VisibleRectWithScalingClippingAndFilters) { | 3181 TEST_F(LayerTreeHostCommonTest, VisibleRectWithScalingClippingAndFilters) { |
| 3183 LayerImpl* root = root_layer_for_testing(); | 3182 LayerImpl* root = root_layer_for_testing(); |
| 3184 LayerImpl* scale = AddChild<LayerImpl>(root); | 3183 LayerImpl* scale = AddChild<LayerImpl>(root); |
| 3185 LayerImpl* clip = AddChild<LayerImpl>(scale); | 3184 LayerImpl* clip = AddChild<LayerImpl>(scale); |
| 3186 LayerImpl* filter = AddChild<LayerImpl>(clip); | 3185 LayerImpl* filter = AddChild<LayerImpl>(clip); |
| 3187 LayerImpl* filter_child = AddChild<LayerImpl>(filter); | 3186 LayerImpl* filter_child = AddChild<LayerImpl>(filter); |
| 3188 | 3187 |
| 3189 root->SetBounds(gfx::Size(100, 100)); | 3188 root->SetBounds(gfx::Size(100, 100)); |
| 3190 clip->SetBounds(gfx::Size(10, 10)); | 3189 clip->SetBounds(gfx::Size(10, 10)); |
| 3191 filter->test_properties()->force_render_surface = true; | 3190 filter->test_properties()->force_render_surface = true; |
| 3192 filter_child->SetBounds(gfx::Size(2000, 2000)); | 3191 filter_child->SetBounds(gfx::Size(2000, 2000)); |
| 3193 filter_child->SetPosition(gfx::PointF(-50, -50)); | 3192 filter_child->SetPosition(gfx::PointF(-50, -50)); |
| 3194 filter_child->SetDrawsContent(true); | 3193 filter_child->SetDrawsContent(true); |
| 3195 | 3194 |
| 3196 clip->SetMasksToBounds(true); | 3195 clip->SetMasksToBounds(true); |
| 3197 | 3196 |
| 3198 gfx::Transform scale_transform; | 3197 gfx::Transform scale_transform; |
| 3199 scale_transform.Scale(3, 3); | 3198 scale_transform.Scale(3, 3); |
| 3200 scale->test_properties()->transform = scale_transform; | 3199 scale->test_properties()->transform = scale_transform; |
| 3201 | 3200 |
| 3202 ExecuteCalculateDrawProperties(root); | 3201 ExecuteCalculateDrawProperties(root); |
| 3203 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect()); | 3202 EXPECT_EQ(gfx::Rect(50, 50, 10, 10), filter_child->visible_layer_rect()); |
| 3204 EXPECT_EQ(gfx::Rect(30, 30), filter->GetRenderSurface()->content_rect()); | 3203 EXPECT_EQ(gfx::Rect(30, 30), GetRenderSurface(filter)->content_rect()); |
| 3205 | 3204 |
| 3206 FilterOperations blur_filter; | 3205 FilterOperations blur_filter; |
| 3207 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f)); | 3206 blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f)); |
| 3208 filter->test_properties()->filters = blur_filter; | 3207 filter->test_properties()->filters = blur_filter; |
| 3209 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3208 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 3210 | 3209 |
| 3211 ExecuteCalculateDrawProperties(root); | 3210 ExecuteCalculateDrawProperties(root); |
| 3212 | 3211 |
| 3213 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect()); | 3212 EXPECT_EQ(gfx::Rect(38, 38, 34, 34), filter_child->visible_layer_rect()); |
| 3214 EXPECT_EQ(gfx::Rect(-36, -36, 102, 102), | 3213 EXPECT_EQ(gfx::Rect(-36, -36, 102, 102), |
| 3215 filter->GetRenderSurface()->content_rect()); | 3214 GetRenderSurface(filter)->content_rect()); |
| 3216 | 3215 |
| 3217 gfx::Transform vertical_flip; | 3216 gfx::Transform vertical_flip; |
| 3218 vertical_flip.Scale(1, -1); | 3217 vertical_flip.Scale(1, -1); |
| 3219 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter( | 3218 sk_sp<SkImageFilter> flip_filter = SkImageFilter::MakeMatrixFilter( |
| 3220 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr); | 3219 vertical_flip.matrix(), kLow_SkFilterQuality, nullptr); |
| 3221 FilterOperations reflection_filter; | 3220 FilterOperations reflection_filter; |
| 3222 reflection_filter.Append( | 3221 reflection_filter.Append( |
| 3223 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make( | 3222 FilterOperation::CreateReferenceFilter(SkXfermodeImageFilter::Make( |
| 3224 SkBlendMode::kSrcOver, std::move(flip_filter)))); | 3223 SkBlendMode::kSrcOver, std::move(flip_filter)))); |
| 3225 filter->test_properties()->filters = reflection_filter; | 3224 filter->test_properties()->filters = reflection_filter; |
| 3226 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3225 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 3227 | 3226 |
| 3228 ExecuteCalculateDrawProperties(root); | 3227 ExecuteCalculateDrawProperties(root); |
| 3229 | 3228 |
| 3230 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect()); | 3229 EXPECT_EQ(gfx::Rect(50, 40, 10, 20), filter_child->visible_layer_rect()); |
| 3231 EXPECT_EQ(gfx::Rect(0, -30, 30, 60), | 3230 EXPECT_EQ(gfx::Rect(0, -30, 30, 60), |
| 3232 filter->GetRenderSurface()->content_rect()); | 3231 GetRenderSurface(filter)->content_rect()); |
| 3233 } | 3232 } |
| 3234 | 3233 |
| 3235 TEST_F(LayerTreeHostCommonTest, ClipRectWithClipParentAndFilters) { | 3234 TEST_F(LayerTreeHostCommonTest, ClipRectWithClipParentAndFilters) { |
| 3236 LayerImpl* root = root_layer_for_testing(); | 3235 LayerImpl* root = root_layer_for_testing(); |
| 3237 LayerImpl* clip = AddChild<LayerImpl>(root); | 3236 LayerImpl* clip = AddChild<LayerImpl>(root); |
| 3238 LayerImpl* filter = AddChild<LayerImpl>(clip); | 3237 LayerImpl* filter = AddChild<LayerImpl>(clip); |
| 3239 LayerImpl* filter_child_1 = AddChild<LayerImpl>(filter); | 3238 LayerImpl* filter_child_1 = AddChild<LayerImpl>(filter); |
| 3240 LayerImpl* filter_child_2 = AddChild<LayerImpl>(filter); | 3239 LayerImpl* filter_child_2 = AddChild<LayerImpl>(filter); |
| 3241 | 3240 |
| 3242 root->SetBounds(gfx::Size(100, 100)); | 3241 root->SetBounds(gfx::Size(100, 100)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3320 child1->SetBounds(gfx::Size(50, 50)); | 3319 child1->SetBounds(gfx::Size(50, 50)); |
| 3321 child1->SetDrawsContent(true); | 3320 child1->SetDrawsContent(true); |
| 3322 child2->SetPosition(gfx::PointF(75.f, 75.f)); | 3321 child2->SetPosition(gfx::PointF(75.f, 75.f)); |
| 3323 child2->SetBounds(gfx::Size(50, 50)); | 3322 child2->SetBounds(gfx::Size(50, 50)); |
| 3324 child2->SetDrawsContent(true); | 3323 child2->SetDrawsContent(true); |
| 3325 child3->SetPosition(gfx::PointF(125.f, 125.f)); | 3324 child3->SetPosition(gfx::PointF(125.f, 125.f)); |
| 3326 child3->SetBounds(gfx::Size(50, 50)); | 3325 child3->SetBounds(gfx::Size(50, 50)); |
| 3327 child3->SetDrawsContent(true); | 3326 child3->SetDrawsContent(true); |
| 3328 ExecuteCalculateDrawProperties(root); | 3327 ExecuteCalculateDrawProperties(root); |
| 3329 | 3328 |
| 3330 ASSERT_TRUE(render_surface->GetRenderSurface()); | 3329 ASSERT_TRUE(GetRenderSurface(render_surface)); |
| 3331 | 3330 |
| 3332 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3331 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3333 root->GetRenderSurface()->DrawableContentRect()); | 3332 GetRenderSurface(root)->DrawableContentRect()); |
| 3334 | 3333 |
| 3335 // Layers that do not draw content should have empty visible content rects. | 3334 // Layers that do not draw content should have empty visible content rects. |
| 3336 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 3335 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 3337 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); | 3336 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); |
| 3338 | 3337 |
| 3339 // An unclipped surface grows its DrawableContentRect to include all drawable | 3338 // An unclipped surface grows its DrawableContentRect to include all drawable |
| 3340 // regions of the subtree. | 3339 // regions of the subtree. |
| 3341 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), | 3340 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), |
| 3342 render_surface->GetRenderSurface()->DrawableContentRect()); | 3341 GetRenderSurface(render_surface)->DrawableContentRect()); |
| 3343 | 3342 |
| 3344 // All layers that draw content into the unclipped surface are also unclipped. | 3343 // All layers that draw content into the unclipped surface are also unclipped. |
| 3345 // Only the viewport clip should apply | 3344 // Only the viewport clip should apply |
| 3346 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); | 3345 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); |
| 3347 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); | 3346 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); |
| 3348 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect()); | 3347 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect()); |
| 3349 | 3348 |
| 3350 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); | 3349 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
| 3351 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); | 3350 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| 3352 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); | 3351 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3547 child3->SetPosition(gfx::PointF(125.f, 125.f)); | 3546 child3->SetPosition(gfx::PointF(125.f, 125.f)); |
| 3548 child3->SetBounds(gfx::Size(50, 50)); | 3547 child3->SetBounds(gfx::Size(50, 50)); |
| 3549 child3->SetDrawsContent(true); | 3548 child3->SetDrawsContent(true); |
| 3550 | 3549 |
| 3551 RenderSurfaceList render_surface_list_impl; | 3550 RenderSurfaceList render_surface_list_impl; |
| 3552 // Now set the root render surface an empty clip. | 3551 // Now set the root render surface an empty clip. |
| 3553 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 3552 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 3554 root, gfx::Size(), &render_surface_list_impl); | 3553 root, gfx::Size(), &render_surface_list_impl); |
| 3555 | 3554 |
| 3556 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 3555 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 3557 ASSERT_TRUE(root->GetRenderSurface()); | 3556 ASSERT_TRUE(GetRenderSurface(root)); |
| 3558 EXPECT_FALSE(root->is_clipped()); | 3557 EXPECT_FALSE(root->is_clipped()); |
| 3559 | 3558 |
| 3560 gfx::Rect empty; | 3559 gfx::Rect empty; |
| 3561 EXPECT_EQ(empty, root->GetRenderSurface()->clip_rect()); | 3560 EXPECT_EQ(empty, GetRenderSurface(root)->clip_rect()); |
| 3562 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); | 3561 EXPECT_TRUE(GetRenderSurface(root)->is_clipped()); |
| 3563 | 3562 |
| 3564 // Visible content rect calculation will check if the target surface is | 3563 // Visible content rect calculation will check if the target surface is |
| 3565 // clipped or not. An empty clip rect does not indicate the render surface | 3564 // clipped or not. An empty clip rect does not indicate the render surface |
| 3566 // is unclipped. | 3565 // is unclipped. |
| 3567 EXPECT_EQ(empty, child1->visible_layer_rect()); | 3566 EXPECT_EQ(empty, child1->visible_layer_rect()); |
| 3568 EXPECT_EQ(empty, child2->visible_layer_rect()); | 3567 EXPECT_EQ(empty, child2->visible_layer_rect()); |
| 3569 EXPECT_EQ(empty, child3->visible_layer_rect()); | 3568 EXPECT_EQ(empty, child3->visible_layer_rect()); |
| 3570 } | 3569 } |
| 3571 | 3570 |
| 3572 TEST_F(LayerTreeHostCommonTest, | 3571 TEST_F(LayerTreeHostCommonTest, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3706 child->test_properties()->AddChild(std::move(surface_sibling)); | 3705 child->test_properties()->AddChild(std::move(surface_sibling)); |
| 3707 root->test_properties()->AddChild(std::move(child)); | 3706 root->test_properties()->AddChild(std::move(child)); |
| 3708 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 3707 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 3709 host_impl.SetVisible(true); | 3708 host_impl.SetVisible(true); |
| 3710 host_impl.InitializeRenderer(compositor_frame_sink.get()); | 3709 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 3711 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 3710 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 3712 bool update_lcd_text = false; | 3711 bool update_lcd_text = false; |
| 3713 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); | 3712 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 3714 | 3713 |
| 3715 EXPECT_TRANSFORMATION_MATRIX_EQ( | 3714 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 3716 surface_ptr->GetRenderSurface()->draw_transform(), translate); | 3715 GetRenderSurface(surface_ptr)->draw_transform(), translate); |
| 3717 // surface_sibling draws into the root render surface and occludes | 3716 // surface_sibling draws into the root render surface and occludes |
| 3718 // surface_child's contents. | 3717 // surface_child's contents. |
| 3719 Occlusion actual_occlusion = | 3718 Occlusion actual_occlusion = |
| 3720 surface_child_ptr->GetRenderSurface()->occlusion_in_content_space(); | 3719 GetRenderSurface(surface_child_ptr)->occlusion_in_content_space(); |
| 3721 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), | 3720 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), |
| 3722 SimpleEnclosedRegion(gfx::Rect(200, 200))); | 3721 SimpleEnclosedRegion(gfx::Rect(200, 200))); |
| 3723 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); | 3722 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); |
| 3724 | 3723 |
| 3725 // Mask layer should have the same occlusion. | 3724 // Mask layer should have the same occlusion. |
| 3726 actual_occlusion = | 3725 actual_occlusion = |
| 3727 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; | 3726 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; |
| 3728 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); | 3727 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); |
| 3729 } | 3728 } |
| 3730 | 3729 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3863 child1->SetBounds(gfx::Size(50, 50)); | 3862 child1->SetBounds(gfx::Size(50, 50)); |
| 3864 child1->SetDrawsContent(true); | 3863 child1->SetDrawsContent(true); |
| 3865 child2->SetPosition(gfx::PointF(75.f, 75.f)); | 3864 child2->SetPosition(gfx::PointF(75.f, 75.f)); |
| 3866 child2->SetBounds(gfx::Size(50, 50)); | 3865 child2->SetBounds(gfx::Size(50, 50)); |
| 3867 child2->SetDrawsContent(true); | 3866 child2->SetDrawsContent(true); |
| 3868 child3->SetPosition(gfx::PointF(125.f, 125.f)); | 3867 child3->SetPosition(gfx::PointF(125.f, 125.f)); |
| 3869 child3->SetBounds(gfx::Size(50, 50)); | 3868 child3->SetBounds(gfx::Size(50, 50)); |
| 3870 child3->SetDrawsContent(true); | 3869 child3->SetDrawsContent(true); |
| 3871 ExecuteCalculateDrawProperties(root); | 3870 ExecuteCalculateDrawProperties(root); |
| 3872 | 3871 |
| 3873 ASSERT_TRUE(render_surface->GetRenderSurface()); | 3872 ASSERT_TRUE(GetRenderSurface(render_surface)); |
| 3874 | 3873 |
| 3875 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3874 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3876 root->GetRenderSurface()->DrawableContentRect()); | 3875 GetRenderSurface(root)->DrawableContentRect()); |
| 3877 | 3876 |
| 3878 // Layers that do not draw content should have empty visible content rects. | 3877 // Layers that do not draw content should have empty visible content rects. |
| 3879 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 3878 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 3880 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); | 3879 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); |
| 3881 | 3880 |
| 3882 // A clipped surface grows its DrawableContentRect to include all drawable | 3881 // A clipped surface grows its DrawableContentRect to include all drawable |
| 3883 // regions of the subtree, but also gets clamped by the ancestor's clip. | 3882 // regions of the subtree, but also gets clamped by the ancestor's clip. |
| 3884 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), | 3883 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), |
| 3885 render_surface->GetRenderSurface()->DrawableContentRect()); | 3884 GetRenderSurface(render_surface)->DrawableContentRect()); |
| 3886 | 3885 |
| 3887 // All layers that draw content into the surface have their visible content | 3886 // All layers that draw content into the surface have their visible content |
| 3888 // rect clipped by the surface clip rect. | 3887 // rect clipped by the surface clip rect. |
| 3889 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); | 3888 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); |
| 3890 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); | 3889 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); |
| 3891 EXPECT_TRUE(child3->visible_layer_rect().IsEmpty()); | 3890 EXPECT_TRUE(child3->visible_layer_rect().IsEmpty()); |
| 3892 | 3891 |
| 3893 // But the DrawableContentRects are unclipped. | 3892 // But the DrawableContentRects are unclipped. |
| 3894 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); | 3893 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
| 3895 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); | 3894 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3916 child1->SetBounds(gfx::Size(50, 50)); | 3915 child1->SetBounds(gfx::Size(50, 50)); |
| 3917 child1->SetDrawsContent(true); | 3916 child1->SetDrawsContent(true); |
| 3918 child2->SetPosition(gfx::PointF(75.f, 75.f)); | 3917 child2->SetPosition(gfx::PointF(75.f, 75.f)); |
| 3919 child2->SetBounds(gfx::Size(50, 50)); | 3918 child2->SetBounds(gfx::Size(50, 50)); |
| 3920 child2->SetDrawsContent(true); | 3919 child2->SetDrawsContent(true); |
| 3921 child3->SetPosition(gfx::PointF(125.f, 125.f)); | 3920 child3->SetPosition(gfx::PointF(125.f, 125.f)); |
| 3922 child3->SetBounds(gfx::Size(50, 50)); | 3921 child3->SetBounds(gfx::Size(50, 50)); |
| 3923 child3->SetDrawsContent(true); | 3922 child3->SetDrawsContent(true); |
| 3924 ExecuteCalculateDrawProperties(root); | 3923 ExecuteCalculateDrawProperties(root); |
| 3925 | 3924 |
| 3926 ASSERT_TRUE(render_surface1->GetRenderSurface()); | 3925 ASSERT_TRUE(GetRenderSurface(render_surface1)); |
| 3927 ASSERT_TRUE(render_surface2->GetRenderSurface()); | 3926 ASSERT_TRUE(GetRenderSurface(render_surface2)); |
| 3928 | 3927 |
| 3929 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3928 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3930 root->GetRenderSurface()->DrawableContentRect()); | 3929 GetRenderSurface(root)->DrawableContentRect()); |
| 3931 | 3930 |
| 3932 // Layers that do not draw content should have empty visible content rects. | 3931 // Layers that do not draw content should have empty visible content rects. |
| 3933 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 3932 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 3934 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect()); | 3933 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect()); |
| 3935 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect()); | 3934 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect()); |
| 3936 | 3935 |
| 3937 // A clipped surface grows its DrawableContentRect to include all drawable | 3936 // A clipped surface grows its DrawableContentRect to include all drawable |
| 3938 // regions of the subtree, but also gets clamped by the ancestor's clip. | 3937 // regions of the subtree, but also gets clamped by the ancestor's clip. |
| 3939 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), | 3938 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), |
| 3940 render_surface1->GetRenderSurface()->DrawableContentRect()); | 3939 GetRenderSurface(render_surface1)->DrawableContentRect()); |
| 3941 | 3940 |
| 3942 // render_surface1 lives in the "unclipped universe" of render_surface1, and | 3941 // render_surface1 lives in the "unclipped universe" of render_surface1, and |
| 3943 // is only implicitly clipped by render_surface1's content rect. So, | 3942 // is only implicitly clipped by render_surface1's content rect. So, |
| 3944 // render_surface2 grows to enclose all drawable content of its subtree. | 3943 // render_surface2 grows to enclose all drawable content of its subtree. |
| 3945 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), | 3944 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), |
| 3946 render_surface2->GetRenderSurface()->DrawableContentRect()); | 3945 GetRenderSurface(render_surface2)->DrawableContentRect()); |
| 3947 | 3946 |
| 3948 // All layers that draw content into render_surface2 think they are unclipped | 3947 // All layers that draw content into render_surface2 think they are unclipped |
| 3949 // by the surface. So, only the viewport clip applies. | 3948 // by the surface. So, only the viewport clip applies. |
| 3950 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); | 3949 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); |
| 3951 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); | 3950 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect()); |
| 3952 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect()); | 3951 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child3->visible_layer_rect()); |
| 3953 | 3952 |
| 3954 // DrawableContentRects are also unclipped. | 3953 // DrawableContentRects are also unclipped. |
| 3955 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); | 3954 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
| 3956 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); | 3955 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4047 render_surface2->SetBounds(gfx::Size(60, 60)); | 4046 render_surface2->SetBounds(gfx::Size(60, 60)); |
| 4048 render_surface2->SetDrawsContent(true); | 4047 render_surface2->SetDrawsContent(true); |
| 4049 render_surface2->test_properties()->force_render_surface = true; | 4048 render_surface2->test_properties()->force_render_surface = true; |
| 4050 | 4049 |
| 4051 clip_parent->SetMasksToBounds(true); | 4050 clip_parent->SetMasksToBounds(true); |
| 4052 clip_layer->SetMasksToBounds(true); | 4051 clip_layer->SetMasksToBounds(true); |
| 4053 render_surface1->SetMasksToBounds(true); | 4052 render_surface1->SetMasksToBounds(true); |
| 4054 | 4053 |
| 4055 float device_scale_factor = 1.f; | 4054 float device_scale_factor = 1.f; |
| 4056 ExecuteCalculateDrawProperties(root, device_scale_factor); | 4055 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 4057 EXPECT_EQ(gfx::Rect(50, 50), | 4056 EXPECT_EQ(gfx::Rect(50, 50), GetRenderSurface(render_surface2)->clip_rect()); |
| 4058 render_surface2->GetRenderSurface()->clip_rect()); | |
| 4059 device_scale_factor = 2.f; | 4057 device_scale_factor = 2.f; |
| 4060 ExecuteCalculateDrawProperties(root, device_scale_factor); | 4058 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 4061 EXPECT_EQ(gfx::Rect(100, 100), | 4059 EXPECT_EQ(gfx::Rect(100, 100), |
| 4062 render_surface2->GetRenderSurface()->clip_rect()); | 4060 GetRenderSurface(render_surface2)->clip_rect()); |
| 4063 } | 4061 } |
| 4064 | 4062 |
| 4065 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWhenLayerNotDrawn) { | 4063 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWhenLayerNotDrawn) { |
| 4066 // Test that only drawn layers contribute to render surface content rect. | 4064 // Test that only drawn layers contribute to render surface content rect. |
| 4067 LayerImpl* root = root_layer_for_testing(); | 4065 LayerImpl* root = root_layer_for_testing(); |
| 4068 LayerImpl* surface = AddChildToRoot<LayerImpl>(); | 4066 LayerImpl* surface = AddChildToRoot<LayerImpl>(); |
| 4069 LayerImpl* test_layer = AddChild<LayerImpl>(surface); | 4067 LayerImpl* test_layer = AddChild<LayerImpl>(surface); |
| 4070 | 4068 |
| 4071 root->SetBounds(gfx::Size(200, 200)); | 4069 root->SetBounds(gfx::Size(200, 200)); |
| 4072 surface->SetBounds(gfx::Size(100, 100)); | 4070 surface->SetBounds(gfx::Size(100, 100)); |
| 4073 surface->SetDrawsContent(true); | 4071 surface->SetDrawsContent(true); |
| 4074 surface->test_properties()->force_render_surface = true; | 4072 surface->test_properties()->force_render_surface = true; |
| 4075 test_layer->SetBounds(gfx::Size(150, 150)); | 4073 test_layer->SetBounds(gfx::Size(150, 150)); |
| 4076 | 4074 |
| 4077 ExecuteCalculateDrawProperties(root); | 4075 ExecuteCalculateDrawProperties(root); |
| 4078 EXPECT_EQ(gfx::Rect(100, 100), surface->GetRenderSurface()->content_rect()); | 4076 EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(surface)->content_rect()); |
| 4079 | 4077 |
| 4080 test_layer->SetDrawsContent(true); | 4078 test_layer->SetDrawsContent(true); |
| 4081 ExecuteCalculateDrawProperties(root); | 4079 ExecuteCalculateDrawProperties(root); |
| 4082 EXPECT_EQ(gfx::Rect(150, 150), surface->GetRenderSurface()->content_rect()); | 4080 EXPECT_EQ(gfx::Rect(150, 150), GetRenderSurface(surface)->content_rect()); |
| 4083 } | 4081 } |
| 4084 | 4082 |
| 4085 TEST_F(LayerTreeHostCommonTest, VisibleRectsMultipleSurfaces) { | 4083 TEST_F(LayerTreeHostCommonTest, VisibleRectsMultipleSurfaces) { |
| 4086 // Tests visible rects computation when we have unclipped_surface-> | 4084 // Tests visible rects computation when we have unclipped_surface-> |
| 4087 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds | 4085 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds |
| 4088 // of surface_with_unclipped_descendants doesn't propagate to the | 4086 // of surface_with_unclipped_descendants doesn't propagate to the |
| 4089 // clipped_surface below it. | 4087 // clipped_surface below it. |
| 4090 LayerImpl* root = root_layer_for_testing(); | 4088 LayerImpl* root = root_layer_for_testing(); |
| 4091 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); | 4089 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); |
| 4092 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); | 4090 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4180 root->SetBounds(gfx::Size(100, 100)); | 4178 root->SetBounds(gfx::Size(100, 100)); |
| 4181 render_surface->SetBounds(gfx::Size(3, 4)); | 4179 render_surface->SetBounds(gfx::Size(3, 4)); |
| 4182 render_surface->test_properties()->force_render_surface = true; | 4180 render_surface->test_properties()->force_render_surface = true; |
| 4183 child1->test_properties()->transform = child_rotation; | 4181 child1->test_properties()->transform = child_rotation; |
| 4184 child1->SetPosition(gfx::PointF(25.f, 25.f)); | 4182 child1->SetPosition(gfx::PointF(25.f, 25.f)); |
| 4185 child1->SetBounds(gfx::Size(50, 50)); | 4183 child1->SetBounds(gfx::Size(50, 50)); |
| 4186 child1->SetDrawsContent(true); | 4184 child1->SetDrawsContent(true); |
| 4187 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); | 4185 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); |
| 4188 ExecuteCalculateDrawProperties(root); | 4186 ExecuteCalculateDrawProperties(root); |
| 4189 | 4187 |
| 4190 ASSERT_TRUE(render_surface->GetRenderSurface()); | 4188 ASSERT_TRUE(GetRenderSurface(render_surface)); |
| 4191 | 4189 |
| 4192 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 4190 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 4193 root->GetRenderSurface()->DrawableContentRect()); | 4191 GetRenderSurface(root)->DrawableContentRect()); |
| 4194 | 4192 |
| 4195 // Layers that do not draw content should have empty visible content rects. | 4193 // Layers that do not draw content should have empty visible content rects. |
| 4196 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 4194 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 4197 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); | 4195 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); |
| 4198 | 4196 |
| 4199 // The unclipped surface grows its DrawableContentRect to include all drawable | 4197 // The unclipped surface grows its DrawableContentRect to include all drawable |
| 4200 // regions of the subtree. | 4198 // regions of the subtree. |
| 4201 int diagonal_radius = ceil(sqrt(2.0) * 25.0); | 4199 int diagonal_radius = ceil(sqrt(2.0) * 25.0); |
| 4202 gfx::Rect expected_surface_drawable_content = | 4200 gfx::Rect expected_surface_drawable_content = |
| 4203 gfx::Rect(50 - diagonal_radius, | 4201 gfx::Rect(50 - diagonal_radius, |
| 4204 50 - diagonal_radius, | 4202 50 - diagonal_radius, |
| 4205 diagonal_radius * 2, | 4203 diagonal_radius * 2, |
| 4206 diagonal_radius * 2); | 4204 diagonal_radius * 2); |
| 4207 EXPECT_EQ(gfx::RectF(expected_surface_drawable_content), | 4205 EXPECT_EQ(gfx::RectF(expected_surface_drawable_content), |
| 4208 render_surface->GetRenderSurface()->DrawableContentRect()); | 4206 GetRenderSurface(render_surface)->DrawableContentRect()); |
| 4209 | 4207 |
| 4210 // All layers that draw content into the unclipped surface are also unclipped. | 4208 // All layers that draw content into the unclipped surface are also unclipped. |
| 4211 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); | 4209 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); |
| 4212 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect()); | 4210 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect()); |
| 4213 } | 4211 } |
| 4214 | 4212 |
| 4215 TEST_F(LayerTreeHostCommonTest, | 4213 TEST_F(LayerTreeHostCommonTest, |
| 4216 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { | 4214 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { |
| 4217 // Layers that have non-axis aligned bounds (due to transforms) have an | 4215 // Layers that have non-axis aligned bounds (due to transforms) have an |
| 4218 // expanded, axis-aligned DrawableContentRect and visible content rect. | 4216 // expanded, axis-aligned DrawableContentRect and visible content rect. |
| 4219 LayerImpl* root = root_layer_for_testing(); | 4217 LayerImpl* root = root_layer_for_testing(); |
| 4220 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); | 4218 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); |
| 4221 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); | 4219 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); |
| 4222 | 4220 |
| 4223 gfx::Transform child_rotation; | 4221 gfx::Transform child_rotation; |
| 4224 child_rotation.Rotate(45.0); | 4222 child_rotation.Rotate(45.0); |
| 4225 | 4223 |
| 4226 root->SetBounds(gfx::Size(50, 50)); | 4224 root->SetBounds(gfx::Size(50, 50)); |
| 4227 root->SetMasksToBounds(true); | 4225 root->SetMasksToBounds(true); |
| 4228 render_surface->SetBounds(gfx::Size(3, 4)); | 4226 render_surface->SetBounds(gfx::Size(3, 4)); |
| 4229 render_surface->test_properties()->force_render_surface = true; | 4227 render_surface->test_properties()->force_render_surface = true; |
| 4230 child1->SetPosition(gfx::PointF(25.f, 25.f)); | 4228 child1->SetPosition(gfx::PointF(25.f, 25.f)); |
| 4231 child1->SetBounds(gfx::Size(50, 50)); | 4229 child1->SetBounds(gfx::Size(50, 50)); |
| 4232 child1->SetDrawsContent(true); | 4230 child1->SetDrawsContent(true); |
| 4233 child1->test_properties()->transform = child_rotation; | 4231 child1->test_properties()->transform = child_rotation; |
| 4234 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); | 4232 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); |
| 4235 ExecuteCalculateDrawProperties(root); | 4233 ExecuteCalculateDrawProperties(root); |
| 4236 | 4234 |
| 4237 ASSERT_TRUE(render_surface->GetRenderSurface()); | 4235 ASSERT_TRUE(GetRenderSurface(render_surface)); |
| 4238 | 4236 |
| 4239 // The clipped surface clamps the DrawableContentRect that encloses the | 4237 // The clipped surface clamps the DrawableContentRect that encloses the |
| 4240 // rotated layer. | 4238 // rotated layer. |
| 4241 int diagonal_radius = ceil(sqrt(2.0) * 25.0); | 4239 int diagonal_radius = ceil(sqrt(2.0) * 25.0); |
| 4242 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius, | 4240 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius, |
| 4243 50 - diagonal_radius, | 4241 50 - diagonal_radius, |
| 4244 diagonal_radius * 2, | 4242 diagonal_radius * 2, |
| 4245 diagonal_radius * 2); | 4243 diagonal_radius * 2); |
| 4246 gfx::RectF expected_surface_drawable_content( | 4244 gfx::RectF expected_surface_drawable_content( |
| 4247 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(50, 50))); | 4245 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(50, 50))); |
| 4248 EXPECT_EQ(expected_surface_drawable_content, | 4246 EXPECT_EQ(expected_surface_drawable_content, |
| 4249 render_surface->GetRenderSurface()->DrawableContentRect()); | 4247 GetRenderSurface(render_surface)->DrawableContentRect()); |
| 4250 | 4248 |
| 4251 // On the clipped surface, only a quarter of the child1 is visible, but when | 4249 // On the clipped surface, only a quarter of the child1 is visible, but when |
| 4252 // rotating it back to child1's content space, the actual enclosing rect ends | 4250 // rotating it back to child1's content space, the actual enclosing rect ends |
| 4253 // up covering the full left half of child1. | 4251 // up covering the full left half of child1. |
| 4254 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect()); | 4252 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect()); |
| 4255 | 4253 |
| 4256 // The child's DrawableContentRect is unclipped. | 4254 // The child's DrawableContentRect is unclipped. |
| 4257 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); | 4255 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); |
| 4258 } | 4256 } |
| 4259 | 4257 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4285 child1->SetDrawsContent(true); | 4283 child1->SetDrawsContent(true); |
| 4286 child2->SetBounds(gfx::Size(50, 50)); | 4284 child2->SetBounds(gfx::Size(50, 50)); |
| 4287 child2->SetPosition(gfx::PointF(75.f, 75.f)); | 4285 child2->SetPosition(gfx::PointF(75.f, 75.f)); |
| 4288 child2->SetDrawsContent(true); | 4286 child2->SetDrawsContent(true); |
| 4289 child3->SetBounds(gfx::Size(50, 50)); | 4287 child3->SetBounds(gfx::Size(50, 50)); |
| 4290 child3->SetPosition(gfx::PointF(125.f, 125.f)); | 4288 child3->SetPosition(gfx::PointF(125.f, 125.f)); |
| 4291 child3->SetDrawsContent(true); | 4289 child3->SetDrawsContent(true); |
| 4292 float device_scale_factor = 2.f; | 4290 float device_scale_factor = 2.f; |
| 4293 ExecuteCalculateDrawProperties(root, device_scale_factor); | 4291 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 4294 | 4292 |
| 4295 ASSERT_TRUE(render_surface1->GetRenderSurface()); | 4293 ASSERT_TRUE(GetRenderSurface(render_surface1)); |
| 4296 ASSERT_TRUE(render_surface2->GetRenderSurface()); | 4294 ASSERT_TRUE(GetRenderSurface(render_surface2)); |
| 4297 | 4295 |
| 4298 // drawable_content_rects for all layers and surfaces are scaled by | 4296 // drawable_content_rects for all layers and surfaces are scaled by |
| 4299 // device_scale_factor. | 4297 // device_scale_factor. |
| 4300 EXPECT_EQ(gfx::RectF(200.f, 200.f), | 4298 EXPECT_EQ(gfx::RectF(200.f, 200.f), |
| 4301 root->GetRenderSurface()->DrawableContentRect()); | 4299 GetRenderSurface(root)->DrawableContentRect()); |
| 4302 EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f), | 4300 EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f), |
| 4303 render_surface1->GetRenderSurface()->DrawableContentRect()); | 4301 GetRenderSurface(render_surface1)->DrawableContentRect()); |
| 4304 | 4302 |
| 4305 // render_surface2 lives in the "unclipped universe" of render_surface1, and | 4303 // render_surface2 lives in the "unclipped universe" of render_surface1, and |
| 4306 // is only implicitly clipped by render_surface1. | 4304 // is only implicitly clipped by render_surface1. |
| 4307 EXPECT_EQ(gfx::RectF(10.f, 10.f, 350.f, 350.f), | 4305 EXPECT_EQ(gfx::RectF(10.f, 10.f, 350.f, 350.f), |
| 4308 render_surface2->GetRenderSurface()->DrawableContentRect()); | 4306 GetRenderSurface(render_surface2)->DrawableContentRect()); |
| 4309 | 4307 |
| 4310 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect()); | 4308 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect()); |
| 4311 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect()); | 4309 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect()); |
| 4312 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect()); | 4310 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect()); |
| 4313 | 4311 |
| 4314 // The root layer does not actually draw content of its own. | 4312 // The root layer does not actually draw content of its own. |
| 4315 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); | 4313 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); |
| 4316 | 4314 |
| 4317 // All layer visible content rects are not expressed in content space of each | 4315 // All layer visible content rects are not expressed in content space of each |
| 4318 // layer, so they are not scaled by the device_scale_factor. | 4316 // layer, so they are not scaled by the device_scale_factor. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4390 backface_matrix; | 4388 backface_matrix; |
| 4391 back_facing_child_of_back_facing_surface->test_properties()->transform = | 4389 back_facing_child_of_back_facing_surface->test_properties()->transform = |
| 4392 backface_matrix; | 4390 backface_matrix; |
| 4393 | 4391 |
| 4394 // Note: No layers preserve 3d. According to current W3C CSS gfx::Transforms | 4392 // Note: No layers preserve 3d. According to current W3C CSS gfx::Transforms |
| 4395 // spec, these layers should blindly use their own local transforms to | 4393 // spec, these layers should blindly use their own local transforms to |
| 4396 // determine back-face culling. | 4394 // determine back-face culling. |
| 4397 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 4395 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 4398 | 4396 |
| 4399 // Verify which render surfaces were created. | 4397 // Verify which render surfaces were created. |
| 4400 EXPECT_FALSE(front_facing_child->GetRenderSurface()); | 4398 EXPECT_FALSE(GetRenderSurface(front_facing_child)); |
| 4401 EXPECT_FALSE(back_facing_child->GetRenderSurface()); | 4399 EXPECT_FALSE(GetRenderSurface(back_facing_child)); |
| 4402 EXPECT_TRUE(front_facing_surface->GetRenderSurface()); | 4400 EXPECT_TRUE(GetRenderSurface(front_facing_surface)); |
| 4403 EXPECT_TRUE(back_facing_surface->GetRenderSurface()); | 4401 EXPECT_TRUE(GetRenderSurface(back_facing_surface)); |
| 4404 EXPECT_FALSE(front_facing_child_of_front_facing_surface->GetRenderSurface()); | 4402 EXPECT_FALSE(GetRenderSurface(front_facing_child_of_front_facing_surface)); |
| 4405 EXPECT_FALSE(back_facing_child_of_front_facing_surface->GetRenderSurface()); | 4403 EXPECT_FALSE(GetRenderSurface(back_facing_child_of_front_facing_surface)); |
| 4406 EXPECT_FALSE(front_facing_child_of_back_facing_surface->GetRenderSurface()); | 4404 EXPECT_FALSE(GetRenderSurface(front_facing_child_of_back_facing_surface)); |
| 4407 EXPECT_FALSE(back_facing_child_of_back_facing_surface->GetRenderSurface()); | 4405 EXPECT_FALSE(GetRenderSurface(back_facing_child_of_back_facing_surface)); |
| 4408 | 4406 |
| 4409 EXPECT_EQ(3u, update_layer_list_impl()->size()); | 4407 EXPECT_EQ(3u, update_layer_list_impl()->size()); |
| 4410 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); | 4408 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); |
| 4411 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); | 4409 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); |
| 4412 EXPECT_TRUE(UpdateLayerListImplContains( | 4410 EXPECT_TRUE(UpdateLayerListImplContains( |
| 4413 front_facing_child_of_front_facing_surface->id())); | 4411 front_facing_child_of_front_facing_surface->id())); |
| 4414 } | 4412 } |
| 4415 | 4413 |
| 4416 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { | 4414 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { |
| 4417 // Verify the behavior of back-face culling when preserves-3d transform style | 4415 // Verify the behavior of back-face culling when preserves-3d transform style |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4498 back_facing_child_of_front_facing_surface->test_properties() | 4496 back_facing_child_of_front_facing_surface->test_properties() |
| 4499 ->sorting_context_id = 1; | 4497 ->sorting_context_id = 1; |
| 4500 front_facing_child_of_back_facing_surface->test_properties() | 4498 front_facing_child_of_back_facing_surface->test_properties() |
| 4501 ->sorting_context_id = 1; | 4499 ->sorting_context_id = 1; |
| 4502 back_facing_child_of_back_facing_surface->test_properties() | 4500 back_facing_child_of_back_facing_surface->test_properties() |
| 4503 ->sorting_context_id = 1; | 4501 ->sorting_context_id = 1; |
| 4504 | 4502 |
| 4505 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 4503 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 4506 | 4504 |
| 4507 // Verify which render surfaces were created and used. | 4505 // Verify which render surfaces were created and used. |
| 4508 EXPECT_FALSE(front_facing_child->GetRenderSurface()); | 4506 EXPECT_FALSE(GetRenderSurface(front_facing_child)); |
| 4509 EXPECT_FALSE(back_facing_child->GetRenderSurface()); | 4507 EXPECT_FALSE(GetRenderSurface(back_facing_child)); |
| 4510 EXPECT_TRUE(front_facing_surface->GetRenderSurface()); | 4508 EXPECT_TRUE(GetRenderSurface(front_facing_surface)); |
| 4511 // We expect that a has_render_surface was created but not used. | 4509 // We expect that a has_render_surface was created but not used. |
| 4512 EXPECT_TRUE(back_facing_surface->GetRenderSurface()); | 4510 EXPECT_TRUE(GetRenderSurface(back_facing_surface)); |
| 4513 EXPECT_FALSE(front_facing_child_of_front_facing_surface->GetRenderSurface()); | 4511 EXPECT_FALSE(GetRenderSurface(front_facing_child_of_front_facing_surface)); |
| 4514 EXPECT_FALSE(back_facing_child_of_front_facing_surface->GetRenderSurface()); | 4512 EXPECT_FALSE(GetRenderSurface(back_facing_child_of_front_facing_surface)); |
| 4515 EXPECT_FALSE(front_facing_child_of_back_facing_surface->GetRenderSurface()); | 4513 EXPECT_FALSE(GetRenderSurface(front_facing_child_of_back_facing_surface)); |
| 4516 EXPECT_FALSE(back_facing_child_of_back_facing_surface->GetRenderSurface()); | 4514 EXPECT_FALSE(GetRenderSurface(back_facing_child_of_back_facing_surface)); |
| 4517 | 4515 |
| 4518 EXPECT_EQ(3u, update_layer_list_impl()->size()); | 4516 EXPECT_EQ(3u, update_layer_list_impl()->size()); |
| 4519 | 4517 |
| 4520 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); | 4518 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); |
| 4521 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); | 4519 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); |
| 4522 EXPECT_TRUE(UpdateLayerListImplContains( | 4520 EXPECT_TRUE(UpdateLayerListImplContains( |
| 4523 front_facing_child_of_front_facing_surface->id())); | 4521 front_facing_child_of_front_facing_surface->id())); |
| 4524 } | 4522 } |
| 4525 | 4523 |
| 4526 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { | 4524 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4572 animating_surface->test_properties()->transform = backface_matrix; | 4570 animating_surface->test_properties()->transform = backface_matrix; |
| 4573 animating_surface->test_properties()->force_render_surface = true; | 4571 animating_surface->test_properties()->force_render_surface = true; |
| 4574 child_of_animating_surface->SetBounds(gfx::Size(100, 100)); | 4572 child_of_animating_surface->SetBounds(gfx::Size(100, 100)); |
| 4575 child_of_animating_surface->test_properties()->transform = backface_matrix; | 4573 child_of_animating_surface->test_properties()->transform = backface_matrix; |
| 4576 animating_child->SetBounds(gfx::Size(100, 100)); | 4574 animating_child->SetBounds(gfx::Size(100, 100)); |
| 4577 animating_child->test_properties()->transform = backface_matrix; | 4575 animating_child->test_properties()->transform = backface_matrix; |
| 4578 child2->SetBounds(gfx::Size(100, 100)); | 4576 child2->SetBounds(gfx::Size(100, 100)); |
| 4579 | 4577 |
| 4580 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 4578 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 4581 | 4579 |
| 4582 EXPECT_FALSE(child->GetRenderSurface()); | 4580 EXPECT_FALSE(GetRenderSurface(child)); |
| 4583 EXPECT_TRUE(animating_surface->GetRenderSurface()); | 4581 EXPECT_TRUE(GetRenderSurface(animating_surface)); |
| 4584 EXPECT_FALSE(child_of_animating_surface->GetRenderSurface()); | 4582 EXPECT_FALSE(GetRenderSurface(child_of_animating_surface)); |
| 4585 EXPECT_FALSE(animating_child->GetRenderSurface()); | 4583 EXPECT_FALSE(GetRenderSurface(animating_child)); |
| 4586 EXPECT_FALSE(child2->GetRenderSurface()); | 4584 EXPECT_FALSE(GetRenderSurface(child2)); |
| 4587 | 4585 |
| 4588 EXPECT_EQ(1u, update_layer_list_impl()->size()); | 4586 EXPECT_EQ(1u, update_layer_list_impl()->size()); |
| 4589 | 4587 |
| 4590 // The back facing layers are culled from the layer list, and have an empty | 4588 // The back facing layers are culled from the layer list, and have an empty |
| 4591 // visible rect. | 4589 // visible rect. |
| 4592 EXPECT_TRUE(UpdateLayerListImplContains(child2->id())); | 4590 EXPECT_TRUE(UpdateLayerListImplContains(child2->id())); |
| 4593 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); | 4591 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); |
| 4594 EXPECT_TRUE(animating_surface->visible_layer_rect().IsEmpty()); | 4592 EXPECT_TRUE(animating_surface->visible_layer_rect().IsEmpty()); |
| 4595 EXPECT_TRUE(child_of_animating_surface->visible_layer_rect().IsEmpty()); | 4593 EXPECT_TRUE(child_of_animating_surface->visible_layer_rect().IsEmpty()); |
| 4596 EXPECT_TRUE(animating_child->visible_layer_rect().IsEmpty()); | 4594 EXPECT_TRUE(animating_child->visible_layer_rect().IsEmpty()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4632 back_facing_surface->test_properties()->force_render_surface = true; | 4630 back_facing_surface->test_properties()->force_render_surface = true; |
| 4633 child1->SetBounds(gfx::Size(100, 100)); | 4631 child1->SetBounds(gfx::Size(100, 100)); |
| 4634 child2->SetBounds(gfx::Size(100, 100)); | 4632 child2->SetBounds(gfx::Size(100, 100)); |
| 4635 | 4633 |
| 4636 front_facing_surface->test_properties()->sorting_context_id = 1; | 4634 front_facing_surface->test_properties()->sorting_context_id = 1; |
| 4637 back_facing_surface->test_properties()->sorting_context_id = 1; | 4635 back_facing_surface->test_properties()->sorting_context_id = 1; |
| 4638 | 4636 |
| 4639 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 4637 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 4640 | 4638 |
| 4641 // Verify which render surfaces were created and used. | 4639 // Verify which render surfaces were created and used. |
| 4642 EXPECT_TRUE(front_facing_surface->GetRenderSurface()); | 4640 EXPECT_TRUE(GetRenderSurface(front_facing_surface)); |
| 4643 | 4641 |
| 4644 // We expect the render surface to have been created, but remain unused. | 4642 // We expect the render surface to have been created, but remain unused. |
| 4645 EXPECT_TRUE(back_facing_surface->GetRenderSurface()); | 4643 EXPECT_TRUE(GetRenderSurface(back_facing_surface)); |
| 4646 EXPECT_FALSE(child1->GetRenderSurface()); | 4644 EXPECT_FALSE(GetRenderSurface(child1)); |
| 4647 EXPECT_FALSE(child2->GetRenderSurface()); | 4645 EXPECT_FALSE(GetRenderSurface(child2)); |
| 4648 | 4646 |
| 4649 EXPECT_EQ(2u, update_layer_list_impl()->size()); | 4647 EXPECT_EQ(2u, update_layer_list_impl()->size()); |
| 4650 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); | 4648 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); |
| 4651 EXPECT_TRUE(UpdateLayerListImplContains(child1->id())); | 4649 EXPECT_TRUE(UpdateLayerListImplContains(child1->id())); |
| 4652 } | 4650 } |
| 4653 | 4651 |
| 4654 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { | 4652 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { |
| 4655 // Verify draw and screen space transforms of layers not in a surface. | 4653 // Verify draw and screen space transforms of layers not in a surface. |
| 4656 LayerImpl* root = root_layer_for_testing(); | 4654 LayerImpl* root = root_layer_for_testing(); |
| 4657 root->SetBounds(gfx::Size(100, 100)); | 4655 root->SetBounds(gfx::Size(100, 100)); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4821 expected_perspective_surface_draw_transform.PreconcatTransform( | 4819 expected_perspective_surface_draw_transform.PreconcatTransform( |
| 4822 perspective_matrix); | 4820 perspective_matrix); |
| 4823 expected_perspective_surface_draw_transform.PreconcatTransform( | 4821 expected_perspective_surface_draw_transform.PreconcatTransform( |
| 4824 scale_small_matrix); | 4822 scale_small_matrix); |
| 4825 gfx::Transform expected_perspective_surface_layer_draw_transform; | 4823 gfx::Transform expected_perspective_surface_layer_draw_transform; |
| 4826 expected_perspective_surface_layer_draw_transform.Scale( | 4824 expected_perspective_surface_layer_draw_transform.Scale( |
| 4827 device_scale_factor * page_scale_factor, | 4825 device_scale_factor * page_scale_factor, |
| 4828 device_scale_factor * page_scale_factor); | 4826 device_scale_factor * page_scale_factor); |
| 4829 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4827 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4830 expected_perspective_surface_draw_transform, | 4828 expected_perspective_surface_draw_transform, |
| 4831 perspective_surface->GetRenderSurface()->draw_transform()); | 4829 GetRenderSurface(perspective_surface)->draw_transform()); |
| 4832 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4830 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4833 expected_perspective_surface_layer_draw_transform, | 4831 expected_perspective_surface_layer_draw_transform, |
| 4834 perspective_surface->DrawTransform()); | 4832 perspective_surface->DrawTransform()); |
| 4835 } | 4833 } |
| 4836 | 4834 |
| 4837 TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) { | 4835 TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) { |
| 4838 gfx::Transform parent_scale_matrix; | 4836 gfx::Transform parent_scale_matrix; |
| 4839 SkMScalar initial_parent_scale = 1.75; | 4837 SkMScalar initial_parent_scale = 1.75; |
| 4840 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 4838 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
| 4841 | 4839 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4964 duplicate_child_non_owner->ScreenSpaceTransform()); | 4962 duplicate_child_non_owner->ScreenSpaceTransform()); |
| 4965 EXPECT_EQ(child->drawable_content_rect(), | 4963 EXPECT_EQ(child->drawable_content_rect(), |
| 4966 duplicate_child_non_owner->drawable_content_rect()); | 4964 duplicate_child_non_owner->drawable_content_rect()); |
| 4967 EXPECT_EQ(child->bounds(), duplicate_child_non_owner->bounds()); | 4965 EXPECT_EQ(child->bounds(), duplicate_child_non_owner->bounds()); |
| 4968 | 4966 |
| 4969 gfx::Transform expected_render_surface_draw_transform; | 4967 gfx::Transform expected_render_surface_draw_transform; |
| 4970 expected_render_surface_draw_transform.Translate( | 4968 expected_render_surface_draw_transform.Translate( |
| 4971 device_scale_factor * child->position().x(), | 4969 device_scale_factor * child->position().x(), |
| 4972 device_scale_factor * child->position().y()); | 4970 device_scale_factor * child->position().y()); |
| 4973 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_render_surface_draw_transform, | 4971 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_render_surface_draw_transform, |
| 4974 child->GetRenderSurface()->draw_transform()); | 4972 GetRenderSurface(child)->draw_transform()); |
| 4975 | 4973 |
| 4976 gfx::Transform expected_surface_draw_transform; | 4974 gfx::Transform expected_surface_draw_transform; |
| 4977 expected_surface_draw_transform.Translate(device_scale_factor * 2.f, | 4975 expected_surface_draw_transform.Translate(device_scale_factor * 2.f, |
| 4978 device_scale_factor * 2.f); | 4976 device_scale_factor * 2.f); |
| 4979 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_surface_draw_transform, | 4977 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_surface_draw_transform, |
| 4980 child->GetRenderSurface()->draw_transform()); | 4978 GetRenderSurface(child)->draw_transform()); |
| 4981 | 4979 |
| 4982 gfx::Transform expected_surface_screen_space_transform; | 4980 gfx::Transform expected_surface_screen_space_transform; |
| 4983 expected_surface_screen_space_transform.Translate(device_scale_factor * 2.f, | 4981 expected_surface_screen_space_transform.Translate(device_scale_factor * 2.f, |
| 4984 device_scale_factor * 2.f); | 4982 device_scale_factor * 2.f); |
| 4985 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4983 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4986 expected_surface_screen_space_transform, | 4984 expected_surface_screen_space_transform, |
| 4987 child->GetRenderSurface()->screen_space_transform()); | 4985 GetRenderSurface(child)->screen_space_transform()); |
| 4988 } | 4986 } |
| 4989 | 4987 |
| 4990 TEST_F(LayerTreeHostCommonTest, | 4988 TEST_F(LayerTreeHostCommonTest, |
| 4991 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { | 4989 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { |
| 4992 LayerImpl* parent = root_layer_for_testing(); | 4990 LayerImpl* parent = root_layer_for_testing(); |
| 4993 parent->SetBounds(gfx::Size(33, 31)); | 4991 parent->SetBounds(gfx::Size(33, 31)); |
| 4994 parent->SetDrawsContent(true); | 4992 parent->SetDrawsContent(true); |
| 4995 | 4993 |
| 4996 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4994 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4997 child->SetBounds(gfx::Size(13, 11)); | 4995 child->SetBounds(gfx::Size(13, 11)); |
| 4998 child->SetDrawsContent(true); | 4996 child->SetDrawsContent(true); |
| 4999 child->test_properties()->force_render_surface = true; | 4997 child->test_properties()->force_render_surface = true; |
| 5000 | 4998 |
| 5001 float device_scale_factor = 1.7f; | 4999 float device_scale_factor = 1.7f; |
| 5002 ExecuteCalculateDrawProperties(parent, device_scale_factor); | 5000 ExecuteCalculateDrawProperties(parent, device_scale_factor); |
| 5003 | 5001 |
| 5004 // We should have two render surfaces. The root's render surface and child's | 5002 // We should have two render surfaces. The root's render surface and child's |
| 5005 // render surface (it needs one because of force_render_surface). | 5003 // render surface (it needs one because of force_render_surface). |
| 5006 EXPECT_EQ(2u, render_surface_list_impl()->size()); | 5004 EXPECT_EQ(2u, render_surface_list_impl()->size()); |
| 5007 | 5005 |
| 5008 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 5006 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 5009 child->GetRenderSurface()->draw_transform()); | 5007 GetRenderSurface(child)->draw_transform()); |
| 5010 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 5008 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 5011 child->GetRenderSurface()->draw_transform()); | 5009 GetRenderSurface(child)->draw_transform()); |
| 5012 EXPECT_TRANSFORMATION_MATRIX_EQ( | 5010 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 5013 gfx::Transform(), child->GetRenderSurface()->screen_space_transform()); | 5011 gfx::Transform(), GetRenderSurface(child)->screen_space_transform()); |
| 5014 } | 5012 } |
| 5015 | 5013 |
| 5016 TEST_F(LayerTreeHostCommonTest, LayerSearch) { | 5014 TEST_F(LayerTreeHostCommonTest, LayerSearch) { |
| 5017 scoped_refptr<Layer> root = Layer::Create(); | 5015 scoped_refptr<Layer> root = Layer::Create(); |
| 5018 scoped_refptr<Layer> child = Layer::Create(); | 5016 scoped_refptr<Layer> child = Layer::Create(); |
| 5019 scoped_refptr<Layer> grand_child = Layer::Create(); | 5017 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 5020 scoped_refptr<Layer> mask_layer = Layer::Create(); | 5018 scoped_refptr<Layer> mask_layer = Layer::Create(); |
| 5021 | 5019 |
| 5022 child->AddChild(grand_child.get()); | 5020 child->AddChild(grand_child.get()); |
| 5023 child->SetMaskLayer(mask_layer.get()); | 5021 child->SetMaskLayer(mask_layer.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5037 LayerImpl* root = root_layer_for_testing(); | 5035 LayerImpl* root = root_layer_for_testing(); |
| 5038 LayerImpl* child = AddChild<LayerImpl>(root); | 5036 LayerImpl* child = AddChild<LayerImpl>(root); |
| 5039 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 5037 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 5040 | 5038 |
| 5041 root->SetBounds(gfx::Size(100, 100)); | 5039 root->SetBounds(gfx::Size(100, 100)); |
| 5042 child->SetBounds(gfx::Size(10, 10)); | 5040 child->SetBounds(gfx::Size(10, 10)); |
| 5043 child->test_properties()->opacity = 0.5f; | 5041 child->test_properties()->opacity = 0.5f; |
| 5044 grand_child->SetBounds(gfx::Size(10, 10)); | 5042 grand_child->SetBounds(gfx::Size(10, 10)); |
| 5045 grand_child->SetDrawsContent(true); | 5043 grand_child->SetDrawsContent(true); |
| 5046 ExecuteCalculateDrawProperties(root); | 5044 ExecuteCalculateDrawProperties(root); |
| 5047 EXPECT_FALSE(child->GetRenderSurface()); | 5045 EXPECT_FALSE(GetRenderSurface(child)); |
| 5048 } | 5046 } |
| 5049 | 5047 |
| 5050 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { | 5048 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { |
| 5051 FakeImplTaskRunnerProvider task_runner_provider; | 5049 FakeImplTaskRunnerProvider task_runner_provider; |
| 5052 TestTaskGraphRunner task_graph_runner; | 5050 TestTaskGraphRunner task_graph_runner; |
| 5053 FakeLayerTreeHostImpl host_impl(host()->GetSettings(), &task_runner_provider, | 5051 FakeLayerTreeHostImpl host_impl(host()->GetSettings(), &task_runner_provider, |
| 5054 &task_graph_runner); | 5052 &task_graph_runner); |
| 5055 host_impl.CreatePendingTree(); | 5053 host_impl.CreatePendingTree(); |
| 5056 std::unique_ptr<LayerImpl> root = | 5054 std::unique_ptr<LayerImpl> root = |
| 5057 LayerImpl::Create(host_impl.pending_tree(), 1); | 5055 LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5083 | 5081 |
| 5084 RenderSurfaceList render_surface_list; | 5082 RenderSurfaceList render_surface_list; |
| 5085 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5083 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5086 root_layer, root_layer->bounds(), &render_surface_list); | 5084 root_layer, root_layer->bounds(), &render_surface_list); |
| 5087 inputs.can_adjust_raster_scales = true; | 5085 inputs.can_adjust_raster_scales = true; |
| 5088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5086 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5089 | 5087 |
| 5090 // We should have one render surface and one layer. The child | 5088 // We should have one render surface and one layer. The child |
| 5091 // layer should not be included as its transparent. | 5089 // layer should not be included as its transparent. |
| 5092 ASSERT_EQ(1u, render_surface_list.size()); | 5090 ASSERT_EQ(1u, render_surface_list.size()); |
| 5093 ASSERT_EQ(1, root_layer->GetRenderSurface()->num_contributors()); | 5091 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); |
| 5094 | 5092 |
| 5095 // If the root itself is hidden, the child should not be drawn and should not | 5093 // If the root itself is hidden, the child should not be drawn and should not |
| 5096 // raster even if it has an animating opacity. | 5094 // raster even if it has an animating opacity. |
| 5097 root_layer->test_properties()->opacity = 0.0f; | 5095 root_layer->test_properties()->opacity = 0.0f; |
| 5098 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5096 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5099 RenderSurfaceList render_surface_list2; | 5097 RenderSurfaceList render_surface_list2; |
| 5100 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( | 5098 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( |
| 5101 root_layer, root_layer->bounds(), &render_surface_list2); | 5099 root_layer, root_layer->bounds(), &render_surface_list2); |
| 5102 inputs2.can_adjust_raster_scales = true; | 5100 inputs2.can_adjust_raster_scales = true; |
| 5103 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); | 5101 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5385 | 5383 |
| 5386 RenderSurfaceList render_surface_list; | 5384 RenderSurfaceList render_surface_list; |
| 5387 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5385 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5388 root_layer, root_layer->bounds(), &render_surface_list); | 5386 root_layer, root_layer->bounds(), &render_surface_list); |
| 5389 inputs.can_adjust_raster_scales = true; | 5387 inputs.can_adjust_raster_scales = true; |
| 5390 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5388 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5391 | 5389 |
| 5392 // We should have one render surface and two layers. The grand child has | 5390 // We should have one render surface and two layers. The grand child has |
| 5393 // hidden itself. | 5391 // hidden itself. |
| 5394 ASSERT_EQ(1u, render_surface_list.size()); | 5392 ASSERT_EQ(1u, render_surface_list.size()); |
| 5395 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5393 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
| 5396 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 5394 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5397 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); | 5395 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); |
| 5398 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | 5396 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); |
| 5399 } | 5397 } |
| 5400 | 5398 |
| 5401 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 5399 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 5402 FakeImplTaskRunnerProvider task_runner_provider; | 5400 FakeImplTaskRunnerProvider task_runner_provider; |
| 5403 TestTaskGraphRunner task_graph_runner; | 5401 TestTaskGraphRunner task_graph_runner; |
| 5404 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 5402 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 5405 host_impl.CreatePendingTree(); | 5403 host_impl.CreatePendingTree(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5429 | 5427 |
| 5430 RenderSurfaceList render_surface_list; | 5428 RenderSurfaceList render_surface_list; |
| 5431 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5429 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5432 root_layer, root_layer->bounds(), &render_surface_list); | 5430 root_layer, root_layer->bounds(), &render_surface_list); |
| 5433 inputs.can_adjust_raster_scales = true; | 5431 inputs.can_adjust_raster_scales = true; |
| 5434 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5432 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5435 | 5433 |
| 5436 // We should have one render surface and one layer. The child has | 5434 // We should have one render surface and one layer. The child has |
| 5437 // hidden itself and the grand child. | 5435 // hidden itself and the grand child. |
| 5438 ASSERT_EQ(1u, render_surface_list.size()); | 5436 ASSERT_EQ(1u, render_surface_list.size()); |
| 5439 ASSERT_EQ(1, root_layer->GetRenderSurface()->num_contributors()); | 5437 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors()); |
| 5440 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 5438 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5441 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); | 5439 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface()); |
| 5442 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); | 5440 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface()); |
| 5443 } | 5441 } |
| 5444 | 5442 |
| 5445 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 5443 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 5446 | 5444 |
| 5447 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 5445 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
| 5448 FakeImplTaskRunnerProvider task_runner_provider; | 5446 FakeImplTaskRunnerProvider task_runner_provider; |
| 5449 TestTaskGraphRunner task_graph_runner; | 5447 TestTaskGraphRunner task_graph_runner; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5539 // We should have four render surfaces, one for the root, one for the grand | 5537 // We should have four render surfaces, one for the root, one for the grand |
| 5540 // parent since it has opacity and two drawing descendants, one for the parent | 5538 // parent since it has opacity and two drawing descendants, one for the parent |
| 5541 // since it owns a surface, and one for the copy_layer. | 5539 // since it owns a surface, and one for the copy_layer. |
| 5542 ASSERT_EQ(4u, render_surface_list.size()); | 5540 ASSERT_EQ(4u, render_surface_list.size()); |
| 5543 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 5541 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
| 5544 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); | 5542 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id()); |
| 5545 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); | 5543 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id()); |
| 5546 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); | 5544 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id()); |
| 5547 | 5545 |
| 5548 // The root render surface should have 2 contributing layers. | 5546 // The root render surface should have 2 contributing layers. |
| 5549 EXPECT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5547 EXPECT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
| 5550 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 5548 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5551 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); | 5549 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface()); |
| 5552 EXPECT_FALSE(copy_grand_parent_sibling_before_layer | 5550 EXPECT_FALSE(copy_grand_parent_sibling_before_layer |
| 5553 ->contributes_to_drawn_render_surface()); | 5551 ->contributes_to_drawn_render_surface()); |
| 5554 EXPECT_FALSE(copy_grand_parent_sibling_after_layer | 5552 EXPECT_FALSE(copy_grand_parent_sibling_after_layer |
| 5555 ->contributes_to_drawn_render_surface()); | 5553 ->contributes_to_drawn_render_surface()); |
| 5556 | 5554 |
| 5557 // Nothing actually draws into the copy parent, so only the copy_layer will | 5555 // Nothing actually draws into the copy parent, so only the copy_layer will |
| 5558 // appear in its list, since it needs to be drawn for the copy request. | 5556 // appear in its list, since it needs to be drawn for the copy request. |
| 5559 ASSERT_EQ(1, copy_parent_layer->GetRenderSurface()->num_contributors()); | 5557 ASSERT_EQ(1, GetRenderSurface(copy_parent_layer)->num_contributors()); |
| 5560 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); | 5558 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface()); |
| 5561 | 5559 |
| 5562 // The copy layer's render surface should have 2 contributing layers. | 5560 // The copy layer's render surface should have 2 contributing layers. |
| 5563 ASSERT_EQ(2, copy_layer->GetRenderSurface()->num_contributors()); | 5561 ASSERT_EQ(2, GetRenderSurface(copy_layer)->num_contributors()); |
| 5564 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); | 5562 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); |
| 5565 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); | 5563 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface()); |
| 5566 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); | 5564 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface()); |
| 5567 | 5565 |
| 5568 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | 5566 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, |
| 5569 // but the copy_layer and copy_child should be drawn for the copy request. | 5567 // but the copy_layer and copy_child should be drawn for the copy request. |
| 5570 // copy grand child should not be drawn as its hidden even in the copy | 5568 // copy grand child should not be drawn as its hidden even in the copy |
| 5571 // request. | 5569 // request. |
| 5572 EffectTree& tree = | 5570 EffectTree& tree = |
| 5573 root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5571 root_layer->layer_tree_impl()->property_trees()->effect_tree; |
| 5574 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | 5572 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); |
| 5575 EXPECT_FALSE(node->is_drawn); | 5573 EXPECT_FALSE(node->is_drawn); |
| 5576 node = tree.Node(copy_parent_layer->effect_tree_index()); | 5574 node = tree.Node(copy_parent_layer->effect_tree_index()); |
| 5577 EXPECT_FALSE(node->is_drawn); | 5575 EXPECT_FALSE(node->is_drawn); |
| 5578 node = tree.Node(copy_layer->effect_tree_index()); | 5576 node = tree.Node(copy_layer->effect_tree_index()); |
| 5579 EXPECT_TRUE(node->is_drawn); | 5577 EXPECT_TRUE(node->is_drawn); |
| 5580 node = tree.Node(copy_child_layer->effect_tree_index()); | 5578 node = tree.Node(copy_child_layer->effect_tree_index()); |
| 5581 EXPECT_TRUE(node->is_drawn); | 5579 EXPECT_TRUE(node->is_drawn); |
| 5582 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | 5580 node = tree.Node(copy_grand_child_layer->effect_tree_index()); |
| 5583 EXPECT_FALSE(node->is_drawn); | 5581 EXPECT_FALSE(node->is_drawn); |
| 5584 | 5582 |
| 5585 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its | 5583 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its |
| 5586 // actually hidden. | 5584 // actually hidden. |
| 5587 EXPECT_FALSE(copy_layer->GetRenderSurface()->contributes_to_drawn_surface()); | 5585 EXPECT_FALSE(GetRenderSurface(copy_layer)->contributes_to_drawn_surface()); |
| 5588 } | 5586 } |
| 5589 | 5587 |
| 5590 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5588 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 5591 FakeImplTaskRunnerProvider task_runner_provider; | 5589 FakeImplTaskRunnerProvider task_runner_provider; |
| 5592 TestTaskGraphRunner task_graph_runner; | 5590 TestTaskGraphRunner task_graph_runner; |
| 5593 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 5591 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 5594 host_impl.CreatePendingTree(); | 5592 host_impl.CreatePendingTree(); |
| 5595 | 5593 |
| 5596 std::unique_ptr<LayerImpl> root = | 5594 std::unique_ptr<LayerImpl> root = |
| 5597 LayerImpl::Create(host_impl.pending_tree(), 1); | 5595 LayerImpl::Create(host_impl.pending_tree(), 1); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5628 root_layer, root_layer->bounds(), &render_surface_list); | 5626 root_layer, root_layer->bounds(), &render_surface_list); |
| 5629 inputs.can_adjust_raster_scales = true; | 5627 inputs.can_adjust_raster_scales = true; |
| 5630 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5628 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5631 | 5629 |
| 5632 // We should have two render surface, as the others are clipped out. | 5630 // We should have two render surface, as the others are clipped out. |
| 5633 ASSERT_EQ(2u, render_surface_list.size()); | 5631 ASSERT_EQ(2u, render_surface_list.size()); |
| 5634 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 5632 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
| 5635 | 5633 |
| 5636 // The root render surface should have only 2 contributing layer, since the | 5634 // The root render surface should have only 2 contributing layer, since the |
| 5637 // other layers are clipped away. | 5635 // other layers are clipped away. |
| 5638 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5636 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); |
| 5639 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 5637 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
| 5640 } | 5638 } |
| 5641 | 5639 |
| 5642 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { | 5640 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { |
| 5643 LayerImpl* root = root_layer_for_testing(); | 5641 LayerImpl* root = root_layer_for_testing(); |
| 5644 root->SetBounds(gfx::Size(50, 50)); | 5642 root->SetBounds(gfx::Size(50, 50)); |
| 5645 root->SetDrawsContent(true); | 5643 root->SetDrawsContent(true); |
| 5646 | 5644 |
| 5647 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); | 5645 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); |
| 5648 singular_transform_layer->SetBounds(gfx::Size(100, 100)); | 5646 singular_transform_layer->SetBounds(gfx::Size(100, 100)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5793 render_surface->test_properties()->force_render_surface = true; | 5791 render_surface->test_properties()->force_render_surface = true; |
| 5794 clip_parent->test_properties()->transform = scale_transform; | 5792 clip_parent->test_properties()->transform = scale_transform; |
| 5795 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); | 5793 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5796 clip_parent->SetBounds(gfx::Size(10, 10)); | 5794 clip_parent->SetBounds(gfx::Size(10, 10)); |
| 5797 intervening->SetPosition(gfx::PointF(1.f, 1.f)); | 5795 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5798 intervening->SetBounds(gfx::Size(5, 5)); | 5796 intervening->SetBounds(gfx::Size(5, 5)); |
| 5799 clip_child->SetPosition(gfx::PointF(1.f, 1.f)); | 5797 clip_child->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5800 clip_child->SetBounds(gfx::Size(10, 10)); | 5798 clip_child->SetBounds(gfx::Size(10, 10)); |
| 5801 ExecuteCalculateDrawProperties(root); | 5799 ExecuteCalculateDrawProperties(root); |
| 5802 | 5800 |
| 5803 ASSERT_TRUE(root->GetRenderSurface()); | 5801 ASSERT_TRUE(GetRenderSurface(root)); |
| 5804 ASSERT_TRUE(render_surface->GetRenderSurface()); | 5802 ASSERT_TRUE(GetRenderSurface(render_surface)); |
| 5805 | 5803 |
| 5806 // Ensure that we've inherited our clip parent's clip and weren't affected | 5804 // Ensure that we've inherited our clip parent's clip and weren't affected |
| 5807 // by the intervening clip layer. | 5805 // by the intervening clip layer. |
| 5808 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), clip_parent->clip_rect()); | 5806 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), clip_parent->clip_rect()); |
| 5809 ASSERT_EQ(clip_parent->clip_rect(), clip_child->clip_rect()); | 5807 ASSERT_EQ(clip_parent->clip_rect(), clip_child->clip_rect()); |
| 5810 ASSERT_EQ(gfx::Rect(3, 3, 10, 10), intervening->clip_rect()); | 5808 ASSERT_EQ(gfx::Rect(3, 3, 10, 10), intervening->clip_rect()); |
| 5811 | 5809 |
| 5812 // Ensure that the render surface reports a content rect that has been grown | 5810 // Ensure that the render surface reports a content rect that has been grown |
| 5813 // to accomodate for the clip child. | 5811 // to accomodate for the clip child. |
| 5814 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), | 5812 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), |
| 5815 render_surface->GetRenderSurface()->content_rect()); | 5813 GetRenderSurface(render_surface)->content_rect()); |
| 5816 | 5814 |
| 5817 // The above check implies the two below, but they nicely demonstrate that | 5815 // The above check implies the two below, but they nicely demonstrate that |
| 5818 // we've grown, despite the intervening layer's clip. | 5816 // we've grown, despite the intervening layer's clip. |
| 5819 ASSERT_TRUE(clip_parent->clip_rect().Contains( | 5817 ASSERT_TRUE(clip_parent->clip_rect().Contains( |
| 5820 render_surface->GetRenderSurface()->content_rect())); | 5818 GetRenderSurface(render_surface)->content_rect())); |
| 5821 ASSERT_FALSE(intervening->clip_rect().Contains( | 5819 ASSERT_FALSE(intervening->clip_rect().Contains( |
| 5822 render_surface->GetRenderSurface()->content_rect())); | 5820 GetRenderSurface(render_surface)->content_rect())); |
| 5823 } | 5821 } |
| 5824 | 5822 |
| 5825 TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) { | 5823 TEST_F(LayerTreeHostCommonTest, ClipParentWithInterveningRenderSurface) { |
| 5826 // Ensure that intervening render surfaces are not a problem in the basic | 5824 // Ensure that intervening render surfaces are not a problem in the basic |
| 5827 // case. In the following tree, both render surfaces should be resized to | 5825 // case. In the following tree, both render surfaces should be resized to |
| 5828 // accomodate for the clip child, despite an intervening clip. | 5826 // accomodate for the clip child, despite an intervening clip. |
| 5829 // | 5827 // |
| 5830 // root (a render surface) | 5828 // root (a render surface) |
| 5831 // + clip_parent (masks to bounds) | 5829 // + clip_parent (masks to bounds) |
| 5832 // + render_surface1 (sets opacity) | 5830 // + render_surface1 (sets opacity) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5858 render_surface1->SetBounds(gfx::Size(10, 10)); | 5856 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 5859 render_surface1->test_properties()->force_render_surface = true; | 5857 render_surface1->test_properties()->force_render_surface = true; |
| 5860 intervening->SetPosition(gfx::PointF(1.f, 1.f)); | 5858 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5861 intervening->SetBounds(gfx::Size(5, 5)); | 5859 intervening->SetBounds(gfx::Size(5, 5)); |
| 5862 render_surface2->SetBounds(gfx::Size(10, 10)); | 5860 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5863 render_surface2->test_properties()->force_render_surface = true; | 5861 render_surface2->test_properties()->force_render_surface = true; |
| 5864 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); | 5862 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5865 clip_child->SetBounds(gfx::Size(60, 60)); | 5863 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5866 ExecuteCalculateDrawProperties(root); | 5864 ExecuteCalculateDrawProperties(root); |
| 5867 | 5865 |
| 5868 EXPECT_TRUE(root->GetRenderSurface()); | 5866 EXPECT_TRUE(GetRenderSurface(root)); |
| 5869 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 5867 EXPECT_TRUE(GetRenderSurface(render_surface1)); |
| 5870 EXPECT_TRUE(render_surface2->GetRenderSurface()); | 5868 EXPECT_TRUE(GetRenderSurface(render_surface2)); |
| 5871 | 5869 |
| 5872 // render_surface1 should apply the clip from clip_parent. Though there is a | 5870 // render_surface1 should apply the clip from clip_parent. Though there is a |
| 5873 // clip child, render_surface1 can apply the clip as there are no clips | 5871 // clip child, render_surface1 can apply the clip as there are no clips |
| 5874 // between the clip parent and render_surface1 | 5872 // between the clip parent and render_surface1 |
| 5875 EXPECT_EQ(gfx::Rect(1, 1, 40, 40), | 5873 EXPECT_EQ(gfx::Rect(1, 1, 40, 40), |
| 5876 render_surface1->GetRenderSurface()->clip_rect()); | 5874 GetRenderSurface(render_surface1)->clip_rect()); |
| 5877 EXPECT_TRUE(render_surface1->GetRenderSurface()->is_clipped()); | 5875 EXPECT_TRUE(GetRenderSurface(render_surface1)->is_clipped()); |
| 5878 EXPECT_EQ(gfx::Rect(), render_surface1->clip_rect()); | 5876 EXPECT_EQ(gfx::Rect(), render_surface1->clip_rect()); |
| 5879 EXPECT_FALSE(render_surface1->is_clipped()); | 5877 EXPECT_FALSE(render_surface1->is_clipped()); |
| 5880 | 5878 |
| 5881 // render_surface2 could have expanded, as there is a clip between | 5879 // render_surface2 could have expanded, as there is a clip between |
| 5882 // clip_child's clip (clip_parent) and render_surface2's clip (intervening). | 5880 // clip_child's clip (clip_parent) and render_surface2's clip (intervening). |
| 5883 // So, it should not be clipped (their bounds would no longer be reliable). | 5881 // So, it should not be clipped (their bounds would no longer be reliable). |
| 5884 // We should resort to layer clipping in this case. | 5882 // We should resort to layer clipping in this case. |
| 5885 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5883 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 5886 render_surface2->GetRenderSurface()->clip_rect()); | 5884 GetRenderSurface(render_surface2)->clip_rect()); |
| 5887 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped()); | 5885 EXPECT_FALSE(GetRenderSurface(render_surface2)->is_clipped()); |
| 5888 | 5886 |
| 5889 // This value is inherited from the clipping ancestor layer, 'intervening'. | 5887 // This value is inherited from the clipping ancestor layer, 'intervening'. |
| 5890 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); | 5888 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); |
| 5891 EXPECT_TRUE(render_surface2->is_clipped()); | 5889 EXPECT_TRUE(render_surface2->is_clipped()); |
| 5892 | 5890 |
| 5893 // The content rects of render_surface2 should have expanded to contain the | 5891 // The content rects of render_surface2 should have expanded to contain the |
| 5894 // clip child. | 5892 // clip child. |
| 5895 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), | 5893 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), |
| 5896 render_surface1->GetRenderSurface()->content_rect()); | 5894 GetRenderSurface(render_surface1)->content_rect()); |
| 5897 EXPECT_EQ(gfx::Rect(-10, -10, 60, 60), | 5895 EXPECT_EQ(gfx::Rect(-10, -10, 60, 60), |
| 5898 render_surface2->GetRenderSurface()->content_rect()); | 5896 GetRenderSurface(render_surface2)->content_rect()); |
| 5899 | 5897 |
| 5900 // The clip child should have inherited the clip parent's clip (projected to | 5898 // The clip child should have inherited the clip parent's clip (projected to |
| 5901 // the right space, of course), but as render_surface1 already applies that | 5899 // the right space, of course), but as render_surface1 already applies that |
| 5902 // clip, clip_child need not apply it again. | 5900 // clip, clip_child need not apply it again. |
| 5903 EXPECT_EQ(gfx::Rect(), clip_child->clip_rect()); | 5901 EXPECT_EQ(gfx::Rect(), clip_child->clip_rect()); |
| 5904 EXPECT_EQ(gfx::Rect(9, 9, 40, 40), clip_child->visible_layer_rect()); | 5902 EXPECT_EQ(gfx::Rect(9, 9, 40, 40), clip_child->visible_layer_rect()); |
| 5905 EXPECT_FALSE(clip_child->is_clipped()); | 5903 EXPECT_FALSE(clip_child->is_clipped()); |
| 5906 } | 5904 } |
| 5907 | 5905 |
| 5908 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { | 5906 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5944 render_surface1->SetBounds(gfx::Size(10, 10)); | 5942 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 5945 render_surface1->test_properties()->force_render_surface = true; | 5943 render_surface1->test_properties()->force_render_surface = true; |
| 5946 intervening->SetPosition(gfx::PointF(1.f, 1.f)); | 5944 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5947 intervening->SetBounds(gfx::Size(5, 5)); | 5945 intervening->SetBounds(gfx::Size(5, 5)); |
| 5948 render_surface2->SetBounds(gfx::Size(10, 10)); | 5946 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5949 render_surface2->test_properties()->force_render_surface = true; | 5947 render_surface2->test_properties()->force_render_surface = true; |
| 5950 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); | 5948 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5951 clip_child->SetBounds(gfx::Size(60, 60)); | 5949 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5952 ExecuteCalculateDrawProperties(root); | 5950 ExecuteCalculateDrawProperties(root); |
| 5953 | 5951 |
| 5954 EXPECT_TRUE(root->GetRenderSurface()); | 5952 EXPECT_TRUE(GetRenderSurface(root)); |
| 5955 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 5953 EXPECT_TRUE(GetRenderSurface(render_surface1)); |
| 5956 EXPECT_TRUE(render_surface2->GetRenderSurface()); | 5954 EXPECT_TRUE(GetRenderSurface(render_surface2)); |
| 5957 | 5955 |
| 5958 // render_surface1 should apply the clip from clip_parent. Though there is a | 5956 // render_surface1 should apply the clip from clip_parent. Though there is a |
| 5959 // clip child, render_surface1 can apply the clip as there are no clips | 5957 // clip child, render_surface1 can apply the clip as there are no clips |
| 5960 // between the clip parent and render_surface1 | 5958 // between the clip parent and render_surface1 |
| 5961 EXPECT_EQ(gfx::Rect(3, 3, 40, 40), | 5959 EXPECT_EQ(gfx::Rect(3, 3, 40, 40), |
| 5962 render_surface1->GetRenderSurface()->clip_rect()); | 5960 GetRenderSurface(render_surface1)->clip_rect()); |
| 5963 EXPECT_TRUE(render_surface1->GetRenderSurface()->is_clipped()); | 5961 EXPECT_TRUE(GetRenderSurface(render_surface1)->is_clipped()); |
| 5964 EXPECT_EQ(gfx::Rect(), render_surface1->clip_rect()); | 5962 EXPECT_EQ(gfx::Rect(), render_surface1->clip_rect()); |
| 5965 EXPECT_FALSE(render_surface1->is_clipped()); | 5963 EXPECT_FALSE(render_surface1->is_clipped()); |
| 5966 | 5964 |
| 5967 // render_surface2 could have expanded, as there is a clip between | 5965 // render_surface2 could have expanded, as there is a clip between |
| 5968 // clip_child's clip (clip_parent) and render_surface2's clip (intervening). | 5966 // clip_child's clip (clip_parent) and render_surface2's clip (intervening). |
| 5969 // So, it should not be clipped (their bounds would no longer be reliable). | 5967 // So, it should not be clipped (their bounds would no longer be reliable). |
| 5970 // We should resort to layer clipping in this case. | 5968 // We should resort to layer clipping in this case. |
| 5971 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5969 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 5972 render_surface2->GetRenderSurface()->clip_rect()); | 5970 GetRenderSurface(render_surface2)->clip_rect()); |
| 5973 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped()); | 5971 EXPECT_FALSE(GetRenderSurface(render_surface2)->is_clipped()); |
| 5974 // This value is inherited from the clipping ancestor layer, 'intervening'. | 5972 // This value is inherited from the clipping ancestor layer, 'intervening'. |
| 5975 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); | 5973 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); |
| 5976 EXPECT_TRUE(render_surface2->is_clipped()); | 5974 EXPECT_TRUE(render_surface2->is_clipped()); |
| 5977 | 5975 |
| 5978 // The content rects of render_surface2 should have expanded to contain the | 5976 // The content rects of render_surface2 should have expanded to contain the |
| 5979 // clip child. | 5977 // clip child. |
| 5980 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), | 5978 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), |
| 5981 render_surface1->GetRenderSurface()->content_rect()); | 5979 GetRenderSurface(render_surface1)->content_rect()); |
| 5982 EXPECT_EQ(gfx::Rect(-10, -10, 60, 60), | 5980 EXPECT_EQ(gfx::Rect(-10, -10, 60, 60), |
| 5983 render_surface2->GetRenderSurface()->content_rect()); | 5981 GetRenderSurface(render_surface2)->content_rect()); |
| 5984 | 5982 |
| 5985 // The clip child should have inherited the clip parent's clip (projected to | 5983 // The clip child should have inherited the clip parent's clip (projected to |
| 5986 // the right space, of course), but as render_surface1 already applies that | 5984 // the right space, of course), but as render_surface1 already applies that |
| 5987 // clip, clip_child need not apply it again. | 5985 // clip, clip_child need not apply it again. |
| 5988 EXPECT_EQ(gfx::Rect(), clip_child->clip_rect()); | 5986 EXPECT_EQ(gfx::Rect(), clip_child->clip_rect()); |
| 5989 EXPECT_EQ(gfx::Rect(12, 12, 40, 40), clip_child->visible_layer_rect()); | 5987 EXPECT_EQ(gfx::Rect(12, 12, 40, 40), clip_child->visible_layer_rect()); |
| 5990 EXPECT_FALSE(clip_child->is_clipped()); | 5988 EXPECT_FALSE(clip_child->is_clipped()); |
| 5991 } | 5989 } |
| 5992 | 5990 |
| 5993 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { | 5991 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6015 root->SetBounds(gfx::Size(50, 50)); | 6013 root->SetBounds(gfx::Size(50, 50)); |
| 6016 clip_parent->SetBounds(gfx::Size(40, 40)); | 6014 clip_parent->SetBounds(gfx::Size(40, 40)); |
| 6017 clip_parent->SetMasksToBounds(true); | 6015 clip_parent->SetMasksToBounds(true); |
| 6018 intervening->SetBounds(gfx::Size(5, 5)); | 6016 intervening->SetBounds(gfx::Size(5, 5)); |
| 6019 intervening->SetMasksToBounds(true); | 6017 intervening->SetMasksToBounds(true); |
| 6020 clip_child->SetBounds(gfx::Size(60, 60)); | 6018 clip_child->SetBounds(gfx::Size(60, 60)); |
| 6021 child->SetBounds(gfx::Size(60, 60)); | 6019 child->SetBounds(gfx::Size(60, 60)); |
| 6022 | 6020 |
| 6023 ExecuteCalculateDrawProperties(root); | 6021 ExecuteCalculateDrawProperties(root); |
| 6024 | 6022 |
| 6025 EXPECT_TRUE(root->GetRenderSurface()); | 6023 EXPECT_TRUE(GetRenderSurface(root)); |
| 6026 | 6024 |
| 6027 // Neither the clip child nor its descendant should have inherited the clip | 6025 // Neither the clip child nor its descendant should have inherited the clip |
| 6028 // from |intervening|. | 6026 // from |intervening|. |
| 6029 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), clip_child->clip_rect()); | 6027 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), clip_child->clip_rect()); |
| 6030 EXPECT_TRUE(clip_child->is_clipped()); | 6028 EXPECT_TRUE(clip_child->is_clipped()); |
| 6031 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), child->visible_layer_rect()); | 6029 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), child->visible_layer_rect()); |
| 6032 EXPECT_TRUE(child->is_clipped()); | 6030 EXPECT_TRUE(child->is_clipped()); |
| 6033 } | 6031 } |
| 6034 | 6032 |
| 6035 TEST_F(LayerTreeHostCommonTest, | 6033 TEST_F(LayerTreeHostCommonTest, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6074 render_surface1->SetBounds(gfx::Size(5, 5)); | 6072 render_surface1->SetBounds(gfx::Size(5, 5)); |
| 6075 render_surface1->test_properties()->force_render_surface = true; | 6073 render_surface1->test_properties()->force_render_surface = true; |
| 6076 render_surface2->SetBounds(gfx::Size(5, 5)); | 6074 render_surface2->SetBounds(gfx::Size(5, 5)); |
| 6077 render_surface2->test_properties()->force_render_surface = true; | 6075 render_surface2->test_properties()->force_render_surface = true; |
| 6078 clip_child->SetPosition(gfx::PointF(-1, 1)); | 6076 clip_child->SetPosition(gfx::PointF(-1, 1)); |
| 6079 clip_child->SetBounds(gfx::Size(10, 10)); | 6077 clip_child->SetBounds(gfx::Size(10, 10)); |
| 6080 non_clip_child->SetBounds(gfx::Size(5, 5)); | 6078 non_clip_child->SetBounds(gfx::Size(5, 5)); |
| 6081 | 6079 |
| 6082 ExecuteCalculateDrawProperties(root); | 6080 ExecuteCalculateDrawProperties(root); |
| 6083 | 6081 |
| 6084 EXPECT_TRUE(root->GetRenderSurface()); | 6082 EXPECT_TRUE(GetRenderSurface(root)); |
| 6085 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 6083 EXPECT_TRUE(GetRenderSurface(render_surface1)); |
| 6086 EXPECT_TRUE(render_surface2->GetRenderSurface()); | 6084 EXPECT_TRUE(GetRenderSurface(render_surface2)); |
| 6087 | 6085 |
| 6088 EXPECT_EQ(gfx::Rect(-5, -5, 10, 10), render_surface1->clip_rect()); | 6086 EXPECT_EQ(gfx::Rect(-5, -5, 10, 10), render_surface1->clip_rect()); |
| 6089 EXPECT_TRUE(render_surface1->is_clipped()); | 6087 EXPECT_TRUE(render_surface1->is_clipped()); |
| 6090 | 6088 |
| 6091 // The render surface should not clip (it has unclipped descendants), instead | 6089 // The render surface should not clip (it has unclipped descendants), instead |
| 6092 // it should rely on layer clipping. | 6090 // it should rely on layer clipping. |
| 6093 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 6091 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 6094 render_surface1->GetRenderSurface()->clip_rect()); | 6092 GetRenderSurface(render_surface1)->clip_rect()); |
| 6095 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped()); | 6093 EXPECT_FALSE(GetRenderSurface(render_surface1)->is_clipped()); |
| 6096 | 6094 |
| 6097 // That said, it should have grown to accomodate the unclipped descendant and | 6095 // That said, it should have grown to accomodate the unclipped descendant and |
| 6098 // its own size. | 6096 // its own size. |
| 6099 EXPECT_EQ(gfx::Rect(-1, 0, 6, 5), | 6097 EXPECT_EQ(gfx::Rect(-1, 0, 6, 5), |
| 6100 render_surface1->GetRenderSurface()->content_rect()); | 6098 GetRenderSurface(render_surface1)->content_rect()); |
| 6101 | 6099 |
| 6102 // This render surface should clip. It has no unclipped descendants. | 6100 // This render surface should clip. It has no unclipped descendants. |
| 6103 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), | 6101 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), |
| 6104 render_surface2->GetRenderSurface()->clip_rect()); | 6102 GetRenderSurface(render_surface2)->clip_rect()); |
| 6105 EXPECT_TRUE(render_surface2->GetRenderSurface()->is_clipped()); | 6103 EXPECT_TRUE(GetRenderSurface(render_surface2)->is_clipped()); |
| 6106 EXPECT_FALSE(render_surface2->is_clipped()); | 6104 EXPECT_FALSE(render_surface2->is_clipped()); |
| 6107 | 6105 |
| 6108 // It also shouldn't have grown to accomodate the clip child. | 6106 // It also shouldn't have grown to accomodate the clip child. |
| 6109 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), | 6107 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), |
| 6110 render_surface2->GetRenderSurface()->content_rect()); | 6108 GetRenderSurface(render_surface2)->content_rect()); |
| 6111 } | 6109 } |
| 6112 | 6110 |
| 6113 TEST_F(LayerTreeHostCommonTest, | 6111 TEST_F(LayerTreeHostCommonTest, |
| 6114 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { | 6112 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { |
| 6115 // Verifies that Render Surfaces are created at the edge of rendering context. | 6113 // Verifies that Render Surfaces are created at the edge of rendering context. |
| 6116 | 6114 |
| 6117 LayerImpl* root = root_layer_for_testing(); | 6115 LayerImpl* root = root_layer_for_testing(); |
| 6118 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); | 6116 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); |
| 6119 LayerImpl* child2 = AddChild<LayerImpl>(child1); | 6117 LayerImpl* child2 = AddChild<LayerImpl>(child1); |
| 6120 LayerImpl* child3 = AddChild<LayerImpl>(child2); | 6118 LayerImpl* child3 = AddChild<LayerImpl>(child2); |
| 6121 root->SetDrawsContent(true); | 6119 root->SetDrawsContent(true); |
| 6122 | 6120 |
| 6123 gfx::Size bounds(100, 100); | 6121 gfx::Size bounds(100, 100); |
| 6124 | 6122 |
| 6125 root->SetBounds(bounds); | 6123 root->SetBounds(bounds); |
| 6126 child1->SetBounds(bounds); | 6124 child1->SetBounds(bounds); |
| 6127 child1->SetDrawsContent(true); | 6125 child1->SetDrawsContent(true); |
| 6128 child1->test_properties()->should_flatten_transform = false; | 6126 child1->test_properties()->should_flatten_transform = false; |
| 6129 child1->test_properties()->sorting_context_id = 1; | 6127 child1->test_properties()->sorting_context_id = 1; |
| 6130 child2->SetBounds(bounds); | 6128 child2->SetBounds(bounds); |
| 6131 child2->SetDrawsContent(true); | 6129 child2->SetDrawsContent(true); |
| 6132 child2->test_properties()->sorting_context_id = 1; | 6130 child2->test_properties()->sorting_context_id = 1; |
| 6133 child3->SetBounds(bounds); | 6131 child3->SetBounds(bounds); |
| 6134 child3->SetDrawsContent(true); | 6132 child3->SetDrawsContent(true); |
| 6135 child3->test_properties()->sorting_context_id = 1; | 6133 child3->test_properties()->sorting_context_id = 1; |
| 6136 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 6134 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
| 6137 | 6135 |
| 6138 // Verify which render surfaces were created. | 6136 // Verify which render surfaces were created. |
| 6139 EXPECT_TRUE(root->GetRenderSurface()); | 6137 EXPECT_TRUE(GetRenderSurface(root)); |
| 6140 EXPECT_FALSE(child1->GetRenderSurface()); | 6138 EXPECT_FALSE(GetRenderSurface(child1)); |
| 6141 EXPECT_TRUE(child2->GetRenderSurface()); | 6139 EXPECT_TRUE(GetRenderSurface(child2)); |
| 6142 EXPECT_FALSE(child3->GetRenderSurface()); | 6140 EXPECT_FALSE(GetRenderSurface(child3)); |
| 6143 } | 6141 } |
| 6144 | 6142 |
| 6145 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { | 6143 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { |
| 6146 FakeImplTaskRunnerProvider task_runner_provider; | 6144 FakeImplTaskRunnerProvider task_runner_provider; |
| 6147 TestTaskGraphRunner task_graph_runner; | 6145 TestTaskGraphRunner task_graph_runner; |
| 6148 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 6146 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 6149 | 6147 |
| 6150 std::unique_ptr<LayerImpl> root = | 6148 std::unique_ptr<LayerImpl> root = |
| 6151 LayerImpl::Create(host_impl.active_tree(), 12345); | 6149 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 6152 std::unique_ptr<LayerImpl> child1 = | 6150 std::unique_ptr<LayerImpl> child1 = |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6455 base::MakeUnique<std::set<LayerImpl*>>(); | 6453 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6456 scroll_parent->test_properties()->scroll_children->insert(scroll_child); | 6454 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6457 | 6455 |
| 6458 root->SetBounds(gfx::Size(50, 50)); | 6456 root->SetBounds(gfx::Size(50, 50)); |
| 6459 scroll_parent_border->SetBounds(gfx::Size(40, 40)); | 6457 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6460 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); | 6458 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6461 scroll_parent->SetBounds(gfx::Size(50, 50)); | 6459 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6462 scroll_child->SetBounds(gfx::Size(50, 50)); | 6460 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6463 ExecuteCalculateDrawProperties(root); | 6461 ExecuteCalculateDrawProperties(root); |
| 6464 | 6462 |
| 6465 EXPECT_TRUE(root->GetRenderSurface()); | 6463 EXPECT_TRUE(GetRenderSurface(root)); |
| 6466 | 6464 |
| 6467 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); | 6465 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); |
| 6468 EXPECT_TRUE(scroll_child->is_clipped()); | 6466 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6469 } | 6467 } |
| 6470 | 6468 |
| 6471 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { | 6469 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { |
| 6472 // Tests the computation of draw transform for the scroll child when its | 6470 // Tests the computation of draw transform for the scroll child when its |
| 6473 // target is different from its scroll parent's target. | 6471 // target is different from its scroll parent's target. |
| 6474 LayerImpl* root = root_layer_for_testing(); | 6472 LayerImpl* root = root_layer_for_testing(); |
| 6475 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); | 6473 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6582 scroll_parent->SetBounds(gfx::Size(50, 50)); | 6580 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6583 scroll_child->SetBounds(gfx::Size(50, 50)); | 6581 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6584 | 6582 |
| 6585 scroll_child->test_properties()->scroll_parent = scroll_parent; | 6583 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 6586 scroll_parent->test_properties()->scroll_children = | 6584 scroll_parent->test_properties()->scroll_children = |
| 6587 base::MakeUnique<std::set<LayerImpl*>>(); | 6585 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6588 scroll_parent->test_properties()->scroll_children->insert(scroll_child); | 6586 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6589 | 6587 |
| 6590 ExecuteCalculateDrawProperties(root); | 6588 ExecuteCalculateDrawProperties(root); |
| 6591 | 6589 |
| 6592 EXPECT_TRUE(root->GetRenderSurface()); | 6590 EXPECT_TRUE(GetRenderSurface(root)); |
| 6593 | 6591 |
| 6594 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); | 6592 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); |
| 6595 EXPECT_TRUE(scroll_child->is_clipped()); | 6593 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6596 } | 6594 } |
| 6597 | 6595 |
| 6598 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { | 6596 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { |
| 6599 // Checks that clipping by a scroll parent and scroll grandparent that follow | 6597 // Checks that clipping by a scroll parent and scroll grandparent that follow |
| 6600 // you in paint order still results in correct clipping. | 6598 // you in paint order still results in correct clipping. |
| 6601 // | 6599 // |
| 6602 // + root | 6600 // + root |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6640 scroll_grandparent_border->SetBounds(gfx::Size(40, 40)); | 6638 scroll_grandparent_border->SetBounds(gfx::Size(40, 40)); |
| 6641 scroll_grandparent_clip->SetBounds(gfx::Size(20, 20)); | 6639 scroll_grandparent_clip->SetBounds(gfx::Size(20, 20)); |
| 6642 scroll_grandparent->SetBounds(gfx::Size(50, 50)); | 6640 scroll_grandparent->SetBounds(gfx::Size(50, 50)); |
| 6643 scroll_parent_border->SetBounds(gfx::Size(40, 40)); | 6641 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6644 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); | 6642 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6645 scroll_parent->SetBounds(gfx::Size(50, 50)); | 6643 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6646 scroll_child->SetBounds(gfx::Size(50, 50)); | 6644 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6647 | 6645 |
| 6648 ExecuteCalculateDrawProperties(root); | 6646 ExecuteCalculateDrawProperties(root); |
| 6649 | 6647 |
| 6650 EXPECT_TRUE(root->GetRenderSurface()); | 6648 EXPECT_TRUE(GetRenderSurface(root)); |
| 6651 | 6649 |
| 6652 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); | 6650 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); |
| 6653 EXPECT_TRUE(scroll_child->is_clipped()); | 6651 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6654 | 6652 |
| 6655 // Despite the fact that we visited the above layers out of order to get the | 6653 // Despite the fact that we visited the above layers out of order to get the |
| 6656 // correct clip, the layer lists should be unaffected. | 6654 // correct clip, the layer lists should be unaffected. |
| 6657 EXPECT_EQ(3, root->GetRenderSurface()->num_contributors()); | 6655 EXPECT_EQ(3, GetRenderSurface(root)->num_contributors()); |
| 6658 EXPECT_TRUE(scroll_child->contributes_to_drawn_render_surface()); | 6656 EXPECT_TRUE(scroll_child->contributes_to_drawn_render_surface()); |
| 6659 EXPECT_TRUE(scroll_parent->contributes_to_drawn_render_surface()); | 6657 EXPECT_TRUE(scroll_parent->contributes_to_drawn_render_surface()); |
| 6660 EXPECT_TRUE(scroll_grandparent->contributes_to_drawn_render_surface()); | 6658 EXPECT_TRUE(scroll_grandparent->contributes_to_drawn_render_surface()); |
| 6661 } | 6659 } |
| 6662 | 6660 |
| 6663 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { | 6661 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { |
| 6664 // Ensures that even if we visit layers out of order, we still produce a | 6662 // Ensures that even if we visit layers out of order, we still produce a |
| 6665 // correctly ordered render surface layer list. | 6663 // correctly ordered render surface layer list. |
| 6666 // + root | 6664 // + root |
| 6667 // + scroll_child | 6665 // + scroll_child |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6717 render_surface1->test_properties()->force_render_surface = true; | 6715 render_surface1->test_properties()->force_render_surface = true; |
| 6718 scroll_parent_border->SetBounds(gfx::Size(40, 40)); | 6716 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6719 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); | 6717 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6720 scroll_parent->SetBounds(gfx::Size(50, 50)); | 6718 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6721 render_surface2->SetBounds(gfx::Size(50, 50)); | 6719 render_surface2->SetBounds(gfx::Size(50, 50)); |
| 6722 render_surface2->test_properties()->force_render_surface = true; | 6720 render_surface2->test_properties()->force_render_surface = true; |
| 6723 scroll_child->SetBounds(gfx::Size(50, 50)); | 6721 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6724 | 6722 |
| 6725 ExecuteCalculateDrawProperties(root); | 6723 ExecuteCalculateDrawProperties(root); |
| 6726 | 6724 |
| 6727 EXPECT_TRUE(root->GetRenderSurface()); | 6725 EXPECT_TRUE(GetRenderSurface(root)); |
| 6728 | 6726 |
| 6729 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); | 6727 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); |
| 6730 EXPECT_TRUE(scroll_child->is_clipped()); | 6728 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6731 | 6729 |
| 6732 // Despite the fact that we had to process the layers out of order to get the | 6730 // Despite the fact that we had to process the layers out of order to get the |
| 6733 // right clip, our render_surface_list's order should be unaffected. | 6731 // right clip, our render_surface_list's order should be unaffected. |
| 6734 EXPECT_EQ(3u, render_surface_list_impl()->size()); | 6732 EXPECT_EQ(3u, render_surface_list_impl()->size()); |
| 6735 EXPECT_EQ(root->GetRenderSurface(), render_surface_list_impl()->at(0)); | 6733 EXPECT_EQ(GetRenderSurface(root), render_surface_list_impl()->at(0)); |
| 6736 EXPECT_EQ(render_surface2->GetRenderSurface(), | 6734 EXPECT_EQ(GetRenderSurface(render_surface2), |
| 6737 render_surface_list_impl()->at(1)); | 6735 render_surface_list_impl()->at(1)); |
| 6738 EXPECT_EQ(render_surface1->GetRenderSurface(), | 6736 EXPECT_EQ(GetRenderSurface(render_surface1), |
| 6739 render_surface_list_impl()->at(2)); | 6737 render_surface_list_impl()->at(2)); |
| 6740 } | 6738 } |
| 6741 | 6739 |
| 6742 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) { | 6740 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) { |
| 6743 // Ensures that when we have a render surface between a fixed position layer | 6741 // Ensures that when we have a render surface between a fixed position layer |
| 6744 // and its container, we compute the fixed position layer's draw transform | 6742 // and its container, we compute the fixed position layer's draw transform |
| 6745 // with respect to that intervening render surface, not with respect to its | 6743 // with respect to that intervening render surface, not with respect to its |
| 6746 // container's render target. | 6744 // container's render target. |
| 6747 // | 6745 // |
| 6748 // + root | 6746 // + root |
| (...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9110 child->SetDrawsContent(true); | 9108 child->SetDrawsContent(true); |
| 9111 grandchild->SetBounds(gfx::Size(50, 50)); | 9109 grandchild->SetBounds(gfx::Size(50, 50)); |
| 9112 grandchild->SetDrawsContent(true); | 9110 grandchild->SetDrawsContent(true); |
| 9113 | 9111 |
| 9114 SetElementIdsForTesting(); | 9112 SetElementIdsForTesting(); |
| 9115 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), | 9113 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), |
| 9116 10.0, 1.f, 0.2f, false); | 9114 10.0, 1.f, 0.2f, false); |
| 9117 ExecuteCalculateDrawProperties(root); | 9115 ExecuteCalculateDrawProperties(root); |
| 9118 | 9116 |
| 9119 EXPECT_EQ(1.f, child->Opacity()); | 9117 EXPECT_EQ(1.f, child->Opacity()); |
| 9120 EXPECT_TRUE(root->GetRenderSurface()); | 9118 EXPECT_TRUE(GetRenderSurface(root)); |
| 9121 EXPECT_TRUE(child->GetRenderSurface()); | 9119 EXPECT_TRUE(GetRenderSurface(child)); |
| 9122 EXPECT_FALSE(grandchild->GetRenderSurface()); | 9120 EXPECT_FALSE(GetRenderSurface(grandchild)); |
| 9123 } | 9121 } |
| 9124 | 9122 |
| 9125 // Verify that having an animated filter (but no current filter, as these | 9123 // Verify that having an animated filter (but no current filter, as these |
| 9126 // are mutually exclusive) correctly creates a render surface. | 9124 // are mutually exclusive) correctly creates a render surface. |
| 9127 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { | 9125 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
| 9128 LayerImpl* root = root_layer_for_testing(); | 9126 LayerImpl* root = root_layer_for_testing(); |
| 9129 LayerImpl* child = AddChild<LayerImpl>(root); | 9127 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9130 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 9128 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 9131 | 9129 |
| 9132 root->SetBounds(gfx::Size(50, 50)); | 9130 root->SetBounds(gfx::Size(50, 50)); |
| 9133 child->SetBounds(gfx::Size(50, 50)); | 9131 child->SetBounds(gfx::Size(50, 50)); |
| 9134 grandchild->SetBounds(gfx::Size(50, 50)); | 9132 grandchild->SetBounds(gfx::Size(50, 50)); |
| 9135 | 9133 |
| 9136 SetElementIdsForTesting(); | 9134 SetElementIdsForTesting(); |
| 9137 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), | 9135 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), |
| 9138 10.0, 0.1f, 0.2f); | 9136 10.0, 0.1f, 0.2f); |
| 9139 ExecuteCalculateDrawProperties(root); | 9137 ExecuteCalculateDrawProperties(root); |
| 9140 | 9138 |
| 9141 EXPECT_TRUE(root->GetRenderSurface()); | 9139 EXPECT_TRUE(GetRenderSurface(root)); |
| 9142 EXPECT_TRUE(child->GetRenderSurface()); | 9140 EXPECT_TRUE(GetRenderSurface(child)); |
| 9143 EXPECT_FALSE(grandchild->GetRenderSurface()); | 9141 EXPECT_FALSE(GetRenderSurface(grandchild)); |
| 9144 | 9142 |
| 9145 EXPECT_TRUE(root->GetRenderSurface()->Filters().IsEmpty()); | 9143 EXPECT_TRUE(GetRenderSurface(root)->Filters().IsEmpty()); |
| 9146 EXPECT_TRUE(child->GetRenderSurface()->Filters().IsEmpty()); | 9144 EXPECT_TRUE(GetRenderSurface(child)->Filters().IsEmpty()); |
| 9147 | 9145 |
| 9148 EXPECT_FALSE(root->FilterIsAnimating()); | 9146 EXPECT_FALSE(root->FilterIsAnimating()); |
| 9149 EXPECT_TRUE(child->FilterIsAnimating()); | 9147 EXPECT_TRUE(child->FilterIsAnimating()); |
| 9150 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 9148 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
| 9151 } | 9149 } |
| 9152 | 9150 |
| 9153 // Verify that having a filter animation with a delayed start time creates a | 9151 // Verify that having a filter animation with a delayed start time creates a |
| 9154 // render surface. | 9152 // render surface. |
| 9155 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { | 9153 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { |
| 9156 LayerImpl* root = root_layer_for_testing(); | 9154 LayerImpl* root = root_layer_for_testing(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9175 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); | 9173 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); |
| 9176 std::unique_ptr<Animation> animation = | 9174 std::unique_ptr<Animation> animation = |
| 9177 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); | 9175 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); |
| 9178 animation->set_fill_mode(Animation::FillMode::NONE); | 9176 animation->set_fill_mode(Animation::FillMode::NONE); |
| 9179 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9177 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 9180 | 9178 |
| 9181 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), | 9179 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), |
| 9182 std::move(animation)); | 9180 std::move(animation)); |
| 9183 ExecuteCalculateDrawProperties(root); | 9181 ExecuteCalculateDrawProperties(root); |
| 9184 | 9182 |
| 9185 EXPECT_TRUE(root->GetRenderSurface()); | 9183 EXPECT_TRUE(GetRenderSurface(root)); |
| 9186 EXPECT_TRUE(child->GetRenderSurface()); | 9184 EXPECT_TRUE(GetRenderSurface(child)); |
| 9187 EXPECT_FALSE(grandchild->GetRenderSurface()); | 9185 EXPECT_FALSE(GetRenderSurface(grandchild)); |
| 9188 | 9186 |
| 9189 EXPECT_TRUE(root->GetRenderSurface()->Filters().IsEmpty()); | 9187 EXPECT_TRUE(GetRenderSurface(root)->Filters().IsEmpty()); |
| 9190 EXPECT_TRUE(child->GetRenderSurface()->Filters().IsEmpty()); | 9188 EXPECT_TRUE(GetRenderSurface(child)->Filters().IsEmpty()); |
| 9191 | 9189 |
| 9192 EXPECT_FALSE(root->FilterIsAnimating()); | 9190 EXPECT_FALSE(root->FilterIsAnimating()); |
| 9193 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); | 9191 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); |
| 9194 EXPECT_FALSE(child->FilterIsAnimating()); | 9192 EXPECT_FALSE(child->FilterIsAnimating()); |
| 9195 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); | 9193 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); |
| 9196 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 9194 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
| 9197 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); | 9195 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); |
| 9198 } | 9196 } |
| 9199 | 9197 |
| 9200 // Ensures that the property tree code accounts for offsets between fixed | 9198 // Ensures that the property tree code accounts for offsets between fixed |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9887 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, | 9885 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, |
| 9888 page_scale_layer, inner_viewport_scroll_layer, | 9886 page_scale_layer, inner_viewport_scroll_layer, |
| 9889 outer_viewport_scroll_layer); | 9887 outer_viewport_scroll_layer); |
| 9890 | 9888 |
| 9891 TransformTree& transform_tree = | 9889 TransformTree& transform_tree = |
| 9892 root->layer_tree_impl()->property_trees()->transform_tree; | 9890 root->layer_tree_impl()->property_trees()->transform_tree; |
| 9893 TransformNode* transform_node = | 9891 TransformNode* transform_node = |
| 9894 transform_tree.Node(significant_transform->transform_tree_index()); | 9892 transform_tree.Node(significant_transform->transform_tree_index()); |
| 9895 EXPECT_EQ(transform_node->owning_layer_id, significant_transform->id()); | 9893 EXPECT_EQ(transform_node->owning_layer_id, significant_transform->id()); |
| 9896 | 9894 |
| 9897 EXPECT_TRUE(root->GetRenderSurface()); | 9895 EXPECT_TRUE(GetRenderSurface(root)); |
| 9898 EXPECT_FALSE(significant_transform->GetRenderSurface()); | 9896 EXPECT_FALSE(GetRenderSurface(significant_transform)); |
| 9899 EXPECT_TRUE(layer_clips_subtree->GetRenderSurface()); | 9897 EXPECT_TRUE(GetRenderSurface(layer_clips_subtree)); |
| 9900 EXPECT_TRUE(render_surface->GetRenderSurface()); | 9898 EXPECT_TRUE(GetRenderSurface(render_surface)); |
| 9901 EXPECT_FALSE(test_layer->GetRenderSurface()); | 9899 EXPECT_FALSE(GetRenderSurface(test_layer)); |
| 9902 | 9900 |
| 9903 EXPECT_EQ(gfx::Rect(30, 20), test_layer->visible_layer_rect()); | 9901 EXPECT_EQ(gfx::Rect(30, 20), test_layer->visible_layer_rect()); |
| 9904 } | 9902 } |
| 9905 | 9903 |
| 9906 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { | 9904 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { |
| 9907 // Ensure that when parent clip node's transform is an ancestor of current | 9905 // Ensure that when parent clip node's transform is an ancestor of current |
| 9908 // clip node's target, clip is 'projected' from parent space to current | 9906 // clip node's target, clip is 'projected' from parent space to current |
| 9909 // target space and visible rects are calculated correctly. | 9907 // target space and visible rects are calculated correctly. |
| 9910 LayerImpl* root = root_layer_for_testing(); | 9908 LayerImpl* root = root_layer_for_testing(); |
| 9911 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 9909 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10097 clipped_surface->SetDrawsContent(true); | 10095 clipped_surface->SetDrawsContent(true); |
| 10098 clipped_surface->test_properties()->force_render_surface = true; | 10096 clipped_surface->test_properties()->force_render_surface = true; |
| 10099 | 10097 |
| 10100 clip_child->test_properties()->clip_parent = clip_parent; | 10098 clip_child->test_properties()->clip_parent = clip_parent; |
| 10101 clip_parent->test_properties()->clip_children = | 10099 clip_parent->test_properties()->clip_children = |
| 10102 base::MakeUnique<std::set<LayerImpl*>>(); | 10100 base::MakeUnique<std::set<LayerImpl*>>(); |
| 10103 clip_parent->test_properties()->clip_children->insert(clip_child); | 10101 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 10104 | 10102 |
| 10105 ExecuteCalculateDrawProperties(root); | 10103 ExecuteCalculateDrawProperties(root); |
| 10106 EXPECT_EQ(gfx::Rect(50, 50), | 10104 EXPECT_EQ(gfx::Rect(50, 50), |
| 10107 unclipped_surface->GetRenderSurface()->content_rect()); | 10105 GetRenderSurface(unclipped_surface)->content_rect()); |
| 10108 EXPECT_EQ(gfx::Rect(50, 50), | 10106 EXPECT_EQ(gfx::Rect(50, 50), |
| 10109 unclipped_desc_surface->GetRenderSurface()->content_rect()); | 10107 GetRenderSurface(unclipped_desc_surface)->content_rect()); |
| 10110 EXPECT_EQ(gfx::Rect(60, 60), | 10108 EXPECT_EQ(gfx::Rect(60, 60), |
| 10111 unclipped_desc_surface2->GetRenderSurface()->content_rect()); | 10109 GetRenderSurface(unclipped_desc_surface2)->content_rect()); |
| 10112 EXPECT_EQ(gfx::Rect(50, 50), | 10110 EXPECT_EQ(gfx::Rect(50, 50), |
| 10113 clipped_surface->GetRenderSurface()->content_rect()); | 10111 GetRenderSurface(clipped_surface)->content_rect()); |
| 10114 } | 10112 } |
| 10115 | 10113 |
| 10116 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { | 10114 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { |
| 10117 // Tests the value of render surface content rect when we have a layer that | 10115 // Tests the value of render surface content rect when we have a layer that |
| 10118 // clips between the clip parent's target and clip child's target. | 10116 // clips between the clip parent's target and clip child's target. |
| 10119 LayerImpl* root = root_layer_for_testing(); | 10117 LayerImpl* root = root_layer_for_testing(); |
| 10120 LayerImpl* surface = AddChildToRoot<LayerImpl>(); | 10118 LayerImpl* surface = AddChildToRoot<LayerImpl>(); |
| 10121 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); | 10119 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); |
| 10122 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | 10120 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 10123 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 10121 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 10145 clip_child->SetDrawsContent(true); | 10143 clip_child->SetDrawsContent(true); |
| 10146 | 10144 |
| 10147 clip_child->test_properties()->clip_parent = clip_parent; | 10145 clip_child->test_properties()->clip_parent = clip_parent; |
| 10148 clip_parent->test_properties()->clip_children = | 10146 clip_parent->test_properties()->clip_children = |
| 10149 base::MakeUnique<std::set<LayerImpl*>>(); | 10147 base::MakeUnique<std::set<LayerImpl*>>(); |
| 10150 clip_parent->test_properties()->clip_children->insert(clip_child); | 10148 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 10151 | 10149 |
| 10152 ExecuteCalculateDrawProperties(root); | 10150 ExecuteCalculateDrawProperties(root); |
| 10153 | 10151 |
| 10154 EXPECT_EQ(gfx::Rect(10, 10), | 10152 EXPECT_EQ(gfx::Rect(10, 10), |
| 10155 unclipped_desc_surface->GetRenderSurface()->content_rect()); | 10153 GetRenderSurface(unclipped_desc_surface)->content_rect()); |
| 10156 } | 10154 } |
| 10157 | 10155 |
| 10158 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) { | 10156 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) { |
| 10159 LayerImpl* root = root_layer_for_testing(); | 10157 LayerImpl* root = root_layer_for_testing(); |
| 10160 LayerImpl* surface = AddChildToRoot<LayerImpl>(); | 10158 LayerImpl* surface = AddChildToRoot<LayerImpl>(); |
| 10161 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); | 10159 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); |
| 10162 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | 10160 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 10163 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 10161 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| 10164 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | 10162 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); |
| 10165 | 10163 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10309 | 10307 |
| 10310 root->SetBounds(gfx::Size(30, 30)); | 10308 root->SetBounds(gfx::Size(30, 30)); |
| 10311 hidden->SetBounds(gfx::Size(30, 30)); | 10309 hidden->SetBounds(gfx::Size(30, 30)); |
| 10312 hidden->test_properties()->force_render_surface = true; | 10310 hidden->test_properties()->force_render_surface = true; |
| 10313 hidden->test_properties()->hide_layer_and_subtree = true; | 10311 hidden->test_properties()->hide_layer_and_subtree = true; |
| 10314 test->SetBounds(gfx::Size(30, 30)); | 10312 test->SetBounds(gfx::Size(30, 30)); |
| 10315 test->test_properties()->force_render_surface = true; | 10313 test->test_properties()->force_render_surface = true; |
| 10316 | 10314 |
| 10317 ExecuteCalculateDrawProperties(root); | 10315 ExecuteCalculateDrawProperties(root); |
| 10318 EXPECT_EQ(0.f, | 10316 EXPECT_EQ(0.f, |
| 10319 test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); | 10317 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); |
| 10320 | 10318 |
| 10321 hidden->test_properties()->hide_layer_and_subtree = false; | 10319 hidden->test_properties()->hide_layer_and_subtree = false; |
| 10322 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 10320 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 10323 ExecuteCalculateDrawProperties(root); | 10321 ExecuteCalculateDrawProperties(root); |
| 10324 EXPECT_EQ(1.f, | 10322 EXPECT_EQ(1.f, |
| 10325 test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); | 10323 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); |
| 10326 } | 10324 } |
| 10327 | 10325 |
| 10328 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 10326 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 10329 LayerImpl* root = root_layer_for_testing(); | 10327 LayerImpl* root = root_layer_for_testing(); |
| 10330 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 10328 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 10331 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); | 10329 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 10332 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 10330 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 10333 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 10331 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 10334 | 10332 |
| 10335 root->SetBounds(gfx::Size(30, 30)); | 10333 root->SetBounds(gfx::Size(30, 30)); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10503 // child has one, the large transform applied to child will result in NaNs in | 10501 // child has one, the large transform applied to child will result in NaNs in |
| 10504 // the draw_transform of the render_surface, thus make draw property updates | 10502 // the draw_transform of the render_surface, thus make draw property updates |
| 10505 // skip the child layer. We need further investigation into this to know | 10503 // skip the child layer. We need further investigation into this to know |
| 10506 // what exactly happens here. | 10504 // what exactly happens here. |
| 10507 child->test_properties()->transform = large_transform; | 10505 child->test_properties()->transform = large_transform; |
| 10508 child->SetBounds(gfx::Size(30, 30)); | 10506 child->SetBounds(gfx::Size(30, 30)); |
| 10509 | 10507 |
| 10510 ExecuteCalculateDrawProperties(root); | 10508 ExecuteCalculateDrawProperties(root); |
| 10511 | 10509 |
| 10512 EXPECT_EQ(gfx::RectF(), | 10510 EXPECT_EQ(gfx::RectF(), |
| 10513 render_surface1->GetRenderSurface()->DrawableContentRect()); | 10511 GetRenderSurface(render_surface1)->DrawableContentRect()); |
| 10514 | 10512 |
| 10515 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || | 10513 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || |
| 10516 std::isnan(child->DrawTransform().matrix().get(0, 0)); | 10514 std::isnan(child->DrawTransform().matrix().get(0, 0)); |
| 10517 EXPECT_TRUE(is_inf_or_nan); | 10515 EXPECT_TRUE(is_inf_or_nan); |
| 10518 | 10516 |
| 10519 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || | 10517 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || |
| 10520 std::isnan(child->DrawTransform().matrix().get(1, 1)); | 10518 std::isnan(child->DrawTransform().matrix().get(1, 1)); |
| 10521 EXPECT_TRUE(is_inf_or_nan); | 10519 EXPECT_TRUE(is_inf_or_nan); |
| 10522 | 10520 |
| 10523 // The root layer should be in the RenderSurfaceList. | 10521 // The root layer should be in the RenderSurfaceList. |
| 10524 const auto* rsl = render_surface_list_impl(); | 10522 const auto* rsl = render_surface_list_impl(); |
| 10525 EXPECT_NE(std::find(rsl->begin(), rsl->end(), root->GetRenderSurface()), | 10523 EXPECT_NE(std::find(rsl->begin(), rsl->end(), GetRenderSurface(root)), |
| 10526 rsl->end()); | 10524 rsl->end()); |
| 10527 } | 10525 } |
| 10528 | 10526 |
| 10529 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { | 10527 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { |
| 10530 scoped_refptr<Layer> root = Layer::Create(); | 10528 scoped_refptr<Layer> root = Layer::Create(); |
| 10531 scoped_refptr<LayerWithForcedDrawsContent> child = | 10529 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 10532 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10530 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 10533 root->AddChild(child); | 10531 root->AddChild(child); |
| 10534 host()->SetRootLayer(root); | 10532 host()->SetRootLayer(root); |
| 10535 | 10533 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10893 render_surface->test_properties()->transform = transform; | 10891 render_surface->test_properties()->transform = transform; |
| 10894 | 10892 |
| 10895 child->SetDrawsContent(true); | 10893 child->SetDrawsContent(true); |
| 10896 child->SetMasksToBounds(true); | 10894 child->SetMasksToBounds(true); |
| 10897 child->SetBounds(gfx::Size(10, 10)); | 10895 child->SetBounds(gfx::Size(10, 10)); |
| 10898 | 10896 |
| 10899 ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales(root); | 10897 ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales(root); |
| 10900 | 10898 |
| 10901 // Check surface draw properties. | 10899 // Check surface draw properties. |
| 10902 EXPECT_EQ(gfx::Rect(10, 10), | 10900 EXPECT_EQ(gfx::Rect(10, 10), |
| 10903 render_surface->GetRenderSurface()->content_rect()); | 10901 GetRenderSurface(render_surface)->content_rect()); |
| 10904 EXPECT_EQ(transform, render_surface->GetRenderSurface()->draw_transform()); | 10902 EXPECT_EQ(transform, GetRenderSurface(render_surface)->draw_transform()); |
| 10905 EXPECT_EQ(gfx::RectF(50.0f, 50.0f), | 10903 EXPECT_EQ(gfx::RectF(50.0f, 50.0f), |
| 10906 render_surface->GetRenderSurface()->DrawableContentRect()); | 10904 GetRenderSurface(render_surface)->DrawableContentRect()); |
| 10907 | 10905 |
| 10908 // Check child layer draw properties. | 10906 // Check child layer draw properties. |
| 10909 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10907 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10910 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10908 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10911 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10909 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10912 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10910 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10913 } | 10911 } |
| 10914 | 10912 |
| 10915 } // namespace | 10913 } // namespace |
| 10916 } // namespace cc | 10914 } // namespace cc |
| OLD | NEW |