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

Side by Side Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 157293002: cc: Refactor WorkerPoolTaskClient::AcquireBufferForRaster (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed cc_perftests compile error Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.h ('k') | cc/resources/raster_worker_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/pixel_buffer_raster_worker_pool.h" 5 #include "cc/resources/pixel_buffer_raster_worker_pool.h"
6 6
7 #include "base/containers/stack_container.h" 7 #include "base/containers/stack_container.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/debug/traced_value.h" 10 #include "cc/debug/traced_value.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 raster_task_states_.erase(task); 220 raster_task_states_.erase(task);
221 221
222 task->RunReplyOnOriginThread(); 222 task->RunReplyOnOriginThread();
223 223
224 completed_raster_tasks_.pop_front(); 224 completed_raster_tasks_.pop_front();
225 } 225 }
226 226
227 CheckForCompletedGpuRasterTasks(); 227 CheckForCompletedGpuRasterTasks();
228 } 228 }
229 229
230 void* PixelBufferRasterWorkerPool::AcquireBufferForRaster( 230 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster(
231 internal::RasterWorkerPoolTask* task, 231 internal::RasterWorkerPoolTask* task) {
232 int* stride) { 232 if (task->use_gpu_rasterization())
233 // Request a pixel buffer. This will reserve shared memory. 233 return resource_provider()->MapDirectRasterBuffer(task->resource()->id());
234 resource_provider()->AcquirePixelBuffer(task->resource()->id());
235 234
236 *stride = 0; 235 resource_provider()->AcquirePixelRasterBuffer(task->resource()->id());
237 return resource_provider()->MapPixelBuffer(task->resource()->id()); 236 return resource_provider()->MapPixelRasterBuffer(task->resource()->id());
238 } 237 }
239 238
240 void PixelBufferRasterWorkerPool::OnRasterCompleted( 239 void PixelBufferRasterWorkerPool::OnRasterCompleted(
241 internal::RasterWorkerPoolTask* task, 240 internal::RasterWorkerPoolTask* task,
242 const PicturePileImpl::Analysis& analysis) { 241 const PicturePileImpl::Analysis& analysis) {
242 if (task->use_gpu_rasterization()) {
243 resource_provider()->UnmapDirectRasterBuffer(task->resource()->id());
244 return;
245 }
246
243 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), 247 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"),
244 "PixelBufferRasterWorkerPool::OnRasterCompleted", 248 "PixelBufferRasterWorkerPool::OnRasterCompleted",
245 "was_canceled", 249 "was_canceled",
246 !task->HasFinishedRunning(), 250 !task->HasFinishedRunning(),
247 "needs_upload", 251 "needs_upload",
248 task->HasFinishedRunning() && !analysis.is_solid_color); 252 task->HasFinishedRunning() && !analysis.is_solid_color);
249 253
250 DCHECK(raster_task_states_.find(task) != raster_task_states_.end()); 254 DCHECK(raster_task_states_.find(task) != raster_task_states_.end());
251 DCHECK_EQ(SCHEDULED, raster_task_states_[task]); 255 DCHECK_EQ(SCHEDULED, raster_task_states_[task]);
252 256
253 // Balanced with MapPixelBuffer() call in AcquireBufferForRaster(). 257 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster().
254 resource_provider()->UnmapPixelBuffer(task->resource()->id()); 258 resource_provider()->UnmapPixelRasterBuffer(task->resource()->id());
255 259
256 if (!task->HasFinishedRunning() || analysis.is_solid_color) { 260 if (!task->HasFinishedRunning() || analysis.is_solid_color) {
257 resource_provider()->ReleasePixelBuffer(task->resource()->id()); 261 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id());
258 262
259 if (!task->HasFinishedRunning()) { 263 if (!task->HasFinishedRunning()) {
260 // When priorites change, a raster task can be canceled as a result of 264 // When priorites change, a raster task can be canceled as a result of
261 // no longer being of high enough priority to fit in our throttled 265 // no longer being of high enough priority to fit in our throttled
262 // raster task budget. The task has not yet completed in this case. 266 // raster task budget. The task has not yet completed in this case.
263 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { 267 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) {
264 if (*it == task) { 268 if (*it == task) {
265 raster_task_states_[task] = UNSCHEDULED; 269 raster_task_states_[task] = UNSCHEDULED;
266 return; 270 return;
267 } 271 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 384 }
381 } 385 }
382 386
383 // Release shared memory and move tasks with completed uploads 387 // Release shared memory and move tasks with completed uploads
384 // to |completed_raster_tasks_|. 388 // to |completed_raster_tasks_|.
385 while (!tasks_with_completed_uploads.empty()) { 389 while (!tasks_with_completed_uploads.empty()) {
386 internal::RasterWorkerPoolTask* task = 390 internal::RasterWorkerPoolTask* task =
387 tasks_with_completed_uploads.front().get(); 391 tasks_with_completed_uploads.front().get();
388 392
389 // It's now safe to release the pixel buffer and the shared memory. 393 // It's now safe to release the pixel buffer and the shared memory.
390 resource_provider()->ReleasePixelBuffer(task->resource()->id()); 394 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id());
391 395
392 bytes_pending_upload_ -= task->resource()->bytes(); 396 bytes_pending_upload_ -= task->resource()->bytes();
393 397
394 DCHECK(std::find(completed_raster_tasks_.begin(), 398 DCHECK(std::find(completed_raster_tasks_.begin(),
395 completed_raster_tasks_.end(), 399 completed_raster_tasks_.end(),
396 task) == completed_raster_tasks_.end()); 400 task) == completed_raster_tasks_.end());
397 completed_raster_tasks_.push_back(task); 401 completed_raster_tasks_.push_back(task);
398 raster_task_states_[task] = COMPLETED; 402 raster_task_states_[task] = COMPLETED;
399 403
400 raster_tasks_required_for_activation_.erase(task); 404 raster_tasks_required_for_activation_.erase(task);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 700
697 throttle_state->SetInteger("bytes_available_for_upload", 701 throttle_state->SetInteger("bytes_available_for_upload",
698 max_bytes_pending_upload_ - bytes_pending_upload_); 702 max_bytes_pending_upload_ - bytes_pending_upload_);
699 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 703 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
700 throttle_state->SetInteger("scheduled_raster_task_count", 704 throttle_state->SetInteger("scheduled_raster_task_count",
701 scheduled_raster_task_count_); 705 scheduled_raster_task_count_);
702 return throttle_state.PassAs<base::Value>(); 706 return throttle_state.PassAs<base::Value>();
703 } 707 }
704 708
705 } // namespace cc 709 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.h ('k') | cc/resources/raster_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698