diff options
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 5 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 54 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_impl.cc | 12 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_impl.h | 1 |
4 files changed, 63 insertions, 9 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 1f8e5a8..763f05e 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -936,7 +936,10 @@ bool PictureLayerImpl::MarkVisibleTilesAsRequired( if (optional_twin_tiling) { Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); if (!twin_tile || twin_tile == tile) { - twin_had_missing_tile = true; + // However if the shared tile is being used on the active tree, then + // there's no missing content in this place, and low res is not needed. + if (!twin_tile || !twin_tile->IsReadyToDraw()) + twin_had_missing_tile = true; continue; } } diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 249dcf0..ba6c6bb 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -2822,7 +2822,7 @@ TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); } -TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { +TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { gfx::Size tile_size(100, 100); gfx::Size layer_bounds(1000, 1000); @@ -2841,12 +2841,58 @@ TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { // Initialize all high-res tiles. pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); - // High-res tiles should not be enough. + // High-res tiles should be enough, since they cover everything visible. + EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); +} + +TEST_F(PictureLayerImplTest, + SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { + gfx::Size tile_size(100, 100); + gfx::Size layer_bounds(1000, 1000); + + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); + + // Make sure some tiles are not shared. + pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); + + CreateHighLowResAndSetAllTilesVisible(); + + // Initialize all high-res tiles in the active layer. + active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); + // And all the low-res tiles in the pending layer. + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); + + pending_layer_->MarkVisibleResourcesAsRequired(); + + // The unshared high-res tiles are not ready, so we cannot activate. EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); - // Initialize remaining tiles. - pending_layer_->SetAllTilesReady(); + // When the unshared pending high-res tiles are ready, we can activate. + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); + EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); +} + +TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { + gfx::Size tile_size(100, 100); + gfx::Size layer_bounds(1000, 1000); + + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); + // Make sure some tiles are not shared. + pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); + + CreateHighLowResAndSetAllTilesVisible(); + + // Initialize all high-res tiles in the active layer. + active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); + + pending_layer_->MarkVisibleResourcesAsRequired(); + + // The unshared high-res tiles are not ready, so we cannot activate. + EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); + + // When the unshared pending high-res tiles are ready, we can activate. + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); } diff --git a/cc/test/fake_picture_layer_impl.cc b/cc/test/fake_picture_layer_impl.cc index 78924cd..98e0f6e 100644 --- a/cc/test/fake_picture_layer_impl.cc +++ b/cc/test/fake_picture_layer_impl.cc @@ -140,13 +140,17 @@ void FakePictureLayerImpl::SetAllTilesReadyInTiling( std::vector<Tile*> tiles = tiling->AllTilesForTesting(); for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { Tile* tile = tiles[tile_idx]; - ManagedTileState& state = tile->managed_state(); - for (size_t mode_idx = 0; mode_idx < NUM_RASTER_MODES; ++mode_idx) - state.tile_versions[mode_idx].SetSolidColorForTesting(true); - DCHECK(tile->IsReadyToDraw()); + SetTileReady(tile); } } +void FakePictureLayerImpl::SetTileReady(Tile* tile) { + ManagedTileState& state = tile->managed_state(); + for (size_t mode_idx = 0; mode_idx < NUM_RASTER_MODES; ++mode_idx) + state.tile_versions[mode_idx].SetSolidColorForTesting(true); + DCHECK(tile->IsReadyToDraw()); +} + void FakePictureLayerImpl::CreateDefaultTilingsAndTiles() { layer_tree_impl()->UpdateDrawProperties(); diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h index 915b740..fbaecf7 100644 --- a/cc/test/fake_picture_layer_impl.h +++ b/cc/test/fake_picture_layer_impl.h @@ -108,6 +108,7 @@ class FakePictureLayerImpl : public PictureLayerImpl { void SetAllTilesVisible(); void SetAllTilesReady(); void SetAllTilesReadyInTiling(PictureLayerTiling* tiling); + void SetTileReady(Tile* tile); void ResetAllTilesPriorities(); PictureLayerTilingSet* GetTilings() { return tilings_.get(); } |