Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: cc/tiles/picture_layer_tiling.cc

Issue 1587283002: Switch cc to std::unordered_*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unordered-map
Patch Set: Fix MSVC build issue Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/tile_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..67d70963de286bc99be71c8c549369595c71e0d9 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 pending_iter = pending_twin->tiles_.begin();
+ tiles_[pending_iter->first] = std::move(pending_iter->second);
+ pending_twin->tiles_.erase(pending_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;
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698