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

Unified Diff: cc/resources/tile_manager.cc

Issue 23757024: cc: Speed up CleanUpImageDecodeTasks a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
}
}
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698