diff options
author | vmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 21:01:33 +0000 |
---|---|---|
committer | vmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 21:01:33 +0000 |
commit | 86b1819ea0f9e1ff666b89835957ab1ad68ef706 (patch) | |
tree | 9fc7d42c3c09729f61dad9f55eeb56116d6bdffa /cc | |
parent | eac65cbf0888cfd8c57e1f7f03299f7f7f88cd8e (diff) | |
download | chromium_src-86b1819ea0f9e1ff666b89835957ab1ad68ef706.zip chromium_src-86b1819ea0f9e1ff666b89835957ab1ad68ef706.tar.gz chromium_src-86b1819ea0f9e1ff666b89835957ab1ad68ef706.tar.bz2 |
cc: Reset tiling size upon destruction.
Since bundles are shared, if at any point a tiling is deleted, we
have to make sure we clear the tiles on the current tree for that
tiling.
If we don't, we can run into a situation where a tiling is
deleted (and still exists on the twin at the same scale), then when
we sync we create a new tiling with bundles coming from the twin.
However, since the new tiling bounds are initially empty, we try
to create all the tiles in the interest rect. Since the tiling already
existed on the twin, it might already have the tiles on the current
tree.
BUG=328044
R=enne
Review URL: https://codereview.chromium.org/103693007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240744 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/resources/picture_layer_tiling.cc | 6 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling_unittest.cc | 40 |
2 files changed, 46 insertions, 0 deletions
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 9ec9293..9513d2d 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -78,6 +78,7 @@ PictureLayerTiling::PictureLayerTiling(float contents_scale, } PictureLayerTiling::~PictureLayerTiling() { + SetLiveTilesRect(gfx::Rect()); } void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { @@ -715,6 +716,11 @@ void PictureLayerTiling::SetLiveTilesRect(gfx::Rect new_live_tiles_rect) { RemoveBundleContainingTileAtIfEmpty(tile_x, tile_y); } + if (new_live_tiles_rect.IsEmpty()) { + live_tiles_rect_ = new_live_tiles_rect; + return; + } + const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); // Iterate to allocate new tiles for all regions with newly exposed area. diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc index f5e7cde..530ccc8 100644 --- a/cc/resources/picture_layer_tiling_unittest.cc +++ b/cc/resources/picture_layer_tiling_unittest.cc @@ -316,6 +316,46 @@ TEST(PictureLayerTilingTest, BundleAtContainsTileAt) { } } +TEST(PictureLayerTilingTest, TilesCleanedUp) { + FakeTileManagerClient tile_manager_client; + FakeTileManager tile_manager(&tile_manager_client); + FakePictureLayerTilingClient client(&tile_manager); + FakePictureLayerTilingClient twin_client(&tile_manager); + + gfx::Size current_layer_bounds(400, 400); + client.SetTileSize(gfx::Size(100, 100)); + twin_client.SetTileSize(gfx::Size(100, 100)); + scoped_ptr<TestablePictureLayerTiling> tiling = + TestablePictureLayerTiling::Create(1.0f, current_layer_bounds, &client); + scoped_ptr<TestablePictureLayerTiling> twin_tiling = + TestablePictureLayerTiling::Create( + 1.0f, current_layer_bounds, &twin_client); + + client.set_twin_tiling(twin_tiling.get()); + twin_client.set_twin_tiling(tiling.get()); + + tiling->CreateTilesForTesting(ACTIVE_TREE); + twin_tiling->CreateTilesForTesting(PENDING_TREE); + for (int tile_y = 0; tile_y < 4; ++tile_y) { + for (int tile_x = 0; tile_x < 4; ++tile_x) { + EXPECT_TRUE(tiling->TileAt(ACTIVE_TREE, tile_x, tile_y) == + twin_tiling->TileAt(ACTIVE_TREE, tile_x, tile_y)); + EXPECT_TRUE(tiling->TileAt(PENDING_TREE, tile_x, tile_y) == + twin_tiling->TileAt(PENDING_TREE, tile_x, tile_y)); + } + } + + client.set_twin_tiling(NULL); + twin_tiling.reset(); + + for (int tile_y = 0; tile_y < 4; ++tile_y) { + for (int tile_x = 0; tile_x < 4; ++tile_x) { + EXPECT_TRUE(tiling->TileAt(ACTIVE_TREE, tile_x, tile_y) != NULL); + EXPECT_TRUE(tiling->TileAt(PENDING_TREE, tile_x, tile_y) == NULL); + } + } +} + TEST(PictureLayerTilingTest, DidBecomeActiveSwapsTiles) { FakeTileManagerClient tile_manager_client; FakeTileManager tile_manager(&tile_manager_client); |