Chromium Code Reviews| Index: cc/resources/tile_manager.cc |
| diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc |
| index d83b8243682e717fd3cf33b585742eff0c9d5472..30c63a2d9776ce48063cf0d5d539bb1b8f4caf4b 100644 |
| --- a/cc/resources/tile_manager.cc |
| +++ b/cc/resources/tile_manager.cc |
| @@ -329,8 +329,12 @@ void TileManager::DidFinishRunningTasks(TaskSet task_set) { |
| rasterizer_->CheckForCompletedTasks(); |
| did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| + client_->BuildRasterQueue(&raster_priority_queue_, |
| + global_state_.tree_priority); |
| TileVector tiles_that_need_to_be_rasterized; |
| - AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); |
| + AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, |
| + scheduled_raster_task_limit_); |
| + raster_priority_queue_.Reset(); |
| // |tiles_that_need_to_be_rasterized| will be empty when we reach a |
| // steady memory state. Keep scheduling tasks until we reach this state. |
| @@ -354,12 +358,11 @@ void TileManager::DidFinishRunningTasks(TaskSet task_set) { |
| global_state_.memory_limit_policy != ALLOW_NOTHING; |
| // Use on-demand raster for any required-for-activation tiles that have |
| - // not |
| - // been been assigned memory after reaching a steady memory state. This |
| - // ensures that we activate even when OOM. Note that we have to rebuilt |
| - // the |
| - // queue in case the last AssignGpuMemoryToTiles evicted some tiles that |
| - // would otherwise not be picked up by the old raster queue. |
| + // not been been assigned memory after reaching a steady memory |
| + // state. This ensures that we activate even when OOM. Note that we have |
| + // to rebuilt the queue in case the last AssignGpuMemoryToTiles evicted |
| + // some tiles that would otherwise not be picked up by the old raster |
| + // queue. |
| client_->BuildRasterQueue(&raster_priority_queue_, |
| global_state_.tree_priority); |
| bool ready_to_activate = true; |
| @@ -398,6 +401,69 @@ void TileManager::DidFinishRunningTasks(TaskSet task_set) { |
| NOTREACHED(); |
| } |
| +void TileManager::RasterizeTiles( |
| + const GlobalStateThatImpactsTilePriority& state) { |
| + TRACE_EVENT0("cc", "TileManager::RasterizeTiles"); |
| + |
| + global_state_ = state; |
| + |
| + FreeResourcesForReleasedTiles(); |
| + CleanUpReleasedTiles(); |
| + |
| + client_->BuildRasterQueue(&raster_priority_queue_, |
| + global_state_.tree_priority); |
| + TileVector tiles_that_need_to_be_rasterized; |
| + AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, |
| + std::numeric_limits<size_t>::max()); |
| + |
| + // Build a new task queue containing all task currently needed. |
| + raster_queue_.Reset(); |
| + for (auto& tile : tiles_that_need_to_be_rasterized) { |
| + ManagedTileState& mts = tile->managed_state(); |
| + |
| + if (!mts.raster_task.get()) |
| + mts.raster_task = CreateRasterTask(tile); |
| + |
| + TaskSetCollection task_sets; |
| + if (tile->required_for_draw()) |
| + task_sets.set(REQUIRED_FOR_DRAW); |
| + task_sets.set(ALL); |
| + raster_queue_.items.push_back( |
| + RasterTaskQueue::Item(mts.raster_task.get(), task_sets)); |
| + } |
| + |
| + // We must reduce the amount of unused resoruces before calling |
| + // RunTasks to prevent usage from rising above limits. |
| + resource_pool_->ReduceResourceUsage(); |
| + |
| + // Run and complete all raster task synchronously. |
| + rasterizer_->RunTasks(&raster_queue_); |
| + |
| + // Use on-demand raster for any tiles that have not been been assigned |
| + // memory. This ensures that we draw even when OOM. |
| + while (!raster_priority_queue_.IsEmpty()) { |
|
vmpstr
2014/11/20 18:40:59
I think you still need to reset/rebuilt raster_pri
vmiura
2014/11/20 20:10:10
Is it possible for some required_for_draw tiles to
|
| + Tile* tile = raster_priority_queue_.Top(); |
| + ManagedTileState& mts = tile->managed_state(); |
| + |
| + if (!mts.draw_info.IsReadyToDraw()) { |
| + mts.draw_info.set_rasterize_on_demand(); |
| + client_->NotifyTileStateChanged(tile); |
| + } |
| + raster_priority_queue_.Pop(); |
| + } |
| + raster_priority_queue_.Reset(); |
| + |
| + if (IsReadyToDraw()) |
| + client_->NotifyReadyToDraw(); |
| + |
| + TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state", |
| + BasicStateAsValue()); |
| + |
| + TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this, |
| + resource_pool_->total_memory_usage_bytes() - |
| + resource_pool_->acquired_memory_usage_bytes()); |
| +} |
| + |
| void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { |
| TRACE_EVENT0("cc", "TileManager::ManageTiles"); |
| @@ -413,8 +479,12 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { |
| FreeResourcesForReleasedTiles(); |
| CleanUpReleasedTiles(); |
| + client_->BuildRasterQueue(&raster_priority_queue_, |
| + global_state_.tree_priority); |
| TileVector tiles_that_need_to_be_rasterized; |
| - AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); |
| + AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, |
| + scheduled_raster_task_limit_); |
| + raster_priority_queue_.Reset(); |
| // Finally, schedule rasterizer tasks. |
| ScheduleTasks(tiles_that_need_to_be_rasterized); |
| @@ -531,7 +601,8 @@ bool TileManager::TilePriorityViolatesMemoryPolicy( |
| } |
| void TileManager::AssignGpuMemoryToTiles( |
| - TileVector* tiles_that_need_to_be_rasterized) { |
| + TileVector* tiles_that_need_to_be_rasterized, |
| + size_t scheduled_raster_task_limit) { |
| TRACE_EVENT_BEGIN0("cc", "TileManager::AssignGpuMemoryToTiles"); |
| // Maintain the list of released resources that can potentially be re-used |
| @@ -555,8 +626,6 @@ void TileManager::AssignGpuMemoryToTiles( |
| resource_pool_->acquired_resource_count()); |
| eviction_priority_queue_is_up_to_date_ = false; |
| - client_->BuildRasterQueue(&raster_priority_queue_, |
|
vmpstr
2014/11/20 18:40:59
What's the motivation for pulling this out of this
|
| - global_state_.tree_priority); |
| while (!raster_priority_queue_.IsEmpty()) { |
| Tile* tile = raster_priority_queue_.Top(); |
| @@ -572,7 +641,7 @@ void TileManager::AssignGpuMemoryToTiles( |
| // We won't be able to schedule this tile, so break out early. |
| if (tiles_that_need_to_be_rasterized->size() >= |
| - scheduled_raster_task_limit_) { |
| + scheduled_raster_task_limit) { |
| all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
| break; |
| } |
| @@ -637,8 +706,6 @@ void TileManager::AssignGpuMemoryToTiles( |
| memory_stats_from_last_assign_.had_enough_memory = |
| had_enough_memory_to_schedule_tiles_needed_now; |
| - raster_priority_queue_.Reset(); |
| - |
| TRACE_EVENT_END2("cc", |
| "TileManager::AssignGpuMemoryToTiles", |
| "all_tiles_that_need_to_be_rasterized_are_scheduled", |