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

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

Issue 1921503005: cc: Move main thread hierarchy dependencies into PropertyTreeBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 false); 1105 false);
1106 grand_child->SetDrawsContent(true); 1106 grand_child->SetDrawsContent(true);
1107 1107
1108 // render_surface will have a sublayer scale because of device scale factor. 1108 // render_surface will have a sublayer scale because of device scale factor.
1109 float device_scale_factor = 2.0f; 1109 float device_scale_factor = 2.0f;
1110 LayerImplList render_surface_layer_list_impl; 1110 LayerImplList render_surface_layer_list_impl;
1111 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1111 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1112 root, root->bounds(), translate, &render_surface_layer_list_impl); 1112 root, root->bounds(), translate, &render_surface_layer_list_impl);
1113 inputs.device_scale_factor = device_scale_factor; 1113 inputs.device_scale_factor = device_scale_factor;
1114 inputs.property_trees->needs_rebuild = true; 1114 inputs.property_trees->needs_rebuild = true;
1115 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1115 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1116 1116
1117 // Between grand_child and render_surface, we translate by (10, 10) and scale 1117 // Between grand_child and render_surface, we translate by (10, 10) and scale
1118 // by a factor of 2. 1118 // by a factor of 2.
1119 gfx::Vector2dF expected_translation(20.0f, 20.0f); 1119 gfx::Vector2dF expected_translation(20.0f, 20.0f);
1120 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(), 1120 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(),
1121 expected_translation); 1121 expected_translation);
1122 } 1122 }
1123 1123
1124 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { 1124 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
1125 // Transformations applied at the root of the tree should be forwarded 1125 // Transformations applied at the root of the tree should be forwarded
(...skipping 13 matching lines...) Expand all
1139 gfx::PointF(), gfx::Size(20, 20), true, false, 1139 gfx::PointF(), gfx::Size(20, 20), true, false,
1140 false); 1140 false);
1141 1141
1142 gfx::Transform translate; 1142 gfx::Transform translate;
1143 translate.Translate(50, 50); 1143 translate.Translate(50, 50);
1144 { 1144 {
1145 LayerImplList render_surface_layer_list_impl; 1145 LayerImplList render_surface_layer_list_impl;
1146 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1146 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1147 root, root->bounds(), translate, &render_surface_layer_list_impl); 1147 root, root->bounds(), translate, &render_surface_layer_list_impl);
1148 inputs.property_trees->needs_rebuild = true; 1148 inputs.property_trees->needs_rebuild = true;
1149 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1149 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1150 EXPECT_EQ(translate, root->draw_properties().target_space_transform); 1150 EXPECT_EQ(translate, root->draw_properties().target_space_transform);
1151 EXPECT_EQ(translate, child->draw_properties().target_space_transform); 1151 EXPECT_EQ(translate, child->draw_properties().target_space_transform);
1152 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1152 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1153 } 1153 }
1154 1154
1155 gfx::Transform scale; 1155 gfx::Transform scale;
1156 scale.Scale(2, 2); 1156 scale.Scale(2, 2);
1157 { 1157 {
1158 LayerImplList render_surface_layer_list_impl; 1158 LayerImplList render_surface_layer_list_impl;
1159 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1159 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1160 root, root->bounds(), scale, &render_surface_layer_list_impl); 1160 root, root->bounds(), scale, &render_surface_layer_list_impl);
1161 inputs.property_trees->needs_rebuild = true; 1161 inputs.property_trees->needs_rebuild = true;
1162 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1162 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1163 EXPECT_EQ(scale, root->draw_properties().target_space_transform); 1163 EXPECT_EQ(scale, root->draw_properties().target_space_transform);
1164 EXPECT_EQ(scale, child->draw_properties().target_space_transform); 1164 EXPECT_EQ(scale, child->draw_properties().target_space_transform);
1165 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1165 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1166 } 1166 }
1167 1167
1168 gfx::Transform rotate; 1168 gfx::Transform rotate;
1169 rotate.Rotate(2); 1169 rotate.Rotate(2);
1170 { 1170 {
1171 LayerImplList render_surface_layer_list_impl; 1171 LayerImplList render_surface_layer_list_impl;
1172 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1172 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1173 root, root->bounds(), rotate, &render_surface_layer_list_impl); 1173 root, root->bounds(), rotate, &render_surface_layer_list_impl);
1174 inputs.property_trees->needs_rebuild = true; 1174 inputs.property_trees->needs_rebuild = true;
1175 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1175 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1176 EXPECT_EQ(rotate, root->draw_properties().target_space_transform); 1176 EXPECT_EQ(rotate, root->draw_properties().target_space_transform);
1177 EXPECT_EQ(rotate, child->draw_properties().target_space_transform); 1177 EXPECT_EQ(rotate, child->draw_properties().target_space_transform);
1178 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1178 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1179 } 1179 }
1180 1180
1181 gfx::Transform composite; 1181 gfx::Transform composite;
1182 composite.ConcatTransform(translate); 1182 composite.ConcatTransform(translate);
1183 composite.ConcatTransform(scale); 1183 composite.ConcatTransform(scale);
1184 composite.ConcatTransform(rotate); 1184 composite.ConcatTransform(rotate);
1185 { 1185 {
1186 LayerImplList render_surface_layer_list_impl; 1186 LayerImplList render_surface_layer_list_impl;
1187 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1187 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1188 root, root->bounds(), composite, &render_surface_layer_list_impl); 1188 root, root->bounds(), composite, &render_surface_layer_list_impl);
1189 inputs.property_trees->needs_rebuild = true; 1189 inputs.property_trees->needs_rebuild = true;
1190 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1190 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1191 EXPECT_EQ(composite, root->draw_properties().target_space_transform); 1191 EXPECT_EQ(composite, root->draw_properties().target_space_transform);
1192 EXPECT_EQ(composite, child->draw_properties().target_space_transform); 1192 EXPECT_EQ(composite, child->draw_properties().target_space_transform);
1193 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1193 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1194 } 1194 }
1195 1195
1196 // Verify it composes correctly with device scale. 1196 // Verify it composes correctly with device scale.
1197 float device_scale_factor = 1.5f; 1197 float device_scale_factor = 1.5f;
1198 1198
1199 { 1199 {
1200 LayerImplList render_surface_layer_list_impl; 1200 LayerImplList render_surface_layer_list_impl;
1201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1202 root, root->bounds(), translate, &render_surface_layer_list_impl); 1202 root, root->bounds(), translate, &render_surface_layer_list_impl);
1203 inputs.device_scale_factor = device_scale_factor; 1203 inputs.device_scale_factor = device_scale_factor;
1204 inputs.property_trees->needs_rebuild = true; 1204 inputs.property_trees->needs_rebuild = true;
1205 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1205 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1206 gfx::Transform device_scaled_translate = translate; 1206 gfx::Transform device_scaled_translate = translate;
1207 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); 1207 device_scaled_translate.Scale(device_scale_factor, device_scale_factor);
1208 EXPECT_EQ(device_scaled_translate, 1208 EXPECT_EQ(device_scaled_translate,
1209 root->draw_properties().target_space_transform); 1209 root->draw_properties().target_space_transform);
1210 EXPECT_EQ(device_scaled_translate, 1210 EXPECT_EQ(device_scaled_translate,
1211 child->draw_properties().target_space_transform); 1211 child->draw_properties().target_space_transform);
1212 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1212 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1213 } 1213 }
1214 1214
1215 // Verify it composes correctly with page scale. 1215 // Verify it composes correctly with page scale.
1216 float page_scale_factor = 2.f; 1216 float page_scale_factor = 2.f;
1217 1217
1218 { 1218 {
1219 LayerImplList render_surface_layer_list_impl; 1219 LayerImplList render_surface_layer_list_impl;
1220 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1220 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1221 root, root->bounds(), translate, &render_surface_layer_list_impl); 1221 root, root->bounds(), translate, &render_surface_layer_list_impl);
1222 inputs.page_scale_factor = page_scale_factor; 1222 inputs.page_scale_factor = page_scale_factor;
1223 inputs.page_scale_layer = root; 1223 inputs.page_scale_layer = root;
1224 inputs.property_trees->needs_rebuild = true; 1224 inputs.property_trees->needs_rebuild = true;
1225 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1225 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1226 gfx::Transform page_scaled_translate = translate; 1226 gfx::Transform page_scaled_translate = translate;
1227 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); 1227 page_scaled_translate.Scale(page_scale_factor, page_scale_factor);
1228 EXPECT_EQ(page_scaled_translate, 1228 EXPECT_EQ(page_scaled_translate,
1229 root->draw_properties().target_space_transform); 1229 root->draw_properties().target_space_transform);
1230 EXPECT_EQ(page_scaled_translate, 1230 EXPECT_EQ(page_scaled_translate,
1231 child->draw_properties().target_space_transform); 1231 child->draw_properties().target_space_transform);
1232 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1232 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1233 } 1233 }
1234 1234
1235 // Verify that it composes correctly with transforms directly on root layer. 1235 // Verify that it composes correctly with transforms directly on root layer.
1236 root->SetTransform(composite); 1236 root->SetTransform(composite);
1237 1237
1238 { 1238 {
1239 LayerImplList render_surface_layer_list_impl; 1239 LayerImplList render_surface_layer_list_impl;
1240 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1240 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1241 root, root->bounds(), composite, &render_surface_layer_list_impl); 1241 root, root->bounds(), composite, &render_surface_layer_list_impl);
1242 inputs.property_trees->needs_rebuild = true; 1242 inputs.property_trees->needs_rebuild = true;
1243 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1243 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1244 gfx::Transform compositeSquared = composite; 1244 gfx::Transform compositeSquared = composite;
1245 compositeSquared.ConcatTransform(composite); 1245 compositeSquared.ConcatTransform(composite);
1246 EXPECT_TRANSFORMATION_MATRIX_EQ( 1246 EXPECT_TRANSFORMATION_MATRIX_EQ(
1247 compositeSquared, root->draw_properties().target_space_transform); 1247 compositeSquared, root->draw_properties().target_space_transform);
1248 EXPECT_TRANSFORMATION_MATRIX_EQ( 1248 EXPECT_TRANSFORMATION_MATRIX_EQ(
1249 compositeSquared, child->draw_properties().target_space_transform); 1249 compositeSquared, child->draw_properties().target_space_transform);
1250 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1250 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1251 } 1251 }
1252 } 1252 }
1253 1253
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 true); 1293 true);
1294 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1294 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1295 gfx::PointF(), gfx::Size(10, 10), true, false, 1295 gfx::PointF(), gfx::Size(10, 10), true, false,
1296 false); 1296 false);
1297 render_surface1->SetOpacity(0.f); 1297 render_surface1->SetOpacity(0.f);
1298 1298
1299 LayerImplList render_surface_layer_list; 1299 LayerImplList render_surface_layer_list;
1300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1301 parent, parent->bounds(), &render_surface_layer_list); 1301 parent, parent->bounds(), &render_surface_layer_list);
1302 inputs.can_adjust_raster_scales = true; 1302 inputs.can_adjust_raster_scales = true;
1303 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1303 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1304 1304
1305 // Since the layer is transparent, render_surface1->render_surface() should 1305 // Since the layer is transparent, render_surface1->render_surface() should
1306 // not have gotten added anywhere. Also, the drawable content rect should not 1306 // not have gotten added anywhere. Also, the drawable content rect should not
1307 // have been extended by the children. 1307 // have been extended by the children.
1308 ASSERT_TRUE(parent->render_surface()); 1308 ASSERT_TRUE(parent->render_surface());
1309 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); 1309 EXPECT_EQ(0U, parent->render_surface()->layer_list().size());
1310 EXPECT_EQ(1U, render_surface_layer_list.size()); 1310 EXPECT_EQ(1U, render_surface_layer_list.size());
1311 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 1311 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
1312 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); 1312 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect());
1313 } 1313 }
(...skipping 20 matching lines...) Expand all
1334 child->SetDrawsContent(true); 1334 child->SetDrawsContent(true);
1335 FilterOperations filters; 1335 FilterOperations filters;
1336 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); 1336 filters.Append(FilterOperation::CreateBlurFilter(1.5f));
1337 render_surface1->SetBackgroundFilters(filters); 1337 render_surface1->SetBackgroundFilters(filters);
1338 1338
1339 { 1339 {
1340 LayerImplList render_surface_layer_list; 1340 LayerImplList render_surface_layer_list;
1341 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1341 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1342 parent, parent->bounds(), &render_surface_layer_list); 1342 parent, parent->bounds(), &render_surface_layer_list);
1343 inputs.can_adjust_raster_scales = true; 1343 inputs.can_adjust_raster_scales = true;
1344 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1344 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1345 EXPECT_EQ(2U, render_surface_layer_list.size()); 1345 EXPECT_EQ(2U, render_surface_layer_list.size());
1346 } 1346 }
1347 // The layer is fully transparent, but has a background filter, so it 1347 // The layer is fully transparent, but has a background filter, so it
1348 // shouldn't be skipped and should be drawn. 1348 // shouldn't be skipped and should be drawn.
1349 ASSERT_TRUE(parent->render_surface()); 1349 ASSERT_TRUE(parent->render_surface());
1350 EXPECT_EQ(1U, parent->render_surface()->layer_list().size()); 1350 EXPECT_EQ(1U, parent->render_surface()->layer_list().size());
1351 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), 1351 EXPECT_EQ(gfx::RectF(0, 0, 10, 10),
1352 parent->render_surface()->DrawableContentRect()); 1352 parent->render_surface()->DrawableContentRect());
1353 EffectTree& effect_tree = 1353 EffectTree& effect_tree =
1354 parent->layer_tree_impl()->property_trees()->effect_tree; 1354 parent->layer_tree_impl()->property_trees()->effect_tree;
1355 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); 1355 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index());
1356 EXPECT_TRUE(node->data.is_drawn); 1356 EXPECT_TRUE(node->data.is_drawn);
1357 1357
1358 // When parent is transparent, the layer should not be drawn. 1358 // When parent is transparent, the layer should not be drawn.
1359 parent->OnOpacityAnimated(0.f); 1359 parent->OnOpacityAnimated(0.f);
1360 render_surface1->OnOpacityAnimated(1.f); 1360 render_surface1->OnOpacityAnimated(1.f);
1361 render_surface1->set_visible_layer_rect(gfx::Rect()); 1361 render_surface1->set_visible_layer_rect(gfx::Rect());
1362 { 1362 {
1363 LayerImplList render_surface_layer_list; 1363 LayerImplList render_surface_layer_list;
1364 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1364 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1365 parent, parent->bounds(), &render_surface_layer_list); 1365 parent, parent->bounds(), &render_surface_layer_list);
1366 inputs.can_adjust_raster_scales = true; 1366 inputs.can_adjust_raster_scales = true;
1367 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1367 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1368 } 1368 }
1369 1369
1370 node = effect_tree.Node(render_surface1->effect_tree_index()); 1370 node = effect_tree.Node(render_surface1->effect_tree_index());
1371 EXPECT_FALSE(node->data.is_drawn); 1371 EXPECT_FALSE(node->data.is_drawn);
1372 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect()); 1372 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect());
1373 } 1373 }
1374 1374
1375 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { 1375 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) {
1376 LayerImpl* root = root_layer(); 1376 LayerImpl* root = root_layer();
1377 LayerImpl* parent = AddChild<LayerImpl>(root); 1377 LayerImpl* parent = AddChild<LayerImpl>(root);
(...skipping 17 matching lines...) Expand all
1395 gfx::PointF(25, 25), gfx::Size(25, 25), true, 1395 gfx::PointF(25, 25), gfx::Size(25, 25), true,
1396 false, true); 1396 false, true);
1397 FilterOperations filters; 1397 FilterOperations filters;
1398 filters.Append(FilterOperation::CreateBlurFilter(10.0f)); 1398 filters.Append(FilterOperation::CreateBlurFilter(10.0f));
1399 parent->SetFilters(filters); 1399 parent->SetFilters(filters);
1400 1400
1401 LayerImplList render_surface_layer_list; 1401 LayerImplList render_surface_layer_list;
1402 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1402 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1403 root, root->bounds(), &render_surface_layer_list); 1403 root, root->bounds(), &render_surface_layer_list);
1404 inputs.can_adjust_raster_scales = true; 1404 inputs.can_adjust_raster_scales = true;
1405 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1405 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1406 1406
1407 ASSERT_TRUE(parent->render_surface()); 1407 ASSERT_TRUE(parent->render_surface());
1408 EXPECT_EQ(2U, parent->render_surface()->layer_list().size()); 1408 EXPECT_EQ(2U, parent->render_surface()->layer_list().size());
1409 EXPECT_EQ(4U, render_surface_layer_list.size()); 1409 EXPECT_EQ(4U, render_surface_layer_list.size());
1410 EXPECT_EQ(gfx::RectF(-29, -29, 158, 158), 1410 EXPECT_EQ(gfx::RectF(-29, -29, 158, 158),
1411 parent->render_surface()->DrawableContentRect()); 1411 parent->render_surface()->DrawableContentRect());
1412 } 1412 }
1413 1413
1414 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1414 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1415 LayerImpl* parent = root_layer(); 1415 LayerImpl* parent = root_layer();
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3431 false, false); 3431 false, false);
3432 SetLayerPropertiesForTesting(child3, identity_matrix, gfx::Point3F(), 3432 SetLayerPropertiesForTesting(child3, identity_matrix, gfx::Point3F(),
3433 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), 3433 gfx::PointF(125.f, 125.f), gfx::Size(50, 50),
3434 true, false, false); 3434 true, false, false);
3435 3435
3436 LayerImplList render_surface_layer_list_impl; 3436 LayerImplList render_surface_layer_list_impl;
3437 // Now set the root render surface an empty clip. 3437 // Now set the root render surface an empty clip.
3438 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 3438 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
3439 root, gfx::Size(), &render_surface_layer_list_impl); 3439 root, gfx::Size(), &render_surface_layer_list_impl);
3440 3440
3441 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 3441 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
3442 ASSERT_TRUE(root->render_surface()); 3442 ASSERT_TRUE(root->render_surface());
3443 EXPECT_FALSE(root->is_clipped()); 3443 EXPECT_FALSE(root->is_clipped());
3444 3444
3445 gfx::Rect empty; 3445 gfx::Rect empty;
3446 EXPECT_EQ(empty, root->render_surface()->clip_rect()); 3446 EXPECT_EQ(empty, root->render_surface()->clip_rect());
3447 EXPECT_TRUE(root->render_surface()->is_clipped()); 3447 EXPECT_TRUE(root->render_surface()->is_clipped());
3448 3448
3449 // Visible content rect calculation will check if the target surface is 3449 // Visible content rect calculation will check if the target surface is
3450 // clipped or not. An empty clip rect does not indicate the render surface 3450 // clipped or not. An empty clip rect does not indicate the render surface
3451 // is unclipped. 3451 // is unclipped.
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 5194
5195 root->AddChild(std::move(child)); 5195 root->AddChild(std::move(child));
5196 root->SetHasRenderSurface(true); 5196 root->SetHasRenderSurface(true);
5197 LayerImpl* root_layer = root.get(); 5197 LayerImpl* root_layer = root.get();
5198 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5198 host_impl.pending_tree()->SetRootLayer(std::move(root));
5199 5199
5200 LayerImplList render_surface_layer_list; 5200 LayerImplList render_surface_layer_list;
5201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5202 root_layer, root_layer->bounds(), &render_surface_layer_list); 5202 root_layer, root_layer->bounds(), &render_surface_layer_list);
5203 inputs.can_adjust_raster_scales = true; 5203 inputs.can_adjust_raster_scales = true;
5204 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5204 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5205 5205
5206 // We should have one render surface and two layers. The child 5206 // We should have one render surface and two layers. The child
5207 // layer should be included even though it is transparent. 5207 // layer should be included even though it is transparent.
5208 ASSERT_EQ(1u, render_surface_layer_list.size()); 5208 ASSERT_EQ(1u, render_surface_layer_list.size());
5209 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5209 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5210 5210
5211 // If the root itself is hidden, the child should not be drawn even if it has 5211 // If the root itself is hidden, the child should not be drawn even if it has
5212 // an animating opacity. 5212 // an animating opacity.
5213 root_layer->SetOpacity(0.0f); 5213 root_layer->SetOpacity(0.0f);
5214 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5214 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5215 LayerImplList render_surface_layer_list2; 5215 LayerImplList render_surface_layer_list2;
5216 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( 5216 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2(
5217 root_layer, root_layer->bounds(), &render_surface_layer_list2); 5217 root_layer, root_layer->bounds(), &render_surface_layer_list2);
5218 inputs2.can_adjust_raster_scales = true; 5218 inputs2.can_adjust_raster_scales = true;
5219 LayerTreeHostCommon::CalculateDrawProperties(&inputs2); 5219 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2);
5220 5220
5221 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5221 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5222 EffectTree& tree = 5222 EffectTree& tree =
5223 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5223 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5224 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); 5224 EffectNode* node = tree.Node(child_ptr->effect_tree_index());
5225 EXPECT_FALSE(node->data.is_drawn); 5225 EXPECT_FALSE(node->data.is_drawn);
5226 5226
5227 // A layer should be drawn and it should contribute to drawn surface when 5227 // A layer should be drawn and it should contribute to drawn surface when
5228 // it has animating opacity even if it has opacity 0. 5228 // it has animating opacity even if it has opacity 0.
5229 root_layer->SetOpacity(1.0f); 5229 root_layer->SetOpacity(1.0f);
5230 child_ptr->SetOpacity(0.0f); 5230 child_ptr->SetOpacity(0.0f);
5231 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5231 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5232 LayerImplList render_surface_layer_list3; 5232 LayerImplList render_surface_layer_list3;
5233 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( 5233 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
5234 root_layer, root_layer->bounds(), &render_surface_layer_list3); 5234 root_layer, root_layer->bounds(), &render_surface_layer_list3);
5235 inputs3.can_adjust_raster_scales = true; 5235 inputs3.can_adjust_raster_scales = true;
5236 LayerTreeHostCommon::CalculateDrawProperties(&inputs3); 5236 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3);
5237 5237
5238 child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5238 child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5239 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; 5239 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree;
5240 node = tree.Node(child_ptr->effect_tree_index()); 5240 node = tree.Node(child_ptr->effect_tree_index());
5241 EXPECT_TRUE(node->data.is_drawn); 5241 EXPECT_TRUE(node->data.is_drawn);
5242 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); 5242 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index()));
5243 5243
5244 // But if the opacity of the layer remains 0 after activation, it should not 5244 // But if the opacity of the layer remains 0 after activation, it should not
5245 // be drawn. 5245 // be drawn.
5246 host_impl.ActivateSyncTree(); 5246 host_impl.ActivateSyncTree();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5524 5524
5525 child->AddChild(std::move(grand_child)); 5525 child->AddChild(std::move(grand_child));
5526 root->AddChild(std::move(child)); 5526 root->AddChild(std::move(child));
5527 root->SetHasRenderSurface(true); 5527 root->SetHasRenderSurface(true);
5528 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5528 host_impl.pending_tree()->SetRootLayer(std::move(root));
5529 5529
5530 LayerImplList render_surface_layer_list; 5530 LayerImplList render_surface_layer_list;
5531 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5531 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5532 root_layer, root_layer->bounds(), &render_surface_layer_list); 5532 root_layer, root_layer->bounds(), &render_surface_layer_list);
5533 inputs.can_adjust_raster_scales = true; 5533 inputs.can_adjust_raster_scales = true;
5534 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5534 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5535 5535
5536 // We should have one render surface and two layers. The grand child has 5536 // We should have one render surface and two layers. The grand child has
5537 // hidden itself. 5537 // hidden itself.
5538 ASSERT_EQ(1u, render_surface_layer_list.size()); 5538 ASSERT_EQ(1u, render_surface_layer_list.size());
5539 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5539 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5540 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id()); 5540 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id());
5541 EXPECT_EQ(2, root_layer->render_surface()->layer_list().at(1)->id()); 5541 EXPECT_EQ(2, root_layer->render_surface()->layer_list().at(1)->id());
5542 } 5542 }
5543 5543
5544 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { 5544 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
(...skipping 29 matching lines...) Expand all
5574 grand_child->SetDrawsContent(true); 5574 grand_child->SetDrawsContent(true);
5575 5575
5576 child->AddChild(std::move(grand_child)); 5576 child->AddChild(std::move(grand_child));
5577 root->AddChild(std::move(child)); 5577 root->AddChild(std::move(child));
5578 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5578 host_impl.pending_tree()->SetRootLayer(std::move(root));
5579 5579
5580 LayerImplList render_surface_layer_list; 5580 LayerImplList render_surface_layer_list;
5581 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5581 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5582 root_layer, root_layer->bounds(), &render_surface_layer_list); 5582 root_layer, root_layer->bounds(), &render_surface_layer_list);
5583 inputs.can_adjust_raster_scales = true; 5583 inputs.can_adjust_raster_scales = true;
5584 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5584 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5585 5585
5586 // We should have one render surface and one layers. The child has 5586 // We should have one render surface and one layers. The child has
5587 // hidden itself and the grand child. 5587 // hidden itself and the grand child.
5588 ASSERT_EQ(1u, render_surface_layer_list.size()); 5588 ASSERT_EQ(1u, render_surface_layer_list.size());
5589 ASSERT_EQ(1u, root_layer->render_surface()->layer_list().size()); 5589 ASSERT_EQ(1u, root_layer->render_surface()->layer_list().size());
5590 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id()); 5590 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id());
5591 } 5591 }
5592 5592
5593 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 5593 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
5594 5594
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5687 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; 5687 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests;
5688 copy_requests.push_back( 5688 copy_requests.push_back(
5689 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5689 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5690 copy_layer->PassCopyRequests(&copy_requests); 5690 copy_layer->PassCopyRequests(&copy_requests);
5691 EXPECT_TRUE(copy_layer->HasCopyRequest()); 5691 EXPECT_TRUE(copy_layer->HasCopyRequest());
5692 5692
5693 LayerImplList render_surface_layer_list; 5693 LayerImplList render_surface_layer_list;
5694 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5694 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5695 root_layer, root_layer->bounds(), &render_surface_layer_list); 5695 root_layer, root_layer->bounds(), &render_surface_layer_list);
5696 inputs.can_adjust_raster_scales = true; 5696 inputs.can_adjust_raster_scales = true;
5697 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5697 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5698 5698
5699 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0); 5699 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0);
5700 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); 5700 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0);
5701 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); 5701 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0);
5702 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); 5702 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0);
5703 5703
5704 // We should have four render surfaces, one for the root, one for the grand 5704 // We should have four render surfaces, one for the root, one for the grand
5705 // parent since it has opacity and two drawing descendants, one for the parent 5705 // parent since it has opacity and two drawing descendants, one for the parent
5706 // since it owns a surface, and one for the copy_layer. 5706 // since it owns a surface, and one for the copy_layer.
5707 ASSERT_EQ(4u, render_surface_layer_list.size()); 5707 ASSERT_EQ(4u, render_surface_layer_list.size());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5800 copy_layer->AddChild(std::move(copy_child)); 5800 copy_layer->AddChild(std::move(copy_child));
5801 copy_parent->AddChild(std::move(copy_layer)); 5801 copy_parent->AddChild(std::move(copy_layer));
5802 root->AddChild(std::move(copy_parent)); 5802 root->AddChild(std::move(copy_parent));
5803 5803
5804 LayerImplList render_surface_layer_list; 5804 LayerImplList render_surface_layer_list;
5805 LayerImpl* root_layer = root.get(); 5805 LayerImpl* root_layer = root.get();
5806 root_layer->layer_tree_impl()->SetRootLayer(std::move(root)); 5806 root_layer->layer_tree_impl()->SetRootLayer(std::move(root));
5807 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5807 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5808 root_layer, root_layer->bounds(), &render_surface_layer_list); 5808 root_layer, root_layer->bounds(), &render_surface_layer_list);
5809 inputs.can_adjust_raster_scales = true; 5809 inputs.can_adjust_raster_scales = true;
5810 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5810 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5811 5811
5812 // We should have two render surface, as the others are clipped out. 5812 // We should have two render surface, as the others are clipped out.
5813 ASSERT_EQ(2u, render_surface_layer_list.size()); 5813 ASSERT_EQ(2u, render_surface_layer_list.size());
5814 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5814 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5815 5815
5816 // The root render surface should only have 2 contributing layer, since the 5816 // The root render surface should only have 2 contributing layer, since the
5817 // other layers are empty/clipped away. 5817 // other layers are empty/clipped away.
5818 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5818 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5819 EXPECT_EQ(root_layer->id(), 5819 EXPECT_EQ(root_layer->id(),
5820 root_layer->render_surface()->layer_list().at(0)->id()); 5820 root_layer->render_surface()->layer_list().at(0)->id());
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
6322 root->AddChild(std::move(child1)); 6322 root->AddChild(std::move(child1));
6323 LayerImpl* root_layer = root.get(); 6323 LayerImpl* root_layer = root.get();
6324 root_layer->layer_tree_impl()->SetRootLayer(std::move(root)); 6324 root_layer->layer_tree_impl()->SetRootLayer(std::move(root));
6325 6325
6326 { 6326 {
6327 LayerImplList render_surface_layer_list; 6327 LayerImplList render_surface_layer_list;
6328 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer); 6328 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer);
6329 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6329 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6330 root_layer, root_layer->bounds(), &render_surface_layer_list); 6330 root_layer, root_layer->bounds(), &render_surface_layer_list);
6331 inputs.can_render_to_separate_surface = true; 6331 inputs.can_render_to_separate_surface = true;
6332 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6332 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6333 6333
6334 EXPECT_EQ(2u, render_surface_layer_list.size()); 6334 EXPECT_EQ(2u, render_surface_layer_list.size());
6335 6335
6336 int count_represents_target_render_surface = 0; 6336 int count_represents_target_render_surface = 0;
6337 int count_represents_contributing_render_surface = 0; 6337 int count_represents_contributing_render_surface = 0;
6338 int count_represents_itself = 0; 6338 int count_represents_itself = 0;
6339 LayerIterator end = LayerIterator::End(&render_surface_layer_list); 6339 LayerIterator end = LayerIterator::End(&render_surface_layer_list);
6340 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); 6340 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
6341 it != end; ++it) { 6341 it != end; ++it) {
6342 if (it.represents_target_render_surface()) 6342 if (it.represents_target_render_surface())
(...skipping 10 matching lines...) Expand all
6353 EXPECT_EQ(1, count_represents_contributing_render_surface); 6353 EXPECT_EQ(1, count_represents_contributing_render_surface);
6354 // All 4 layers represent itself. 6354 // All 4 layers represent itself.
6355 EXPECT_EQ(4, count_represents_itself); 6355 EXPECT_EQ(4, count_represents_itself);
6356 } 6356 }
6357 6357
6358 { 6358 {
6359 LayerImplList render_surface_layer_list; 6359 LayerImplList render_surface_layer_list;
6360 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6360 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6361 root_layer, root_layer->bounds(), &render_surface_layer_list); 6361 root_layer, root_layer->bounds(), &render_surface_layer_list);
6362 inputs.can_render_to_separate_surface = false; 6362 inputs.can_render_to_separate_surface = false;
6363 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6363 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6364 6364
6365 EXPECT_EQ(1u, render_surface_layer_list.size()); 6365 EXPECT_EQ(1u, render_surface_layer_list.size());
6366 6366
6367 int count_represents_target_render_surface = 0; 6367 int count_represents_target_render_surface = 0;
6368 int count_represents_contributing_render_surface = 0; 6368 int count_represents_contributing_render_surface = 0;
6369 int count_represents_itself = 0; 6369 int count_represents_itself = 0;
6370 LayerIterator end = LayerIterator::End(&render_surface_layer_list); 6370 LayerIterator end = LayerIterator::End(&render_surface_layer_list);
6371 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); 6371 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
6372 it != end; ++it) { 6372 it != end; ++it) {
6373 if (it.represents_target_render_surface()) 6373 if (it.represents_target_render_surface())
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
6643 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), 6643 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
6644 true, false, false); 6644 true, false, false);
6645 scroll_parent_target->SetMasksToBounds(true); 6645 scroll_parent_target->SetMasksToBounds(true);
6646 6646
6647 float device_scale_factor = 1.5f; 6647 float device_scale_factor = 1.5f;
6648 LayerImplList render_surface_layer_list_impl; 6648 LayerImplList render_surface_layer_list_impl;
6649 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6649 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6650 root, root->bounds(), identity_transform, 6650 root, root->bounds(), identity_transform,
6651 &render_surface_layer_list_impl); 6651 &render_surface_layer_list_impl);
6652 inputs.device_scale_factor = device_scale_factor; 6652 inputs.device_scale_factor = device_scale_factor;
6653 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6653 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6654 6654
6655 EXPECT_EQ(scroll_child->effect_tree_index(), 6655 EXPECT_EQ(scroll_child->effect_tree_index(),
6656 scroll_child_target->effect_tree_index()); 6656 scroll_child_target->effect_tree_index());
6657 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40)); 6657 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40));
6658 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75)); 6658 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75));
6659 gfx::Transform scale; 6659 gfx::Transform scale;
6660 scale.Scale(1.5f, 1.5f); 6660 scale.Scale(1.5f, 1.5f);
6661 EXPECT_EQ(scroll_child->DrawTransform(), scale); 6661 EXPECT_EQ(scroll_child->DrawTransform(), scale);
6662 } 6662 }
6663 6663
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
7078 7078
7079 gfx::Vector2dF scroll_delta(3.0, 5.0); 7079 gfx::Vector2dF scroll_delta(3.0, 5.0);
7080 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7080 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7081 7081
7082 LayerImplList render_surface_layer_list; 7082 LayerImplList render_surface_layer_list;
7083 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7083 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7084 root, root->bounds(), &render_surface_layer_list); 7084 root, root->bounds(), &render_surface_layer_list);
7085 root->layer_tree_impl() 7085 root->layer_tree_impl()
7086 ->property_trees() 7086 ->property_trees()
7087 ->transform_tree.set_source_to_parent_updates_allowed(false); 7087 ->transform_tree.set_source_to_parent_updates_allowed(false);
7088 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7089 7089
7090 EXPECT_TRANSFORMATION_MATRIX_EQ( 7090 EXPECT_TRANSFORMATION_MATRIX_EQ(
7091 container_layer->draw_properties().screen_space_transform, 7091 container_layer->draw_properties().screen_space_transform,
7092 fixed_layer->draw_properties().screen_space_transform); 7092 fixed_layer->draw_properties().screen_space_transform);
7093 EXPECT_VECTOR_EQ( 7093 EXPECT_VECTOR_EQ(
7094 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 7094 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7095 container_offset); 7095 container_offset);
7096 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 7096 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
7097 .screen_space_transform.To2dTranslation(), 7097 .screen_space_transform.To2dTranslation(),
7098 container_offset - scroll_delta); 7098 container_offset - scroll_delta);
7099 } 7099 }
7100 7100
7101 // Scroll delta requiring rounding. 7101 // Scroll delta requiring rounding.
7102 { 7102 {
7103 root->layer_tree_impl()->BuildPropertyTreesForTesting(); 7103 root->layer_tree_impl()->BuildPropertyTreesForTesting();
7104 7104
7105 gfx::Vector2dF scroll_delta(4.1f, 8.1f); 7105 gfx::Vector2dF scroll_delta(4.1f, 8.1f);
7106 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7106 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7107 7107
7108 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); 7108 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f);
7109 7109
7110 LayerImplList render_surface_layer_list; 7110 LayerImplList render_surface_layer_list;
7111 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7111 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7112 root, root->bounds(), &render_surface_layer_list); 7112 root, root->bounds(), &render_surface_layer_list);
7113 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7113 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7114 7114
7115 EXPECT_TRANSFORMATION_MATRIX_EQ( 7115 EXPECT_TRANSFORMATION_MATRIX_EQ(
7116 container_layer->draw_properties().screen_space_transform, 7116 container_layer->draw_properties().screen_space_transform,
7117 fixed_layer->draw_properties().screen_space_transform); 7117 fixed_layer->draw_properties().screen_space_transform);
7118 EXPECT_VECTOR_EQ( 7118 EXPECT_VECTOR_EQ(
7119 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 7119 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7120 container_offset); 7120 container_offset);
7121 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 7121 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
7122 .screen_space_transform.To2dTranslation(), 7122 .screen_space_transform.To2dTranslation(),
7123 container_offset - rounded_scroll_delta); 7123 container_offset - rounded_scroll_delta);
7124 } 7124 }
7125 7125
7126 // Scale is applied earlier in the tree. 7126 // Scale is applied earlier in the tree.
7127 { 7127 {
7128 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); 7128 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
7129 gfx::Transform scaled_container_transform = container_transform; 7129 gfx::Transform scaled_container_transform = container_transform;
7130 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); 7130 scaled_container_transform.Scale3d(2.0, 2.0, 1.0);
7131 container_layer->SetTransform(scaled_container_transform); 7131 container_layer->SetTransform(scaled_container_transform);
7132 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 7132 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
7133 root->layer_tree_impl()->BuildPropertyTreesForTesting(); 7133 root->layer_tree_impl()->BuildPropertyTreesForTesting();
7134 7134
7135 gfx::Vector2dF scroll_delta(4.5f, 8.5f); 7135 gfx::Vector2dF scroll_delta(4.5f, 8.5f);
7136 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7136 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7137 7137
7138 LayerImplList render_surface_layer_list; 7138 LayerImplList render_surface_layer_list;
7139 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7139 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7140 root, root->bounds(), &render_surface_layer_list); 7140 root, root->bounds(), &render_surface_layer_list);
7141 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7141 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7142 7142
7143 EXPECT_TRANSFORMATION_MATRIX_EQ( 7143 EXPECT_TRANSFORMATION_MATRIX_EQ(
7144 container_layer->draw_properties().screen_space_transform, 7144 container_layer->draw_properties().screen_space_transform,
7145 fixed_layer->draw_properties().screen_space_transform); 7145 fixed_layer->draw_properties().screen_space_transform);
7146 EXPECT_VECTOR_EQ( 7146 EXPECT_VECTOR_EQ(
7147 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 7147 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7148 container_offset); 7148 container_offset);
7149 7149
7150 container_layer->SetTransform(container_transform); 7150 container_layer->SetTransform(container_transform);
7151 } 7151 }
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
7925 std::vector<LayerImpl*> render_surface_layer_list; 7925 std::vector<LayerImpl*> render_surface_layer_list;
7926 gfx::Size device_viewport_size = 7926 gfx::Size device_viewport_size =
7927 gfx::Size(root_layer->bounds().width() * device_scale_factor, 7927 gfx::Size(root_layer->bounds().width() * device_scale_factor,
7928 root_layer->bounds().height() * device_scale_factor); 7928 root_layer->bounds().height() * device_scale_factor);
7929 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7929 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7930 root_layer, device_viewport_size, &render_surface_layer_list); 7930 root_layer, device_viewport_size, &render_surface_layer_list);
7931 7931
7932 inputs.page_scale_factor = page_scale_factor; 7932 inputs.page_scale_factor = page_scale_factor;
7933 inputs.can_adjust_raster_scales = true; 7933 inputs.can_adjust_raster_scales = true;
7934 inputs.page_scale_layer = root_layer; 7934 inputs.page_scale_layer = root_layer;
7935 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7935 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7936 7936
7937 EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale()); 7937 EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale());
7938 EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale()); 7938 EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale());
7939 EXPECT_FLOAT_EQ(9.f, child1_layer->mask_layer()->GetIdealContentsScale()); 7939 EXPECT_FLOAT_EQ(9.f, child1_layer->mask_layer()->GetIdealContentsScale());
7940 EXPECT_FLOAT_EQ( 7940 EXPECT_FLOAT_EQ(
7941 9.f, 7941 9.f,
7942 child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale()); 7942 child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale());
7943 EXPECT_FLOAT_EQ(15.f, child2_layer->GetIdealContentsScale()); 7943 EXPECT_FLOAT_EQ(15.f, child2_layer->GetIdealContentsScale());
7944 7944
7945 EXPECT_FLOAT_EQ( 7945 EXPECT_FLOAT_EQ(
(...skipping 12 matching lines...) Expand all
7958 EXPECT_FLOAT_EQ( 7958 EXPECT_FLOAT_EQ(
7959 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); 7959 24.f, child2_layer->draw_properties().maximum_animation_contents_scale);
7960 7960
7961 // Changing device-scale would affect ideal_contents_scale and 7961 // Changing device-scale would affect ideal_contents_scale and
7962 // maximum_animation_contents_scale. 7962 // maximum_animation_contents_scale.
7963 7963
7964 device_scale_factor = 4.0f; 7964 device_scale_factor = 4.0f;
7965 inputs.device_scale_factor = device_scale_factor; 7965 inputs.device_scale_factor = device_scale_factor;
7966 inputs.can_adjust_raster_scales = true; 7966 inputs.can_adjust_raster_scales = true;
7967 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 7967 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
7968 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7968 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7969 7969
7970 EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale()); 7970 EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale());
7971 EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale()); 7971 EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale());
7972 EXPECT_FLOAT_EQ(36.f, child1_layer->mask_layer()->GetIdealContentsScale()); 7972 EXPECT_FLOAT_EQ(36.f, child1_layer->mask_layer()->GetIdealContentsScale());
7973 EXPECT_FLOAT_EQ( 7973 EXPECT_FLOAT_EQ(
7974 36.f, 7974 36.f,
7975 child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale()); 7975 child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale());
7976 EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale()); 7976 EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale());
7977 7977
7978 EXPECT_FLOAT_EQ( 7978 EXPECT_FLOAT_EQ(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8012 content->SetDrawsContent(true); 8012 content->SetDrawsContent(true);
8013 8013
8014 gfx::Size device_viewport_size(768, 582); 8014 gfx::Size device_viewport_size(768, 582);
8015 LayerImplList render_surface_layer_list_impl; 8015 LayerImplList render_surface_layer_list_impl;
8016 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8016 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8017 root, device_viewport_size, identity_matrix, 8017 root, device_viewport_size, identity_matrix,
8018 &render_surface_layer_list_impl); 8018 &render_surface_layer_list_impl);
8019 inputs.device_scale_factor = 2.f; 8019 inputs.device_scale_factor = 2.f;
8020 inputs.page_scale_factor = 1.f; 8020 inputs.page_scale_factor = 1.f;
8021 inputs.page_scale_layer = NULL; 8021 inputs.page_scale_layer = NULL;
8022 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8022 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8023 8023
8024 // Layers in the root render surface have their visible content rect clipped 8024 // Layers in the root render surface have their visible content rect clipped
8025 // by the viewport. 8025 // by the viewport.
8026 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect()); 8026 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect());
8027 8027
8028 // Layers drawing to a child render surface should still have their visible 8028 // Layers drawing to a child render surface should still have their visible
8029 // content rect clipped by the viewport. 8029 // content rect clipped by the viewport.
8030 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_layer_rect()); 8030 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_layer_rect());
8031 } 8031 }
8032 8032
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8074 sublayer_size, 8074 sublayer_size,
8075 false, 8075 false,
8076 false, 8076 false,
8077 false); 8077 false);
8078 sublayer->SetDrawsContent(true); 8078 sublayer->SetDrawsContent(true);
8079 8079
8080 LayerImplList layer_impl_list; 8080 LayerImplList layer_impl_list;
8081 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8081 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8082 root, device_viewport_size, &layer_impl_list); 8082 root, device_viewport_size, &layer_impl_list);
8083 8083
8084 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8084 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8085 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); 8085 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect());
8086 8086
8087 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); 8087 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0));
8088 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8089 8089
8090 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8090 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8091 root_size.height() + 50); 8091 root_size.height() + 50);
8092 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect()); 8092 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect());
8093 } 8093 }
8094 8094
8095 TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) { 8095 TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) {
8096 scoped_refptr<Layer> root = Layer::Create(); 8096 scoped_refptr<Layer> root = Layer::Create();
8097 scoped_refptr<Layer> inner_viewport_container_layer = Layer::Create(); 8097 scoped_refptr<Layer> inner_viewport_container_layer = Layer::Create();
8098 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); 8098 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create();
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
10070 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10070 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10071 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10071 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10072 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10072 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10073 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10073 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10074 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10074 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10075 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10075 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10076 } 10076 }
10077 10077
10078 } // namespace 10078 } // namespace
10079 } // namespace cc 10079 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698