| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 411 |
| 412 // We must reduce the amount of unused resources before calling | 412 // We must reduce the amount of unused resources before calling |
| 413 // RunTasks to prevent usage from rising above limits. | 413 // RunTasks to prevent usage from rising above limits. |
| 414 resource_pool_->ReduceResourceUsage(); | 414 resource_pool_->ReduceResourceUsage(); |
| 415 | 415 |
| 416 // Run and complete all raster task synchronously. | 416 // Run and complete all raster task synchronously. |
| 417 rasterizer_->RasterizeTiles( | 417 rasterizer_->RasterizeTiles( |
| 418 tiles_that_need_to_be_rasterized, resource_pool_, | 418 tiles_that_need_to_be_rasterized, resource_pool_, |
| 419 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); | 419 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); |
| 420 | 420 |
| 421 // Use on-demand raster for any required-for-activation tiles that have not | |
| 422 // been been assigned memory after reaching a steady memory state. This | |
| 423 // ensures that we activate even when OOM. Note that we have to rebuilt the | |
| 424 // queue in case the last AssignGpuMemoryToTiles evicted some tiles that would | |
| 425 // otherwise not be picked up by the old raster queue. | |
| 426 client_->BuildRasterQueue(&raster_priority_queue_, | |
| 427 global_state_.tree_priority); | |
| 428 | |
| 429 // Use on-demand raster for any tiles that have not been been assigned | |
| 430 // memory. This ensures that we draw even when OOM. | |
| 431 while (!raster_priority_queue_.IsEmpty()) { | |
| 432 Tile* tile = raster_priority_queue_.Top(); | |
| 433 TileDrawInfo& draw_info = tile->draw_info(); | |
| 434 | |
| 435 if (tile->required_for_draw() && !draw_info.IsReadyToDraw()) { | |
| 436 draw_info.set_rasterize_on_demand(); | |
| 437 client_->NotifyTileStateChanged(tile); | |
| 438 } | |
| 439 raster_priority_queue_.Pop(); | |
| 440 } | |
| 441 raster_priority_queue_.Reset(); | |
| 442 | |
| 443 TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state", | 421 TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state", |
| 444 BasicStateAsValue()); | 422 BasicStateAsValue()); |
| 445 | 423 |
| 446 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this, | 424 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this, |
| 447 resource_pool_->total_memory_usage_bytes() - | 425 resource_pool_->total_memory_usage_bytes() - |
| 448 resource_pool_->acquired_memory_usage_bytes()); | 426 resource_pool_->acquired_memory_usage_bytes()); |
| 449 } | 427 } |
| 450 | 428 |
| 451 void TileManager::UpdateVisibleTiles( | 429 void TileManager::UpdateVisibleTiles( |
| 452 const GlobalStateThatImpactsTilePriority& state) { | 430 const GlobalStateThatImpactsTilePriority& state) { |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 result -= other; | 1028 result -= other; |
| 1051 return result; | 1029 return result; |
| 1052 } | 1030 } |
| 1053 | 1031 |
| 1054 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1032 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 1055 return memory_bytes_ > limit.memory_bytes_ || | 1033 return memory_bytes_ > limit.memory_bytes_ || |
| 1056 resource_count_ > limit.resource_count_; | 1034 resource_count_ > limit.resource_count_; |
| 1057 } | 1035 } |
| 1058 | 1036 |
| 1059 } // namespace cc | 1037 } // namespace cc |
| OLD | NEW |