Chromium Code Reviews| Index: cc/tiles/picture_layer_tiling.cc |
| diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc |
| index 73909131d9da3298b64fabfeff08958a2aac5a8e..ee680ad5ba444bbeaa88e4a11ffdd43aed8e0173 100644 |
| --- a/cc/tiles/picture_layer_tiling.cc |
| +++ b/cc/tiles/picture_layer_tiling.cc |
| @@ -11,7 +11,6 @@ |
| #include <limits> |
| #include <set> |
| -#include "base/containers/hash_tables.h" |
| #include "base/containers/small_map.h" |
| #include "base/logging.h" |
| #include "base/numerics/safe_conversions.h" |
| @@ -117,7 +116,7 @@ Tile* PictureLayerTiling::CreateTile(const Tile::CreateInfo& info) { |
| all_tiles_done_ = false; |
| ScopedTilePtr tile = client_->CreateTile(info); |
| Tile* raw_ptr = tile.get(); |
| - tiles_.add(key, std::move(tile)); |
| + tiles_[key] = std::move(tile); |
| return raw_ptr; |
| } |
| @@ -186,8 +185,9 @@ void PictureLayerTiling::TakeTilesAndPropertiesFrom( |
| all_tiles_done_ = pending_twin->all_tiles_done_; |
| } else { |
| while (!pending_twin->tiles_.empty()) { |
| - TileMapKey key = pending_twin->tiles_.begin()->first; |
| - tiles_.set(key, pending_twin->tiles_.take_and_erase(key)); |
| + auto iter = pending_twin->tiles_.begin(); |
|
danakj
2016/01/14 21:12:32
nit: pending_iter?
davidben
2016/01/21 01:33:57
Done.
|
| + tiles_[iter->first] = std::move(iter->second); |
| + pending_twin->tiles_.erase(iter); |
| } |
| all_tiles_done_ &= pending_twin->all_tiles_done_; |
| } |
| @@ -296,11 +296,12 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, |
| // twin, so it's slated for removal in the future. |
| if (live_tiles_rect_.IsEmpty()) |
| return; |
| - // Pick 16 for the size of the SmallMap before it promotes to a hash_map. |
| + // Pick 16 for the size of the SmallMap before it promotes to a unordered_map. |
| // 4x4 tiles should cover most small invalidations, and walking a vector of |
| // 16 is fast enough. If an invalidation is huge we will fall back to a |
| - // hash_map instead of a vector in the SmallMap. |
| - base::SmallMap<base::hash_map<TileMapKey, gfx::Rect>, 16> remove_tiles; |
| + // unordered_map instead of a vector in the SmallMap. |
| + base::SmallMap<std::unordered_map<TileMapKey, gfx::Rect, TileMapKeyHash>, 16> |
| + remove_tiles; |
| gfx::Rect expanded_live_tiles_rect = |
| tiling_data_.ExpandRectToTileBounds(live_tiles_rect_); |
| for (Region::Iterator iter(layer_invalidation); iter.has_rect(); |
| @@ -547,7 +548,9 @@ ScopedTilePtr PictureLayerTiling::TakeTileAt(int i, int j) { |
| TileMap::iterator found = tiles_.find(TileMapKey(i, j)); |
| if (found == tiles_.end()) |
| return nullptr; |
| - return tiles_.take_and_erase(found); |
| + ScopedTilePtr result = std::move(found->second); |
| + tiles_.erase(found); |
| + return result; |
| } |
| bool PictureLayerTiling::RemoveTileAt(int i, int j) { |
| @@ -934,7 +937,7 @@ std::map<const Tile*, PrioritizedTile> |
| PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { |
| std::map<const Tile*, PrioritizedTile> result; |
| for (const auto& key_tile_pair : tiles_) { |
| - Tile* tile = key_tile_pair.second; |
| + Tile* tile = key_tile_pair.second.get(); |
| UpdateRequiredStatesOnTile(tile); |
| PrioritizedTile prioritized_tile = |
| MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); |
| @@ -1005,7 +1008,7 @@ PictureLayerTiling::ComputePriorityRectTypeForTile(const Tile* tile) const { |
| void PictureLayerTiling::GetAllPrioritizedTilesForTracing( |
| std::vector<PrioritizedTile>* prioritized_tiles) const { |
| for (const auto& tile_pair : tiles_) { |
| - Tile* tile = tile_pair.second; |
| + Tile* tile = tile_pair.second.get(); |
| prioritized_tiles->push_back( |
| MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile))); |
| } |
| @@ -1026,7 +1029,7 @@ void PictureLayerTiling::AsValueInto( |
| size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
| size_t amount = 0; |
| for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| - const Tile* tile = it->second; |
| + const Tile* tile = it->second.get(); |
| amount += tile->GPUMemoryUsageInBytes(); |
| } |
| return amount; |