Chromium Code Reviews| Index: cc/resources/tile_manager.cc |
| diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc |
| index 50668c01f8dc52cabaae57d9363e0e96e0a62ebc..b2131b57dc2b4082c406f046675d6bac7dc6d8f3 100644 |
| --- a/cc/resources/tile_manager.cc |
| +++ b/cc/resources/tile_manager.cc |
| @@ -190,6 +190,7 @@ void TileManager::RegisterTile(Tile* tile) { |
| DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
| tiles_[tile->id()] = tile; |
| + used_layer_counts_[tile->layer_id()]++; |
| prioritized_tiles_dirty_ = true; |
| } |
| @@ -198,6 +199,10 @@ void TileManager::UnregisterTile(Tile* tile) { |
| DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| tiles_.erase(tile->id()); |
| + |
| + DCHECK_GT(used_layer_counts_[tile->layer_id()], 0); |
| + used_layer_counts_[tile->layer_id()]--; |
| + |
| prioritized_tiles_dirty_ = true; |
| } |
| @@ -624,26 +629,22 @@ void TileManager::CleanUpUnusedImageDecodeTasks() { |
| if (image_decode_tasks_.empty()) |
| return; |
| - // Calculate a set of layers that are used by at least one tile. |
| - base::hash_set<int> used_layers; |
| - for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
| - used_layers.insert(it->second->layer_id()); |
| - |
| - // Now calculate the set of layers in |image_decode_tasks_| that are not used |
| - // by any tile. |
| + // Unused layers are layers whose use count is zero. |
| std::vector<int> unused_layers; |
| - for (LayerPixelRefTaskMap::iterator it = image_decode_tasks_.begin(); |
| - it != image_decode_tasks_.end(); |
| + for (LayerCountMap::iterator it = used_layer_counts_.begin(); |
| + it != used_layer_counts_.end(); |
| ++it) { |
| - if (used_layers.find(it->first) == used_layers.end()) |
| + if (it->second == 0) |
| unused_layers.push_back(it->first); |
| } |
| - // Erase unused layers from |image_decode_tasks_|. |
| + // Erase unused layers from |image_decode_tasks_| and from |
| + // |used_layer_counts_|. |
| for (std::vector<int>::iterator it = unused_layers.begin(); |
| it != unused_layers.end(); |
| ++it) { |
| image_decode_tasks_.erase(*it); |
| + used_layer_counts_.erase(*it); |
|
reveman
2013/09/04 21:25:17
can we move these two lines to UnregisterTile and
vmpstr
2013/09/04 22:03:49
Good idea. Done.
|
| } |
| } |