| 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 3394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3405 | 3405 |
| 3406 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3406 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3407 gfx::Size tile_size(100, 100); | 3407 gfx::Size tile_size(100, 100); |
| 3408 gfx::Size layer_bounds(1000, 1000); | 3408 gfx::Size layer_bounds(1000, 1000); |
| 3409 | 3409 |
| 3410 // Make sure some tiles are not shared. | 3410 // Make sure some tiles are not shared. |
| 3411 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3411 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3412 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3412 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3413 | 3413 |
| 3414 // All pending layer tiles required are not ready. | 3414 // All pending layer tiles required are not ready. |
| 3415 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3415 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3416 | 3416 |
| 3417 // Initialize all low-res tiles. | 3417 // Initialize all low-res tiles. |
| 3418 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3418 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3419 | 3419 |
| 3420 // Low-res tiles should not be enough. | 3420 // Low-res tiles should not be enough. |
| 3421 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3421 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3422 | 3422 |
| 3423 // Initialize remaining tiles. | 3423 // Initialize remaining tiles. |
| 3424 pending_layer_->SetAllTilesReady(); | 3424 pending_layer_->SetAllTilesReady(); |
| 3425 | 3425 |
| 3426 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3426 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3427 } | 3427 } |
| 3428 | 3428 |
| 3429 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { | 3429 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
| 3430 gfx::Size tile_size(100, 100); | 3430 gfx::Size tile_size(100, 100); |
| 3431 gfx::Size layer_bounds(1000, 1000); | 3431 gfx::Size layer_bounds(1000, 1000); |
| 3432 | 3432 |
| 3433 // Make sure some tiles are not shared. | 3433 // Make sure some tiles are not shared. |
| 3434 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3434 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3435 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3435 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3436 | 3436 |
| 3437 // All pending layer tiles required are not ready. | 3437 // All pending layer tiles required are not ready. |
| 3438 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3438 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3439 | 3439 |
| 3440 // Initialize all high-res tiles. | 3440 // Initialize all high-res tiles. |
| 3441 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3441 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3442 | 3442 |
| 3443 // High-res tiles should be enough, since they cover everything visible. | 3443 // High-res tiles should be enough, since they cover everything visible. |
| 3444 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3444 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3445 } | 3445 } |
| 3446 | 3446 |
| 3447 TEST_F(PictureLayerImplTest, | 3447 TEST_F(PictureLayerImplTest, |
| 3448 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { | 3448 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
| 3449 gfx::Size tile_size(100, 100); | 3449 gfx::Size tile_size(100, 100); |
| 3450 gfx::Size layer_bounds(1000, 1000); | 3450 gfx::Size layer_bounds(1000, 1000); |
| 3451 | 3451 |
| 3452 // Make sure some tiles are not shared. | 3452 // Make sure some tiles are not shared. |
| 3453 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3453 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3454 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3454 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3455 | 3455 |
| 3456 // Initialize all high-res tiles in the active layer. | 3456 // Initialize all high-res tiles in the active layer. |
| 3457 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3457 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3458 // And all the low-res tiles in the pending layer. | 3458 // And all the low-res tiles in the pending layer. |
| 3459 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3459 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3460 | 3460 |
| 3461 // The unshared high-res tiles are not ready, so we cannot activate. | 3461 // The unshared high-res tiles are not ready, so we cannot activate. |
| 3462 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3462 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3463 | 3463 |
| 3464 // When the unshared pending high-res tiles are ready, we can activate. | 3464 // When the unshared pending high-res tiles are ready, we can activate. |
| 3465 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3465 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3466 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3466 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3467 } | 3467 } |
| 3468 | 3468 |
| 3469 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { | 3469 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { |
| 3470 gfx::Size tile_size(100, 100); | 3470 gfx::Size tile_size(100, 100); |
| 3471 gfx::Size layer_bounds(1000, 1000); | 3471 gfx::Size layer_bounds(1000, 1000); |
| 3472 | 3472 |
| 3473 // Make sure some tiles are not shared. | 3473 // Make sure some tiles are not shared. |
| 3474 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3474 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3475 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3475 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3476 | 3476 |
| 3477 // Initialize all high-res tiles in the active layer. | 3477 // Initialize all high-res tiles in the active layer. |
| 3478 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3478 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3479 | 3479 |
| 3480 // The unshared high-res tiles are not ready, so we cannot activate. | 3480 // The unshared high-res tiles are not ready, so we cannot activate. |
| 3481 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3481 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3482 | 3482 |
| 3483 // When the unshared pending high-res tiles are ready, we can activate. | 3483 // When the unshared pending high-res tiles are ready, we can activate. |
| 3484 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3484 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3485 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3485 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3486 } | 3486 } |
| 3487 | 3487 |
| 3488 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { | 3488 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 3489 gfx::Size tile_size(400, 400); | 3489 gfx::Size tile_size(400, 400); |
| 3490 gfx::Size layer_bounds(1300, 1900); | 3490 gfx::Size layer_bounds(1300, 1900); |
| 3491 | 3491 |
| 3492 scoped_refptr<FakePicturePileImpl> pending_pile = | 3492 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3493 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3493 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3494 scoped_refptr<FakePicturePileImpl> active_pile = | 3494 scoped_refptr<FakePicturePileImpl> active_pile = |
| 3495 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3495 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4882 | 4882 |
| 4883 host_impl_.SetRequiresHighResToDraw(); | 4883 host_impl_.SetRequiresHighResToDraw(); |
| 4884 | 4884 |
| 4885 // Update tiles. | 4885 // Update tiles. |
| 4886 pending_layer_->draw_properties().visible_content_rect = viewport; | 4886 pending_layer_->draw_properties().visible_content_rect = viewport; |
| 4887 pending_layer_->draw_properties().screen_space_transform = transform; | 4887 pending_layer_->draw_properties().screen_space_transform = transform; |
| 4888 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 4888 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 4889 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4889 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 4890 | 4890 |
| 4891 // Ensure we can't activate. | 4891 // Ensure we can't activate. |
| 4892 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 4892 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 4893 | 4893 |
| 4894 // Now in the same frame, move the viewport (this can happen during | 4894 // Now in the same frame, move the viewport (this can happen during |
| 4895 // animation). | 4895 // animation). |
| 4896 viewport = gfx::Rect(0, 2000, 100, 100); | 4896 viewport = gfx::Rect(0, 2000, 100, 100); |
| 4897 | 4897 |
| 4898 // Update tiles. | 4898 // Update tiles. |
| 4899 pending_layer_->draw_properties().visible_content_rect = viewport; | 4899 pending_layer_->draw_properties().visible_content_rect = viewport; |
| 4900 pending_layer_->draw_properties().screen_space_transform = transform; | 4900 pending_layer_->draw_properties().screen_space_transform = transform; |
| 4901 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 4901 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 4902 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4902 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 4903 | 4903 |
| 4904 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. | 4904 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. |
| 4905 std::vector<Tile*> tiles; | 4905 std::vector<Tile*> tiles; |
| 4906 for (PictureLayerTiling::CoverageIterator iter( | 4906 for (PictureLayerTiling::CoverageIterator iter( |
| 4907 pending_layer_->HighResTiling(), | 4907 pending_layer_->HighResTiling(), |
| 4908 1.f, | 4908 1.f, |
| 4909 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4909 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4910 iter; | 4910 iter; |
| 4911 ++iter) { | 4911 ++iter) { |
| 4912 if (*iter) | 4912 if (*iter) |
| 4913 tiles.push_back(*iter); | 4913 tiles.push_back(*iter); |
| 4914 } | 4914 } |
| 4915 | 4915 |
| 4916 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4916 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4917 | 4917 |
| 4918 // Ensure we can activate. | 4918 // Ensure we can activate. |
| 4919 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 4919 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 4920 } | 4920 } |
| 4921 | 4921 |
| 4922 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { | 4922 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { |
| 4923 gfx::Size tile_size(100, 100); | 4923 gfx::Size tile_size(100, 100); |
| 4924 gfx::Size layer_bounds(400, 400); | 4924 gfx::Size layer_bounds(400, 400); |
| 4925 | 4925 |
| 4926 scoped_refptr<FakePicturePileImpl> filled_pile = | 4926 scoped_refptr<FakePicturePileImpl> filled_pile = |
| 4927 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4927 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4928 scoped_refptr<FakePicturePileImpl> partial_pile = | 4928 scoped_refptr<FakePicturePileImpl> partial_pile = |
| 4929 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 4929 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5039 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 5039 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 5040 EXPECT_EQ(result.width(), 448); | 5040 EXPECT_EQ(result.width(), 448); |
| 5041 EXPECT_EQ(result.height(), 448); | 5041 EXPECT_EQ(result.height(), 448); |
| 5042 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 5042 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 5043 EXPECT_EQ(result.width(), 512); | 5043 EXPECT_EQ(result.width(), 512); |
| 5044 EXPECT_EQ(result.height(), 500 + 2); | 5044 EXPECT_EQ(result.height(), 500 + 2); |
| 5045 } | 5045 } |
| 5046 | 5046 |
| 5047 } // namespace | 5047 } // namespace |
| 5048 } // namespace cc | 5048 } // namespace cc |
| OLD | NEW |