Index: cc/tiles/tile_manager.cc |
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc |
index aab3047b3343be0aa2a889f2258d490f2dae0a54..de6c149930d8993a147e02f91bce733318e95352 100644 |
--- a/cc/tiles/tile_manager.cc |
+++ b/cc/tiles/tile_manager.cc |
@@ -347,8 +347,9 @@ void TileManager::FinishTasksAndCleanUp() { |
// uninitialized resources. |
tile_task_manager_->Shutdown(); |
- // Now that all tasks have been finished, we can clear any |
- // |orphan_tasks_|. |
+ raster_buffer_provider_->Shutdown(); |
+ |
+ // Now that all tasks have been finished, we can clear any |orphan_tasks_|. |
orphan_tasks_.clear(); |
tile_task_manager_->CheckForCompletedTasks(); |
@@ -370,6 +371,7 @@ void TileManager::FinishTasksAndCleanUp() { |
void TileManager::SetResources(ResourcePool* resource_pool, |
ImageDecodeController* image_decode_controller, |
TileTaskManager* tile_task_manager, |
+ RasterBufferProvider* raster_buffer_provider, |
size_t scheduled_raster_task_limit, |
bool use_gpu_rasterization) { |
DCHECK(!tile_task_manager_); |
@@ -380,6 +382,7 @@ void TileManager::SetResources(ResourcePool* resource_pool, |
resource_pool_ = resource_pool; |
image_decode_controller_ = image_decode_controller; |
tile_task_manager_ = tile_task_manager; |
+ raster_buffer_provider_ = raster_buffer_provider; |
} |
void TileManager::Release(Tile* tile) { |
@@ -878,6 +881,26 @@ void TileManager::ScheduleTasks( |
// below, so we do a swap instead of a move. |
locked_images_.swap(new_locked_images); |
+ // We must reduce the amount of unused resources before calling |
+ // ScheduleTasks to prevent usage from rising above limits. |
+ resource_pool_->ReduceResourceUsage(); |
+ image_decode_controller_->ReduceCacheUsage(); |
+ |
+ // Synchronize worker with compositor. If that fails do not schedule tasks. |
vmpstr
2016/06/15 00:39:34
Can you expand this comment a little bit to mentio
sunnyps
2016/06/15 00:42:00
Calling task->OnTaskCompleted will free up resourc
sunnyps
2016/06/15 01:56:58
Done.
|
+ if (!raster_buffer_provider_->OrderingBarrier()) { |
+ // Cancel tasks to appease DCHECKs in TileTask dtor. |
+ for (auto& node : graph_.nodes) { |
+ TileTask* task = static_cast<TileTask*>(node.task); |
+ task->state().DidCancel(); |
+ task->OnTaskCompleted(); |
+ task->DidComplete(); |
+ } |
+ graph_.Reset(); |
+ required_for_activate_count = 0; |
+ required_for_draw_count = 0; |
+ all_count = 0; |
+ } |
+ |
// Insert nodes for our task completion tasks. We enqueue these using |
// NONCONCURRENT_FOREGROUND category this is the highest prioirty category and |
// we'd like to run these tasks as soon as possible. |
@@ -892,11 +915,6 @@ void TileManager::ScheduleTasks( |
TASK_CATEGORY_NONCONCURRENT_FOREGROUND, |
kAllDoneTaskPriority, all_count); |
- // We must reduce the amount of unused resoruces before calling |
- // ScheduleTasks to prevent usage from rising above limits. |
- resource_pool_->ReduceResourceUsage(); |
- image_decode_controller_->ReduceCacheUsage(); |
- |
// Schedule running of |raster_queue_|. This replaces any previously |
// scheduled tasks and effectively cancels all tasks not present |
// in |raster_queue_|. |
@@ -974,7 +992,7 @@ scoped_refptr<TileTask> TileManager::CreateRasterTask( |
bool supports_concurrent_execution = !use_gpu_rasterization_; |
std::unique_ptr<RasterBuffer> raster_buffer = |
- tile_task_manager_->GetRasterBufferProvider()->AcquireBufferForRaster( |
+ raster_buffer_provider_->AcquireBufferForRaster( |
resource, resource_content_id, tile->invalidated_id()); |
return make_scoped_refptr(new RasterTaskImpl( |
this, tile, resource, prioritized_tile.raster_source(), playback_settings, |
@@ -989,8 +1007,7 @@ void TileManager::OnRasterTaskCompleted( |
bool was_canceled) { |
DCHECK(tile); |
DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
- tile_task_manager_->GetRasterBufferProvider()->ReleaseBufferForRaster( |
- std::move(raster_buffer)); |
+ raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); |
TileDrawInfo& draw_info = tile->draw_info(); |
DCHECK(tile->raster_task_.get()); |
@@ -1046,6 +1063,11 @@ void TileManager::SetTileTaskManagerForTesting( |
tile_task_manager_ = tile_task_manager; |
} |
+void TileManager::SetRasterBufferProviderForTesting( |
+ RasterBufferProvider* raster_buffer_provider) { |
+ raster_buffer_provider_ = raster_buffer_provider; |
+} |
+ |
bool TileManager::AreRequiredTilesReadyToDraw( |
RasterTilePriorityQueue::Type type) const { |
std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
@@ -1215,13 +1237,12 @@ bool TileManager::MarkTilesOutOfMemory( |
} |
ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { |
- return tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat( |
- !tile->is_opaque()); |
+ return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); |
} |
bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { |
- return tile_task_manager_->GetRasterBufferProvider() |
- ->GetResourceRequiresSwizzle(!tile->is_opaque()); |
+ return raster_buffer_provider_->GetResourceRequiresSwizzle( |
+ !tile->is_opaque()); |
} |
std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |