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

Side by Side Diff: cc/raster/one_copy_tile_task_worker_pool.cc

Issue 1910213005: cc: Refactor TileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_states
Patch Set: nits Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/raster/one_copy_tile_task_worker_pool.h" 5 #include "cc/raster/one_copy_tile_task_worker_pool.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good 64 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good
65 // default batch size for copy operations. 65 // default batch size for copy operations.
66 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; 66 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4;
67 67
68 } // namespace 68 } // namespace
69 69
70 // static 70 // static
71 std::unique_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create( 71 std::unique_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create(
72 base::SequencedTaskRunner* task_runner, 72 base::SequencedTaskRunner* task_runner,
73 TaskGraphRunner* task_graph_runner,
74 ContextProvider* context_provider, 73 ContextProvider* context_provider,
75 ResourceProvider* resource_provider, 74 ResourceProvider* resource_provider,
76 int max_copy_texture_chromium_size, 75 int max_copy_texture_chromium_size,
77 bool use_partial_raster, 76 bool use_partial_raster,
78 int max_staging_buffer_usage_in_bytes, 77 int max_staging_buffer_usage_in_bytes,
79 ResourceFormat preferred_tile_format) { 78 ResourceFormat preferred_tile_format) {
80 return base::WrapUnique<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool( 79 return base::WrapUnique<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool(
81 task_runner, task_graph_runner, resource_provider, 80 task_runner, resource_provider, max_copy_texture_chromium_size,
82 max_copy_texture_chromium_size, use_partial_raster, 81 use_partial_raster, max_staging_buffer_usage_in_bytes,
83 max_staging_buffer_usage_in_bytes, preferred_tile_format)); 82 preferred_tile_format));
84 } 83 }
85 84
86 OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( 85 OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
87 base::SequencedTaskRunner* task_runner, 86 base::SequencedTaskRunner* task_runner,
88 TaskGraphRunner* task_graph_runner,
89 ResourceProvider* resource_provider, 87 ResourceProvider* resource_provider,
90 int max_copy_texture_chromium_size, 88 int max_copy_texture_chromium_size,
91 bool use_partial_raster, 89 bool use_partial_raster,
92 int max_staging_buffer_usage_in_bytes, 90 int max_staging_buffer_usage_in_bytes,
93 ResourceFormat preferred_tile_format) 91 ResourceFormat preferred_tile_format)
94 : task_graph_runner_(task_graph_runner), 92 : resource_provider_(resource_provider),
95 namespace_token_(task_graph_runner->GetNamespaceToken()),
96 resource_provider_(resource_provider),
97 max_bytes_per_copy_operation_( 93 max_bytes_per_copy_operation_(
98 max_copy_texture_chromium_size 94 max_copy_texture_chromium_size
99 ? std::min(kMaxBytesPerCopyOperation, 95 ? std::min(kMaxBytesPerCopyOperation,
100 max_copy_texture_chromium_size) 96 max_copy_texture_chromium_size)
101 : kMaxBytesPerCopyOperation), 97 : kMaxBytesPerCopyOperation),
102 use_partial_raster_(use_partial_raster), 98 use_partial_raster_(use_partial_raster),
103 bytes_scheduled_since_last_flush_(0), 99 bytes_scheduled_since_last_flush_(0),
104 preferred_tile_format_(preferred_tile_format) { 100 preferred_tile_format_(preferred_tile_format) {
105 staging_pool_ = StagingBufferPool::Create(task_runner, resource_provider, 101 staging_pool_ = StagingBufferPool::Create(task_runner, resource_provider,
106 use_partial_raster, 102 use_partial_raster,
107 max_staging_buffer_usage_in_bytes); 103 max_staging_buffer_usage_in_bytes);
108 } 104 }
109 105
110 OneCopyTileTaskWorkerPool::~OneCopyTileTaskWorkerPool() { 106 OneCopyTileTaskWorkerPool::~OneCopyTileTaskWorkerPool() {
111 } 107 }
112 108
113 void OneCopyTileTaskWorkerPool::Shutdown() { 109 void OneCopyTileTaskWorkerPool::BarrierToSyncResources() {
114 TRACE_EVENT0("cc", "OneCopyTileTaskWorkerPool::Shutdown"); 110 TRACE_EVENT0("cc", "OneCopyTileTaskWorkerPool::BarrierToSyncResources");
115 111
116 TaskGraph empty;
117 task_graph_runner_->ScheduleTasks(namespace_token_, &empty);
118 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_);
119
120 staging_pool_->Shutdown();
121 }
122
123 void OneCopyTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) {
124 TRACE_EVENT0("cc", "OneCopyTileTaskWorkerPool::ScheduleTasks");
125
126 ScheduleTasksOnOriginThread(this, graph);
127
128 // Barrier to sync any new resources to the worker context.
129 resource_provider_->output_surface() 112 resource_provider_->output_surface()
130 ->context_provider() 113 ->context_provider()
131 ->ContextGL() 114 ->ContextGL()
132 ->OrderingBarrierCHROMIUM(); 115 ->OrderingBarrierCHROMIUM();
133
134 task_graph_runner_->ScheduleTasks(namespace_token_, graph);
135 }
136
137 void OneCopyTileTaskWorkerPool::CheckForCompletedTasks() {
138 TRACE_EVENT0("cc", "OneCopyTileTaskWorkerPool::CheckForCompletedTasks");
139
140 task_graph_runner_->CollectCompletedTasks(namespace_token_,
141 &completed_tasks_);
142
143 for (Task::Vector::const_iterator it = completed_tasks_.begin();
144 it != completed_tasks_.end(); ++it) {
145 TileTask* task = static_cast<TileTask*>(it->get());
146
147 task->WillComplete();
148 task->CompleteOnOriginThread(this);
149 task->DidComplete();
150 }
151 completed_tasks_.clear();
152 } 116 }
153 117
154 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat( 118 ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat(
155 bool must_support_alpha) const { 119 bool must_support_alpha) const {
156 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && 120 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) &&
157 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || 121 (DoesResourceFormatSupportAlpha(preferred_tile_format_) ||
158 !must_support_alpha)) { 122 !must_support_alpha)) {
159 return preferred_tile_format_; 123 return preferred_tile_format_;
160 } 124 }
161 125
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 gl->OrderingBarrierCHROMIUM(); 339 gl->OrderingBarrierCHROMIUM();
376 340
377 // Generate sync token after the barrier for cross context synchronization. 341 // Generate sync token after the barrier for cross context synchronization.
378 gpu::SyncToken sync_token; 342 gpu::SyncToken sync_token;
379 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 343 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
380 resource_lock->UpdateResourceSyncToken(sync_token); 344 resource_lock->UpdateResourceSyncToken(sync_token);
381 } 345 }
382 } 346 }
383 347
384 } // namespace cc 348 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698