Chromium Code Reviews| Index: cc/tiles/tile_manager.cc |
| diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc |
| index 503e43c486cd03d4da0c827a7b8d9af1f128d590..7095711713184104468d449300da4c4b4fe18987 100644 |
| --- a/cc/tiles/tile_manager.cc |
| +++ b/cc/tiles/tile_manager.cc |
| @@ -348,14 +348,8 @@ TileManager::TileManager(TileManagerClient* client, |
| bool use_partial_raster) |
| : client_(client), |
| task_runner_(task_runner), |
| - resource_pool_(nullptr), |
| - tile_task_manager_(nullptr), |
| scheduled_raster_task_limit_(scheduled_raster_task_limit), |
| use_partial_raster_(use_partial_raster), |
| - use_gpu_rasterization_(false), |
| - all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
| - did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
| - did_oom_on_last_assign_(false), |
| more_tiles_need_prepare_check_notifier_( |
| task_runner_, |
| base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, |
| @@ -363,10 +357,8 @@ TileManager::TileManager(TileManagerClient* client, |
| signals_check_notifier_(task_runner_, |
| base::Bind(&TileManager::CheckAndIssueSignals, |
| base::Unretained(this))), |
| - has_scheduled_tile_tasks_(false), |
| - prepare_tiles_count_(0u), |
| - next_tile_id_(0u), |
| - task_set_finished_weak_ptr_factory_(this) {} |
| + task_set_finished_weak_ptr_factory_(this), |
| + weak_ptr_factory_(this) {} |
| TileManager::~TileManager() { |
| FinishTasksAndCleanUp(); |
| @@ -397,6 +389,7 @@ void TileManager::FinishTasksAndCleanUp() { |
| more_tiles_need_prepare_check_notifier_.Cancel(); |
| signals_check_notifier_.Cancel(); |
| task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
| + weak_ptr_factory_.InvalidateWeakPtrs(); |
| image_manager_.SetImageDecodeController(nullptr); |
| locked_image_tasks_.clear(); |
| @@ -450,6 +443,45 @@ void TileManager::DidFinishRunningTileTasksRequiredForActivation() { |
| "TileManager::DidFinishRunningTileTasksRequiredForActivation"); |
| TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| ScheduledTasksStateAsValue()); |
| + |
| + // In SMOOTHNESS_TAKES_PRIORITY, we want to wait on all required for |
| + // activation |
|
vmpstr
2016/12/07 21:00:25
nit: reformat plz
|
| + // resources being ready to draw (from the RasterBufferProvider's perspective) |
| + // before activating. Depending on the RasterBufferProvider, this may involve |
| + // waiting on a GL sync token for GPU work to complete. |
| + if (global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY) { |
| + // Build a list of all resources required for activation. |
| + ResourceProvider::ResourceIdArray array; |
|
vmpstr
2016/12/07 21:00:25
nit: resource_ids
|
| + auto raster_priority_queue(client_->BuildRasterQueue( |
|
vmpstr
2016/12/07 21:00:25
nit: I kinda prefer = instead of ()
|
| + global_state_.tree_priority, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| + for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| + const TileDrawInfo& draw_info = |
| + raster_priority_queue->Top().tile()->draw_info(); |
| + if (!draw_info.has_resource()) { |
|
vmpstr
2016/12/07 21:00:25
Can you verify that OOM case is still handled. I t
|
| + // If we encounter any required for activation tile with a missing |
| + // resource, more raster tasks need to be scheduled to activate, so |
| + // there's no reason to wait on a callback yet. |
| + return; |
| + } |
| + array.push_back(draw_info.resource_id()); |
| + } |
| + |
| + // Enqueue a callback which will be triggered when all resources in |array| |
| + // are ready for draw. |
| + pending_activation_callback_id_ = |
| + raster_buffer_provider_->SetReadyToDrawCallback( |
| + array, |
| + base::Bind(&TileManager::RequiredForActivationTilesAreReadyToDraw, |
| + weak_ptr_factory_.GetWeakPtr()), |
| + pending_activation_callback_id_); |
| + |
| + if (pending_activation_callback_id_ != 0) { |
| + // We need to wait on the callback, don't schedule any notifications. |
| + return; |
| + } |
| + } |
| + |
| // TODO(vmpstr): Temporary check to debug crbug.com/642927. |
| CHECK(tile_task_manager_); |
| signals_.ready_to_activate = true; |
| @@ -816,6 +848,8 @@ void TileManager::ScheduleTasks( |
| // will always trigger a DidFinishRunningTileTasks notification. Because of |
| // this we unconditionally set |has_scheduled_tile_tasks_| to true. |
| has_scheduled_tile_tasks_ = true; |
| + // And reset |pending_activation_callback_id_|. |
| + pending_activation_callback_id_ = 0; |
| // Track the number of dependents for each *_done task. |
| size_t required_for_activate_count = 0; |
| @@ -1103,8 +1137,9 @@ bool TileManager::AreRequiredTilesReadyToDraw( |
| bool TileManager::IsReadyToActivate() const { |
| TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
| - return AreRequiredTilesReadyToDraw( |
| - RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| + return pending_activation_callback_id_ == 0 && |
| + AreRequiredTilesReadyToDraw( |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| } |
| bool TileManager::IsReadyToDraw() const { |
| @@ -1271,6 +1306,18 @@ bool TileManager::UsePartialRaster() const { |
| raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); |
| } |
| +void TileManager::RequiredForActivationTilesAreReadyToDraw( |
| + uint64_t callback_id) { |
| + if (pending_activation_callback_id_ != callback_id) { |
| + // This callback has already been superceded by a new one. Ignore it. |
| + return; |
| + } |
| + |
| + pending_activation_callback_id_ = 0; |
| + signals_.ready_to_activate = true; |
| + signals_check_notifier_.Schedule(); |
| +} |
| + |
| // Utility function that can be used to create a "Task set finished" task that |
| // posts |callback| to |task_runner| when run. |
| scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( |