Chromium Code Reviews| Index: cc/resources/picture_layer_tiling.cc |
| diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc |
| index de2cb4a19f1cca0e9587f3943e83c2d837072fe7..11fc1632a1067942a4e0c68b2e4515f30f1b6142 100644 |
| --- a/cc/resources/picture_layer_tiling.cc |
| +++ b/cc/resources/picture_layer_tiling.cc |
| @@ -227,11 +227,11 @@ void PictureLayerTiling::SetRasterSourceAndResize( |
| // Drop tiles outside the new layer bounds if the layer shrank. |
| for (int i = after_right + 1; i <= before_right; ++i) { |
| for (int j = before_top; j <= before_bottom; ++j) |
| - RemoveTileAt(i, j); |
| + RemoveTileAt(i, j, nullptr); |
| } |
| for (int i = before_left; i <= after_right; ++i) { |
| for (int j = after_bottom + 1; j <= before_bottom; ++j) |
| - RemoveTileAt(i, j); |
| + RemoveTileAt(i, j, nullptr); |
| } |
| if (after_right > before_right) { |
| @@ -262,7 +262,11 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, |
| // twin, so it's slated for removal in the future. |
| if (live_tiles_rect_.IsEmpty()) |
| return; |
| - std::vector<TileMapKey> new_tile_keys; |
| + struct InvalidTiles { |
| + TileMapKey key; |
| + gfx::Rect invalid_rect; |
| + }; |
| + std::vector<InvalidTiles> new_tile_keys; |
|
vmpstr
2015/05/14 17:58:49
If you make this a (hash)map keyed by TileMapKey,
danakj
2015/05/14 19:59:47
enne@ just pointed out to me that I can just union
vmpstr
2015/05/14 20:08:34
You'd still need to record which tiles were invali
danakj
2015/05/14 20:10:18
The original vector of keys, yah. I have this chan
|
| gfx::Rect expanded_live_tiles_rect = |
| tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
| for (Region::Iterator iter(layer_invalidation); iter.has_rect(); |
| @@ -286,15 +290,27 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, |
| for ( |
| TilingData::Iterator iter(&tiling_data_, content_rect, include_borders); |
| iter; ++iter) { |
| - if (RemoveTileAt(iter.index_x(), iter.index_y())) { |
| - if (recreate_tiles) |
| - new_tile_keys.push_back(iter.index()); |
| + auto it = std::find_if( |
| + new_tile_keys.begin(), new_tile_keys.end(), |
| + [&iter](const InvalidTiles& inv) { return inv.key == iter.index(); }); |
| + if (it == new_tile_keys.end()) { |
| + InvalidTiles inv; |
| + inv.key = iter.index(); |
| + new_tile_keys.push_back(inv); |
| + it = new_tile_keys.end() - 1; |
| } |
| + it->invalid_rect.Union(content_rect); |
| } |
| } |
| - for (const auto& key : new_tile_keys) |
| - CreateTile(key.first, key.second); |
| + for (const InvalidTiles& inv : new_tile_keys) { |
| + Tile::Id old_id; |
| + if (RemoveTileAt(inv.key.first, inv.key.second, &old_id) && |
| + recreate_tiles) { |
| + Tile* tile = CreateTile(inv.key.first, inv.key.second); |
| + tile->SetInvalidated(inv.invalid_rect, old_id); |
| + } |
| + } |
| } |
| void PictureLayerTiling::SetRasterSourceOnTiles() { |
| @@ -500,10 +516,12 @@ gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const { |
| return texture_rect; |
| } |
| -bool PictureLayerTiling::RemoveTileAt(int i, int j) { |
| +bool PictureLayerTiling::RemoveTileAt(int i, int j, Tile::Id* id) { |
| TileMap::iterator found = tiles_.find(TileMapKey(i, j)); |
| if (found == tiles_.end()) |
| return false; |
| + if (id) |
| + *id = found->second->id(); |
| tiles_.erase(found); |
| return true; |
| } |
| @@ -661,7 +679,7 @@ void PictureLayerTiling::SetLiveTilesRect( |
| for (TilingData::DifferenceIterator iter(&tiling_data_, live_tiles_rect_, |
| new_live_tiles_rect); |
| iter; ++iter) { |
| - RemoveTileAt(iter.index_x(), iter.index_y()); |
| + RemoveTileAt(iter.index_x(), iter.index_y(), nullptr); |
| } |
| // Iterate to allocate new tiles for all regions with newly exposed area. |