diff options
author | hendrikw <hendrikw@chromium.org> | 2014-11-12 12:09:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-12 20:09:59 +0000 |
commit | 17c209dc32efee8e0b128a72404ea9afb184434b (patch) | |
tree | 57a46e594e927db61084380e40debdee29ce0c31 | |
parent | 463f1f0eb19bc15b1d4342ef2cea6b00177c942f (diff) | |
download | chromium_src-17c209dc32efee8e0b128a72404ea9afb184434b.zip chromium_src-17c209dc32efee8e0b128a72404ea9afb184434b.tar.gz chromium_src-17c209dc32efee8e0b128a72404ea9afb184434b.tar.bz2 |
cc: RemoveAllTilings on tile size change
- Update the tilings if either the layer size or the tile size
changes.
- Added a unit test to make sure we correctly resize tiles when
the tilesize changes
BUG=400864
Review URL: https://codereview.chromium.org/719123002
Cr-Commit-Position: refs/heads/master@{#303882}
-rw-r--r-- | cc/resources/picture_layer_tiling.cc | 8 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling_unittest.cc | 24 |
2 files changed, 27 insertions, 5 deletions
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 562b111..04b18c3 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -172,13 +172,11 @@ void PictureLayerTiling::UpdateTilesToCurrentRasterSource( const gfx::Size& new_layer_bounds) { DCHECK(!new_layer_bounds.IsEmpty()); - gfx::Size tile_size = tiling_data_.max_texture_size(); + gfx::Size content_bounds = + gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); + gfx::Size tile_size = client_->CalculateTileSize(content_bounds); if (new_layer_bounds != layer_bounds_) { - gfx::Size content_bounds = - gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); - - tile_size = client_->CalculateTileSize(content_bounds); if (tile_size.IsEmpty()) { layer_bounds_ = gfx::Size(); content_bounds = gfx::Size(); diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc index 675ce88..786f943 100644 --- a/cc/resources/picture_layer_tiling_unittest.cc +++ b/cc/resources/picture_layer_tiling_unittest.cc @@ -2178,5 +2178,29 @@ TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); } +TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { + // The tiling has four rows and three columns. + Initialize(gfx::Size(150, 100), 1, gfx::Size(250, 150)); + tiling_->CreateAllTilesForTesting(); + EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); + EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); + EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); + + client_.SetTileSize(gfx::Size(250, 200)); + client_.set_tree(PENDING_TREE); + + // Tile size in the tiling should still be 150x100. + EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); + EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); + + Region invalidation; + tiling_->UpdateTilesToCurrentRasterSource(invalidation, gfx::Size(250, 150)); + + // Tile size in the tiling should be resized to 250x200. + EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); + EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); + EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); +} + } // namespace } // namespace cc |