Chromium Code Reviews| 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/resources/picture_layer_tiling_set.h" | 5 #include "cc/resources/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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 | 330 |
| 331 // The tiles should get the correct size. | 331 // The tiles should get the correct size. |
| 332 std::vector<Tile*> pending_tiles = | 332 std::vector<Tile*> pending_tiles = |
| 333 pending_set->tiling_at(0)->AllTilesForTesting(); | 333 pending_set->tiling_at(0)->AllTilesForTesting(); |
| 334 EXPECT_GT(pending_tiles.size(), 0u); | 334 EXPECT_GT(pending_tiles.size(), 0u); |
| 335 for (const auto& tile : pending_tiles) | 335 for (const auto& tile : pending_tiles) |
| 336 EXPECT_EQ(tile_size1, tile->content_rect().size()); | 336 EXPECT_EQ(tile_size1, tile->content_rect().size()); |
| 337 | 337 |
| 338 // Update to a new source frame with a new tile size. | 338 // Update to a new source frame with a new tile size. |
| 339 pending_client.SetTileSize(tile_size2); | 339 pending_client.SetTileSize(tile_size2); |
| 340 pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), | 340 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), |
| 341 1.f, 1.f); | 341 Region()); |
| 342 // The tiling should get the correct tile size. | 342 // The tiling should get the correct tile size. |
| 343 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | 343 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); |
| 344 | 344 |
| 345 // Set a priority rect so we get tiles. | 345 // Set a priority rect so we get tiles. |
| 346 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, | 346 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, |
| 347 Occlusion(), false); | 347 Occlusion(), false); |
| 348 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | 348 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); |
| 349 | 349 |
| 350 // Tiles should have the new correct size. | 350 // Tiles should have the new correct size. |
| 351 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | 351 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); |
| 352 EXPECT_GT(pending_tiles.size(), 0u); | 352 EXPECT_GT(pending_tiles.size(), 0u); |
| 353 for (const auto& tile : pending_tiles) | 353 for (const auto& tile : pending_tiles) |
| 354 EXPECT_EQ(tile_size2, tile->content_rect().size()); | 354 EXPECT_EQ(tile_size2, tile->content_rect().size()); |
| 355 | 355 |
| 356 // Clone from the pending to the active tree. | 356 // Clone from the pending to the active tree. |
| 357 active_client.SetTileSize(tile_size2); | 357 active_client.SetTileSize(tile_size2); |
| 358 active_set->UpdateTilingsToCurrentRasterSource(pile.get(), pending_set.get(), | 358 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
| 359 Region(), 1.f, 1.f); | 359 pile.get(), pending_set.get(), Region()); |
| 360 // The active tiling should get the right tile size. | 360 // The active tiling should get the right tile size. |
| 361 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); | 361 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); |
| 362 | 362 |
| 363 // Cloned tiles should have the right size. | 363 // Cloned tiles should have the right size. |
| 364 std::vector<Tile*> active_tiles = | 364 std::vector<Tile*> active_tiles = |
| 365 active_set->tiling_at(0)->AllTilesForTesting(); | 365 active_set->tiling_at(0)->AllTilesForTesting(); |
| 366 EXPECT_GT(active_tiles.size(), 0u); | 366 EXPECT_GT(active_tiles.size(), 0u); |
| 367 for (const auto& tile : active_tiles) | 367 for (const auto& tile : active_tiles) |
| 368 EXPECT_EQ(tile_size2, tile->content_rect().size()); | 368 EXPECT_EQ(tile_size2, tile->content_rect().size()); |
| 369 | 369 |
| 370 // A new source frame with a new tile size. | 370 // A new source frame with a new tile size. |
| 371 pending_client.SetTileSize(tile_size3); | 371 pending_client.SetTileSize(tile_size3); |
| 372 pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), | 372 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), |
| 373 1.f, 1.f); | 373 Region()); |
| 374 // The tiling gets the new size correctly. | 374 // The tiling gets the new size correctly. |
| 375 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | 375 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); |
| 376 | 376 |
| 377 // Set a priority rect so we get tiles. | 377 // Set a priority rect so we get tiles. |
| 378 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, | 378 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, |
| 379 Occlusion(), false); | 379 Occlusion(), false); |
| 380 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | 380 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); |
| 381 | 381 |
| 382 // Tiles are resized for the new size. | 382 // Tiles are resized for the new size. |
| 383 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | 383 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); |
| 384 EXPECT_GT(pending_tiles.size(), 0u); | 384 EXPECT_GT(pending_tiles.size(), 0u); |
| 385 for (const auto& tile : pending_tiles) | 385 for (const auto& tile : pending_tiles) |
| 386 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 386 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
| 387 | 387 |
| 388 // Now we activate with a different tile size for the active tiling. | 388 // Now we activate with a different tile size for the active tiling. |
| 389 active_client.SetTileSize(tile_size3); | 389 active_client.SetTileSize(tile_size3); |
| 390 active_set->UpdateTilingsToCurrentRasterSource(pile.get(), pending_set.get(), | 390 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
| 391 Region(), 1.f, 1.f); | 391 pile.get(), pending_set.get(), Region()); |
| 392 // The active tiling changes its tile size. | 392 // The active tiling changes its tile size. |
| 393 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); | 393 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); |
| 394 | 394 |
| 395 // And its tiles are resized. | 395 // And its tiles are resized. |
| 396 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); | 396 active_tiles = 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 (const auto& tile : active_tiles) |
| 399 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 399 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
| 400 } | 400 } |
| 401 | 401 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 416 pending_set->AddTiling(2.f, pile); | 416 pending_set->AddTiling(2.f, pile); |
| 417 pending_set->AddTiling(3.f, pile); | 417 pending_set->AddTiling(3.f, pile); |
| 418 | 418 |
| 419 // Set some expected things for the tiling set to function. | 419 // Set some expected things for the tiling set to function. |
| 420 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 420 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
| 421 active_client.set_twin_tiling_set(pending_set.get()); | 421 active_client.set_twin_tiling_set(pending_set.get()); |
| 422 | 422 |
| 423 // Update to a new source frame with a max content scale that is larger than | 423 // Update to a new source frame with a max content scale that is larger than |
| 424 // everything. | 424 // everything. |
| 425 float max_content_scale = 3.f; | 425 float max_content_scale = 3.f; |
| 426 pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), | 426 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), |
| 427 1.f, max_content_scale); | 427 Region()); |
| 428 | |
| 428 // All the tilings are there still. | 429 // All the tilings are there still. |
| 429 EXPECT_EQ(3u, pending_set->num_tilings()); | 430 EXPECT_EQ(3u, pending_set->num_tilings()); |
| 430 | 431 |
| 431 // Clone from the pending to the active tree with the same max content size. | 432 // Clone from the pending to the active tree with the same max content size. |
| 432 active_set->UpdateTilingsToCurrentRasterSource( | 433 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
| 433 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | 434 pile.get(), pending_set.get(), Region()); |
| 434 // All the tilings are on the active tree. | 435 // All the tilings are on the active tree. |
| 435 EXPECT_EQ(3u, active_set->num_tilings()); | 436 EXPECT_EQ(3u, active_set->num_tilings()); |
| 436 | 437 |
| 437 // Update to a new source frame with a max content scale that will drop one | 438 // Update to a new source frame with a max content scale that will drop one |
|
enne (OOO)
2015/03/31 19:53:02
This test no longer really makes any sense, since
vmpstr
2015/04/01 23:53:41
Changed it back with RemoveTilings being a part of
| |
| 438 // tiling. | 439 // tiling. |
| 439 max_content_scale = 2.9f; | 440 max_content_scale = 2.9f; |
| 440 pending_set->UpdateTilingsToCurrentRasterSource(pile.get(), nullptr, Region(), | 441 pending_set->RemoveTilingsBelowScale(1.f); |
| 441 1.f, max_content_scale); | 442 pending_set->RemoveTilingsAboveScale(max_content_scale); |
| 443 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), | |
| 444 Region()); | |
| 442 // All the tilings are there still. | 445 // All the tilings are there still. |
| 443 EXPECT_EQ(2u, pending_set->num_tilings()); | 446 EXPECT_EQ(2u, pending_set->num_tilings()); |
| 444 | 447 |
| 445 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 448 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
| 446 | 449 |
| 447 // Clone from the pending to the active tree with the same max content size. | 450 // Clone from the pending to the active tree with the same max content size. |
| 448 active_set->UpdateTilingsToCurrentRasterSource( | 451 active_set->RemoveTilingsBelowScale(1.f); |
| 449 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | 452 active_set->RemoveTilingsAboveScale(max_content_scale); |
| 453 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | |
| 454 pile.get(), pending_set.get(), Region()); | |
| 450 // All the tilings are on the active tree. | 455 // All the tilings are on the active tree. |
| 451 EXPECT_EQ(2u, active_set->num_tilings()); | 456 EXPECT_EQ(2u, active_set->num_tilings()); |
| 452 } | 457 } |
| 453 | 458 |
| 454 } // namespace | 459 } // namespace |
| 455 } // namespace cc | 460 } // namespace cc |
| OLD | NEW |