| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/tiles/picture_layer_tiling_set.h" | 5 #include "cc/tiles/picture_layer_tiling_set.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 // Set a priority rect so we get tiles. | 351 // Set a priority rect so we get tiles. |
| 352 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0, | 352 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0, |
| 353 Occlusion(), false); | 353 Occlusion(), false); |
| 354 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); | 354 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); |
| 355 | 355 |
| 356 // The tiles should get the correct size. | 356 // The tiles should get the correct size. |
| 357 std::vector<Tile*> pending_tiles = | 357 std::vector<Tile*> pending_tiles = |
| 358 pending_set->tiling_at(0)->AllTilesForTesting(); | 358 pending_set->tiling_at(0)->AllTilesForTesting(); |
| 359 EXPECT_GT(pending_tiles.size(), 0u); | 359 EXPECT_GT(pending_tiles.size(), 0u); |
| 360 for (const auto& tile : pending_tiles) | 360 for (auto* tile : pending_tiles) |
| 361 EXPECT_EQ(tile_size1, tile->content_rect().size()); | 361 EXPECT_EQ(tile_size1, tile->content_rect().size()); |
| 362 | 362 |
| 363 // Update to a new source frame with a new tile size. | 363 // Update to a new source frame with a new tile size. |
| 364 // Note that setting a new raster source can typically only happen after | 364 // Note that setting a new raster source can typically only happen after |
| 365 // activation, since we can't set the raster source twice on the pending tree | 365 // activation, since we can't set the raster source twice on the pending tree |
| 366 // without activating. For test, just remove and add a new tiling instead. | 366 // without activating. For test, just remove and add a new tiling instead. |
| 367 pending_set->RemoveAllTilings(); | 367 pending_set->RemoveAllTilings(); |
| 368 pending_set->AddTiling(1.f, raster_source); | 368 pending_set->AddTiling(1.f, raster_source); |
| 369 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 369 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
| 370 pending_client.SetTileSize(tile_size2); | 370 pending_client.SetTileSize(tile_size2); |
| 371 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), | 371 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), |
| 372 Region(), 1.f, 1.f); | 372 Region(), 1.f, 1.f); |
| 373 // The tiling should get the correct tile size. | 373 // The tiling should get the correct tile size. |
| 374 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | 374 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); |
| 375 | 375 |
| 376 // Set a priority rect so we get tiles. | 376 // Set a priority rect so we get tiles. |
| 377 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, | 377 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, |
| 378 Occlusion(), false); | 378 Occlusion(), false); |
| 379 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | 379 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); |
| 380 | 380 |
| 381 // Tiles should have the new correct size. | 381 // Tiles should have the new correct size. |
| 382 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | 382 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); |
| 383 EXPECT_GT(pending_tiles.size(), 0u); | 383 EXPECT_GT(pending_tiles.size(), 0u); |
| 384 for (const auto& tile : pending_tiles) | 384 for (auto* tile : pending_tiles) |
| 385 EXPECT_EQ(tile_size2, tile->content_rect().size()); | 385 EXPECT_EQ(tile_size2, tile->content_rect().size()); |
| 386 | 386 |
| 387 // Clone from the pending to the active tree. | 387 // Clone from the pending to the active tree. |
| 388 active_client.SetTileSize(tile_size2); | 388 active_client.SetTileSize(tile_size2); |
| 389 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 389 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
| 390 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f); | 390 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f); |
| 391 // The active tiling should get the right tile size. | 391 // The active tiling should get the right tile size. |
| 392 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); | 392 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); |
| 393 | 393 |
| 394 // Cloned tiles should have the right size. | 394 // Cloned tiles should have the right size. |
| 395 std::vector<Tile*> active_tiles = | 395 std::vector<Tile*> active_tiles = |
| 396 active_set->tiling_at(0)->AllTilesForTesting(); | 396 active_set->tiling_at(0)->AllTilesForTesting(); |
| 397 EXPECT_GT(active_tiles.size(), 0u); | 397 EXPECT_GT(active_tiles.size(), 0u); |
| 398 for (const auto& tile : active_tiles) | 398 for (auto* tile : active_tiles) |
| 399 EXPECT_EQ(tile_size2, tile->content_rect().size()); | 399 EXPECT_EQ(tile_size2, tile->content_rect().size()); |
| 400 | 400 |
| 401 // A new source frame with a new tile size. | 401 // A new source frame with a new tile size. |
| 402 pending_client.SetTileSize(tile_size3); | 402 pending_client.SetTileSize(tile_size3); |
| 403 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), | 403 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), |
| 404 Region(), 1.f, 1.f); | 404 Region(), 1.f, 1.f); |
| 405 // The tiling gets the new size correctly. | 405 // The tiling gets the new size correctly. |
| 406 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | 406 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); |
| 407 | 407 |
| 408 // Set a priority rect so we get tiles. | 408 // Set a priority rect so we get tiles. |
| 409 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, | 409 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, |
| 410 Occlusion(), false); | 410 Occlusion(), false); |
| 411 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | 411 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); |
| 412 | 412 |
| 413 // Tiles are resized for the new size. | 413 // Tiles are resized for the new size. |
| 414 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | 414 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); |
| 415 EXPECT_GT(pending_tiles.size(), 0u); | 415 EXPECT_GT(pending_tiles.size(), 0u); |
| 416 for (const auto& tile : pending_tiles) | 416 for (auto* tile : pending_tiles) |
| 417 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 417 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
| 418 | 418 |
| 419 // Now we activate with a different tile size for the active tiling. | 419 // Now we activate with a different tile size for the active tiling. |
| 420 active_client.SetTileSize(tile_size3); | 420 active_client.SetTileSize(tile_size3); |
| 421 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 421 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
| 422 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f); | 422 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f); |
| 423 // The active tiling changes its tile size. | 423 // The active tiling changes its tile size. |
| 424 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); | 424 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); |
| 425 | 425 |
| 426 // And its tiles are resized. | 426 // And its tiles are resized. |
| 427 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); | 427 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); |
| 428 EXPECT_GT(active_tiles.size(), 0u); | 428 EXPECT_GT(active_tiles.size(), 0u); |
| 429 for (const auto& tile : active_tiles) | 429 for (auto* tile : active_tiles) |
| 430 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 430 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
| 431 } | 431 } |
| 432 | 432 |
| 433 TEST(PictureLayerTilingSetTest, MaxContentScale) { | 433 TEST(PictureLayerTilingSetTest, MaxContentScale) { |
| 434 FakePictureLayerTilingClient pending_client; | 434 FakePictureLayerTilingClient pending_client; |
| 435 FakePictureLayerTilingClient active_client; | 435 FakePictureLayerTilingClient active_client; |
| 436 std::unique_ptr<PictureLayerTilingSet> pending_set = | 436 std::unique_ptr<PictureLayerTilingSet> pending_set = |
| 437 PictureLayerTilingSet::Create(PENDING_TREE, &pending_client, 1000, 1.f, | 437 PictureLayerTilingSet::Create(PENDING_TREE, &pending_client, 1000, 1.f, |
| 438 1000); | 438 1000); |
| 439 std::unique_ptr<PictureLayerTilingSet> active_set = | 439 std::unique_ptr<PictureLayerTilingSet> active_set = |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 | 979 |
| 980 // This will invalidate tilings. | 980 // This will invalidate tilings. |
| 981 tiling_set->UpdateRasterSourceDueToLCDChange(raster_source, Region()); | 981 tiling_set->UpdateRasterSourceDueToLCDChange(raster_source, Region()); |
| 982 | 982 |
| 983 EXPECT_TRUE( | 983 EXPECT_TRUE( |
| 984 tiling_set->UpdateTilePriorities(viewport, 1.f, time, Occlusion(), true)); | 984 tiling_set->UpdateTilePriorities(viewport, 1.f, time, Occlusion(), true)); |
| 985 } | 985 } |
| 986 | 986 |
| 987 } // namespace | 987 } // namespace |
| 988 } // namespace cc | 988 } // namespace cc |
| OLD | NEW |