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