Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2205)

Unified Diff: cc/tiles/tile_manager.cc

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: cleanup tasks if ordering barrier fails Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/tiles/tile_manager.cc
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index aab3047b3343be0aa2a889f2258d490f2dae0a54..44d4b1afec4ae2e7d7d8838866f5a03fe24eecc0 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,23 @@ 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.
+ 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();
+ }
+
// 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 +912,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 +989,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 +1004,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 +1060,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 +1234,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>

Powered by Google App Engine
This is Rietveld 408576698