| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 271 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 272 contents_scale, | 272 contents_scale, |
| 273 device_scale_factor, | 273 device_scale_factor, |
| 274 page_scale_factor, | 274 page_scale_factor, |
| 275 maximum_animation_contents_scale, | 275 maximum_animation_contents_scale, |
| 276 animating_transform); | 276 animating_transform); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void ResetTilingsAndRasterScales() { | 279 void ResetTilingsAndRasterScales() { |
| 280 pending_layer_->ReleaseResources(); | 280 pending_layer_->ReleaseResources(); |
| 281 EXPECT_FALSE(pending_layer_->tilings()); |
| 282 pending_layer_->RecreateResources(); |
| 283 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 284 |
| 281 active_layer_->ReleaseResources(); | 285 active_layer_->ReleaseResources(); |
| 282 if (pending_layer_) | 286 EXPECT_FALSE(active_layer_->tilings()); |
| 283 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 287 active_layer_->RecreateResources(); |
| 284 if (active_layer_) | 288 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 285 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | |
| 286 } | 289 } |
| 287 | 290 |
| 288 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 291 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
| 289 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 292 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 290 for (size_t i = 0; i < tiles.size(); ++i) | 293 for (size_t i = 0; i < tiles.size(); ++i) |
| 291 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; | 294 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; |
| 292 EXPECT_GT(tiles.size(), 0u); | 295 EXPECT_GT(tiles.size(), 0u); |
| 293 } | 296 } |
| 294 | 297 |
| 295 void AssertNoTilesRequired(PictureLayerTiling* tiling) { | 298 void AssertNoTilesRequired(PictureLayerTiling* tiling) { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 | 707 |
| 705 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | 708 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
| 706 active_layer_->tilings()->num_tilings()); | 709 active_layer_->tilings()->num_tilings()); |
| 707 | 710 |
| 708 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 711 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 709 EXPECT_GT(tilings->num_tilings(), 0u); | 712 EXPECT_GT(tilings->num_tilings(), 0u); |
| 710 for (size_t i = 0; i < tilings->num_tilings(); ++i) | 713 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
| 711 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); | 714 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); |
| 712 } | 715 } |
| 713 | 716 |
| 714 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 717 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) { |
| 715 gfx::Size tile_size(400, 400); | 718 gfx::Size tile_size(400, 400); |
| 716 gfx::Size layer_bounds(1300, 1900); | 719 gfx::Size layer_bounds(1300, 1900); |
| 717 | 720 |
| 718 scoped_refptr<FakePicturePileImpl> pending_pile = | 721 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 719 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 722 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 720 scoped_refptr<FakePicturePileImpl> active_pile = | 723 scoped_refptr<FakePicturePileImpl> active_pile = |
| 721 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 724 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 722 | 725 |
| 723 SetupTrees(pending_pile, active_pile); | 726 SetupTrees(pending_pile, active_pile); |
| 724 | 727 |
| 725 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 728 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 726 EXPECT_LT(low_res_factor, 1.f); | 729 EXPECT_LT(low_res_factor, 1.f); |
| 727 | 730 |
| 728 active_layer_->ReleaseResources(); | 731 active_layer_->ReleaseResources(); |
| 732 EXPECT_FALSE(active_layer_->tilings()); |
| 733 active_layer_->RecreateResources(); |
| 729 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 734 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 730 | 735 |
| 731 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 736 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 732 6.f, // ideal contents scale | 737 6.f, // ideal contents scale |
| 733 3.f, // device scale | 738 3.f, // device scale |
| 734 2.f, // page scale | 739 2.f, // page scale |
| 735 1.f, // maximum animation scale | 740 1.f, // maximum animation scale |
| 736 false); | 741 false); |
| 737 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 742 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 738 EXPECT_FLOAT_EQ(6.f, | 743 EXPECT_FLOAT_EQ(6.f, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 794 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 790 scoped_refptr<FakePicturePileImpl> active_pile = | 795 scoped_refptr<FakePicturePileImpl> active_pile = |
| 791 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 796 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 792 | 797 |
| 793 SetupTrees(pending_pile, active_pile); | 798 SetupTrees(pending_pile, active_pile); |
| 794 | 799 |
| 795 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 800 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 796 EXPECT_LT(low_res_factor, 1.f); | 801 EXPECT_LT(low_res_factor, 1.f); |
| 797 | 802 |
| 798 pending_layer_->ReleaseResources(); | 803 pending_layer_->ReleaseResources(); |
| 804 EXPECT_FALSE(pending_layer_->tilings()); |
| 805 pending_layer_->RecreateResources(); |
| 799 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 806 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 800 | 807 |
| 801 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 808 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 802 6.f, // ideal contents scale | 809 6.f, // ideal contents scale |
| 803 3.f, // device scale | 810 3.f, // device scale |
| 804 2.f, // page scale | 811 2.f, // page scale |
| 805 1.f, // maximum animation scale | 812 1.f, // maximum animation scale |
| 806 false); | 813 false); |
| 807 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 814 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 808 EXPECT_FLOAT_EQ(6.f, | 815 EXPECT_FLOAT_EQ(6.f, |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 // The mask resource exists. | 1326 // The mask resource exists. |
| 1320 ResourceProvider::ResourceId mask_resource_id; | 1327 ResourceProvider::ResourceId mask_resource_id; |
| 1321 gfx::Size mask_texture_size; | 1328 gfx::Size mask_texture_size; |
| 1322 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1329 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1323 EXPECT_NE(0u, mask_resource_id); | 1330 EXPECT_NE(0u, mask_resource_id); |
| 1324 EXPECT_EQ(active_mask->bounds(), mask_texture_size); | 1331 EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
| 1325 | 1332 |
| 1326 // Drop resources and recreate them, still the same. | 1333 // Drop resources and recreate them, still the same. |
| 1327 pending_mask->ReleaseResources(); | 1334 pending_mask->ReleaseResources(); |
| 1328 active_mask->ReleaseResources(); | 1335 active_mask->ReleaseResources(); |
| 1336 pending_mask->RecreateResources(); |
| 1337 active_mask->RecreateResources(); |
| 1329 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); | 1338 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
| 1330 active_mask->HighResTiling()->CreateAllTilesForTesting(); | 1339 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
| 1331 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1340 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1332 EXPECT_NE(0u, mask_resource_id); | 1341 EXPECT_NE(0u, mask_resource_id); |
| 1333 EXPECT_EQ(active_mask->bounds(), mask_texture_size); | 1342 EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
| 1334 | 1343 |
| 1335 // Resize larger than the max texture size. | 1344 // Resize larger than the max texture size. |
| 1336 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; | 1345 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
| 1337 gfx::Size huge_bounds(max_texture_size + 1, 10); | 1346 gfx::Size huge_bounds(max_texture_size + 1, 10); |
| 1338 scoped_refptr<FakePicturePileImpl> huge_pile = | 1347 scoped_refptr<FakePicturePileImpl> huge_pile = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1362 // The mask resource exists. | 1371 // The mask resource exists. |
| 1363 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1372 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1364 EXPECT_NE(0u, mask_resource_id); | 1373 EXPECT_NE(0u, mask_resource_id); |
| 1365 gfx::Size expected_size = active_mask->bounds(); | 1374 gfx::Size expected_size = active_mask->bounds(); |
| 1366 expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); | 1375 expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); |
| 1367 EXPECT_EQ(expected_size, mask_texture_size); | 1376 EXPECT_EQ(expected_size, mask_texture_size); |
| 1368 | 1377 |
| 1369 // Drop resources and recreate them, still the same. | 1378 // Drop resources and recreate them, still the same. |
| 1370 pending_mask->ReleaseResources(); | 1379 pending_mask->ReleaseResources(); |
| 1371 active_mask->ReleaseResources(); | 1380 active_mask->ReleaseResources(); |
| 1381 pending_mask->RecreateResources(); |
| 1382 active_mask->RecreateResources(); |
| 1372 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); | 1383 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
| 1373 active_mask->HighResTiling()->CreateAllTilesForTesting(); | 1384 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
| 1374 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1385 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1375 EXPECT_NE(0u, mask_resource_id); | 1386 EXPECT_NE(0u, mask_resource_id); |
| 1376 EXPECT_EQ(expected_size, mask_texture_size); | 1387 EXPECT_EQ(expected_size, mask_texture_size); |
| 1377 | 1388 |
| 1378 // Do another activate, the same holds. | 1389 // Do another activate, the same holds. |
| 1379 SetupPendingTree(huge_pile); | 1390 SetupPendingTree(huge_pile); |
| 1380 ActivateTree(); | 1391 ActivateTree(); |
| 1381 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1392 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 scoped_refptr<FakePicturePileImpl> pending_pile = | 1479 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1469 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1480 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1470 scoped_refptr<FakePicturePileImpl> active_pile = | 1481 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1471 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1482 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1472 | 1483 |
| 1473 SetupTrees(pending_pile, active_pile); | 1484 SetupTrees(pending_pile, active_pile); |
| 1474 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1485 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1475 | 1486 |
| 1476 // All tilings should be removed when losing output surface. | 1487 // All tilings should be removed when losing output surface. |
| 1477 active_layer_->ReleaseResources(); | 1488 active_layer_->ReleaseResources(); |
| 1489 EXPECT_FALSE(active_layer_->tilings()); |
| 1490 active_layer_->RecreateResources(); |
| 1478 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1491 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 1479 pending_layer_->ReleaseResources(); | 1492 pending_layer_->ReleaseResources(); |
| 1493 EXPECT_FALSE(pending_layer_->tilings()); |
| 1494 pending_layer_->RecreateResources(); |
| 1480 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1495 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1481 | 1496 |
| 1482 // This should create new tilings. | 1497 // This should create new tilings. |
| 1483 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 1498 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 1484 1.f, // ideal contents scale | 1499 1.f, // ideal contents scale |
| 1485 1.f, // device scale | 1500 1.f, // device scale |
| 1486 1.f, // page scale | 1501 1.f, // page scale |
| 1487 1.f, // maximum animation scale | 1502 1.f, // maximum animation scale |
| 1488 false); | 1503 false); |
| 1489 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1504 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| (...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3737 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3752 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3738 scoped_refptr<FakePicturePileImpl> active_pile = | 3753 scoped_refptr<FakePicturePileImpl> active_pile = |
| 3739 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3754 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3740 | 3755 |
| 3741 SetupTrees(pending_pile, active_pile); | 3756 SetupTrees(pending_pile, active_pile); |
| 3742 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3757 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3743 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3758 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); |
| 3744 | 3759 |
| 3745 // All tilings should be removed when losing output surface. | 3760 // All tilings should be removed when losing output surface. |
| 3746 active_layer_->ReleaseResources(); | 3761 active_layer_->ReleaseResources(); |
| 3762 EXPECT_FALSE(active_layer_->tilings()); |
| 3763 active_layer_->RecreateResources(); |
| 3747 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 3764 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 3748 pending_layer_->ReleaseResources(); | 3765 pending_layer_->ReleaseResources(); |
| 3766 EXPECT_FALSE(pending_layer_->tilings()); |
| 3767 pending_layer_->RecreateResources(); |
| 3749 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 3768 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 3750 | 3769 |
| 3751 // This should create new tilings. | 3770 // This should create new tilings. |
| 3752 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3771 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 3753 1.3f, // ideal contents scale | 3772 1.3f, // ideal contents scale |
| 3754 2.7f, // device scale | 3773 2.7f, // device scale |
| 3755 3.2f, // page scale | 3774 3.2f, // page scale |
| 3756 1.f, // maximum animation scale | 3775 1.f, // maximum animation scale |
| 3757 false); | 3776 false); |
| 3758 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3777 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4917 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4936 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4918 EXPECT_EQ(result.width(), 448); | 4937 EXPECT_EQ(result.width(), 448); |
| 4919 EXPECT_EQ(result.height(), 448); | 4938 EXPECT_EQ(result.height(), 448); |
| 4920 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4939 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4921 EXPECT_EQ(result.width(), 512); | 4940 EXPECT_EQ(result.width(), 512); |
| 4922 EXPECT_EQ(result.height(), 500 + 2); | 4941 EXPECT_EQ(result.height(), 500 + 2); |
| 4923 } | 4942 } |
| 4924 | 4943 |
| 4925 } // namespace | 4944 } // namespace |
| 4926 } // namespace cc | 4945 } // namespace cc |
| OLD | NEW |