| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 animating_transform); | 225 animating_transform); |
| 226 | 226 |
| 227 SetupDrawPropertiesAndUpdateTiles( | 227 SetupDrawPropertiesAndUpdateTiles( |
| 228 active_layer(), contents_scale, device_scale_factor, page_scale_factor, | 228 active_layer(), contents_scale, device_scale_factor, page_scale_factor, |
| 229 maximum_animation_contents_scale, starting_animation_contents_scale, | 229 maximum_animation_contents_scale, starting_animation_contents_scale, |
| 230 animating_transform); | 230 animating_transform); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void ResetTilingsAndRasterScales() { | 233 void ResetTilingsAndRasterScales() { |
| 234 if (pending_layer()) { | 234 if (pending_layer()) { |
| 235 pending_layer()->ReleaseResources(); | 235 pending_layer()->ReleaseTileResources(); |
| 236 EXPECT_FALSE(pending_layer()->tilings()); | 236 EXPECT_FALSE(pending_layer()->tilings()); |
| 237 pending_layer()->RecreateResources(); | 237 pending_layer()->RecreateTileResources(); |
| 238 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); | 238 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 if (active_layer()) { | 241 if (active_layer()) { |
| 242 active_layer()->ReleaseResources(); | 242 active_layer()->ReleaseTileResources(); |
| 243 EXPECT_FALSE(active_layer()->tilings()); | 243 EXPECT_FALSE(active_layer()->tilings()); |
| 244 active_layer()->RecreateResources(); | 244 active_layer()->RecreateTileResources(); |
| 245 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 245 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 size_t NumberOfTilesRequired(PictureLayerTiling* tiling) { | 249 size_t NumberOfTilesRequired(PictureLayerTiling* tiling) { |
| 250 size_t num_required = 0; | 250 size_t num_required = 0; |
| 251 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 251 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 252 for (size_t i = 0; i < tiles.size(); ++i) { | 252 for (size_t i = 0; i < tiles.size(); ++i) { |
| 253 if (tiles[i]->required_for_activation()) | 253 if (tiles[i]->required_for_activation()) |
| 254 num_required++; | 254 num_required++; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| 585 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) { | 585 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) { |
| 586 gfx::Size layer_bounds(1300, 1900); | 586 gfx::Size layer_bounds(1300, 1900); |
| 587 SetupDefaultTrees(layer_bounds); | 587 SetupDefaultTrees(layer_bounds); |
| 588 | 588 |
| 589 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 589 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 590 EXPECT_LT(low_res_factor, 1.f); | 590 EXPECT_LT(low_res_factor, 1.f); |
| 591 | 591 |
| 592 active_layer()->ReleaseResources(); | 592 active_layer()->ReleaseTileResources(); |
| 593 EXPECT_FALSE(active_layer()->tilings()); | 593 EXPECT_FALSE(active_layer()->tilings()); |
| 594 active_layer()->RecreateResources(); | 594 active_layer()->RecreateTileResources(); |
| 595 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 595 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 596 | 596 |
| 597 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 597 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 598 6.f, // ideal contents scale | 598 6.f, // ideal contents scale |
| 599 3.f, // device scale | 599 3.f, // device scale |
| 600 2.f, // page scale | 600 2.f, // page scale |
| 601 1.f, // maximum animation scale | 601 1.f, // maximum animation scale |
| 602 0.f, // starting animation scale | 602 0.f, // starting animation scale |
| 603 false); | 603 false); |
| 604 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 604 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 active_layer()->tilings()->tiling_at(3)->contents_scale()); | 651 active_layer()->tilings()->tiling_at(3)->contents_scale()); |
| 652 } | 652 } |
| 653 | 653 |
| 654 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { | 654 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
| 655 gfx::Size layer_bounds(1300, 1900); | 655 gfx::Size layer_bounds(1300, 1900); |
| 656 SetupDefaultTrees(layer_bounds); | 656 SetupDefaultTrees(layer_bounds); |
| 657 | 657 |
| 658 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 658 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 659 EXPECT_LT(low_res_factor, 1.f); | 659 EXPECT_LT(low_res_factor, 1.f); |
| 660 | 660 |
| 661 pending_layer()->ReleaseResources(); | 661 pending_layer()->ReleaseTileResources(); |
| 662 EXPECT_FALSE(pending_layer()->tilings()); | 662 EXPECT_FALSE(pending_layer()->tilings()); |
| 663 pending_layer()->RecreateResources(); | 663 pending_layer()->RecreateTileResources(); |
| 664 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); | 664 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
| 665 | 665 |
| 666 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 666 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 667 6.f, // ideal contents scale | 667 6.f, // ideal contents scale |
| 668 3.f, // device scale | 668 3.f, // device scale |
| 669 2.f, // page scale | 669 2.f, // page scale |
| 670 1.f, // maximum animation scale | 670 1.f, // maximum animation scale |
| 671 0.f, // starting animation scale | 671 0.f, // starting animation scale |
| 672 false); | 672 false); |
| 673 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 673 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 mask->SetDrawsContent(true); | 1207 mask->SetDrawsContent(true); |
| 1208 pending_layer()->test_properties()->SetMaskLayer(std::move(mask)); | 1208 pending_layer()->test_properties()->SetMaskLayer(std::move(mask)); |
| 1209 pending_layer()->SetHasRenderSurface(true); | 1209 pending_layer()->SetHasRenderSurface(true); |
| 1210 RebuildPropertyTreesOnPendingTree(); | 1210 RebuildPropertyTreesOnPendingTree(); |
| 1211 host_impl()->pending_tree()->UpdateDrawProperties(false); | 1211 host_impl()->pending_tree()->UpdateDrawProperties(false); |
| 1212 | 1212 |
| 1213 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>( | 1213 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>( |
| 1214 pending_layer()->test_properties()->mask_layer); | 1214 pending_layer()->test_properties()->mask_layer); |
| 1215 // We did an UpdateDrawProperties above, which will set a contents scale on | 1215 // We did an UpdateDrawProperties above, which will set a contents scale on |
| 1216 // the mask layer, so allow us to reset the contents scale. | 1216 // the mask layer, so allow us to reset the contents scale. |
| 1217 mask_raw->ReleaseResources(); | 1217 mask_raw->ReleaseTileResources(); |
| 1218 mask_raw->RecreateResources(); | 1218 mask_raw->RecreateTileResources(); |
| 1219 | 1219 |
| 1220 SetupDrawPropertiesAndUpdateTiles( | 1220 SetupDrawPropertiesAndUpdateTiles( |
| 1221 mask_raw, contents_scale, device_scale, page_scale, | 1221 mask_raw, contents_scale, device_scale, page_scale, |
| 1222 maximum_animation_scale, starting_animation_scale, animating_transform); | 1222 maximum_animation_scale, starting_animation_scale, animating_transform); |
| 1223 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); | 1223 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); |
| 1224 EXPECT_EQ(mask_raw->num_tilings(), 1u); | 1224 EXPECT_EQ(mask_raw->num_tilings(), 1u); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1227 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
| 1228 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1228 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 // Mask layers have a tiling with a single tile in it. | 1263 // Mask layers have a tiling with a single tile in it. |
| 1264 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1264 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1265 // The mask resource exists. | 1265 // The mask resource exists. |
| 1266 ResourceId mask_resource_id; | 1266 ResourceId mask_resource_id; |
| 1267 gfx::Size mask_texture_size; | 1267 gfx::Size mask_texture_size; |
| 1268 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1268 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1269 EXPECT_NE(0u, mask_resource_id); | 1269 EXPECT_NE(0u, mask_resource_id); |
| 1270 EXPECT_EQ(active_mask->bounds(), mask_texture_size); | 1270 EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
| 1271 | 1271 |
| 1272 // Drop resources and recreate them, still the same. | 1272 // Drop resources and recreate them, still the same. |
| 1273 pending_mask->ReleaseResources(); | 1273 pending_mask->ReleaseTileResources(); |
| 1274 active_mask->ReleaseResources(); | 1274 active_mask->ReleaseTileResources(); |
| 1275 pending_mask->RecreateResources(); | 1275 pending_mask->RecreateTileResources(); |
| 1276 active_mask->RecreateResources(); | 1276 active_mask->RecreateTileResources(); |
| 1277 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, | 1277 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1278 false); | 1278 false); |
| 1279 active_mask->HighResTiling()->CreateAllTilesForTesting(); | 1279 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
| 1280 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1280 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1281 EXPECT_NE(0u, mask_resource_id); | 1281 EXPECT_NE(0u, mask_resource_id); |
| 1282 EXPECT_EQ(active_mask->bounds(), mask_texture_size); | 1282 EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
| 1283 | 1283 |
| 1284 // Resize larger than the max texture size. | 1284 // Resize larger than the max texture size. |
| 1285 int max_texture_size = host_impl()->resource_provider()->max_texture_size(); | 1285 int max_texture_size = host_impl()->resource_provider()->max_texture_size(); |
| 1286 gfx::Size huge_bounds(max_texture_size + 1, 10); | 1286 gfx::Size huge_bounds(max_texture_size + 1, 10); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1306 // Mask layers have a tiling with a single tile in it. | 1306 // Mask layers have a tiling with a single tile in it. |
| 1307 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1307 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1308 // The mask resource exists. | 1308 // The mask resource exists. |
| 1309 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1309 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1310 EXPECT_NE(0u, mask_resource_id); | 1310 EXPECT_NE(0u, mask_resource_id); |
| 1311 gfx::Size expected_size = active_mask->bounds(); | 1311 gfx::Size expected_size = active_mask->bounds(); |
| 1312 expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); | 1312 expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); |
| 1313 EXPECT_EQ(expected_size, mask_texture_size); | 1313 EXPECT_EQ(expected_size, mask_texture_size); |
| 1314 | 1314 |
| 1315 // Drop resources and recreate them, still the same. | 1315 // Drop resources and recreate them, still the same. |
| 1316 pending_mask->ReleaseResources(); | 1316 pending_mask->ReleaseTileResources(); |
| 1317 active_mask->ReleaseResources(); | 1317 active_mask->ReleaseTileResources(); |
| 1318 pending_mask->RecreateResources(); | 1318 pending_mask->RecreateTileResources(); |
| 1319 active_mask->RecreateResources(); | 1319 active_mask->RecreateTileResources(); |
| 1320 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, | 1320 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1321 false); | 1321 false); |
| 1322 active_mask->HighResTiling()->CreateAllTilesForTesting(); | 1322 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
| 1323 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1323 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1324 EXPECT_NE(0u, mask_resource_id); | 1324 EXPECT_NE(0u, mask_resource_id); |
| 1325 EXPECT_EQ(expected_size, mask_texture_size); | 1325 EXPECT_EQ(expected_size, mask_texture_size); |
| 1326 | 1326 |
| 1327 // Do another activate, the same holds. | 1327 // Do another activate, the same holds. |
| 1328 SetupPendingTree(huge_raster_source); | 1328 SetupPendingTree(huge_raster_source); |
| 1329 ActivateTree(); | 1329 ActivateTree(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 // The mask resource exists. | 1395 // The mask resource exists. |
| 1396 ResourceId mask_resource_id; | 1396 ResourceId mask_resource_id; |
| 1397 gfx::Size mask_texture_size; | 1397 gfx::Size mask_texture_size; |
| 1398 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1398 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1399 EXPECT_NE(0u, mask_resource_id); | 1399 EXPECT_NE(0u, mask_resource_id); |
| 1400 gfx::Size expected_mask_texture_size = | 1400 gfx::Size expected_mask_texture_size = |
| 1401 gfx::ScaleToCeiledSize(active_mask->bounds(), 1.3f); | 1401 gfx::ScaleToCeiledSize(active_mask->bounds(), 1.3f); |
| 1402 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); | 1402 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1405 TEST_F(PictureLayerImplTest, ReleaseTileResources) { |
| 1406 gfx::Size layer_bounds(1300, 1900); | 1406 gfx::Size layer_bounds(1300, 1900); |
| 1407 SetupDefaultTrees(layer_bounds); | 1407 SetupDefaultTrees(layer_bounds); |
| 1408 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 1408 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 1409 | 1409 |
| 1410 // All tilings should be removed when losing output surface. | 1410 // All tilings should be removed when losing output surface. |
| 1411 active_layer()->ReleaseResources(); | 1411 active_layer()->ReleaseTileResources(); |
| 1412 EXPECT_FALSE(active_layer()->tilings()); | 1412 EXPECT_FALSE(active_layer()->tilings()); |
| 1413 active_layer()->RecreateResources(); | 1413 active_layer()->RecreateTileResources(); |
| 1414 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 1414 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 1415 pending_layer()->ReleaseResources(); | 1415 pending_layer()->ReleaseTileResources(); |
| 1416 EXPECT_FALSE(pending_layer()->tilings()); | 1416 EXPECT_FALSE(pending_layer()->tilings()); |
| 1417 pending_layer()->RecreateResources(); | 1417 pending_layer()->RecreateTileResources(); |
| 1418 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); | 1418 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
| 1419 | 1419 |
| 1420 // This should create new tilings. | 1420 // This should create new tilings. |
| 1421 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 1421 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 1422 1.f, // ideal contents scale | 1422 1.f, // ideal contents scale |
| 1423 1.f, // device scale | 1423 1.f, // device scale |
| 1424 1.f, // page scale | 1424 1.f, // page scale |
| 1425 1.f, // maximum animation scale | 1425 1.f, // maximum animation scale |
| 1426 0.f, // starting animation_scale | 1426 0.f, // starting animation_scale |
| 1427 false); | 1427 false); |
| 1428 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 1428 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 // ReleaseResources should behave identically to ReleaseTileResources. |
| 1432 TEST_F(PictureLayerImplTest, ReleaseResources) { |
| 1433 gfx::Size layer_bounds(1300, 1900); |
| 1434 SetupDefaultTrees(layer_bounds); |
| 1435 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 1436 |
| 1437 // All tilings should be removed when losing output surface. |
| 1438 active_layer()->ReleaseResources(); |
| 1439 EXPECT_FALSE(active_layer()->tilings()); |
| 1440 active_layer()->RecreateTileResources(); |
| 1441 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 1442 pending_layer()->ReleaseResources(); |
| 1443 EXPECT_FALSE(pending_layer()->tilings()); |
| 1444 pending_layer()->RecreateTileResources(); |
| 1445 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
| 1446 } |
| 1447 |
| 1431 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { | 1448 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { |
| 1432 gfx::Size layer_bounds(5000, 5000); | 1449 gfx::Size layer_bounds(5000, 5000); |
| 1433 | 1450 |
| 1434 scoped_refptr<FakeRasterSource> pending_raster_source = | 1451 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1435 FakeRasterSource::CreateFilled(layer_bounds); | 1452 FakeRasterSource::CreateFilled(layer_bounds); |
| 1436 | 1453 |
| 1437 SetupPendingTree(pending_raster_source); | 1454 SetupPendingTree(pending_raster_source); |
| 1438 EXPECT_GE(pending_layer()->tilings()->num_tilings(), 1u); | 1455 EXPECT_GE(pending_layer()->tilings()->num_tilings(), 1u); |
| 1439 | 1456 |
| 1440 pending_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1457 pending_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 scoped_refptr<FakeRasterSource> active_raster_source = | 2343 scoped_refptr<FakeRasterSource> active_raster_source = |
| 2327 FakeRasterSource::CreateFilled(layer_bounds); | 2344 FakeRasterSource::CreateFilled(layer_bounds); |
| 2328 | 2345 |
| 2329 SetupTrees(pending_raster_source, active_raster_source); | 2346 SetupTrees(pending_raster_source, active_raster_source); |
| 2330 | 2347 |
| 2331 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); | 2348 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); |
| 2332 EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScale(1.f)); | 2349 EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScale(1.f)); |
| 2333 | 2350 |
| 2334 // Gpu rasterization is disabled by default. | 2351 // Gpu rasterization is disabled by default. |
| 2335 EXPECT_FALSE(host_impl()->use_gpu_rasterization()); | 2352 EXPECT_FALSE(host_impl()->use_gpu_rasterization()); |
| 2353 EXPECT_EQ(0u, pending_layer()->release_tile_resources_count()); |
| 2354 EXPECT_EQ(0u, active_layer()->release_tile_resources_count()); |
| 2336 EXPECT_EQ(0u, pending_layer()->release_resources_count()); | 2355 EXPECT_EQ(0u, pending_layer()->release_resources_count()); |
| 2337 EXPECT_EQ(0u, active_layer()->release_resources_count()); | 2356 EXPECT_EQ(0u, active_layer()->release_resources_count()); |
| 2338 // Toggling the gpu rasterization clears all tilings on both trees. | 2357 // Toggling the gpu rasterization clears all tilings on both trees. |
| 2339 host_impl()->SetHasGpuRasterizationTrigger(true); | 2358 host_impl()->SetHasGpuRasterizationTrigger(true); |
| 2340 host_impl()->SetContentIsSuitableForGpuRasterization(true); | 2359 host_impl()->SetContentIsSuitableForGpuRasterization(true); |
| 2341 host_impl()->CommitComplete(); | 2360 host_impl()->CommitComplete(); |
| 2361 EXPECT_EQ(1u, pending_layer()->release_tile_resources_count()); |
| 2362 EXPECT_EQ(1u, active_layer()->release_tile_resources_count()); |
| 2342 EXPECT_EQ(1u, pending_layer()->release_resources_count()); | 2363 EXPECT_EQ(1u, pending_layer()->release_resources_count()); |
| 2343 EXPECT_EQ(1u, active_layer()->release_resources_count()); | 2364 EXPECT_EQ(1u, active_layer()->release_resources_count()); |
| 2344 | 2365 |
| 2345 // But the pending layer gets a tiling back, and can activate it. | 2366 // But the pending layer gets a tiling back, and can activate it. |
| 2346 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); | 2367 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); |
| 2347 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 2368 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 2348 | 2369 |
| 2349 ActivateTree(); | 2370 ActivateTree(); |
| 2350 EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScale(1.f)); | 2371 EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScale(1.f)); |
| 2351 | 2372 |
| 2352 SetupPendingTree(pending_raster_source); | 2373 SetupPendingTree(pending_raster_source); |
| 2353 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); | 2374 EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); |
| 2354 | 2375 |
| 2355 // Toggling the gpu rasterization clears all tilings on both trees. | 2376 // Toggling the gpu rasterization clears all tilings on both trees. |
| 2356 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); | 2377 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); |
| 2357 host_impl()->SetHasGpuRasterizationTrigger(false); | 2378 host_impl()->SetHasGpuRasterizationTrigger(false); |
| 2358 host_impl()->CommitComplete(); | 2379 host_impl()->CommitComplete(); |
| 2359 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, | 2380 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, |
| 2360 host_impl()->gpu_rasterization_status()); | 2381 host_impl()->gpu_rasterization_status()); |
| 2382 EXPECT_EQ(2u, pending_layer()->release_tile_resources_count()); |
| 2383 EXPECT_EQ(2u, active_layer()->release_tile_resources_count()); |
| 2361 EXPECT_EQ(2u, pending_layer()->release_resources_count()); | 2384 EXPECT_EQ(2u, pending_layer()->release_resources_count()); |
| 2362 EXPECT_EQ(2u, active_layer()->release_resources_count()); | 2385 EXPECT_EQ(2u, active_layer()->release_resources_count()); |
| 2363 | 2386 |
| 2364 host_impl()->SetHasGpuRasterizationTrigger(true); | 2387 host_impl()->SetHasGpuRasterizationTrigger(true); |
| 2365 host_impl()->SetContentIsSuitableForGpuRasterization(false); | 2388 host_impl()->SetContentIsSuitableForGpuRasterization(false); |
| 2366 host_impl()->CommitComplete(); | 2389 host_impl()->CommitComplete(); |
| 2367 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 2390 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
| 2368 host_impl()->gpu_rasterization_status()); | 2391 host_impl()->gpu_rasterization_status()); |
| 2369 } | 2392 } |
| 2370 | 2393 |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 3536 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3514 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3537 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 3515 | 3538 |
| 3516 // If we remove it from our used tilings set, it is outside the range to keep | 3539 // If we remove it from our used tilings set, it is outside the range to keep |
| 3517 // so it is deleted. | 3540 // so it is deleted. |
| 3518 used_tilings.clear(); | 3541 used_tilings.clear(); |
| 3519 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 3542 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3520 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3543 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); |
| 3521 } | 3544 } |
| 3522 | 3545 |
| 3523 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { | 3546 TEST_F(NoLowResPictureLayerImplTest, ReleaseTileResources) { |
| 3524 gfx::Size layer_bounds(1300, 1900); | 3547 gfx::Size layer_bounds(1300, 1900); |
| 3525 SetupDefaultTrees(layer_bounds); | 3548 SetupDefaultTrees(layer_bounds); |
| 3526 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3549 EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 3527 EXPECT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3550 EXPECT_EQ(1u, active_layer()->tilings()->num_tilings()); |
| 3528 | 3551 |
| 3529 // All tilings should be removed when losing output surface. | 3552 // All tilings should be removed when losing output surface. |
| 3530 active_layer()->ReleaseResources(); | 3553 active_layer()->ReleaseTileResources(); |
| 3531 EXPECT_FALSE(active_layer()->tilings()); | 3554 EXPECT_FALSE(active_layer()->tilings()); |
| 3532 active_layer()->RecreateResources(); | 3555 active_layer()->RecreateTileResources(); |
| 3533 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 3556 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 3534 pending_layer()->ReleaseResources(); | 3557 pending_layer()->ReleaseTileResources(); |
| 3535 EXPECT_FALSE(pending_layer()->tilings()); | 3558 EXPECT_FALSE(pending_layer()->tilings()); |
| 3536 pending_layer()->RecreateResources(); | 3559 pending_layer()->RecreateTileResources(); |
| 3537 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); | 3560 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
| 3538 | 3561 |
| 3539 // This should create new tilings. | 3562 // This should create new tilings. |
| 3540 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3563 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 3541 1.3f, // ideal contents scale | 3564 1.3f, // ideal contents scale |
| 3542 2.7f, // device scale | 3565 2.7f, // device scale |
| 3543 3.2f, // page scale | 3566 3.2f, // page scale |
| 3544 1.f, // maximum animation scale | 3567 1.f, // maximum animation scale |
| 3545 0.f, // starting animation scale | 3568 0.f, // starting animation scale |
| 3546 false); | 3569 false); |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4972 EXPECT_FLOAT_EQ(expected_contents_scale, | 4995 EXPECT_FLOAT_EQ(expected_contents_scale, |
| 4973 pending_layer_ptr->picture_layer_tiling_set() | 4996 pending_layer_ptr->picture_layer_tiling_set() |
| 4974 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4997 ->FindTilingWithResolution(HIGH_RESOLUTION) |
| 4975 ->contents_scale()) | 4998 ->contents_scale()) |
| 4976 << "ideal_contents_scale: " << ideal_contents_scale; | 4999 << "ideal_contents_scale: " << ideal_contents_scale; |
| 4977 } | 5000 } |
| 4978 } | 5001 } |
| 4979 | 5002 |
| 4980 } // namespace | 5003 } // namespace |
| 4981 } // namespace cc | 5004 } // namespace cc |
| OLD | NEW |