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/tile_manager.h" | 5 #include "cc/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 137 |
| 138 TileManager::~TileManager() { | 138 TileManager::~TileManager() { |
| 139 // Reset global state and manage. This should cause | 139 // Reset global state and manage. This should cause |
| 140 // our memory usage to drop to zero. | 140 // our memory usage to drop to zero. |
| 141 global_state_ = GlobalStateThatImpactsTilePriority(); | 141 global_state_ = GlobalStateThatImpactsTilePriority(); |
| 142 AssignGpuMemoryToTiles(); | 142 AssignGpuMemoryToTiles(); |
| 143 // This should finish all pending tasks and release any uninitialized | 143 // This should finish all pending tasks and release any uninitialized |
| 144 // resources. | 144 // resources. |
| 145 raster_worker_pool_.reset(); | 145 raster_worker_pool_.reset(); |
| 146 CheckForCompletedTileUploads(); | 146 CheckForCompletedTileUploads(); |
| 147 DCHECK(tiles_with_pending_set_pixels_.size() == 0); | 147 DCHECK_EQ(tiles_with_pending_set_pixels_.size(), 0); |
| 148 DCHECK(tiles_.size() == 0); | 148 DCHECK_EQ(all_tiles_.size(), 0); |
| 149 DCHECK_EQ(live_or_allocated_tiles_.size(), 0); | |
| 149 } | 150 } |
| 150 | 151 |
| 151 void TileManager::SetGlobalState( | 152 void TileManager::SetGlobalState( |
| 152 const GlobalStateThatImpactsTilePriority& global_state) { | 153 const GlobalStateThatImpactsTilePriority& global_state) { |
| 153 global_state_ = global_state; | 154 global_state_ = global_state; |
| 154 resource_pool_->SetMaxMemoryUsageBytes(global_state_.memory_limit_in_bytes); | 155 resource_pool_->SetMaxMemoryUsageBytes(global_state_.memory_limit_in_bytes); |
| 155 ScheduleManageTiles(); | 156 ScheduleManageTiles(); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void TileManager::RegisterTile(Tile* tile) { | 159 void TileManager::RegisterTile(Tile* tile) { |
| 159 tiles_.push_back(tile); | 160 all_tiles_.push_back(tile); |
| 160 | 161 |
| 161 const ManagedTileState& mts = tile->managed_state(); | 162 const ManagedTileState& mts = tile->managed_state(); |
| 162 for (int i = 0; i < NUM_TREES; ++i) | 163 for (int i = 0; i < NUM_TREES; ++i) |
| 163 ++raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; | 164 ++raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; |
| 164 | 165 |
| 165 ScheduleManageTiles(); | 166 ScheduleManageTiles(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void TileManager::UnregisterTile(Tile* tile) { | 169 void TileManager::UnregisterTile(Tile* tile) { |
| 169 for (TileList::iterator it = tiles_with_image_decoding_tasks_.begin(); | 170 for (TileList::iterator it = tiles_with_image_decoding_tasks_.begin(); |
| 170 it != tiles_with_image_decoding_tasks_.end(); it++) { | 171 it != tiles_with_image_decoding_tasks_.end(); it++) { |
| 171 if (*it == tile) { | 172 if (*it == tile) { |
| 172 tiles_with_image_decoding_tasks_.erase(it); | 173 tiles_with_image_decoding_tasks_.erase(it); |
| 173 break; | 174 break; |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 for (TileVector::iterator it = tiles_that_need_to_be_rasterized_.begin(); | 177 for (TileVector::iterator it = tiles_that_need_to_be_rasterized_.begin(); |
| 177 it != tiles_that_need_to_be_rasterized_.end(); it++) { | 178 it != tiles_that_need_to_be_rasterized_.end(); it++) { |
| 178 if (*it == tile) { | 179 if (*it == tile) { |
| 179 tiles_that_need_to_be_rasterized_.erase(it); | 180 tiles_that_need_to_be_rasterized_.erase(it); |
| 180 break; | 181 break; |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); it++) { | 184 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); |
| 185 it != live_or_allocated_tiles_.end(); it++) { | |
| 186 if (*it == tile) { | |
| 187 live_or_allocated_tiles_.erase(it); | |
| 188 break; | |
| 189 } | |
| 190 } | |
| 191 for (TileVector::iterator it = all_tiles_.begin(); | |
| 192 it != all_tiles_.end(); it++) { | |
| 184 if (*it == tile) { | 193 if (*it == tile) { |
| 185 const ManagedTileState& mts = tile->managed_state(); | 194 const ManagedTileState& mts = tile->managed_state(); |
| 186 for (int i = 0; i < NUM_TREES; ++i) | 195 for (int i = 0; i < NUM_TREES; ++i) |
| 187 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; | 196 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; |
| 188 FreeResourcesForTile(tile); | 197 FreeResourcesForTile(tile); |
| 189 tiles_.erase(it); | 198 all_tiles_.erase(it); |
| 190 return; | 199 return; |
| 191 } | 200 } |
| 192 } | 201 } |
| 193 DCHECK(false) << "Could not find tile version."; | 202 DCHECK(false) << "Could not find tile version."; |
| 194 } | 203 } |
| 195 | 204 |
| 196 class BinComparator { | 205 class BinComparator { |
| 197 public: | 206 public: |
| 198 bool operator() (const Tile* a, const Tile* b) const { | 207 bool operator() (const Tile* a, const Tile* b) const { |
| 199 const ManagedTileState& ams = a->managed_state(); | 208 const ManagedTileState& ams = a->managed_state(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 215 if (a_rect.y() != b_rect.y()) | 224 if (a_rect.y() != b_rect.y()) |
| 216 return a_rect.y() < b_rect.y(); | 225 return a_rect.y() < b_rect.y(); |
| 217 return a_rect.x() < b_rect.x(); | 226 return a_rect.x() < b_rect.x(); |
| 218 } | 227 } |
| 219 }; | 228 }; |
| 220 | 229 |
| 221 void TileManager::SortTiles() { | 230 void TileManager::SortTiles() { |
| 222 TRACE_EVENT0("cc", "TileManager::SortTiles"); | 231 TRACE_EVENT0("cc", "TileManager::SortTiles"); |
| 223 | 232 |
| 224 // Sort by bin, resolution and time until needed. | 233 // Sort by bin, resolution and time until needed. |
| 225 std::sort(tiles_.begin(), tiles_.end(), BinComparator()); | 234 std::sort(live_or_allocated_tiles_.begin(), |
|
nduca
2013/02/06 23:54:02
you might need to rebase on origin/master so you c
| |
| 235 live_or_allocated_tiles_.end(), BinComparator()); | |
| 226 } | 236 } |
| 227 | 237 |
| 228 void TileManager::ManageTiles() { | 238 void TileManager::ManageTiles() { |
| 229 TRACE_EVENT0("cc", "TileManager::ManageTiles"); | 239 TRACE_EVENT0("cc", "TileManager::ManageTiles"); |
| 230 manage_tiles_pending_ = false; | 240 manage_tiles_pending_ = false; |
| 231 ++manage_tiles_call_count_; | 241 ++manage_tiles_call_count_; |
| 232 | 242 |
| 233 const TreePriority tree_priority = global_state_.tree_priority; | 243 const TreePriority tree_priority = global_state_.tree_priority; |
| 234 TRACE_COUNTER_ID1("cc", "TileCount", this, tiles_.size()); | 244 TRACE_COUNTER_ID1("cc", "TileCount", this, all_tiles_.size()); |
| 235 | 245 |
| 246 // Memory limit policy works by mapping some bin states to the NEVER bin. | |
| 247 TileManagerBin bin_map[NUM_BINS]; | |
| 248 if (global_state_.memory_limit_policy == ALLOW_NOTHING) { | |
| 249 bin_map[NOW_BIN] = NEVER_BIN; | |
| 250 bin_map[SOON_BIN] = NEVER_BIN; | |
| 251 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | |
| 252 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 253 } else if (global_state_.memory_limit_policy == ALLOW_ABSOLUTE_MINIMUM) { | |
| 254 bin_map[NOW_BIN] = NOW_BIN; | |
| 255 bin_map[SOON_BIN] = NEVER_BIN; | |
| 256 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | |
| 257 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 258 } else if (global_state_.memory_limit_policy == ALLOW_PREPAINT_ONLY) { | |
| 259 bin_map[NOW_BIN] = NOW_BIN; | |
| 260 bin_map[SOON_BIN] = SOON_BIN; | |
| 261 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | |
| 262 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 263 } else { | |
| 264 bin_map[NOW_BIN] = NOW_BIN; | |
| 265 bin_map[SOON_BIN] = SOON_BIN; | |
| 266 bin_map[EVENTUALLY_BIN] = EVENTUALLY_BIN; | |
| 267 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 268 } | |
| 269 | |
| 270 live_or_allocated_tiles_.clear(); | |
| 236 // For each tree, bin into different categories of tiles. | 271 // For each tree, bin into different categories of tiles. |
| 237 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 272 for (TileVector::iterator it = all_tiles_.begin(); |
| 273 it != all_tiles_.end(); ++it) { | |
| 238 Tile* tile = *it; | 274 Tile* tile = *it; |
| 239 ManagedTileState& mts = tile->managed_state(); | 275 ManagedTileState& mts = tile->managed_state(); |
| 240 | 276 |
| 241 TilePriority prio[NUM_BIN_PRIORITIES]; | 277 TilePriority prio[NUM_BIN_PRIORITIES]; |
| 242 switch (tree_priority) { | 278 switch (tree_priority) { |
|
nduca
2013/02/06 23:54:02
can we speed this step by considering alive ness?
| |
| 243 case SAME_PRIORITY_FOR_BOTH_TREES: | 279 case SAME_PRIORITY_FOR_BOTH_TREES: |
| 244 prio[HIGH_PRIORITY_BIN] = prio[LOW_PRIORITY_BIN] = | 280 prio[HIGH_PRIORITY_BIN] = prio[LOW_PRIORITY_BIN] = |
| 245 tile->combined_priority(); | 281 tile->combined_priority(); |
| 246 break; | 282 break; |
| 247 case SMOOTHNESS_TAKES_PRIORITY: | 283 case SMOOTHNESS_TAKES_PRIORITY: |
| 248 prio[HIGH_PRIORITY_BIN] = tile->priority(ACTIVE_TREE); | 284 prio[HIGH_PRIORITY_BIN] = tile->priority(ACTIVE_TREE); |
| 249 prio[LOW_PRIORITY_BIN] = tile->priority(PENDING_TREE); | 285 prio[LOW_PRIORITY_BIN] = tile->priority(PENDING_TREE); |
| 250 break; | 286 break; |
| 251 case NEW_CONTENT_TAKES_PRIORITY: | 287 case NEW_CONTENT_TAKES_PRIORITY: |
| 252 prio[HIGH_PRIORITY_BIN] = tile->priority(PENDING_TREE); | 288 prio[HIGH_PRIORITY_BIN] = tile->priority(PENDING_TREE); |
| 253 prio[LOW_PRIORITY_BIN] = tile->priority(ACTIVE_TREE); | 289 prio[LOW_PRIORITY_BIN] = tile->priority(ACTIVE_TREE); |
| 254 break; | 290 break; |
| 255 } | 291 } |
| 256 | 292 |
| 257 mts.resolution = prio[HIGH_PRIORITY_BIN].resolution; | 293 mts.resolution = prio[HIGH_PRIORITY_BIN].resolution; |
| 258 mts.time_to_needed_in_seconds = | 294 mts.time_to_needed_in_seconds = |
| 259 prio[HIGH_PRIORITY_BIN].time_to_visible_in_seconds; | 295 prio[HIGH_PRIORITY_BIN].time_to_visible_in_seconds; |
| 260 mts.bin[HIGH_PRIORITY_BIN] = BinFromTilePriority(prio[HIGH_PRIORITY_BIN]); | 296 mts.bin[HIGH_PRIORITY_BIN] = BinFromTilePriority(prio[HIGH_PRIORITY_BIN]); |
|
nduca
2013/02/06 23:54:02
if neither tile is alive, is this even needed? We
| |
| 261 mts.bin[LOW_PRIORITY_BIN] = BinFromTilePriority(prio[LOW_PRIORITY_BIN]); | 297 mts.bin[LOW_PRIORITY_BIN] = BinFromTilePriority(prio[LOW_PRIORITY_BIN]); |
| 262 mts.gpu_memmgr_stats_bin = BinFromTilePriority(tile->combined_priority()); | 298 mts.gpu_memmgr_stats_bin = BinFromTilePriority(tile->combined_priority()); |
| 263 | 299 |
| 264 DidTileBinChange(tile, | 300 DidTileBinChange(tile, |
| 265 BinFromTilePriority(tile->priority(ACTIVE_TREE)), | 301 BinFromTilePriority(tile->priority(ACTIVE_TREE)), |
|
nduca
2013/02/06 23:54:02
this bit seems heavy to take in the non-alive case
| |
| 266 ACTIVE_TREE); | 302 ACTIVE_TREE); |
| 267 DidTileBinChange(tile, | 303 DidTileBinChange(tile, |
| 268 BinFromTilePriority(tile->priority(PENDING_TREE)), | 304 BinFromTilePriority(tile->priority(PENDING_TREE)), |
| 269 PENDING_TREE); | 305 PENDING_TREE); |
| 270 } | |
| 271 | 306 |
| 272 // Memory limit policy works by mapping some bin states to the NEVER bin. | |
| 273 TileManagerBin bin_map[NUM_BINS]; | |
| 274 if (global_state_.memory_limit_policy == ALLOW_NOTHING) { | |
| 275 bin_map[NOW_BIN] = NEVER_BIN; | |
| 276 bin_map[SOON_BIN] = NEVER_BIN; | |
| 277 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | |
| 278 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 279 } else if (global_state_.memory_limit_policy == ALLOW_ABSOLUTE_MINIMUM) { | |
| 280 bin_map[NOW_BIN] = NOW_BIN; | |
| 281 bin_map[SOON_BIN] = NEVER_BIN; | |
| 282 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | |
| 283 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 284 } else if (global_state_.memory_limit_policy == ALLOW_PREPAINT_ONLY) { | |
| 285 bin_map[NOW_BIN] = NOW_BIN; | |
| 286 bin_map[SOON_BIN] = SOON_BIN; | |
| 287 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | |
| 288 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 289 } else { | |
| 290 bin_map[NOW_BIN] = NOW_BIN; | |
| 291 bin_map[SOON_BIN] = SOON_BIN; | |
| 292 bin_map[EVENTUALLY_BIN] = EVENTUALLY_BIN; | |
| 293 bin_map[NEVER_BIN] = NEVER_BIN; | |
| 294 } | |
| 295 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
| 296 Tile* tile = *it; | |
| 297 ManagedTileState& mts = tile->managed_state(); | |
| 298 for (int i = 0; i < NUM_BIN_PRIORITIES; ++i) | 307 for (int i = 0; i < NUM_BIN_PRIORITIES; ++i) |
| 299 mts.bin[i] = bin_map[mts.bin[i]]; | 308 mts.bin[i] = bin_map[mts.bin[i]]; |
| 300 | 309 |
| 301 DidTileBinChange(tile, bin_map[mts.tree_bin[ACTIVE_TREE]], ACTIVE_TREE); | 310 DidTileBinChange(tile, bin_map[mts.tree_bin[ACTIVE_TREE]], ACTIVE_TREE); |
| 302 DidTileBinChange(tile, bin_map[mts.tree_bin[PENDING_TREE]], PENDING_TREE); | 311 DidTileBinChange(tile, bin_map[mts.tree_bin[PENDING_TREE]], PENDING_TREE); |
| 312 | |
| 313 if (tile->priority(ACTIVE_TREE).is_live || | |
| 314 tile->priority(PENDING_TREE).is_live || | |
| 315 tile->GetResourceId() != 0) { | |
| 316 live_or_allocated_tiles_.push_back(tile); | |
| 317 } | |
| 303 } | 318 } |
| 319 TRACE_COUNTER_ID1("cc", "LiveOrAllocatedTileCount", this, | |
| 320 live_or_allocated_tiles_.size()); | |
| 304 | 321 |
| 305 SortTiles(); | 322 SortTiles(); |
| 306 | 323 |
| 307 // Assign gpu memory and determine what tiles need to be rasterized. | 324 // Assign gpu memory and determine what tiles need to be rasterized. |
| 308 AssignGpuMemoryToTiles(); | 325 AssignGpuMemoryToTiles(); |
| 309 | 326 |
| 310 TRACE_EVENT_INSTANT1("cc", "DidManage", "state", ValueToString(AsValue())); | 327 TRACE_EVENT_INSTANT1("cc", "DidManage", "state", ValueToString(AsValue())); |
| 311 | 328 |
| 312 // Finally, kick the rasterizer. | 329 // Finally, kick the rasterizer. |
| 313 DispatchMoreTasks(); | 330 DispatchMoreTasks(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 342 DispatchMoreTasks(); | 359 DispatchMoreTasks(); |
| 343 } | 360 } |
| 344 | 361 |
| 345 void TileManager::GetMemoryStats( | 362 void TileManager::GetMemoryStats( |
| 346 size_t* memoryRequiredBytes, | 363 size_t* memoryRequiredBytes, |
| 347 size_t* memoryNiceToHaveBytes, | 364 size_t* memoryNiceToHaveBytes, |
| 348 size_t* memoryUsedBytes) const { | 365 size_t* memoryUsedBytes) const { |
| 349 *memoryRequiredBytes = 0; | 366 *memoryRequiredBytes = 0; |
| 350 *memoryNiceToHaveBytes = 0; | 367 *memoryNiceToHaveBytes = 0; |
| 351 *memoryUsedBytes = 0; | 368 *memoryUsedBytes = 0; |
| 352 for(size_t i = 0; i < tiles_.size(); i++) { | 369 for (size_t i = 0; i < all_tiles_.size(); i++) { |
|
nduca
2013/02/06 23:54:02
does this really need all_tiles?
whunt
2013/02/07 00:30:48
It shouldn't, I'll change that.
| |
| 353 const Tile* tile = tiles_[i]; | 370 const Tile* tile = all_tiles_[i]; |
| 354 const ManagedTileState& mts = tile->managed_state(); | 371 const ManagedTileState& mts = tile->managed_state(); |
| 355 size_t tile_bytes = tile->bytes_consumed_if_allocated(); | 372 size_t tile_bytes = tile->bytes_consumed_if_allocated(); |
| 356 if (mts.gpu_memmgr_stats_bin == NOW_BIN) | 373 if (mts.gpu_memmgr_stats_bin == NOW_BIN) |
| 357 *memoryRequiredBytes += tile_bytes; | 374 *memoryRequiredBytes += tile_bytes; |
| 358 if (mts.gpu_memmgr_stats_bin != NEVER_BIN) | 375 if (mts.gpu_memmgr_stats_bin != NEVER_BIN) |
| 359 *memoryNiceToHaveBytes += tile_bytes; | 376 *memoryNiceToHaveBytes += tile_bytes; |
| 360 if (mts.can_use_gpu_memory) | 377 if (mts.can_use_gpu_memory) |
| 361 *memoryUsedBytes += tile_bytes; | 378 *memoryUsedBytes += tile_bytes; |
| 362 } | 379 } |
| 363 } | 380 } |
| 364 | 381 |
| 365 scoped_ptr<base::Value> TileManager::AsValue() const { | 382 scoped_ptr<base::Value> TileManager::AsValue() const { |
| 366 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 383 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 367 state->SetInteger("tile_count", tiles_.size()); | 384 state->SetInteger("tile_count", all_tiles_.size()); |
| 368 | 385 |
| 369 state->Set("global_state", global_state_.AsValue().release()); | 386 state->Set("global_state", global_state_.AsValue().release()); |
| 370 | 387 |
| 371 state->Set("memory_requirements", GetMemoryRequirementsAsValue().release()); | 388 state->Set("memory_requirements", GetMemoryRequirementsAsValue().release()); |
| 372 return state.PassAs<base::Value>(); | 389 return state.PassAs<base::Value>(); |
| 373 } | 390 } |
| 374 | 391 |
| 375 scoped_ptr<base::Value> TileManager::GetMemoryRequirementsAsValue() const { | 392 scoped_ptr<base::Value> TileManager::GetMemoryRequirementsAsValue() const { |
| 376 scoped_ptr<base::DictionaryValue> requirements( | 393 scoped_ptr<base::DictionaryValue> requirements( |
| 377 new base::DictionaryValue()); | 394 new base::DictionaryValue()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 } | 437 } |
| 421 } | 438 } |
| 422 | 439 |
| 423 return false; | 440 return false; |
| 424 } | 441 } |
| 425 | 442 |
| 426 void TileManager::AssignGpuMemoryToTiles() { | 443 void TileManager::AssignGpuMemoryToTiles() { |
| 427 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); | 444 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); |
| 428 // Some memory cannot be released. Figure out which. | 445 // Some memory cannot be released. Figure out which. |
| 429 size_t unreleasable_bytes = 0; | 446 size_t unreleasable_bytes = 0; |
| 430 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
| 431 Tile* tile = *it; | |
| 432 if (!tile->managed_state().can_be_freed) | |
| 433 unreleasable_bytes += tile->bytes_consumed_if_allocated(); | |
| 434 } | |
| 435 | 447 |
| 436 // Now give memory out to the tiles until we're out, and build | 448 // Now give memory out to the tiles until we're out, and build |
| 437 // the needs-to-be-rasterized queue. | 449 // the needs-to-be-rasterized queue. |
| 438 tiles_that_need_to_be_rasterized_.erase( | 450 tiles_that_need_to_be_rasterized_.clear(); |
| 439 tiles_that_need_to_be_rasterized_.begin(), | |
| 440 tiles_that_need_to_be_rasterized_.end()); | |
| 441 | 451 |
| 442 // Reset the image decoding list so that we don't mess up with tile | 452 // Reset the image decoding list so that we don't mess up with tile |
| 443 // priorities. Tiles will be added to the image decoding list again | 453 // priorities. Tiles will be added to the image decoding list again |
| 444 // when DispatchMoreTasks() is called. | 454 // when DispatchMoreTasks() is called. |
| 445 tiles_with_image_decoding_tasks_.clear(); | 455 tiles_with_image_decoding_tasks_.clear(); |
| 446 | 456 |
| 447 // By clearing the tiles_that_need_to_be_rasterized_ vector and | 457 // By clearing the tiles_that_need_to_be_rasterized_ vector and |
|
nduca
2013/02/06 23:54:02
You should update and fuse all these comments toge
| |
| 448 // tiles_with_image_decoding_tasks_ list above we move all tiles | 458 // tiles_with_image_decoding_tasks_ list above we move all tiles |
| 449 // currently waiting for raster to idle state. | 459 // currently waiting for raster to idle state. |
| 450 // Call DidTileRasterStateChange() for each of these tiles to | 460 // Call DidTileRasterStateChange() for each of these tiles to |
| 451 // have this state change take effect. | 461 // have this state change take effect. |
| 452 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 462 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); |
| 463 it != live_or_allocated_tiles_.end(); ++it) { | |
| 453 Tile* tile = *it; | 464 Tile* tile = *it; |
| 465 if (!tile->managed_state().can_be_freed) | |
| 466 unreleasable_bytes += tile->bytes_consumed_if_allocated(); | |
| 454 if (tile->managed_state().raster_state == WAITING_FOR_RASTER_STATE) | 467 if (tile->managed_state().raster_state == WAITING_FOR_RASTER_STATE) |
| 455 DidTileRasterStateChange(tile, IDLE_STATE); | 468 DidTileRasterStateChange(tile, IDLE_STATE); |
| 456 } | 469 } |
| 457 | 470 |
| 458 size_t bytes_allocatable = global_state_.memory_limit_in_bytes - unreleasable_ bytes; | 471 size_t bytes_allocatable = global_state_.memory_limit_in_bytes - unreleasable_ bytes; |
| 459 size_t bytes_that_exceeded_memory_budget = 0; | 472 size_t bytes_that_exceeded_memory_budget = 0; |
| 460 size_t bytes_left = bytes_allocatable; | 473 size_t bytes_left = bytes_allocatable; |
| 461 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 474 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); |
| 475 it != live_or_allocated_tiles_.end(); ++it) { | |
| 462 Tile* tile = *it; | 476 Tile* tile = *it; |
| 463 size_t tile_bytes = tile->bytes_consumed_if_allocated(); | 477 size_t tile_bytes = tile->bytes_consumed_if_allocated(); |
| 464 ManagedTileState& managed_tile_state = tile->managed_state(); | 478 ManagedTileState& managed_tile_state = tile->managed_state(); |
| 465 if (!managed_tile_state.can_be_freed) | 479 if (!managed_tile_state.can_be_freed) |
| 466 continue; | 480 continue; |
| 467 if (managed_tile_state.bin[HIGH_PRIORITY_BIN] == NEVER_BIN && | 481 if (managed_tile_state.bin[HIGH_PRIORITY_BIN] == NEVER_BIN && |
| 468 managed_tile_state.bin[LOW_PRIORITY_BIN] == NEVER_BIN) { | 482 managed_tile_state.bin[LOW_PRIORITY_BIN] == NEVER_BIN) { |
| 469 managed_tile_state.can_use_gpu_memory = false; | 483 managed_tile_state.can_use_gpu_memory = false; |
| 470 FreeResourcesForTile(tile); | 484 FreeResourcesForTile(tile); |
| 471 continue; | 485 continue; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; | 773 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; |
| 760 DCHECK_GE(raster_state_count_[mts.raster_state][i][mts.tree_bin[i]], 0); | 774 DCHECK_GE(raster_state_count_[mts.raster_state][i][mts.tree_bin[i]], 0); |
| 761 | 775 |
| 762 // Increment count for new state. | 776 // Increment count for new state. |
| 763 ++raster_state_count_[state][i][mts.tree_bin[i]]; | 777 ++raster_state_count_[state][i][mts.tree_bin[i]]; |
| 764 } | 778 } |
| 765 | 779 |
| 766 mts.raster_state = state; | 780 mts.raster_state = state; |
| 767 } | 781 } |
| 768 | 782 |
| 769 void TileManager::DidTileBinChange(Tile* tile, | 783 void TileManager::DidTileBinChange(Tile* tile, |
|
nduca
2013/02/06 23:54:02
while you're here, can you change this DidTileTree
| |
| 770 TileManagerBin bin, | 784 TileManagerBin bin, |
|
nduca
2013/02/06 23:54:02
would this be better titled new_tree_bin?
| |
| 771 WhichTree tree) { | 785 WhichTree tree) { |
| 772 ManagedTileState& mts = tile->managed_state(); | 786 ManagedTileState& mts = tile->managed_state(); |
| 773 | 787 |
| 774 // Decrement count for current bin. | 788 // Decrement count for current bin. |
| 775 --raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]]; | 789 --raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]]; |
| 776 DCHECK_GE(raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]], 0); | 790 DCHECK_GE(raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]], 0); |
| 777 | 791 |
| 778 // Increment count for new bin. | 792 // Increment count for new bin. |
| 779 ++raster_state_count_[mts.raster_state][tree][bin]; | 793 ++raster_state_count_[mts.raster_state][tree][bin]; |
| 780 | 794 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 decode_begin_time = base::TimeTicks::Now(); | 860 decode_begin_time = base::TimeTicks::Now(); |
| 847 pixel_ref->Decode(); | 861 pixel_ref->Decode(); |
| 848 if (stats) { | 862 if (stats) { |
| 849 stats->totalDeferredImageDecodeCount++; | 863 stats->totalDeferredImageDecodeCount++; |
| 850 stats->totalDeferredImageDecodeTime += | 864 stats->totalDeferredImageDecodeTime += |
| 851 base::TimeTicks::Now() - decode_begin_time; | 865 base::TimeTicks::Now() - decode_begin_time; |
| 852 } | 866 } |
| 853 } | 867 } |
| 854 | 868 |
| 855 } // namespace cc | 869 } // namespace cc |
| OLD | NEW |