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

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

Issue 2834123002: cc: Replace render surface layer list with a render surface list (Closed)
Patch Set: Address review comments Created 3 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_perftest.cc ('k') | cc/trees/layer_tree_host_impl.h » ('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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 132 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
133 133
134 root_layer->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); 134 root_layer->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
135 135
136 EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f)); 136 EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f));
137 137
138 gfx::Size device_viewport_size = 138 gfx::Size device_viewport_size =
139 gfx::Size(root_layer->bounds().width() * device_scale_factor, 139 gfx::Size(root_layer->bounds().width() * device_scale_factor,
140 root_layer->bounds().height() * device_scale_factor); 140 root_layer->bounds().height() * device_scale_factor);
141 141
142 render_surface_layer_list_impl_.reset(new LayerImplList); 142 render_surface_list_impl_.reset(new RenderSurfaceList);
143 143
144 // We are probably not testing what is intended if the root_layer bounds are 144 // We are probably not testing what is intended if the root_layer bounds are
145 // empty. 145 // empty.
146 DCHECK(!root_layer->bounds().IsEmpty()); 146 DCHECK(!root_layer->bounds().IsEmpty());
147 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 147 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
148 root_layer, device_viewport_size, 148 root_layer, device_viewport_size, render_surface_list_impl_.get());
149 render_surface_layer_list_impl_.get());
150 inputs.device_scale_factor = device_scale_factor; 149 inputs.device_scale_factor = device_scale_factor;
151 inputs.page_scale_factor = page_scale_factor; 150 inputs.page_scale_factor = page_scale_factor;
152 inputs.page_scale_layer = page_scale_layer; 151 inputs.page_scale_layer = page_scale_layer;
153 inputs.inner_viewport_scroll_layer = inner_viewport_scroll_layer; 152 inputs.inner_viewport_scroll_layer = inner_viewport_scroll_layer;
154 inputs.outer_viewport_scroll_layer = outer_viewport_scroll_layer; 153 inputs.outer_viewport_scroll_layer = outer_viewport_scroll_layer;
155 inputs.can_adjust_raster_scales = true; 154 inputs.can_adjust_raster_scales = true;
156 155
157 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 156 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
158 } 157 }
159 158
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 root_layer->layer_tree_impl(), property_trees, 250 root_layer->layer_tree_impl(), property_trees,
252 update_layer_list_impl_.get()); 251 update_layer_list_impl_.get());
253 draw_property_utils::ComputeDrawPropertiesOfVisibleLayers( 252 draw_property_utils::ComputeDrawPropertiesOfVisibleLayers(
254 update_layer_list_impl(), property_trees); 253 update_layer_list_impl(), property_trees);
255 } 254 }
256 255
257 void ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces( 256 void ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(
258 LayerImpl* root_layer) { 257 LayerImpl* root_layer) {
259 gfx::Size device_viewport_size = 258 gfx::Size device_viewport_size =
260 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); 259 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height());
261 render_surface_layer_list_impl_.reset(new LayerImplList); 260 render_surface_list_impl_.reset(new RenderSurfaceList);
262 261
263 DCHECK(!root_layer->bounds().IsEmpty()); 262 DCHECK(!root_layer->bounds().IsEmpty());
264 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 263 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
265 root_layer, device_viewport_size, 264 root_layer, device_viewport_size, render_surface_list_impl_.get());
266 render_surface_layer_list_impl_.get());
267 inputs.can_adjust_raster_scales = true; 265 inputs.can_adjust_raster_scales = true;
268 inputs.can_render_to_separate_surface = false; 266 inputs.can_render_to_separate_surface = false;
269 267
270 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 268 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
271 } 269 }
272 270
273 void ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales( 271 void ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales(
274 LayerImpl* root_layer) { 272 LayerImpl* root_layer) {
275 gfx::Size device_viewport_size = 273 gfx::Size device_viewport_size =
276 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); 274 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height());
277 render_surface_layer_list_impl_.reset(new LayerImplList); 275 render_surface_list_impl_.reset(new RenderSurfaceList);
278 276
279 DCHECK(!root_layer->bounds().IsEmpty()); 277 DCHECK(!root_layer->bounds().IsEmpty());
280 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 278 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
281 root_layer, device_viewport_size, 279 root_layer, device_viewport_size, render_surface_list_impl_.get());
282 render_surface_layer_list_impl_.get());
283 inputs.can_render_to_separate_surface = true; 280 inputs.can_render_to_separate_surface = true;
284 inputs.can_adjust_raster_scales = false; 281 inputs.can_adjust_raster_scales = false;
285 282
286 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 283 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
287 } 284 }
288 285
289 bool UpdateLayerListImplContains(int id) const { 286 bool UpdateLayerListImplContains(int id) const {
290 for (auto* layer : *update_layer_list_impl_) { 287 for (auto* layer : *update_layer_list_impl_) {
291 if (layer->id() == id) 288 if (layer->id() == id)
292 return true; 289 return true;
293 } 290 }
294 return false; 291 return false;
295 } 292 }
296 293
297 bool UpdateLayerListContains(int id) const { 294 bool UpdateLayerListContains(int id) const {
298 for (const auto& layer : update_layer_list_) { 295 for (const auto& layer : update_layer_list_) {
299 if (layer->id() == id) 296 if (layer->id() == id)
300 return true; 297 return true;
301 } 298 }
302 return false; 299 return false;
303 } 300 }
304 301
305 const LayerImplList* render_surface_layer_list_impl() const { 302 const RenderSurfaceList* render_surface_list_impl() const {
306 return render_surface_layer_list_impl_.get(); 303 return render_surface_list_impl_.get();
307 } 304 }
308 const LayerImplList* update_layer_list_impl() const { 305 const LayerImplList* update_layer_list_impl() const {
309 return update_layer_list_impl_.get(); 306 return update_layer_list_impl_.get();
310 } 307 }
311 const LayerList& update_layer_list() const { return update_layer_list_; } 308 const LayerList& update_layer_list() const { return update_layer_list_; }
312 309
313 bool VerifyLayerInList(scoped_refptr<Layer> layer, 310 bool VerifyLayerInList(scoped_refptr<Layer> layer,
314 const LayerList* layer_list) { 311 const LayerList* layer_list) {
315 return std::find(layer_list->begin(), layer_list->end(), layer) != 312 return std::find(layer_list->begin(), layer_list->end(), layer) !=
316 layer_list->end(); 313 layer_list->end();
317 } 314 }
318 315
319 private: 316 private:
320 std::unique_ptr<std::vector<LayerImpl*>> render_surface_layer_list_impl_; 317 std::unique_ptr<RenderSurfaceList> render_surface_list_impl_;
321 LayerList update_layer_list_; 318 LayerList update_layer_list_;
322 std::unique_ptr<LayerImplList> update_layer_list_impl_; 319 std::unique_ptr<LayerImplList> update_layer_list_impl_;
323 }; 320 };
324 321
325 class LayerTreeHostCommonTest : public LayerTreeHostCommonTestBase, 322 class LayerTreeHostCommonTest : public LayerTreeHostCommonTestBase,
326 public testing::Test {}; 323 public testing::Test {};
327 324
328 class LayerWithForcedDrawsContent : public Layer { 325 class LayerWithForcedDrawsContent : public Layer {
329 public: 326 public:
330 LayerWithForcedDrawsContent() {} 327 LayerWithForcedDrawsContent() {}
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 render_surface->SetBounds(gfx::Size(100, 100)); 1189 render_surface->SetBounds(gfx::Size(100, 100));
1193 render_surface->test_properties()->force_render_surface = true; 1190 render_surface->test_properties()->force_render_surface = true;
1194 child->test_properties()->transform = translate; 1191 child->test_properties()->transform = translate;
1195 child->SetBounds(gfx::Size(100, 100)); 1192 child->SetBounds(gfx::Size(100, 100));
1196 grand_child->test_properties()->transform = translate; 1193 grand_child->test_properties()->transform = translate;
1197 grand_child->SetBounds(gfx::Size(100, 100)); 1194 grand_child->SetBounds(gfx::Size(100, 100));
1198 grand_child->SetDrawsContent(true); 1195 grand_child->SetDrawsContent(true);
1199 1196
1200 // render_surface will have a sublayer scale because of device scale factor. 1197 // render_surface will have a sublayer scale because of device scale factor.
1201 float device_scale_factor = 2.0f; 1198 float device_scale_factor = 2.0f;
1202 LayerImplList render_surface_layer_list_impl; 1199 RenderSurfaceList render_surface_list_impl;
1203 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1200 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1204 root, root->bounds(), translate, &render_surface_layer_list_impl); 1201 root, root->bounds(), translate, &render_surface_list_impl);
1205 inputs.device_scale_factor = device_scale_factor; 1202 inputs.device_scale_factor = device_scale_factor;
1206 inputs.property_trees->needs_rebuild = true; 1203 inputs.property_trees->needs_rebuild = true;
1207 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1204 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1208 1205
1209 // Between grand_child and render_surface, we translate by (10, 10) and scale 1206 // Between grand_child and render_surface, we translate by (10, 10) and scale
1210 // by a factor of 2. 1207 // by a factor of 2.
1211 gfx::Vector2dF expected_translation(20.0f, 20.0f); 1208 gfx::Vector2dF expected_translation(20.0f, 20.0f);
1212 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(), 1209 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(),
1213 expected_translation); 1210 expected_translation);
1214 } 1211 }
1215 1212
1216 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { 1213 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
1217 // Transformations applied at the root of the tree should be forwarded 1214 // Transformations applied at the root of the tree should be forwarded
1218 // to child layers instead of applied to the root RenderSurface. 1215 // to child layers instead of applied to the root RenderSurface.
1219 LayerImpl* root = root_layer_for_testing(); 1216 LayerImpl* root = root_layer_for_testing();
1220 LayerImpl* child = AddChild<LayerImpl>(root); 1217 LayerImpl* child = AddChild<LayerImpl>(root);
1221 1218
1222 root->SetDrawsContent(true); 1219 root->SetDrawsContent(true);
1223 root->SetBounds(gfx::Size(100, 100)); 1220 root->SetBounds(gfx::Size(100, 100));
1224 child->SetDrawsContent(true); 1221 child->SetDrawsContent(true);
1225 child->SetScrollClipLayer(root->id()); 1222 child->SetScrollClipLayer(root->id());
1226 child->SetBounds(gfx::Size(100, 100)); 1223 child->SetBounds(gfx::Size(100, 100));
1227 child->SetMasksToBounds(true); 1224 child->SetMasksToBounds(true);
1228 1225
1229 gfx::Transform translate; 1226 gfx::Transform translate;
1230 translate.Translate(50, 50); 1227 translate.Translate(50, 50);
1231 { 1228 {
1232 LayerImplList render_surface_layer_list_impl; 1229 RenderSurfaceList render_surface_list_impl;
1233 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1230 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1234 root, root->bounds(), translate, &render_surface_layer_list_impl); 1231 root, root->bounds(), translate, &render_surface_list_impl);
1235 inputs.property_trees->needs_rebuild = true; 1232 inputs.property_trees->needs_rebuild = true;
1236 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1233 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1237 EXPECT_TRANSFORMATION_MATRIX_EQ( 1234 EXPECT_TRANSFORMATION_MATRIX_EQ(
1238 translate, root->draw_properties().target_space_transform); 1235 translate, root->draw_properties().target_space_transform);
1239 EXPECT_TRANSFORMATION_MATRIX_EQ( 1236 EXPECT_TRANSFORMATION_MATRIX_EQ(
1240 translate, child->draw_properties().target_space_transform); 1237 translate, child->draw_properties().target_space_transform);
1241 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1238 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1242 root->GetRenderSurface()->draw_transform()); 1239 root->GetRenderSurface()->draw_transform());
1243 EXPECT_TRANSFORMATION_MATRIX_EQ(translate, child->ScreenSpaceTransform()); 1240 EXPECT_TRANSFORMATION_MATRIX_EQ(translate, child->ScreenSpaceTransform());
1244 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), child->clip_rect()); 1241 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), child->clip_rect());
1245 } 1242 }
1246 1243
1247 gfx::Transform scale; 1244 gfx::Transform scale;
1248 scale.Scale(2, 2); 1245 scale.Scale(2, 2);
1249 { 1246 {
1250 LayerImplList render_surface_layer_list_impl; 1247 RenderSurfaceList render_surface_list_impl;
1251 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1248 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1252 root, root->bounds(), scale, &render_surface_layer_list_impl); 1249 root, root->bounds(), scale, &render_surface_list_impl);
1253 inputs.property_trees->needs_rebuild = true; 1250 inputs.property_trees->needs_rebuild = true;
1254 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1251 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1255 EXPECT_TRANSFORMATION_MATRIX_EQ( 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(
1256 scale, root->draw_properties().target_space_transform); 1253 scale, root->draw_properties().target_space_transform);
1257 EXPECT_TRANSFORMATION_MATRIX_EQ( 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(
1258 scale, child->draw_properties().target_space_transform); 1255 scale, child->draw_properties().target_space_transform);
1259 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1256 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1260 root->GetRenderSurface()->draw_transform()); 1257 root->GetRenderSurface()->draw_transform());
1261 EXPECT_TRANSFORMATION_MATRIX_EQ(scale, child->ScreenSpaceTransform()); 1258 EXPECT_TRANSFORMATION_MATRIX_EQ(scale, child->ScreenSpaceTransform());
1262 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), child->clip_rect()); 1259 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), child->clip_rect());
1263 } 1260 }
1264 1261
1265 gfx::Transform rotate; 1262 gfx::Transform rotate;
1266 rotate.Rotate(2); 1263 rotate.Rotate(2);
1267 { 1264 {
1268 LayerImplList render_surface_layer_list_impl; 1265 RenderSurfaceList render_surface_list_impl;
1269 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1266 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1270 root, root->bounds(), rotate, &render_surface_layer_list_impl); 1267 root, root->bounds(), rotate, &render_surface_list_impl);
1271 inputs.property_trees->needs_rebuild = true; 1268 inputs.property_trees->needs_rebuild = true;
1272 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1269 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1273 EXPECT_TRANSFORMATION_MATRIX_EQ( 1270 EXPECT_TRANSFORMATION_MATRIX_EQ(
1274 rotate, root->draw_properties().target_space_transform); 1271 rotate, root->draw_properties().target_space_transform);
1275 EXPECT_TRANSFORMATION_MATRIX_EQ( 1272 EXPECT_TRANSFORMATION_MATRIX_EQ(
1276 rotate, child->draw_properties().target_space_transform); 1273 rotate, child->draw_properties().target_space_transform);
1277 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1274 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1278 root->GetRenderSurface()->draw_transform()); 1275 root->GetRenderSurface()->draw_transform());
1279 EXPECT_TRANSFORMATION_MATRIX_EQ(rotate, child->ScreenSpaceTransform()); 1276 EXPECT_TRANSFORMATION_MATRIX_EQ(rotate, child->ScreenSpaceTransform());
1280 EXPECT_EQ(gfx::Rect(-4, 0, 104, 104), child->clip_rect()); 1277 EXPECT_EQ(gfx::Rect(-4, 0, 104, 104), child->clip_rect());
1281 } 1278 }
1282 1279
1283 gfx::Transform composite; 1280 gfx::Transform composite;
1284 composite.ConcatTransform(translate); 1281 composite.ConcatTransform(translate);
1285 composite.ConcatTransform(scale); 1282 composite.ConcatTransform(scale);
1286 composite.ConcatTransform(rotate); 1283 composite.ConcatTransform(rotate);
1287 { 1284 {
1288 LayerImplList render_surface_layer_list_impl; 1285 RenderSurfaceList render_surface_list_impl;
1289 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1286 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1290 root, root->bounds(), composite, &render_surface_layer_list_impl); 1287 root, root->bounds(), composite, &render_surface_list_impl);
1291 inputs.property_trees->needs_rebuild = true; 1288 inputs.property_trees->needs_rebuild = true;
1292 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1289 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1293 EXPECT_TRANSFORMATION_MATRIX_EQ( 1290 EXPECT_TRANSFORMATION_MATRIX_EQ(
1294 composite, root->draw_properties().target_space_transform); 1291 composite, root->draw_properties().target_space_transform);
1295 EXPECT_TRANSFORMATION_MATRIX_EQ( 1292 EXPECT_TRANSFORMATION_MATRIX_EQ(
1296 composite, child->draw_properties().target_space_transform); 1293 composite, child->draw_properties().target_space_transform);
1297 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1294 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1298 root->GetRenderSurface()->draw_transform()); 1295 root->GetRenderSurface()->draw_transform());
1299 EXPECT_TRANSFORMATION_MATRIX_EQ(composite, child->ScreenSpaceTransform()); 1296 EXPECT_TRANSFORMATION_MATRIX_EQ(composite, child->ScreenSpaceTransform());
1300 EXPECT_EQ(gfx::Rect(89, 103, 208, 208), child->clip_rect()); 1297 EXPECT_EQ(gfx::Rect(89, 103, 208, 208), child->clip_rect());
1301 } 1298 }
1302 1299
1303 // Verify it composes correctly with device scale. 1300 // Verify it composes correctly with device scale.
1304 float device_scale_factor = 1.5f; 1301 float device_scale_factor = 1.5f;
1305 1302
1306 { 1303 {
1307 LayerImplList render_surface_layer_list_impl; 1304 RenderSurfaceList render_surface_list_impl;
1308 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1305 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1309 root, root->bounds(), translate, &render_surface_layer_list_impl); 1306 root, root->bounds(), translate, &render_surface_list_impl);
1310 inputs.device_scale_factor = device_scale_factor; 1307 inputs.device_scale_factor = device_scale_factor;
1311 inputs.property_trees->needs_rebuild = true; 1308 inputs.property_trees->needs_rebuild = true;
1312 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1309 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1313 gfx::Transform device_scaled_translate = translate; 1310 gfx::Transform device_scaled_translate = translate;
1314 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); 1311 device_scaled_translate.Scale(device_scale_factor, device_scale_factor);
1315 EXPECT_TRANSFORMATION_MATRIX_EQ( 1312 EXPECT_TRANSFORMATION_MATRIX_EQ(
1316 device_scaled_translate, 1313 device_scaled_translate,
1317 root->draw_properties().target_space_transform); 1314 root->draw_properties().target_space_transform);
1318 EXPECT_TRANSFORMATION_MATRIX_EQ( 1315 EXPECT_TRANSFORMATION_MATRIX_EQ(
1319 device_scaled_translate, 1316 device_scaled_translate,
1320 child->draw_properties().target_space_transform); 1317 child->draw_properties().target_space_transform);
1321 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1318 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1322 root->GetRenderSurface()->draw_transform()); 1319 root->GetRenderSurface()->draw_transform());
1323 EXPECT_TRANSFORMATION_MATRIX_EQ(device_scaled_translate, 1320 EXPECT_TRANSFORMATION_MATRIX_EQ(device_scaled_translate,
1324 child->ScreenSpaceTransform()); 1321 child->ScreenSpaceTransform());
1325 EXPECT_EQ(gfx::Rect(50, 50, 150, 150), child->clip_rect()); 1322 EXPECT_EQ(gfx::Rect(50, 50, 150, 150), child->clip_rect());
1326 } 1323 }
1327 1324
1328 // Verify it composes correctly with page scale. 1325 // Verify it composes correctly with page scale.
1329 float page_scale_factor = 2.f; 1326 float page_scale_factor = 2.f;
1330 1327
1331 { 1328 {
1332 LayerImplList render_surface_layer_list_impl; 1329 RenderSurfaceList render_surface_list_impl;
1333 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1330 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1334 root, root->bounds(), translate, &render_surface_layer_list_impl); 1331 root, root->bounds(), translate, &render_surface_list_impl);
1335 inputs.page_scale_factor = page_scale_factor; 1332 inputs.page_scale_factor = page_scale_factor;
1336 inputs.page_scale_layer = root; 1333 inputs.page_scale_layer = root;
1337 inputs.property_trees->needs_rebuild = true; 1334 inputs.property_trees->needs_rebuild = true;
1338 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1335 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1339 gfx::Transform page_scaled_translate = translate; 1336 gfx::Transform page_scaled_translate = translate;
1340 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); 1337 page_scaled_translate.Scale(page_scale_factor, page_scale_factor);
1341 EXPECT_TRANSFORMATION_MATRIX_EQ( 1338 EXPECT_TRANSFORMATION_MATRIX_EQ(
1342 page_scaled_translate, root->draw_properties().target_space_transform); 1339 page_scaled_translate, root->draw_properties().target_space_transform);
1343 EXPECT_TRANSFORMATION_MATRIX_EQ( 1340 EXPECT_TRANSFORMATION_MATRIX_EQ(
1344 page_scaled_translate, child->draw_properties().target_space_transform); 1341 page_scaled_translate, child->draw_properties().target_space_transform);
1345 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1342 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1346 root->GetRenderSurface()->draw_transform()); 1343 root->GetRenderSurface()->draw_transform());
1347 EXPECT_TRANSFORMATION_MATRIX_EQ(page_scaled_translate, 1344 EXPECT_TRANSFORMATION_MATRIX_EQ(page_scaled_translate,
1348 child->ScreenSpaceTransform()); 1345 child->ScreenSpaceTransform());
1349 EXPECT_EQ(gfx::Rect(50, 50, 200, 200), child->clip_rect()); 1346 EXPECT_EQ(gfx::Rect(50, 50, 200, 200), child->clip_rect());
1350 } 1347 }
1351 1348
1352 // Verify that it composes correctly with transforms directly on root layer. 1349 // Verify that it composes correctly with transforms directly on root layer.
1353 root->test_properties()->transform = composite; 1350 root->test_properties()->transform = composite;
1354 1351
1355 { 1352 {
1356 LayerImplList render_surface_layer_list_impl; 1353 RenderSurfaceList render_surface_list_impl;
1357 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1354 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1358 root, root->bounds(), composite, &render_surface_layer_list_impl); 1355 root, root->bounds(), composite, &render_surface_list_impl);
1359 inputs.property_trees->needs_rebuild = true; 1356 inputs.property_trees->needs_rebuild = true;
1360 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1357 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1361 gfx::Transform compositeSquared = composite; 1358 gfx::Transform compositeSquared = composite;
1362 compositeSquared.ConcatTransform(composite); 1359 compositeSquared.ConcatTransform(composite);
1363 EXPECT_TRANSFORMATION_MATRIX_EQ( 1360 EXPECT_TRANSFORMATION_MATRIX_EQ(
1364 compositeSquared, root->draw_properties().target_space_transform); 1361 compositeSquared, root->draw_properties().target_space_transform);
1365 EXPECT_TRANSFORMATION_MATRIX_EQ( 1362 EXPECT_TRANSFORMATION_MATRIX_EQ(
1366 compositeSquared, child->draw_properties().target_space_transform); 1363 compositeSquared, child->draw_properties().target_space_transform);
1367 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1364 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1368 root->GetRenderSurface()->draw_transform()); 1365 root->GetRenderSurface()->draw_transform());
(...skipping 17 matching lines...) Expand all
1386 child->SetPosition(gfx::PointF(30.f, 30.f)); 1383 child->SetPosition(gfx::PointF(30.f, 30.f));
1387 child->SetBounds(gfx::Size(10, 10)); 1384 child->SetBounds(gfx::Size(10, 10));
1388 ExecuteCalculateDrawProperties(root); 1385 ExecuteCalculateDrawProperties(root);
1389 1386
1390 // The child layer's content is entirely outside the root's clip rect, so 1387 // The child layer's content is entirely outside the root's clip rect, so
1391 // the intermediate render surface should not be listed here, even if it was 1388 // the intermediate render surface should not be listed here, even if it was
1392 // forced to be created. Render surfaces without children or visible content 1389 // forced to be created. Render surfaces without children or visible content
1393 // are unexpected at draw time (e.g. we might try to create a content texture 1390 // are unexpected at draw time (e.g. we might try to create a content texture
1394 // of size 0). 1391 // of size 0).
1395 ASSERT_TRUE(root->GetRenderSurface()); 1392 ASSERT_TRUE(root->GetRenderSurface());
1396 EXPECT_EQ(1U, render_surface_layer_list_impl()->size()); 1393 EXPECT_EQ(1U, render_surface_list_impl()->size());
1397 } 1394 }
1398 1395
1399 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) { 1396 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
1400 LayerImpl* root = root_layer_for_testing(); 1397 LayerImpl* root = root_layer_for_testing();
1401 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 1398 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
1402 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1399 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1403 1400
1404 render_surface1->SetBounds(gfx::Size(10, 10)); 1401 render_surface1->SetBounds(gfx::Size(10, 10));
1405 render_surface1->test_properties()->force_render_surface = true; 1402 render_surface1->test_properties()->force_render_surface = true;
1406 render_surface1->test_properties()->opacity = 0.f; 1403 render_surface1->test_properties()->opacity = 0.f;
1407 child->SetBounds(gfx::Size(10, 10)); 1404 child->SetBounds(gfx::Size(10, 10));
1408 child->SetDrawsContent(true); 1405 child->SetDrawsContent(true);
1409 1406
1410 LayerImplList render_surface_layer_list; 1407 RenderSurfaceList render_surface_list;
1411 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1408 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1412 root, root->bounds(), &render_surface_layer_list); 1409 root, root->bounds(), &render_surface_list);
1413 inputs.can_adjust_raster_scales = true; 1410 inputs.can_adjust_raster_scales = true;
1414 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1411 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1415 1412
1416 // Since the layer is transparent, render_surface1->GetRenderSurface() should 1413 // Since the layer is transparent, render_surface1->GetRenderSurface() should
1417 // not have gotten added anywhere. Also, the drawable content rect should not 1414 // not have gotten added anywhere. Also, the drawable content rect should not
1418 // have been extended by the children. 1415 // have been extended by the children.
1419 ASSERT_TRUE(root->GetRenderSurface()); 1416 ASSERT_TRUE(root->GetRenderSurface());
1420 EXPECT_EQ(0U, root->GetRenderSurface()->layer_list().size()); 1417 EXPECT_EQ(0, root->GetRenderSurface()->num_contributors());
1421 EXPECT_EQ(1U, render_surface_layer_list.size()); 1418 EXPECT_EQ(1U, render_surface_list.size());
1422 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); 1419 EXPECT_EQ(root->id(), render_surface_list.at(0)->id());
1423 EXPECT_EQ(gfx::Rect(), root->drawable_content_rect()); 1420 EXPECT_EQ(gfx::Rect(), root->drawable_content_rect());
1424 } 1421 }
1425 1422
1426 TEST_F(LayerTreeHostCommonTest, 1423 TEST_F(LayerTreeHostCommonTest,
1427 RenderSurfaceListForTransparentChildWithBackgroundFilter) { 1424 RenderSurfaceListForTransparentChildWithBackgroundFilter) {
1428 LayerImpl* root = root_layer_for_testing(); 1425 LayerImpl* root = root_layer_for_testing();
1429 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 1426 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
1430 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1427 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1431 1428
1432 root->SetBounds(gfx::Size(10, 10)); 1429 root->SetBounds(gfx::Size(10, 10));
1433 render_surface1->SetBounds(gfx::Size(10, 10)); 1430 render_surface1->SetBounds(gfx::Size(10, 10));
1434 render_surface1->test_properties()->force_render_surface = true; 1431 render_surface1->test_properties()->force_render_surface = true;
1435 render_surface1->test_properties()->opacity = 0.f; 1432 render_surface1->test_properties()->opacity = 0.f;
1436 render_surface1->SetDrawsContent(true); 1433 render_surface1->SetDrawsContent(true);
1437 FilterOperations filters; 1434 FilterOperations filters;
1438 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); 1435 filters.Append(FilterOperation::CreateBlurFilter(1.5f));
1439 render_surface1->test_properties()->background_filters = filters; 1436 render_surface1->test_properties()->background_filters = filters;
1440 child->SetBounds(gfx::Size(10, 10)); 1437 child->SetBounds(gfx::Size(10, 10));
1441 child->SetDrawsContent(true); 1438 child->SetDrawsContent(true);
1442 root->layer_tree_impl()->SetElementIdsForTesting(); 1439 root->layer_tree_impl()->SetElementIdsForTesting();
1443 1440
1444 { 1441 {
1445 LayerImplList render_surface_layer_list; 1442 RenderSurfaceList render_surface_list;
1446 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1443 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1447 root, root->bounds(), &render_surface_layer_list); 1444 root, root->bounds(), &render_surface_list);
1448 inputs.can_adjust_raster_scales = true; 1445 inputs.can_adjust_raster_scales = true;
1449 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1446 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1450 EXPECT_EQ(2U, render_surface_layer_list.size()); 1447 EXPECT_EQ(2U, render_surface_list.size());
1451 } 1448 }
1452 // The layer is fully transparent, but has a background filter, so it 1449 // The layer is fully transparent, but has a background filter, so it
1453 // shouldn't be skipped and should be drawn. 1450 // shouldn't be skipped and should be drawn.
1454 ASSERT_TRUE(root->GetRenderSurface()); 1451 ASSERT_TRUE(root->GetRenderSurface());
1455 EXPECT_EQ(1U, root->GetRenderSurface()->layer_list().size()); 1452 EXPECT_EQ(1, root->GetRenderSurface()->num_contributors());
1456 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), 1453 EXPECT_EQ(gfx::RectF(0, 0, 10, 10),
1457 root->GetRenderSurface()->DrawableContentRect()); 1454 root->GetRenderSurface()->DrawableContentRect());
1458 EffectTree& effect_tree = 1455 EffectTree& effect_tree =
1459 root->layer_tree_impl()->property_trees()->effect_tree; 1456 root->layer_tree_impl()->property_trees()->effect_tree;
1460 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); 1457 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index());
1461 EXPECT_TRUE(node->is_drawn); 1458 EXPECT_TRUE(node->is_drawn);
1462 1459
1463 // When root is transparent, the layer should not be drawn. 1460 // When root is transparent, the layer should not be drawn.
1464 root->layer_tree_impl()->SetOpacityMutated(root->element_id(), 0.f); 1461 root->layer_tree_impl()->SetOpacityMutated(root->element_id(), 0.f);
1465 root->layer_tree_impl()->SetOpacityMutated(render_surface1->element_id(), 1462 root->layer_tree_impl()->SetOpacityMutated(render_surface1->element_id(),
1466 1.f); 1463 1.f);
1467 render_surface1->set_visible_layer_rect(gfx::Rect()); 1464 render_surface1->set_visible_layer_rect(gfx::Rect());
1468 { 1465 {
1469 LayerImplList render_surface_layer_list; 1466 RenderSurfaceList render_surface_list;
1470 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1467 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1471 root, root->bounds(), &render_surface_layer_list); 1468 root, root->bounds(), &render_surface_list);
1472 inputs.can_adjust_raster_scales = true; 1469 inputs.can_adjust_raster_scales = true;
1473 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1470 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1474 } 1471 }
1475 1472
1476 node = effect_tree.Node(render_surface1->effect_tree_index()); 1473 node = effect_tree.Node(render_surface1->effect_tree_index());
1477 EXPECT_FALSE(node->is_drawn); 1474 EXPECT_FALSE(node->is_drawn);
1478 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect()); 1475 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect());
1479 } 1476 }
1480 1477
1481 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { 1478 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) {
(...skipping 12 matching lines...) Expand all
1494 parent->test_properties()->filters = filters; 1491 parent->test_properties()->filters = filters;
1495 parent->test_properties()->force_render_surface = true; 1492 parent->test_properties()->force_render_surface = true;
1496 child1->SetBounds(gfx::Size(25, 25)); 1493 child1->SetBounds(gfx::Size(25, 25));
1497 child1->SetDrawsContent(true); 1494 child1->SetDrawsContent(true);
1498 child1->test_properties()->force_render_surface = true; 1495 child1->test_properties()->force_render_surface = true;
1499 child2->SetPosition(gfx::PointF(25, 25)); 1496 child2->SetPosition(gfx::PointF(25, 25));
1500 child2->SetBounds(gfx::Size(25, 25)); 1497 child2->SetBounds(gfx::Size(25, 25));
1501 child2->SetDrawsContent(true); 1498 child2->SetDrawsContent(true);
1502 child2->test_properties()->force_render_surface = true; 1499 child2->test_properties()->force_render_surface = true;
1503 1500
1504 LayerImplList render_surface_layer_list; 1501 RenderSurfaceList render_surface_list;
1505 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1502 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1506 root, root->bounds(), &render_surface_layer_list); 1503 root, root->bounds(), &render_surface_list);
1507 inputs.can_adjust_raster_scales = true; 1504 inputs.can_adjust_raster_scales = true;
1508 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1505 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1509 1506
1510 ASSERT_TRUE(parent->GetRenderSurface()); 1507 ASSERT_TRUE(parent->GetRenderSurface());
1511 EXPECT_EQ(2U, parent->GetRenderSurface()->layer_list().size()); 1508 EXPECT_EQ(2, parent->GetRenderSurface()->num_contributors());
1512 EXPECT_EQ(4U, render_surface_layer_list.size()); 1509 EXPECT_EQ(4U, render_surface_list.size());
1513 1510
1514 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the 1511 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the
1515 // blur (-30,-30 110x110), and then scaled by the scale matrix 1512 // blur (-30,-30 110x110), and then scaled by the scale matrix
1516 // (-60,-60 220x220). 1513 // (-60,-60 220x220).
1517 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220), 1514 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220),
1518 parent->GetRenderSurface()->DrawableContentRect()); 1515 parent->GetRenderSurface()->DrawableContentRect());
1519 } 1516 }
1520 1517
1521 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) { 1518 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) {
1522 LayerImpl* root = root_layer_for_testing(); 1519 LayerImpl* root = root_layer_for_testing();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; 1736 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis;
1740 flattened_rotation_about_y.FlattenTo2d(); 1737 flattened_rotation_about_y.FlattenTo2d();
1741 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y, 1738 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y,
1742 child->ScreenSpaceTransform()); 1739 child->ScreenSpaceTransform());
1743 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y, 1740 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y,
1744 grand_child->ScreenSpaceTransform()); 1741 grand_child->ScreenSpaceTransform());
1745 } 1742 }
1746 1743
1747 TEST_F(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) { 1744 TEST_F(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) {
1748 // The entire subtree of layers that are outside the clip rect should be 1745 // The entire subtree of layers that are outside the clip rect should be
1749 // culled away, and should not affect the render_surface_layer_list. 1746 // culled away, and should not affect the render_surface_list.
1750 // 1747 //
1751 // The test tree is set up as follows: 1748 // The test tree is set up as follows:
1752 // - all layers except the leaf_nodes are forced to be a new render surface 1749 // - all layers except the leaf_nodes are forced to be a new render surface
1753 // that have something to draw. 1750 // that have something to draw.
1754 // - parent is a large container layer. 1751 // - parent is a large container layer.
1755 // - child has MasksToBounds=true to cause clipping. 1752 // - child has MasksToBounds=true to cause clipping.
1756 // - grand_child is positioned outside of the child's bounds 1753 // - grand_child is positioned outside of the child's bounds
1757 // - great_grand_child is also kept outside child's bounds. 1754 // - great_grand_child is also kept outside child's bounds.
1758 // 1755 //
1759 // In this configuration, grand_child and great_grand_child are completely 1756 // In this configuration, grand_child and great_grand_child are completely
1760 // outside the clip rect, and they should never get scheduled on the list of 1757 // outside the clip rect, and they should never get scheduled on the list of
1761 // render surfaces. 1758 // render surfaces.
1762 1759
1763 LayerImpl* root = root_layer_for_testing(); 1760 LayerImpl* root = root_layer_for_testing();
1764 LayerImpl* child = AddChildToRoot<LayerImpl>(); 1761 LayerImpl* child = AddChildToRoot<LayerImpl>();
1765 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1762 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1766 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); 1763 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child);
1767 1764
1768 // leaf_node1 ensures that root and child are kept on the 1765 // leaf_node1 ensures that root and child are kept on the render_surface_list,
1769 // render_surface_layer_list, even though grand_child and great_grand_child 1766 // even though grand_child and great_grand_child should be clipped.
1770 // should be clipped.
1771 LayerImpl* leaf_node1 = AddChild<LayerImpl>(child); 1767 LayerImpl* leaf_node1 = AddChild<LayerImpl>(child);
1772 LayerImpl* leaf_node2 = AddChild<LayerImpl>(great_grand_child); 1768 LayerImpl* leaf_node2 = AddChild<LayerImpl>(great_grand_child);
1773 1769
1774 root->SetBounds(gfx::Size(500, 500)); 1770 root->SetBounds(gfx::Size(500, 500));
1775 child->SetBounds(gfx::Size(20, 20)); 1771 child->SetBounds(gfx::Size(20, 20));
1776 child->SetMasksToBounds(true); 1772 child->SetMasksToBounds(true);
1777 child->test_properties()->force_render_surface = true; 1773 child->test_properties()->force_render_surface = true;
1778 grand_child->SetPosition(gfx::PointF(45.f, 45.f)); 1774 grand_child->SetPosition(gfx::PointF(45.f, 45.f));
1779 grand_child->SetBounds(gfx::Size(10, 10)); 1775 grand_child->SetBounds(gfx::Size(10, 10));
1780 great_grand_child->SetBounds(gfx::Size(10, 10)); 1776 great_grand_child->SetBounds(gfx::Size(10, 10));
1781 leaf_node1->SetBounds(gfx::Size(500, 500)); 1777 leaf_node1->SetBounds(gfx::Size(500, 500));
1782 leaf_node1->SetDrawsContent(true); 1778 leaf_node1->SetDrawsContent(true);
1783 leaf_node1->SetBounds(gfx::Size(20, 20)); 1779 leaf_node1->SetBounds(gfx::Size(20, 20));
1784 leaf_node2->SetDrawsContent(true); 1780 leaf_node2->SetDrawsContent(true);
1785 ExecuteCalculateDrawProperties(root); 1781 ExecuteCalculateDrawProperties(root);
1786 1782
1787 ASSERT_EQ(2U, render_surface_layer_list_impl()->size()); 1783 ASSERT_EQ(2U, render_surface_list_impl()->size());
1788 EXPECT_EQ(root->id(), render_surface_layer_list_impl()->at(0)->id()); 1784 EXPECT_EQ(root->id(), render_surface_list_impl()->at(0)->id());
1789 EXPECT_EQ(child->id(), render_surface_layer_list_impl()->at(1)->id()); 1785 EXPECT_EQ(child->id(), render_surface_list_impl()->at(1)->id());
1790 } 1786 }
1791 1787
1792 TEST_F(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) { 1788 TEST_F(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) {
1793 // When a render surface has a clip rect, it is used to clip the content rect 1789 // When a render surface has a clip rect, it is used to clip the content rect
1794 // of the surface. 1790 // of the surface.
1795 1791
1796 // The test tree is set up as follows: 1792 // The test tree is set up as follows:
1797 // - root is a container layer that masksToBounds=true to cause clipping. 1793 // - root is a container layer that masksToBounds=true to cause clipping.
1798 // - child is a render surface, which has a clip rect set to the bounds of 1794 // - child is a render surface, which has a clip rect set to the bounds of
1799 // the root. 1795 // the root.
1800 // - grand_child is a render surface, and the only visible content in child. 1796 // - grand_child is a render surface, and the only visible content in child.
1801 // It is positioned outside of the clip rect from root. 1797 // It is positioned outside of the clip rect from root.
1802 1798
1803 // In this configuration, grand_child should be outside the clipped 1799 // In this configuration, grand_child should be outside the clipped
1804 // content rect of the child, making grand_child not appear in the 1800 // content rect of the child, making grand_child not appear in the
1805 // render_surface_layer_list. 1801 // render_surface_list.
1806 1802
1807 LayerImpl* root = root_layer_for_testing(); 1803 LayerImpl* root = root_layer_for_testing();
1808 LayerImpl* child = AddChildToRoot<LayerImpl>(); 1804 LayerImpl* child = AddChildToRoot<LayerImpl>();
1809 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1805 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1810 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); 1806 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
1811 1807
1812 root->SetMasksToBounds(true); 1808 root->SetMasksToBounds(true);
1813 root->SetBounds(gfx::Size(100, 100)); 1809 root->SetBounds(gfx::Size(100, 100));
1814 child->SetBounds(gfx::Size(20, 20)); 1810 child->SetBounds(gfx::Size(20, 20));
1815 child->test_properties()->force_render_surface = true; 1811 child->test_properties()->force_render_surface = true;
1816 grand_child->SetPosition(gfx::PointF(200.f, 200.f)); 1812 grand_child->SetPosition(gfx::PointF(200.f, 200.f));
1817 grand_child->SetBounds(gfx::Size(10, 10)); 1813 grand_child->SetBounds(gfx::Size(10, 10));
1818 grand_child->test_properties()->force_render_surface = true; 1814 grand_child->test_properties()->force_render_surface = true;
1819 leaf_node->SetBounds(gfx::Size(10, 10)); 1815 leaf_node->SetBounds(gfx::Size(10, 10));
1820 leaf_node->SetDrawsContent(true); 1816 leaf_node->SetDrawsContent(true);
1821 ExecuteCalculateDrawProperties(root); 1817 ExecuteCalculateDrawProperties(root);
1822 1818
1823 // We should cull child and grand_child from the 1819 // We should cull child and grand_child from the
1824 // render_surface_layer_list. 1820 // render_surface_list.
1825 ASSERT_EQ(1U, render_surface_layer_list_impl()->size()); 1821 ASSERT_EQ(1U, render_surface_list_impl()->size());
1826 EXPECT_EQ(root->id(), render_surface_layer_list_impl()->at(0)->id()); 1822 EXPECT_EQ(root->id(), render_surface_list_impl()->at(0)->id());
1827 } 1823 }
1828 1824
1829 TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectlyLayerImpl) { 1825 TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectlyLayerImpl) {
1830 // Tests that LayerImpl's IsClipped() property is set to true when: 1826 // Tests that LayerImpl's IsClipped() property is set to true when:
1831 // - the layer clips its subtree, e.g. masks to bounds, 1827 // - the layer clips its subtree, e.g. masks to bounds,
1832 // - the layer is clipped by an ancestor that contributes to the same 1828 // - the layer is clipped by an ancestor that contributes to the same
1833 // render target, 1829 // render target,
1834 // - a surface is clipped by an ancestor that contributes to the same 1830 // - a surface is clipped by an ancestor that contributes to the same
1835 // render target. 1831 // render target.
1836 // 1832 //
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 child1->SetPosition(gfx::PointF(5.f, 5.f)); 3541 child1->SetPosition(gfx::PointF(5.f, 5.f));
3546 child1->SetBounds(gfx::Size(50, 50)); 3542 child1->SetBounds(gfx::Size(50, 50));
3547 child1->SetDrawsContent(true); 3543 child1->SetDrawsContent(true);
3548 child2->SetPosition(gfx::PointF(75.f, 75.f)); 3544 child2->SetPosition(gfx::PointF(75.f, 75.f));
3549 child2->SetBounds(gfx::Size(50, 50)); 3545 child2->SetBounds(gfx::Size(50, 50));
3550 child2->SetDrawsContent(true); 3546 child2->SetDrawsContent(true);
3551 child3->SetPosition(gfx::PointF(125.f, 125.f)); 3547 child3->SetPosition(gfx::PointF(125.f, 125.f));
3552 child3->SetBounds(gfx::Size(50, 50)); 3548 child3->SetBounds(gfx::Size(50, 50));
3553 child3->SetDrawsContent(true); 3549 child3->SetDrawsContent(true);
3554 3550
3555 LayerImplList render_surface_layer_list_impl; 3551 RenderSurfaceList render_surface_list_impl;
3556 // Now set the root render surface an empty clip. 3552 // Now set the root render surface an empty clip.
3557 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 3553 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
3558 root, gfx::Size(), &render_surface_layer_list_impl); 3554 root, gfx::Size(), &render_surface_list_impl);
3559 3555
3560 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 3556 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
3561 ASSERT_TRUE(root->GetRenderSurface()); 3557 ASSERT_TRUE(root->GetRenderSurface());
3562 EXPECT_FALSE(root->is_clipped()); 3558 EXPECT_FALSE(root->is_clipped());
3563 3559
3564 gfx::Rect empty; 3560 gfx::Rect empty;
3565 EXPECT_EQ(empty, root->GetRenderSurface()->clip_rect()); 3561 EXPECT_EQ(empty, root->GetRenderSurface()->clip_rect());
3566 EXPECT_TRUE(root->GetRenderSurface()->is_clipped()); 3562 EXPECT_TRUE(root->GetRenderSurface()->is_clipped());
3567 3563
3568 // Visible content rect calculation will check if the target surface is 3564 // Visible content rect calculation will check if the target surface is
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4672 child2->SetDrawsContent(true); 4668 child2->SetDrawsContent(true);
4673 4669
4674 float device_scale_factor = 2.5f; 4670 float device_scale_factor = 2.5f;
4675 gfx::Size viewport_size(100, 100); 4671 gfx::Size viewport_size(100, 100);
4676 ExecuteCalculateDrawProperties(root, device_scale_factor); 4672 ExecuteCalculateDrawProperties(root, device_scale_factor);
4677 4673
4678 EXPECT_FLOAT_EQ(device_scale_factor, root->GetIdealContentsScale()); 4674 EXPECT_FLOAT_EQ(device_scale_factor, root->GetIdealContentsScale());
4679 EXPECT_FLOAT_EQ(device_scale_factor, child->GetIdealContentsScale()); 4675 EXPECT_FLOAT_EQ(device_scale_factor, child->GetIdealContentsScale());
4680 EXPECT_FLOAT_EQ(device_scale_factor, child2->GetIdealContentsScale()); 4676 EXPECT_FLOAT_EQ(device_scale_factor, child2->GetIdealContentsScale());
4681 4677
4682 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 4678 EXPECT_EQ(1u, render_surface_list_impl()->size());
4683 4679
4684 // Verify root transforms 4680 // Verify root transforms
4685 gfx::Transform expected_root_transform; 4681 gfx::Transform expected_root_transform;
4686 expected_root_transform.Scale(device_scale_factor, device_scale_factor); 4682 expected_root_transform.Scale(device_scale_factor, device_scale_factor);
4687 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_root_transform, 4683 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_root_transform,
4688 root->ScreenSpaceTransform()); 4684 root->ScreenSpaceTransform());
4689 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_root_transform, 4685 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_root_transform,
4690 root->DrawTransform()); 4686 root->DrawTransform());
4691 4687
4692 // Verify results of transformed root rects 4688 // Verify results of transformed root rects
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
4799 4795
4800 // The ideal scale will draw 1:1 with its render target space along 4796 // The ideal scale will draw 1:1 with its render target space along
4801 // the larger-scale axis. 4797 // the larger-scale axis.
4802 gfx::Vector2dF target_space_transform_scales = 4798 gfx::Vector2dF target_space_transform_scales =
4803 MathUtil::ComputeTransform2dScaleComponents( 4799 MathUtil::ComputeTransform2dScaleComponents(
4804 scale_surface->draw_properties().target_space_transform, 0.f); 4800 scale_surface->draw_properties().target_space_transform, 0.f);
4805 EXPECT_FLOAT_EQ(max_2d_scale, 4801 EXPECT_FLOAT_EQ(max_2d_scale,
4806 std::max(target_space_transform_scales.x(), 4802 std::max(target_space_transform_scales.x(),
4807 target_space_transform_scales.y())); 4803 target_space_transform_scales.y()));
4808 4804
4809 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 4805 EXPECT_EQ(3u, render_surface_list_impl()->size());
4810 4806
4811 gfx::Transform expected_parent_draw_transform; 4807 gfx::Transform expected_parent_draw_transform;
4812 expected_parent_draw_transform.Scale(device_scale_factor * page_scale_factor, 4808 expected_parent_draw_transform.Scale(device_scale_factor * page_scale_factor,
4813 device_scale_factor * page_scale_factor); 4809 device_scale_factor * page_scale_factor);
4814 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_draw_transform, 4810 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_draw_transform,
4815 parent->DrawTransform()); 4811 parent->DrawTransform());
4816 4812
4817 // The scale for the perspective surface is not known, so it is rendered 1:1 4813 // The scale for the perspective surface is not known, so it is rendered 1:1
4818 // with the screen, and then scaled during drawing. 4814 // with the screen, and then scaled during drawing.
4819 gfx::Transform expected_perspective_surface_draw_transform; 4815 gfx::Transform expected_perspective_surface_draw_transform;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4930 // and screen space transforms. 4926 // and screen space transforms.
4931 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child); 4927 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child);
4932 duplicate_child_non_owner->SetBounds(gfx::Size(10, 10)); 4928 duplicate_child_non_owner->SetBounds(gfx::Size(10, 10));
4933 duplicate_child_non_owner->SetDrawsContent(true); 4929 duplicate_child_non_owner->SetDrawsContent(true);
4934 4930
4935 float device_scale_factor = 1.5f; 4931 float device_scale_factor = 1.5f;
4936 ExecuteCalculateDrawProperties(parent, device_scale_factor); 4932 ExecuteCalculateDrawProperties(parent, device_scale_factor);
4937 4933
4938 // We should have two render surfaces. The root's render surface and child's 4934 // We should have two render surfaces. The root's render surface and child's
4939 // render surface (it needs one because of force_render_surface). 4935 // render surface (it needs one because of force_render_surface).
4940 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 4936 EXPECT_EQ(2u, render_surface_list_impl()->size());
4941 4937
4942 gfx::Transform expected_parent_transform; 4938 gfx::Transform expected_parent_transform;
4943 expected_parent_transform.Scale(device_scale_factor, device_scale_factor); 4939 expected_parent_transform.Scale(device_scale_factor, device_scale_factor);
4944 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform, 4940 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
4945 parent->ScreenSpaceTransform()); 4941 parent->ScreenSpaceTransform());
4946 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform, 4942 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
4947 parent->DrawTransform()); 4943 parent->DrawTransform());
4948 4944
4949 gfx::Transform expected_draw_transform; 4945 gfx::Transform expected_draw_transform;
4950 expected_draw_transform.Scale(device_scale_factor, device_scale_factor); 4946 expected_draw_transform.Scale(device_scale_factor, device_scale_factor);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5000 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4996 LayerImpl* child = AddChildToRoot<LayerImpl>();
5001 child->SetBounds(gfx::Size(13, 11)); 4997 child->SetBounds(gfx::Size(13, 11));
5002 child->SetDrawsContent(true); 4998 child->SetDrawsContent(true);
5003 child->test_properties()->force_render_surface = true; 4999 child->test_properties()->force_render_surface = true;
5004 5000
5005 float device_scale_factor = 1.7f; 5001 float device_scale_factor = 1.7f;
5006 ExecuteCalculateDrawProperties(parent, device_scale_factor); 5002 ExecuteCalculateDrawProperties(parent, device_scale_factor);
5007 5003
5008 // We should have two render surfaces. The root's render surface and child's 5004 // We should have two render surfaces. The root's render surface and child's
5009 // render surface (it needs one because of force_render_surface). 5005 // render surface (it needs one because of force_render_surface).
5010 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 5006 EXPECT_EQ(2u, render_surface_list_impl()->size());
5011 5007
5012 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 5008 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
5013 child->GetRenderSurface()->draw_transform()); 5009 child->GetRenderSurface()->draw_transform());
5014 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 5010 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
5015 child->GetRenderSurface()->draw_transform()); 5011 child->GetRenderSurface()->draw_transform());
5016 EXPECT_TRANSFORMATION_MATRIX_EQ( 5012 EXPECT_TRANSFORMATION_MATRIX_EQ(
5017 gfx::Transform(), child->GetRenderSurface()->screen_space_transform()); 5013 gfx::Transform(), child->GetRenderSurface()->screen_space_transform());
5018 } 5014 }
5019 5015
5020 TEST_F(LayerTreeHostCommonTest, LayerSearch) { 5016 TEST_F(LayerTreeHostCommonTest, LayerSearch) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5078 scoped_refptr<AnimationTimeline> timeline = 5074 scoped_refptr<AnimationTimeline> timeline =
5079 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5075 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5080 host_impl.animation_host()->AddAnimationTimeline(timeline); 5076 host_impl.animation_host()->AddAnimationTimeline(timeline);
5081 5077
5082 ElementId child_element_id = 5078 ElementId child_element_id =
5083 host_impl.pending_tree()->LayerById(child_id)->element_id(); 5079 host_impl.pending_tree()->LayerById(child_id)->element_id();
5084 5080
5085 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, 5081 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0,
5086 0.0f, 1.0f, false); 5082 0.0f, 1.0f, false);
5087 5083
5088 LayerImplList render_surface_layer_list; 5084 RenderSurfaceList render_surface_list;
5089 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5085 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5090 root_layer, root_layer->bounds(), &render_surface_layer_list); 5086 root_layer, root_layer->bounds(), &render_surface_list);
5091 inputs.can_adjust_raster_scales = true; 5087 inputs.can_adjust_raster_scales = true;
5092 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5093 5089
5094 // We should have one render surface and two layers. The child 5090 // We should have one render surface and two layers. The child
5095 // layer should be included even though it is transparent. 5091 // layer should be included even though it is transparent.
5096 ASSERT_EQ(1u, render_surface_layer_list.size()); 5092 ASSERT_EQ(1u, render_surface_list.size());
5097 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size()); 5093 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors());
5098 5094
5099 // If the root itself is hidden, the child should not be drawn even if it has 5095 // If the root itself is hidden, the child should not be drawn even if it has
5100 // an animating opacity. 5096 // an animating opacity.
5101 root_layer->test_properties()->opacity = 0.0f; 5097 root_layer->test_properties()->opacity = 0.0f;
5102 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5098 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5103 LayerImplList render_surface_layer_list2; 5099 RenderSurfaceList render_surface_list2;
5104 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( 5100 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2(
5105 root_layer, root_layer->bounds(), &render_surface_layer_list2); 5101 root_layer, root_layer->bounds(), &render_surface_list2);
5106 inputs2.can_adjust_raster_scales = true; 5102 inputs2.can_adjust_raster_scales = true;
5107 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); 5103 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2);
5108 5104
5109 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5105 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5110 EffectTree& tree = 5106 EffectTree& tree =
5111 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5107 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5112 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); 5108 EffectNode* node = tree.Node(child_ptr->effect_tree_index());
5113 EXPECT_FALSE(node->is_drawn); 5109 EXPECT_FALSE(node->is_drawn);
5114 5110
5115 // A layer should be drawn and it should contribute to drawn surface when 5111 // A layer should be drawn and it should contribute to drawn surface when
5116 // it has animating opacity even if it has opacity 0. 5112 // it has animating opacity even if it has opacity 0.
5117 root_layer->test_properties()->opacity = 1.0f; 5113 root_layer->test_properties()->opacity = 1.0f;
5118 child_ptr->test_properties()->opacity = 0.0f; 5114 child_ptr->test_properties()->opacity = 0.0f;
5119 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5115 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5120 LayerImplList render_surface_layer_list3; 5116 RenderSurfaceList render_surface_list3;
5121 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( 5117 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
5122 root_layer, root_layer->bounds(), &render_surface_layer_list3); 5118 root_layer, root_layer->bounds(), &render_surface_list3);
5123 inputs3.can_adjust_raster_scales = true; 5119 inputs3.can_adjust_raster_scales = true;
5124 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); 5120 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3);
5125 5121
5126 child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5122 child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5127 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; 5123 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree;
5128 node = tree.Node(child_ptr->effect_tree_index()); 5124 node = tree.Node(child_ptr->effect_tree_index());
5129 EXPECT_TRUE(node->is_drawn); 5125 EXPECT_TRUE(node->is_drawn);
5130 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); 5126 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index()));
5131 5127
5132 // But if the opacity of the layer remains 0 after activation, it should not 5128 // But if the opacity of the layer remains 0 after activation, it should not
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
5377 std::unique_ptr<LayerImpl> root = 5373 std::unique_ptr<LayerImpl> root =
5378 LayerImpl::Create(host_impl.pending_tree(), 1); 5374 LayerImpl::Create(host_impl.pending_tree(), 1);
5379 root->SetBounds(gfx::Size(50, 50)); 5375 root->SetBounds(gfx::Size(50, 50));
5380 root->SetDrawsContent(true); 5376 root->SetDrawsContent(true);
5381 LayerImpl* root_layer = root.get(); 5377 LayerImpl* root_layer = root.get();
5382 5378
5383 std::unique_ptr<LayerImpl> child = 5379 std::unique_ptr<LayerImpl> child =
5384 LayerImpl::Create(host_impl.pending_tree(), 2); 5380 LayerImpl::Create(host_impl.pending_tree(), 2);
5385 child->SetBounds(gfx::Size(40, 40)); 5381 child->SetBounds(gfx::Size(40, 40));
5386 child->SetDrawsContent(true); 5382 child->SetDrawsContent(true);
5383 LayerImpl* child_layer = child.get();
5387 5384
5388 std::unique_ptr<LayerImpl> grand_child = 5385 std::unique_ptr<LayerImpl> grand_child =
5389 LayerImpl::Create(host_impl.pending_tree(), 3); 5386 LayerImpl::Create(host_impl.pending_tree(), 3);
5390 grand_child->SetBounds(gfx::Size(30, 30)); 5387 grand_child->SetBounds(gfx::Size(30, 30));
5391 grand_child->SetDrawsContent(true); 5388 grand_child->SetDrawsContent(true);
5392 grand_child->test_properties()->hide_layer_and_subtree = true; 5389 grand_child->test_properties()->hide_layer_and_subtree = true;
5390 LayerImpl* grand_child_layer = grand_child.get();
5393 5391
5394 child->test_properties()->AddChild(std::move(grand_child)); 5392 child->test_properties()->AddChild(std::move(grand_child));
5395 root->test_properties()->AddChild(std::move(child)); 5393 root->test_properties()->AddChild(std::move(child));
5396 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); 5394 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5397 5395
5398 LayerImplList render_surface_layer_list; 5396 RenderSurfaceList render_surface_list;
5399 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5397 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5400 root_layer, root_layer->bounds(), &render_surface_layer_list); 5398 root_layer, root_layer->bounds(), &render_surface_list);
5401 inputs.can_adjust_raster_scales = true; 5399 inputs.can_adjust_raster_scales = true;
5402 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5400 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5403 5401
5404 // We should have one render surface and two layers. The grand child has 5402 // We should have one render surface and two layers. The grand child has
5405 // hidden itself. 5403 // hidden itself.
5406 ASSERT_EQ(1u, render_surface_layer_list.size()); 5404 ASSERT_EQ(1u, render_surface_list.size());
5407 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size()); 5405 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors());
5408 EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id()); 5406 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member());
5409 EXPECT_EQ(2, root_layer->GetRenderSurface()->layer_list().at(1)->id()); 5407 EXPECT_TRUE(child_layer->is_drawn_render_surface_layer_list_member());
5408 EXPECT_FALSE(grand_child_layer->is_drawn_render_surface_layer_list_member());
5410 } 5409 }
5411 5410
5412 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { 5411 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
5413 FakeImplTaskRunnerProvider task_runner_provider; 5412 FakeImplTaskRunnerProvider task_runner_provider;
5414 TestTaskGraphRunner task_graph_runner; 5413 TestTaskGraphRunner task_graph_runner;
5415 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5414 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5416 host_impl.CreatePendingTree(); 5415 host_impl.CreatePendingTree();
5417 5416
5418 std::unique_ptr<LayerImpl> root = 5417 std::unique_ptr<LayerImpl> root =
5419 LayerImpl::Create(host_impl.pending_tree(), 1); 5418 LayerImpl::Create(host_impl.pending_tree(), 1);
5420 root->SetBounds(gfx::Size(50, 50)); 5419 root->SetBounds(gfx::Size(50, 50));
5421 root->SetDrawsContent(true); 5420 root->SetDrawsContent(true);
5422 LayerImpl* root_layer = root.get(); 5421 LayerImpl* root_layer = root.get();
5423 5422
5424 std::unique_ptr<LayerImpl> child = 5423 std::unique_ptr<LayerImpl> child =
5425 LayerImpl::Create(host_impl.pending_tree(), 2); 5424 LayerImpl::Create(host_impl.pending_tree(), 2);
5426 child->SetBounds(gfx::Size(40, 40)); 5425 child->SetBounds(gfx::Size(40, 40));
5427 child->SetDrawsContent(true); 5426 child->SetDrawsContent(true);
5428 child->test_properties()->hide_layer_and_subtree = true; 5427 child->test_properties()->hide_layer_and_subtree = true;
5428 LayerImpl* child_layer = child.get();
5429 5429
5430 std::unique_ptr<LayerImpl> grand_child = 5430 std::unique_ptr<LayerImpl> grand_child =
5431 LayerImpl::Create(host_impl.pending_tree(), 3); 5431 LayerImpl::Create(host_impl.pending_tree(), 3);
5432 grand_child->SetBounds(gfx::Size(30, 30)); 5432 grand_child->SetBounds(gfx::Size(30, 30));
5433 grand_child->SetDrawsContent(true); 5433 grand_child->SetDrawsContent(true);
5434 LayerImpl* grand_child_layer = grand_child.get();
5434 5435
5435 child->test_properties()->AddChild(std::move(grand_child)); 5436 child->test_properties()->AddChild(std::move(grand_child));
5436 root->test_properties()->AddChild(std::move(child)); 5437 root->test_properties()->AddChild(std::move(child));
5437 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); 5438 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5438 5439
5439 LayerImplList render_surface_layer_list; 5440 RenderSurfaceList render_surface_list;
5440 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5441 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5441 root_layer, root_layer->bounds(), &render_surface_layer_list); 5442 root_layer, root_layer->bounds(), &render_surface_list);
5442 inputs.can_adjust_raster_scales = true; 5443 inputs.can_adjust_raster_scales = true;
5443 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5444 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5444 5445
5445 // We should have one render surface and one layers. The child has 5446 // We should have one render surface and one layer. The child has
5446 // hidden itself and the grand child. 5447 // hidden itself and the grand child.
5447 ASSERT_EQ(1u, render_surface_layer_list.size()); 5448 ASSERT_EQ(1u, render_surface_list.size());
5448 ASSERT_EQ(1u, root_layer->GetRenderSurface()->layer_list().size()); 5449 ASSERT_EQ(1, root_layer->GetRenderSurface()->num_contributors());
5449 EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id()); 5450 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member());
5451 EXPECT_FALSE(child_layer->is_drawn_render_surface_layer_list_member());
5452 EXPECT_FALSE(grand_child_layer->is_drawn_render_surface_layer_list_member());
5450 } 5453 }
5451 5454
5452 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 5455 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
5453 5456
5454 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { 5457 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
5455 FakeImplTaskRunnerProvider task_runner_provider; 5458 FakeImplTaskRunnerProvider task_runner_provider;
5456 TestTaskGraphRunner task_graph_runner; 5459 TestTaskGraphRunner task_graph_runner;
5457 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5460 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5458 host_impl.CreatePendingTree(); 5461 host_impl.CreatePendingTree();
5459 5462
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5525 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true; 5528 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true;
5526 copy_grand_parent_sibling_before_layer->test_properties() 5529 copy_grand_parent_sibling_before_layer->test_properties()
5527 ->hide_layer_and_subtree = true; 5530 ->hide_layer_and_subtree = true;
5528 copy_grand_parent_sibling_after_layer->test_properties() 5531 copy_grand_parent_sibling_after_layer->test_properties()
5529 ->hide_layer_and_subtree = true; 5532 ->hide_layer_and_subtree = true;
5530 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true; 5533 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true;
5531 5534
5532 copy_layer->test_properties()->copy_requests.push_back( 5535 copy_layer->test_properties()->copy_requests.push_back(
5533 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5536 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5534 5537
5535 LayerImplList render_surface_layer_list; 5538 RenderSurfaceList render_surface_list;
5536 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5539 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5537 root_layer, root_layer->bounds(), &render_surface_layer_list); 5540 root_layer, root_layer->bounds(), &render_surface_list);
5538 inputs.can_adjust_raster_scales = true; 5541 inputs.can_adjust_raster_scales = true;
5539 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5542 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5540 5543
5541 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); 5544 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree());
5542 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); 5545 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree());
5543 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); 5546 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree());
5544 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); 5547 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree());
5545 5548
5546 // We should have four render surfaces, one for the root, one for the grand 5549 // We should have four render surfaces, one for the root, one for the grand
5547 // parent since it has opacity and two drawing descendants, one for the parent 5550 // parent since it has opacity and two drawing descendants, one for the parent
5548 // since it owns a surface, and one for the copy_layer. 5551 // since it owns a surface, and one for the copy_layer.
5549 ASSERT_EQ(4u, render_surface_layer_list.size()); 5552 ASSERT_EQ(4u, render_surface_list.size());
5550 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5553 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id());
5551 EXPECT_EQ(copy_grand_parent_layer->id(), 5554 EXPECT_EQ(copy_grand_parent_layer->id(), render_surface_list.at(1)->id());
5552 render_surface_layer_list.at(1)->id()); 5555 EXPECT_EQ(copy_parent_layer->id(), render_surface_list.at(2)->id());
5553 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); 5556 EXPECT_EQ(copy_layer->id(), render_surface_list.at(3)->id());
5554 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
5555 5557
5556 // The root render surface should have 2 contributing layers. 5558 // The root render surface should have 2 contributing layers.
5557 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size()); 5559 EXPECT_EQ(2, root_layer->GetRenderSurface()->num_contributors());
5558 EXPECT_EQ(root_layer->id(), 5560 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member());
5559 root_layer->GetRenderSurface()->layer_list().at(0)->id()); 5561 EXPECT_FALSE(
5560 EXPECT_EQ(copy_grand_parent_layer->id(), 5562 copy_grand_parent_layer->is_drawn_render_surface_layer_list_member());
5561 root_layer->GetRenderSurface()->layer_list().at(1)->id()); 5563 EXPECT_FALSE(copy_grand_parent_sibling_before_layer
5564 ->is_drawn_render_surface_layer_list_member());
5565 EXPECT_FALSE(copy_grand_parent_sibling_after_layer
5566 ->is_drawn_render_surface_layer_list_member());
5562 5567
5563 // Nothing actually draws into the copy parent, so only the copy_layer will 5568 // Nothing actually draws into the copy parent, so only the copy_layer will
5564 // appear in its list, since it needs to be drawn for the copy request. 5569 // appear in its list, since it needs to be drawn for the copy request.
5565 ASSERT_EQ(1u, copy_parent_layer->GetRenderSurface()->layer_list().size()); 5570 ASSERT_EQ(1, copy_parent_layer->GetRenderSurface()->num_contributors());
5566 EXPECT_EQ(copy_layer->id(), 5571 EXPECT_FALSE(copy_parent_layer->is_drawn_render_surface_layer_list_member());
5567 copy_parent_layer->GetRenderSurface()->layer_list().at(0)->id());
5568 5572
5569 // The copy_layer's render surface should have two contributing layers. 5573 // The copy layer's render surface should have 2 contributing layers.
5570 ASSERT_EQ(2u, copy_layer->GetRenderSurface()->layer_list().size()); 5574 ASSERT_EQ(2, copy_layer->GetRenderSurface()->num_contributors());
5571 EXPECT_EQ(copy_layer->id(), 5575 EXPECT_TRUE(copy_layer->is_drawn_render_surface_layer_list_member());
5572 copy_layer->GetRenderSurface()->layer_list().at(0)->id()); 5576 EXPECT_TRUE(copy_child_layer->is_drawn_render_surface_layer_list_member());
5573 EXPECT_EQ(copy_child_layer->id(), 5577 EXPECT_FALSE(
5574 copy_layer->GetRenderSurface()->layer_list().at(1)->id()); 5578 copy_grand_child_layer->is_drawn_render_surface_layer_list_member());
5575 5579
5576 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, 5580 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
5577 // but the copy_layer and copy_child should be drawn for the copy request. 5581 // but the copy_layer and copy_child should be drawn for the copy request.
5578 // copy grand child should not be drawn as its hidden even in the copy 5582 // copy grand child should not be drawn as its hidden even in the copy
5579 // request. 5583 // request.
5580 EffectTree& tree = 5584 EffectTree& tree =
5581 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5585 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5582 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); 5586 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
5583 EXPECT_FALSE(node->is_drawn); 5587 EXPECT_FALSE(node->is_drawn);
5584 node = tree.Node(copy_parent_layer->effect_tree_index()); 5588 node = tree.Node(copy_parent_layer->effect_tree_index());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5622 copy_child->SetBounds(gfx::Size(20, 20)); 5626 copy_child->SetBounds(gfx::Size(20, 20));
5623 copy_child->SetDrawsContent(true); 5627 copy_child->SetDrawsContent(true);
5624 5628
5625 copy_layer->test_properties()->copy_requests.push_back( 5629 copy_layer->test_properties()->copy_requests.push_back(
5626 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5630 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5627 5631
5628 copy_layer->test_properties()->AddChild(std::move(copy_child)); 5632 copy_layer->test_properties()->AddChild(std::move(copy_child));
5629 copy_parent->test_properties()->AddChild(std::move(copy_layer)); 5633 copy_parent->test_properties()->AddChild(std::move(copy_layer));
5630 root->test_properties()->AddChild(std::move(copy_parent)); 5634 root->test_properties()->AddChild(std::move(copy_parent));
5631 5635
5632 LayerImplList render_surface_layer_list; 5636 RenderSurfaceList render_surface_list;
5633 LayerImpl* root_layer = root.get(); 5637 LayerImpl* root_layer = root.get();
5634 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root)); 5638 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root));
5635 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5639 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5636 root_layer, root_layer->bounds(), &render_surface_layer_list); 5640 root_layer, root_layer->bounds(), &render_surface_list);
5637 inputs.can_adjust_raster_scales = true; 5641 inputs.can_adjust_raster_scales = true;
5638 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5642 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5639 5643
5640 // We should have two render surface, as the others are clipped out. 5644 // We should have two render surface, as the others are clipped out.
5641 ASSERT_EQ(2u, render_surface_layer_list.size()); 5645 ASSERT_EQ(2u, render_surface_list.size());
5642 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5646 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id());
5643 5647
5644 // The root render surface should only have 2 contributing layer, since the 5648 // The root render surface should have only 2 contributing layer, since the
5645 // other layers are empty/clipped away. 5649 // other layers are clipped away.
5646 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size()); 5650 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors());
5647 EXPECT_EQ(root_layer->id(), 5651 EXPECT_TRUE(root_layer->is_drawn_render_surface_layer_list_member());
5648 root_layer->GetRenderSurface()->layer_list().at(0)->id());
5649 } 5652 }
5650 5653
5651 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { 5654 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) {
5652 LayerImpl* root = root_layer_for_testing(); 5655 LayerImpl* root = root_layer_for_testing();
5653 root->SetBounds(gfx::Size(50, 50)); 5656 root->SetBounds(gfx::Size(50, 50));
5654 root->SetDrawsContent(true); 5657 root->SetDrawsContent(true);
5655 root->SetMasksToBounds(true); 5658 root->SetMasksToBounds(true);
5656 5659
5657 LayerImpl* copy_layer = AddChild<LayerImpl>(root); 5660 LayerImpl* copy_layer = AddChild<LayerImpl>(root);
5658 copy_layer->SetBounds(gfx::Size(100, 100)); 5661 copy_layer->SetBounds(gfx::Size(100, 100));
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
6139 child3->SetDrawsContent(true); 6142 child3->SetDrawsContent(true);
6140 child3->test_properties()->sorting_context_id = 1; 6143 child3->test_properties()->sorting_context_id = 1;
6141 6144
6142 child2->test_properties()->AddChild(std::move(child3)); 6145 child2->test_properties()->AddChild(std::move(child3));
6143 child1->test_properties()->AddChild(std::move(child2)); 6146 child1->test_properties()->AddChild(std::move(child2));
6144 root->test_properties()->AddChild(std::move(child1)); 6147 root->test_properties()->AddChild(std::move(child1));
6145 LayerImpl* root_layer = root.get(); 6148 LayerImpl* root_layer = root.get();
6146 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root)); 6149 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root));
6147 6150
6148 { 6151 {
6149 LayerImplList render_surface_layer_list; 6152 RenderSurfaceList render_surface_list;
6150 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6153 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6151 root_layer, root_layer->bounds(), &render_surface_layer_list); 6154 root_layer, root_layer->bounds(), &render_surface_list);
6152 inputs.can_render_to_separate_surface = true; 6155 inputs.can_render_to_separate_surface = true;
6153 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6156 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6154 6157
6155 EXPECT_EQ(2u, render_surface_layer_list.size()); 6158 EXPECT_EQ(2u, render_surface_list.size());
6156 6159
6157 int count_represents_target_render_surface = 0; 6160 int count_represents_target_render_surface = 0;
6158 int count_represents_contributing_render_surface = 0; 6161 int count_represents_contributing_render_surface = 0;
6159 int count_represents_itself = 0; 6162 int count_represents_itself = 0;
6160 for (EffectTreeLayerListIterator it(host_impl.active_tree()); 6163 for (EffectTreeLayerListIterator it(host_impl.active_tree());
6161 it.state() != EffectTreeLayerListIterator::State::END; ++it) { 6164 it.state() != EffectTreeLayerListIterator::State::END; ++it) {
6162 if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) { 6165 if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
6163 count_represents_target_render_surface++; 6166 count_represents_target_render_surface++;
6164 } else if (it.state() == 6167 } else if (it.state() ==
6165 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) { 6168 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
6166 count_represents_contributing_render_surface++; 6169 count_represents_contributing_render_surface++;
6167 } else { 6170 } else {
6168 count_represents_itself++; 6171 count_represents_itself++;
6169 } 6172 }
6170 } 6173 }
6171 6174
6172 // Two render surfaces. 6175 // Two render surfaces.
6173 EXPECT_EQ(2, count_represents_target_render_surface); 6176 EXPECT_EQ(2, count_represents_target_render_surface);
6174 // Second render surface contributes to root render surface. 6177 // Second render surface contributes to root render surface.
6175 EXPECT_EQ(1, count_represents_contributing_render_surface); 6178 EXPECT_EQ(1, count_represents_contributing_render_surface);
6176 // All 4 layers represent itself. 6179 // All 4 layers represent itself.
6177 EXPECT_EQ(4, count_represents_itself); 6180 EXPECT_EQ(4, count_represents_itself);
6178 } 6181 }
6179 6182
6180 { 6183 {
6181 LayerImplList render_surface_layer_list; 6184 RenderSurfaceList render_surface_list;
6182 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6185 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6183 root_layer, root_layer->bounds(), &render_surface_layer_list); 6186 root_layer, root_layer->bounds(), &render_surface_list);
6184 inputs.can_render_to_separate_surface = false; 6187 inputs.can_render_to_separate_surface = false;
6185 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6188 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6186 6189
6187 EXPECT_EQ(1u, render_surface_layer_list.size()); 6190 EXPECT_EQ(1u, render_surface_list.size());
6188 6191
6189 int count_represents_target_render_surface = 0; 6192 int count_represents_target_render_surface = 0;
6190 int count_represents_contributing_render_surface = 0; 6193 int count_represents_contributing_render_surface = 0;
6191 int count_represents_itself = 0; 6194 int count_represents_itself = 0;
6192 for (EffectTreeLayerListIterator it(host_impl.active_tree()); 6195 for (EffectTreeLayerListIterator it(host_impl.active_tree());
6193 it.state() != EffectTreeLayerListIterator::State::END; ++it) { 6196 it.state() != EffectTreeLayerListIterator::State::END; ++it) {
6194 if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) { 6197 if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
6195 count_represents_target_render_surface++; 6198 count_represents_target_render_surface++;
6196 } else if (it.state() == 6199 } else if (it.state() ==
6197 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) { 6200 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6236 6239
6237 flattener->SetBounds(gfx::Size(30, 30)); 6240 flattener->SetBounds(gfx::Size(30, 30));
6238 render_surface2->SetBounds(gfx::Size(30, 30)); 6241 render_surface2->SetBounds(gfx::Size(30, 30));
6239 render_surface2->test_properties()->should_flatten_transform = false; 6242 render_surface2->test_properties()->should_flatten_transform = false;
6240 render_surface2->test_properties()->force_render_surface = true; 6243 render_surface2->test_properties()->force_render_surface = true;
6241 render_surface2->test_properties()->double_sided = false; 6244 render_surface2->test_properties()->double_sided = false;
6242 child2->SetBounds(gfx::Size(20, 20)); 6245 child2->SetBounds(gfx::Size(20, 20));
6243 6246
6244 ExecuteCalculateDrawProperties(root); 6247 ExecuteCalculateDrawProperties(root);
6245 6248
6246 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6249 EXPECT_EQ(3u, render_surface_list_impl()->size());
6247 EXPECT_EQ(2u, 6250 EXPECT_EQ(2, render_surface_list_impl()->at(0)->num_contributors());
6248 render_surface_layer_list_impl() 6251 EXPECT_EQ(1, render_surface_list_impl()->at(1)->num_contributors());
6249 ->at(0)
6250 ->GetRenderSurface()
6251 ->layer_list()
6252 .size());
6253 EXPECT_EQ(1u,
6254 render_surface_layer_list_impl()
6255 ->at(1)
6256 ->GetRenderSurface()
6257 ->layer_list()
6258 .size());
6259 6252
6260 gfx::Transform rotation_transform; 6253 gfx::Transform rotation_transform;
6261 rotation_transform.RotateAboutXAxis(180.0); 6254 rotation_transform.RotateAboutXAxis(180.0);
6262 6255
6263 back_facing->test_properties()->transform = rotation_transform; 6256 back_facing->test_properties()->transform = rotation_transform;
6264 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 6257 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6265 6258
6266 ExecuteCalculateDrawProperties(root); 6259 ExecuteCalculateDrawProperties(root);
6267 6260
6268 // render_surface1 is in the same 3d rendering context as back_facing and is 6261 // render_surface1 is in the same 3d rendering context as back_facing and is
6269 // not double sided, so it should not be in RSLL. render_surface2 is also not 6262 // not double sided, so it should not be in RSLL. render_surface2 is also not
6270 // double-sided, but will still be in RSLL as it's in a different 3d rendering 6263 // double-sided, but will still be in RSLL as it's in a different 3d rendering
6271 // context. 6264 // context.
6272 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 6265 EXPECT_EQ(2u, render_surface_list_impl()->size());
6273 EXPECT_EQ(1u, 6266 EXPECT_EQ(1, render_surface_list_impl()->at(0)->num_contributors());
6274 render_surface_layer_list_impl()
6275 ->at(0)
6276 ->GetRenderSurface()
6277 ->layer_list()
6278 .size());
6279 } 6267 }
6280 6268
6281 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { 6269 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) {
6282 LayerImpl* root = root_layer_for_testing(); 6270 LayerImpl* root = root_layer_for_testing();
6283 LayerImpl* child = AddChild<LayerImpl>(root); 6271 LayerImpl* child = AddChild<LayerImpl>(root);
6284 LayerImpl* grand_child = AddChild<LayerImpl>(child); 6272 LayerImpl* grand_child = AddChild<LayerImpl>(child);
6285 6273
6286 root->SetBounds(gfx::Size(50, 50)); 6274 root->SetBounds(gfx::Size(50, 50));
6287 root->test_properties()->should_flatten_transform = false; 6275 root->test_properties()->should_flatten_transform = false;
6288 child->SetBounds(gfx::Size(30, 30)); 6276 child->SetBounds(gfx::Size(30, 30));
6289 child->test_properties()->double_sided = false; 6277 child->test_properties()->double_sided = false;
6290 child->test_properties()->should_flatten_transform = false; 6278 child->test_properties()->should_flatten_transform = false;
6291 grand_child->SetBounds(gfx::Size(20, 20)); 6279 grand_child->SetBounds(gfx::Size(20, 20));
6292 grand_child->SetDrawsContent(true); 6280 grand_child->SetDrawsContent(true);
6293 grand_child->SetUseParentBackfaceVisibility(true); 6281 grand_child->SetUseParentBackfaceVisibility(true);
6294 grand_child->test_properties()->should_flatten_transform = false; 6282 grand_child->test_properties()->should_flatten_transform = false;
6295 ExecuteCalculateDrawProperties(root); 6283 ExecuteCalculateDrawProperties(root);
6296 6284
6297 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6285 EXPECT_EQ(1u, render_surface_list_impl()->size());
6298 EXPECT_EQ(grand_child, 6286 EXPECT_TRUE(grand_child->is_drawn_render_surface_layer_list_member());
6299 render_surface_layer_list_impl()
6300 ->at(0)
6301 ->GetRenderSurface()
6302 ->layer_list()[0]);
6303 6287
6304 // As all layers have identity transform, we shouldn't check for backface 6288 // As all layers have identity transform, we shouldn't check for backface
6305 // visibility. 6289 // visibility.
6306 EXPECT_FALSE(root->should_check_backface_visibility()); 6290 EXPECT_FALSE(root->should_check_backface_visibility());
6307 EXPECT_FALSE(child->should_check_backface_visibility()); 6291 EXPECT_FALSE(child->should_check_backface_visibility());
6308 EXPECT_FALSE(grand_child->should_check_backface_visibility()); 6292 EXPECT_FALSE(grand_child->should_check_backface_visibility());
6309 // As there are no 3d rendering contexts, all layers should use their local 6293 // As there are no 3d rendering contexts, all layers should use their local
6310 // transform for backface visibility. 6294 // transform for backface visibility.
6311 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6295 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
6312 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); 6296 EXPECT_TRUE(child->use_local_transform_for_backface_visibility());
6313 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); 6297 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility());
6314 6298
6315 gfx::Transform rotation_transform; 6299 gfx::Transform rotation_transform;
6316 rotation_transform.RotateAboutXAxis(180.0); 6300 rotation_transform.RotateAboutXAxis(180.0);
6317 6301
6318 child->test_properties()->transform = rotation_transform; 6302 child->test_properties()->transform = rotation_transform;
6319 child->test_properties()->sorting_context_id = 1; 6303 child->test_properties()->sorting_context_id = 1;
6320 grand_child->test_properties()->sorting_context_id = 1; 6304 grand_child->test_properties()->sorting_context_id = 1;
6321 child->layer_tree_impl()->property_trees()->needs_rebuild = true; 6305 child->layer_tree_impl()->property_trees()->needs_rebuild = true;
6322 6306
6323 ExecuteCalculateDrawProperties(root); 6307 ExecuteCalculateDrawProperties(root);
6324 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6308 EXPECT_EQ(1u, render_surface_list_impl()->size());
6325 EXPECT_EQ(0u, 6309 EXPECT_EQ(0, render_surface_list_impl()->at(0)->num_contributors());
6326 render_surface_layer_list_impl()
6327 ->at(0)
6328 ->GetRenderSurface()
6329 ->layer_list()
6330 .size());
6331 6310
6332 // We should check for backface visibilty of child as it has a rotation 6311 // We should check for backface visibilty of child as it has a rotation
6333 // transform. We should also check for grand_child as it uses the backface 6312 // transform. We should also check for grand_child as it uses the backface
6334 // visibility of its parent. 6313 // visibility of its parent.
6335 EXPECT_FALSE(root->should_check_backface_visibility()); 6314 EXPECT_FALSE(root->should_check_backface_visibility());
6336 EXPECT_TRUE(child->should_check_backface_visibility()); 6315 EXPECT_TRUE(child->should_check_backface_visibility());
6337 EXPECT_TRUE(grand_child->should_check_backface_visibility()); 6316 EXPECT_TRUE(grand_child->should_check_backface_visibility());
6338 // child uses its local transform for backface visibility as it is the root of 6317 // child uses its local transform for backface visibility as it is the root of
6339 // a 3d rendering context. grand_child is in a 3d rendering context and is not 6318 // a 3d rendering context. grand_child is in a 3d rendering context and is not
6340 // the root, but it derives its backface visibility from its parent which uses 6319 // the root, but it derives its backface visibility from its parent which uses
6341 // its local transform. 6320 // its local transform.
6342 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6321 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
6343 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); 6322 EXPECT_TRUE(child->use_local_transform_for_backface_visibility());
6344 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); 6323 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility());
6345 6324
6346 grand_child->SetUseParentBackfaceVisibility(false); 6325 grand_child->SetUseParentBackfaceVisibility(false);
6347 grand_child->test_properties()->double_sided = false; 6326 grand_child->test_properties()->double_sided = false;
6348 grand_child->layer_tree_impl()->property_trees()->needs_rebuild = true; 6327 grand_child->layer_tree_impl()->property_trees()->needs_rebuild = true;
6349 6328
6350 ExecuteCalculateDrawProperties(root); 6329 ExecuteCalculateDrawProperties(root);
6351 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6330 EXPECT_EQ(1u, render_surface_list_impl()->size());
6352 EXPECT_EQ(0u, 6331 EXPECT_EQ(0, render_surface_list_impl()->at(0)->num_contributors());
6353 render_surface_layer_list_impl()
6354 ->at(0)
6355 ->GetRenderSurface()
6356 ->layer_list()
6357 .size());
6358 6332
6359 // We should check the backface visibility of child as it has a rotation 6333 // We should check the backface visibility of child as it has a rotation
6360 // transform and for grand_child as it is in a 3d rendering context and not 6334 // transform and for grand_child as it is in a 3d rendering context and not
6361 // the root of it. 6335 // the root of it.
6362 EXPECT_FALSE(root->should_check_backface_visibility()); 6336 EXPECT_FALSE(root->should_check_backface_visibility());
6363 EXPECT_TRUE(child->should_check_backface_visibility()); 6337 EXPECT_TRUE(child->should_check_backface_visibility());
6364 EXPECT_TRUE(grand_child->should_check_backface_visibility()); 6338 EXPECT_TRUE(grand_child->should_check_backface_visibility());
6365 // grand_child is in an existing 3d rendering context, so it should not use 6339 // grand_child is in an existing 3d rendering context, so it should not use
6366 // local transform for backface visibility. 6340 // local transform for backface visibility.
6367 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6341 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
6483 scroll_child_target->SetBounds(gfx::Size(50, 50)); 6457 scroll_child_target->SetBounds(gfx::Size(50, 50));
6484 scroll_child_target->test_properties()->force_render_surface = true; 6458 scroll_child_target->test_properties()->force_render_surface = true;
6485 scroll_child->SetBounds(gfx::Size(50, 50)); 6459 scroll_child->SetBounds(gfx::Size(50, 50));
6486 scroll_parent_target->SetPosition(gfx::PointF(10, 10)); 6460 scroll_parent_target->SetPosition(gfx::PointF(10, 10));
6487 scroll_parent_target->SetBounds(gfx::Size(50, 50)); 6461 scroll_parent_target->SetBounds(gfx::Size(50, 50));
6488 scroll_parent_target->SetMasksToBounds(true); 6462 scroll_parent_target->SetMasksToBounds(true);
6489 scroll_parent_target->test_properties()->force_render_surface = true; 6463 scroll_parent_target->test_properties()->force_render_surface = true;
6490 scroll_parent->SetBounds(gfx::Size(50, 50)); 6464 scroll_parent->SetBounds(gfx::Size(50, 50));
6491 6465
6492 float device_scale_factor = 1.5f; 6466 float device_scale_factor = 1.5f;
6493 LayerImplList render_surface_layer_list_impl; 6467 RenderSurfaceList render_surface_list_impl;
6494 gfx::Size device_viewport_size = 6468 gfx::Size device_viewport_size =
6495 gfx::Size(root->bounds().width() * device_scale_factor, 6469 gfx::Size(root->bounds().width() * device_scale_factor,
6496 root->bounds().height() * device_scale_factor); 6470 root->bounds().height() * device_scale_factor);
6497 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6471 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6498 root, device_viewport_size, gfx::Transform(), 6472 root, device_viewport_size, gfx::Transform(), &render_surface_list_impl);
6499 &render_surface_layer_list_impl);
6500 inputs.device_scale_factor = device_scale_factor; 6473 inputs.device_scale_factor = device_scale_factor;
6501 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6474 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6502 6475
6503 EXPECT_EQ(scroll_child->effect_tree_index(), 6476 EXPECT_EQ(scroll_child->effect_tree_index(),
6504 scroll_child_target->effect_tree_index()); 6477 scroll_child_target->effect_tree_index());
6505 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40)); 6478 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40));
6506 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75)); 6479 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75));
6507 gfx::Transform scale; 6480 gfx::Transform scale;
6508 scale.Scale(1.5f, 1.5f); 6481 scale.Scale(1.5f, 1.5f);
6509 EXPECT_TRANSFORMATION_MATRIX_EQ(scroll_child->DrawTransform(), scale); 6482 EXPECT_TRANSFORMATION_MATRIX_EQ(scroll_child->DrawTransform(), scale);
(...skipping 10 matching lines...) Expand all
6520 parent->SetBounds(gfx::Size(30, 30)); 6493 parent->SetBounds(gfx::Size(30, 30));
6521 parent->SetDrawsContent(true); 6494 parent->SetDrawsContent(true);
6522 parent->test_properties()->force_render_surface = true; 6495 parent->test_properties()->force_render_surface = true;
6523 parent->test_properties()->sorting_context_id = 1; 6496 parent->test_properties()->sorting_context_id = 1;
6524 child->SetBounds(gfx::Size(20, 20)); 6497 child->SetBounds(gfx::Size(20, 20));
6525 child->SetDrawsContent(true); 6498 child->SetDrawsContent(true);
6526 child->test_properties()->force_render_surface = true; 6499 child->test_properties()->force_render_surface = true;
6527 child->test_properties()->sorting_context_id = 1; 6500 child->test_properties()->sorting_context_id = 1;
6528 ExecuteCalculateDrawProperties(root); 6501 ExecuteCalculateDrawProperties(root);
6529 6502
6530 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6503 EXPECT_EQ(3u, render_surface_list_impl()->size());
6531 6504
6532 gfx::Transform singular_transform; 6505 gfx::Transform singular_transform;
6533 singular_transform.Scale3d( 6506 singular_transform.Scale3d(
6534 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); 6507 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0));
6535 6508
6536 child->test_properties()->transform = singular_transform; 6509 child->test_properties()->transform = singular_transform;
6537 6510
6538 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 6511 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6539 ExecuteCalculateDrawProperties(root); 6512 ExecuteCalculateDrawProperties(root);
6540 6513
6541 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 6514 EXPECT_EQ(2u, render_surface_list_impl()->size());
6542 6515
6543 // Ensure that the entire subtree under a layer with singular transform does 6516 // Ensure that the entire subtree under a layer with singular transform does
6544 // not get rendered. 6517 // not get rendered.
6545 parent->test_properties()->transform = singular_transform; 6518 parent->test_properties()->transform = singular_transform;
6546 child->test_properties()->transform = gfx::Transform(); 6519 child->test_properties()->transform = gfx::Transform();
6547 6520
6548 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 6521 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6549 ExecuteCalculateDrawProperties(root); 6522 ExecuteCalculateDrawProperties(root);
6550 6523
6551 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6524 EXPECT_EQ(1u, render_surface_list_impl()->size());
6552 } 6525 }
6553 6526
6554 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { 6527 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) {
6555 // Checks that clipping by a scroll parent that follows you in paint order 6528 // Checks that clipping by a scroll parent that follows you in paint order
6556 // still results in correct clipping. 6529 // still results in correct clipping.
6557 // 6530 //
6558 // + root 6531 // + root
6559 // + scroll_parent_border 6532 // + scroll_parent_border
6560 // + scroll_parent_clip 6533 // + scroll_parent_clip
6561 // + scroll_parent 6534 // + scroll_parent
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 6615
6643 ExecuteCalculateDrawProperties(root); 6616 ExecuteCalculateDrawProperties(root);
6644 6617
6645 EXPECT_TRUE(root->GetRenderSurface()); 6618 EXPECT_TRUE(root->GetRenderSurface());
6646 6619
6647 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); 6620 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect());
6648 EXPECT_TRUE(scroll_child->is_clipped()); 6621 EXPECT_TRUE(scroll_child->is_clipped());
6649 6622
6650 // Despite the fact that we visited the above layers out of order to get the 6623 // Despite the fact that we visited the above layers out of order to get the
6651 // correct clip, the layer lists should be unaffected. 6624 // correct clip, the layer lists should be unaffected.
6652 EXPECT_EQ(3u, root->GetRenderSurface()->layer_list().size()); 6625 EXPECT_EQ(3, root->GetRenderSurface()->num_contributors());
6653 EXPECT_EQ(scroll_child, root->GetRenderSurface()->layer_list().at(0)); 6626 EXPECT_TRUE(scroll_child->is_drawn_render_surface_layer_list_member());
6654 EXPECT_EQ(scroll_parent, root->GetRenderSurface()->layer_list().at(1)); 6627 EXPECT_TRUE(scroll_parent->is_drawn_render_surface_layer_list_member());
6655 EXPECT_EQ(scroll_grandparent, root->GetRenderSurface()->layer_list().at(2)); 6628 EXPECT_TRUE(scroll_grandparent->is_drawn_render_surface_layer_list_member());
6656 } 6629 }
6657 6630
6658 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { 6631 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) {
6659 // Ensures that even if we visit layers out of order, we still produce a 6632 // Ensures that even if we visit layers out of order, we still produce a
6660 // correctly ordered render surface layer list. 6633 // correctly ordered render surface layer list.
6661 // + root 6634 // + root
6662 // + scroll_child 6635 // + scroll_child
6663 // + scroll_parent_border 6636 // + scroll_parent_border
6664 // + scroll_parent_clip 6637 // + scroll_parent_clip
6665 // + scroll_parent 6638 // + scroll_parent
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6718 scroll_child->SetBounds(gfx::Size(50, 50)); 6691 scroll_child->SetBounds(gfx::Size(50, 50));
6719 6692
6720 ExecuteCalculateDrawProperties(root); 6693 ExecuteCalculateDrawProperties(root);
6721 6694
6722 EXPECT_TRUE(root->GetRenderSurface()); 6695 EXPECT_TRUE(root->GetRenderSurface());
6723 6696
6724 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); 6697 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect());
6725 EXPECT_TRUE(scroll_child->is_clipped()); 6698 EXPECT_TRUE(scroll_child->is_clipped());
6726 6699
6727 // Despite the fact that we had to process the layers out of order to get the 6700 // Despite the fact that we had to process the layers out of order to get the
6728 // right clip, our render_surface_layer_list's order should be unaffected. 6701 // right clip, our render_surface_list's order should be unaffected.
6729 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6702 EXPECT_EQ(3u, render_surface_list_impl()->size());
6730 EXPECT_EQ(root, render_surface_layer_list_impl()->at(0)); 6703 EXPECT_EQ(root->GetRenderSurface(), render_surface_list_impl()->at(0));
6731 EXPECT_EQ(render_surface2, render_surface_layer_list_impl()->at(1)); 6704 EXPECT_EQ(render_surface2->GetRenderSurface(),
6732 EXPECT_EQ(render_surface1, render_surface_layer_list_impl()->at(2)); 6705 render_surface_list_impl()->at(1));
6733 EXPECT_TRUE(render_surface_layer_list_impl()->at(0)->GetRenderSurface()); 6706 EXPECT_EQ(render_surface1->GetRenderSurface(),
6734 EXPECT_TRUE(render_surface_layer_list_impl()->at(1)->GetRenderSurface()); 6707 render_surface_list_impl()->at(2));
6735 EXPECT_TRUE(render_surface_layer_list_impl()->at(2)->GetRenderSurface());
6736 } 6708 }
6737 6709
6738 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) { 6710 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) {
6739 // Ensures that when we have a render surface between a fixed position layer 6711 // Ensures that when we have a render surface between a fixed position layer
6740 // and its container, we compute the fixed position layer's draw transform 6712 // and its container, we compute the fixed position layer's draw transform
6741 // with respect to that intervening render surface, not with respect to its 6713 // with respect to that intervening render surface, not with respect to its
6742 // container's render target. 6714 // container's render target.
6743 // 6715 //
6744 // + root 6716 // + root
6745 // + render_surface 6717 // + render_surface
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
6851 container->test_properties()->AddChild(std::move(scroller)); 6823 container->test_properties()->AddChild(std::move(scroller));
6852 root->test_properties()->AddChild(std::move(container)); 6824 root->test_properties()->AddChild(std::move(container));
6853 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr)); 6825 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr));
6854 root->layer_tree_impl()->BuildPropertyTreesForTesting(); 6826 root->layer_tree_impl()->BuildPropertyTreesForTesting();
6855 6827
6856 // Rounded to integers already. 6828 // Rounded to integers already.
6857 { 6829 {
6858 gfx::Vector2dF scroll_delta(3.0, 5.0); 6830 gfx::Vector2dF scroll_delta(3.0, 5.0);
6859 SetScrollOffsetDelta(scroll_layer, scroll_delta); 6831 SetScrollOffsetDelta(scroll_layer, scroll_delta);
6860 6832
6861 LayerImplList render_surface_layer_list; 6833 RenderSurfaceList render_surface_list;
6862 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6834 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6863 root, root->bounds(), &render_surface_layer_list); 6835 root, root->bounds(), &render_surface_list);
6864 root->layer_tree_impl() 6836 root->layer_tree_impl()
6865 ->property_trees() 6837 ->property_trees()
6866 ->transform_tree.set_source_to_parent_updates_allowed(false); 6838 ->transform_tree.set_source_to_parent_updates_allowed(false);
6867 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6839 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6868 6840
6869 EXPECT_TRANSFORMATION_MATRIX_EQ( 6841 EXPECT_TRANSFORMATION_MATRIX_EQ(
6870 container_layer->draw_properties().screen_space_transform, 6842 container_layer->draw_properties().screen_space_transform,
6871 fixed_layer->draw_properties().screen_space_transform); 6843 fixed_layer->draw_properties().screen_space_transform);
6872 EXPECT_VECTOR_EQ( 6844 EXPECT_VECTOR_EQ(
6873 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 6845 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
6874 container_offset); 6846 container_offset);
6875 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 6847 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
6876 .screen_space_transform.To2dTranslation(), 6848 .screen_space_transform.To2dTranslation(),
6877 container_offset - scroll_delta); 6849 container_offset - scroll_delta);
6878 } 6850 }
6879 6851
6880 // Scroll delta requiring rounding. 6852 // Scroll delta requiring rounding.
6881 { 6853 {
6882 gfx::Vector2dF scroll_delta(4.1f, 8.1f); 6854 gfx::Vector2dF scroll_delta(4.1f, 8.1f);
6883 SetScrollOffsetDelta(scroll_layer, scroll_delta); 6855 SetScrollOffsetDelta(scroll_layer, scroll_delta);
6884 6856
6885 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); 6857 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f);
6886 6858
6887 LayerImplList render_surface_layer_list; 6859 RenderSurfaceList render_surface_list;
6888 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6860 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6889 root, root->bounds(), &render_surface_layer_list); 6861 root, root->bounds(), &render_surface_list);
6890 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6862 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6891 6863
6892 EXPECT_TRANSFORMATION_MATRIX_EQ( 6864 EXPECT_TRANSFORMATION_MATRIX_EQ(
6893 container_layer->draw_properties().screen_space_transform, 6865 container_layer->draw_properties().screen_space_transform,
6894 fixed_layer->draw_properties().screen_space_transform); 6866 fixed_layer->draw_properties().screen_space_transform);
6895 EXPECT_VECTOR_EQ( 6867 EXPECT_VECTOR_EQ(
6896 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 6868 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
6897 container_offset); 6869 container_offset);
6898 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 6870 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
6899 .screen_space_transform.To2dTranslation(), 6871 .screen_space_transform.To2dTranslation(),
6900 container_offset - rounded_scroll_delta); 6872 container_offset - rounded_scroll_delta);
6901 } 6873 }
6902 6874
6903 // Scale is applied earlier in the tree. 6875 // Scale is applied earlier in the tree.
6904 { 6876 {
6905 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); 6877 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
6906 gfx::Transform scaled_container_transform = container_transform; 6878 gfx::Transform scaled_container_transform = container_transform;
6907 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); 6879 scaled_container_transform.Scale3d(2.0, 2.0, 1.0);
6908 container_layer->test_properties()->transform = scaled_container_transform; 6880 container_layer->test_properties()->transform = scaled_container_transform;
6909 6881
6910 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 6882 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6911 6883
6912 gfx::Vector2dF scroll_delta(4.5f, 8.5f); 6884 gfx::Vector2dF scroll_delta(4.5f, 8.5f);
6913 SetScrollOffsetDelta(scroll_layer, scroll_delta); 6885 SetScrollOffsetDelta(scroll_layer, scroll_delta);
6914 6886
6915 LayerImplList render_surface_layer_list; 6887 RenderSurfaceList render_surface_list;
6916 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6888 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6917 root, root->bounds(), &render_surface_layer_list); 6889 root, root->bounds(), &render_surface_list);
6918 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6890 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6919 6891
6920 EXPECT_TRANSFORMATION_MATRIX_EQ( 6892 EXPECT_TRANSFORMATION_MATRIX_EQ(
6921 container_layer->draw_properties().screen_space_transform, 6893 container_layer->draw_properties().screen_space_transform,
6922 fixed_layer->draw_properties().screen_space_transform); 6894 fixed_layer->draw_properties().screen_space_transform);
6923 EXPECT_VECTOR_EQ( 6895 EXPECT_VECTOR_EQ(
6924 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 6896 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
6925 container_offset); 6897 container_offset);
6926 6898
6927 container_layer->test_properties()->transform = container_transform; 6899 container_layer->test_properties()->transform = container_transform;
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after
8652 8624
8653 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); 8625 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer));
8654 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); 8626 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer));
8655 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); 8627 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer));
8656 8628
8657 // Changing page-scale would affect ideal_contents_scale and 8629 // Changing page-scale would affect ideal_contents_scale and
8658 // maximum_animation_contents_scale. 8630 // maximum_animation_contents_scale.
8659 8631
8660 float page_scale_factor = 3.f; 8632 float page_scale_factor = 3.f;
8661 float device_scale_factor = 1.0f; 8633 float device_scale_factor = 1.0f;
8662 std::vector<LayerImpl*> render_surface_layer_list; 8634 RenderSurfaceList render_surface_list;
8663 gfx::Size device_viewport_size = 8635 gfx::Size device_viewport_size =
8664 gfx::Size(root_layer->bounds().width() * device_scale_factor, 8636 gfx::Size(root_layer->bounds().width() * device_scale_factor,
8665 root_layer->bounds().height() * device_scale_factor); 8637 root_layer->bounds().height() * device_scale_factor);
8666 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8638 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8667 root_layer, device_viewport_size, &render_surface_layer_list); 8639 root_layer, device_viewport_size, &render_surface_list);
8668 8640
8669 inputs.page_scale_factor = page_scale_factor; 8641 inputs.page_scale_factor = page_scale_factor;
8670 inputs.can_adjust_raster_scales = true; 8642 inputs.can_adjust_raster_scales = true;
8671 inputs.page_scale_layer = root_layer; 8643 inputs.page_scale_layer = root_layer;
8672 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8644 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8673 8645
8674 EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale()); 8646 EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale());
8675 EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale()); 8647 EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale());
8676 EXPECT_FLOAT_EQ( 8648 EXPECT_FLOAT_EQ(
8677 9.f, 8649 9.f,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
8832 8804
8833 root->SetBounds(gfx::Size(768 / 2, 3000)); 8805 root->SetBounds(gfx::Size(768 / 2, 3000));
8834 root->SetDrawsContent(true); 8806 root->SetDrawsContent(true);
8835 clip->SetBounds(gfx::Size(768 / 2, 10000)); 8807 clip->SetBounds(gfx::Size(768 / 2, 10000));
8836 clip->SetMasksToBounds(true); 8808 clip->SetMasksToBounds(true);
8837 content->SetBounds(gfx::Size(768 / 2, 10000)); 8809 content->SetBounds(gfx::Size(768 / 2, 10000));
8838 content->SetDrawsContent(true); 8810 content->SetDrawsContent(true);
8839 content->test_properties()->force_render_surface = true; 8811 content->test_properties()->force_render_surface = true;
8840 8812
8841 gfx::Size device_viewport_size(768, 582); 8813 gfx::Size device_viewport_size(768, 582);
8842 LayerImplList render_surface_layer_list_impl; 8814 RenderSurfaceList render_surface_list_impl;
8843 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8815 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8844 root, device_viewport_size, gfx::Transform(), 8816 root, device_viewport_size, gfx::Transform(), &render_surface_list_impl);
8845 &render_surface_layer_list_impl);
8846 inputs.device_scale_factor = 2.f; 8817 inputs.device_scale_factor = 2.f;
8847 inputs.page_scale_factor = 1.f; 8818 inputs.page_scale_factor = 1.f;
8848 inputs.page_scale_layer = nullptr; 8819 inputs.page_scale_layer = nullptr;
8849 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8820 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8850 8821
8851 // Layers in the root render surface have their visible content rect clipped 8822 // Layers in the root render surface have their visible content rect clipped
8852 // by the viewport. 8823 // by the viewport.
8853 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect()); 8824 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect());
8854 8825
8855 // Layers drawing to a child render surface should still have their visible 8826 // Layers drawing to a child render surface should still have their visible
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8888 8859
8889 root->test_properties()->AddChild( 8860 root->test_properties()->AddChild(
8890 LayerImpl::Create(host_impl.active_tree(), 2)); 8861 LayerImpl::Create(host_impl.active_tree(), 2));
8891 8862
8892 LayerImpl* sublayer = root->test_properties()->children[0]; 8863 LayerImpl* sublayer = root->test_properties()->children[0];
8893 sublayer->SetBounds(sublayer_size); 8864 sublayer->SetBounds(sublayer_size);
8894 sublayer->SetDrawsContent(true); 8865 sublayer->SetDrawsContent(true);
8895 8866
8896 host_impl.active_tree()->BuildPropertyTreesForTesting(); 8867 host_impl.active_tree()->BuildPropertyTreesForTesting();
8897 8868
8898 LayerImplList layer_impl_list; 8869 RenderSurfaceList render_surface_list;
8899 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8870 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8900 root, device_viewport_size, &layer_impl_list); 8871 root, device_viewport_size, &render_surface_list);
8901 8872
8902 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8873 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8903 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); 8874 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect());
8904 8875
8905 root->SetViewportBoundsDelta(gfx::Vector2dF(0.0, 50.0)); 8876 root->SetViewportBoundsDelta(gfx::Vector2dF(0.0, 50.0));
8906 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8877 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8907 8878
8908 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8879 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8909 root_size.height() + 50); 8880 root_size.height() + 50);
8910 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect()); 8881 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect());
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
10472 render_surface1->GetRenderSurface()->DrawableContentRect()); 10443 render_surface1->GetRenderSurface()->DrawableContentRect());
10473 10444
10474 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || 10445 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) ||
10475 std::isnan(child->DrawTransform().matrix().get(0, 0)); 10446 std::isnan(child->DrawTransform().matrix().get(0, 0));
10476 EXPECT_TRUE(is_inf_or_nan); 10447 EXPECT_TRUE(is_inf_or_nan);
10477 10448
10478 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || 10449 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) ||
10479 std::isnan(child->DrawTransform().matrix().get(1, 1)); 10450 std::isnan(child->DrawTransform().matrix().get(1, 1));
10480 EXPECT_TRUE(is_inf_or_nan); 10451 EXPECT_TRUE(is_inf_or_nan);
10481 10452
10482 // The root layer should be in the RenderSurfaceLayerListImpl. 10453 // The root layer should be in the RenderSurfaceList.
10483 const auto* rsll = render_surface_layer_list_impl(); 10454 const auto* rsl = render_surface_list_impl();
10484 EXPECT_NE(std::find(rsll->begin(), rsll->end(), root), rsll->end()); 10455 EXPECT_NE(std::find(rsl->begin(), rsl->end(), root->GetRenderSurface()),
10456 rsl->end());
10485 } 10457 }
10486 10458
10487 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { 10459 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) {
10488 scoped_refptr<Layer> root = Layer::Create(); 10460 scoped_refptr<Layer> root = Layer::Create();
10489 scoped_refptr<LayerWithForcedDrawsContent> child = 10461 scoped_refptr<LayerWithForcedDrawsContent> child =
10490 make_scoped_refptr(new LayerWithForcedDrawsContent()); 10462 make_scoped_refptr(new LayerWithForcedDrawsContent());
10491 root->AddChild(child); 10463 root->AddChild(child);
10492 host()->SetRootLayer(root); 10464 host()->SetRootLayer(root);
10493 10465
10494 root->SetBounds(gfx::Size(100, 100)); 10466 root->SetBounds(gfx::Size(100, 100));
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
10865 10837
10866 // Check child layer draw properties. 10838 // Check child layer draw properties.
10867 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10839 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10868 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10840 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10869 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10841 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10870 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10842 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10871 } 10843 }
10872 10844
10873 } // namespace 10845 } // namespace
10874 } // namespace cc 10846 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_perftest.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698