Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 void TileManager::FreeResourcesForReleasedTiles() { | 270 void TileManager::FreeResourcesForReleasedTiles() { |
| 271 for (std::vector<Tile*>::iterator it = released_tiles_.begin(); | 271 for (std::vector<Tile*>::iterator it = released_tiles_.begin(); |
| 272 it != released_tiles_.end(); | 272 it != released_tiles_.end(); |
| 273 ++it) { | 273 ++it) { |
| 274 Tile* tile = *it; | 274 Tile* tile = *it; |
| 275 FreeResourcesForTile(tile); | 275 FreeResourcesForTile(tile); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 void TileManager::CleanUpReleasedTiles() { | 279 void TileManager::CleanUpReleasedTiles() { |
| 280 std::vector<Tile*>::iterator it = released_tiles_.begin(); | 280 std::vector<Tile*> tiles_to_retain; |
|
enne (OOO)
2015/04/07 23:04:48
Should you reserve this to be the number of tiles
vmpstr
2015/04/07 23:10:23
I'm not sure it's worth it, since the number of ti
| |
| 281 while (it != released_tiles_.end()) { | 281 for (auto* tile : released_tiles_) { |
| 282 Tile* tile = *it; | |
| 283 | |
| 284 if (tile->HasRasterTask()) { | 282 if (tile->HasRasterTask()) { |
| 285 ++it; | 283 tiles_to_retain.push_back(tile); |
| 286 continue; | 284 continue; |
| 287 } | 285 } |
| 288 | 286 |
| 289 DCHECK(!tile->HasResource()); | 287 DCHECK(!tile->HasResource()); |
| 290 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 288 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| 291 tiles_.erase(tile->id()); | 289 tiles_.erase(tile->id()); |
| 292 | 290 |
| 293 LayerCountMap::iterator layer_it = | 291 LayerCountMap::iterator layer_it = |
| 294 used_layer_counts_.find(tile->layer_id()); | 292 used_layer_counts_.find(tile->layer_id()); |
| 295 DCHECK_GT(layer_it->second, 0); | 293 DCHECK_GT(layer_it->second, 0); |
| 296 if (--layer_it->second == 0) { | 294 if (--layer_it->second == 0) { |
| 297 used_layer_counts_.erase(layer_it); | 295 used_layer_counts_.erase(layer_it); |
| 298 image_decode_tasks_.erase(tile->layer_id()); | 296 image_decode_tasks_.erase(tile->layer_id()); |
| 299 } | 297 } |
| 300 | 298 |
| 301 delete tile; | 299 delete tile; |
| 302 it = released_tiles_.erase(it); | |
| 303 } | 300 } |
| 301 released_tiles_.swap(tiles_to_retain); | |
| 304 } | 302 } |
| 305 | 303 |
| 306 void TileManager::DidFinishRunningTileTasks(TaskSet task_set) { | 304 void TileManager::DidFinishRunningTileTasks(TaskSet task_set) { |
| 307 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTileTasks", "task_set", | 305 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTileTasks", "task_set", |
| 308 TaskSetName(task_set)); | 306 TaskSetName(task_set)); |
| 309 | 307 |
| 310 switch (task_set) { | 308 switch (task_set) { |
| 311 case ALL: { | 309 case ALL: { |
| 312 bool memory_usage_above_limit = | 310 bool memory_usage_above_limit = |
| 313 resource_pool_->total_memory_usage_bytes() > | 311 resource_pool_->total_memory_usage_bytes() > |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 969 result -= other; | 967 result -= other; |
| 970 return result; | 968 return result; |
| 971 } | 969 } |
| 972 | 970 |
| 973 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 971 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 974 return memory_bytes_ > limit.memory_bytes_ || | 972 return memory_bytes_ > limit.memory_bytes_ || |
| 975 resource_count_ > limit.resource_count_; | 973 resource_count_ > limit.resource_count_; |
| 976 } | 974 } |
| 977 | 975 |
| 978 } // namespace cc | 976 } // namespace cc |
| OLD | NEW |