Index: cc/resources/picture_layer_tiling.cc |
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc |
index b90d28d19ad4d1424dc7b388372223df367ca5b7..3373d4b356167981ff24c3ae3eea2b9951c86ec7 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" |
@@ -225,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) { |
@@ -260,7 +262,7 @@ 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; |
+ base::SmallMap<base::hash_map<TileMapKey, gfx::Rect>, 16> remove_tiles; |
gfx::Rect expanded_live_tiles_rect = |
tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
for (Region::Iterator iter(layer_invalidation); iter.has_rect(); |
@@ -284,15 +286,20 @@ 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()); |
- } |
+ // This also adds the TileMapKey to the map. |
+ remove_tiles[iter.index()].Union(content_rect); |
} |
} |
- for (const auto& key : new_tile_keys) |
- CreateTile(key.first, key.second); |
+ for (const auto& pair : remove_tiles) { |
+ const TileMapKey& key = pair.first; |
+ const gfx::Rect& invalid_content_rect = pair.second; |
+ Tile::Id old_id(0); |
+ if (RemoveTileAt(key.first, key.second, &old_id) && recreate_tiles) { |
+ if (Tile* tile = CreateTile(key.first, key.second)) |
+ tile->SetInvalidated(invalid_content_rect, old_id); |
+ } |
+ } |
} |
bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { |
@@ -490,10 +497,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) { |
vmpstr
2015/05/15 20:54:21
FWIW, now that you've changed Tile::id() to be > 0
|
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; |
} |
@@ -650,7 +659,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. |