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..17a6c1f133207383100cb329762c31e97e352fc6 100644 |
| --- a/cc/resources/picture_layer_tiling.cc |
| +++ b/cc/resources/picture_layer_tiling.cc |
| @@ -9,6 +9,8 @@ |
| #include <limits> |
| #include <set> |
| +#include "base/containers/hash_tables.h" |
| +#include "base/containers/small_map.h" |
| #include "base/logging.h" |
| #include "base/trace_event/trace_event.h" |
| #include "base/trace_event/trace_event_argument.h" |
| @@ -227,11 +229,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 +264,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 RemoveTileData { |
| + gfx::Rect invalid_content_rect; |
| + Tile::Id invalid_id; |
| + }; |
| + base::SmallMap<base::hash_map<TileMapKey, RemoveTileData>, 16> remove_tiles; |
| gfx::Rect expanded_live_tiles_rect = |
| tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
| for (Region::Iterator iter(layer_invalidation); iter.has_rect(); |
| @@ -286,15 +292,21 @@ 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()); |
| - } |
| + RemoveTileData& remove_tile_data = remove_tiles[iter.index()]; |
|
vmpstr
2015/05/14 22:28:27
At a first glance, this seems to be changing behav
danakj
2015/05/14 22:35:00
Ya you're very right and your suggestion is spot o
|
| + remove_tile_data.invalid_content_rect.Union(content_rect); |
| + Tile::Id old_id; |
| + if (RemoveTileAt(iter.index_x(), iter.index_y(), &old_id)) |
| + remove_tile_data.invalid_id = old_id; |
| } |
| } |
| - for (const auto& key : new_tile_keys) |
| - CreateTile(key.first, key.second); |
| + for (const auto& pair : remove_tiles) { |
| + const TileMapKey& key = pair.first; |
| + const RemoveTileData& remove_tile_data = pair.second; |
| + Tile* tile = CreateTile(key.first, key.second); |
| + tile->SetInvalidatedRect(remove_tile_data.invalid_content_rect); |
| + tile->SetInvalidatedId(remove_tile_data.invalid_id); |
| + } |
| } |
| void PictureLayerTiling::SetRasterSourceOnTiles() { |
| @@ -500,10 +512,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 +675,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. |