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

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: implement acquire/release/map/unmap 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
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 raster_task_states_.erase(task); 209 raster_task_states_.erase(task);
210 210
211 task->RunReplyOnOriginThread(); 211 task->RunReplyOnOriginThread();
212 212
213 completed_raster_tasks_.pop_front(); 213 completed_raster_tasks_.pop_front();
214 } 214 }
215 215
216 CheckForCompletedGpuRasterTasks(); 216 CheckForCompletedGpuRasterTasks();
217 } 217 }
218 218
219 void* PixelBufferRasterWorkerPool::AcquireBufferForRaster( 219 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster(
220 internal::RasterWorkerPoolTask* task, 220 internal::RasterWorkerPoolTask* task) {
221 int* stride) { 221 if (task->use_gpu_rasterization())
222 // Request a pixel buffer. This will reserve shared memory. 222 return RasterWorkerPool::AcquireCanvasForRaster(task);
223 resource_provider()->AcquirePixelBuffer(task->resource()->id()); 223 resource_provider()->AcquirePixelRasterBuffer(task->resource()->id());
224 224 return resource_provider()->MapPixelRasterBuffer(task->resource()->id());
225 *stride = 0;
226 return resource_provider()->MapPixelBuffer(task->resource()->id());
227 } 225 }
228 226
229 void PixelBufferRasterWorkerPool::OnRasterCompleted( 227 void PixelBufferRasterWorkerPool::OnRasterCompleted(
230 internal::RasterWorkerPoolTask* task, 228 internal::RasterWorkerPoolTask* task,
231 const PicturePileImpl::Analysis& analysis) { 229 const PicturePileImpl::Analysis& analysis) {
230 if (task->use_gpu_rasterization()) {
231 RasterWorkerPool::OnRasterCompleted(task, analysis);
232 return;
233 }
234
232 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), 235 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"),
233 "PixelBufferRasterWorkerPool::OnRasterCompleted", 236 "PixelBufferRasterWorkerPool::OnRasterCompleted",
234 "was_canceled", 237 "was_canceled",
235 !task->HasFinishedRunning(), 238 !task->HasFinishedRunning(),
236 "needs_upload", 239 "needs_upload",
237 task->HasFinishedRunning() && !analysis.is_solid_color); 240 task->HasFinishedRunning() && !analysis.is_solid_color);
238 241
239 DCHECK(raster_task_states_.find(task) != raster_task_states_.end()); 242 DCHECK(raster_task_states_.find(task) != raster_task_states_.end());
240 DCHECK_EQ(SCHEDULED, raster_task_states_[task]); 243 DCHECK_EQ(SCHEDULED, raster_task_states_[task]);
241 244
242 // Balanced with MapPixelBuffer() call in AcquireBufferForRaster(). 245 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster().
243 resource_provider()->UnmapPixelBuffer(task->resource()->id()); 246 resource_provider()->UnmapPixelRasterBuffer(task->resource()->id());
244 247
245 if (!task->HasFinishedRunning() || analysis.is_solid_color) { 248 if (!task->HasFinishedRunning() || analysis.is_solid_color) {
246 resource_provider()->ReleasePixelBuffer(task->resource()->id()); 249 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id());
247 250
248 if (!task->HasFinishedRunning()) { 251 if (!task->HasFinishedRunning()) {
249 // When priorites change, a raster task can be canceled as a result of 252 // When priorites change, a raster task can be canceled as a result of
250 // no longer being of high enough priority to fit in our throttled 253 // no longer being of high enough priority to fit in our throttled
251 // raster task budget. The task has not yet completed in this case. 254 // raster task budget. The task has not yet completed in this case.
252 RasterTaskVector::const_iterator it = 255 RasterTaskVector::const_iterator it =
253 std::find(raster_tasks().begin(), raster_tasks().end(), task); 256 std::find(raster_tasks().begin(), raster_tasks().end(), task);
254 if (it != raster_tasks().end()) { 257 if (it != raster_tasks().end()) {
255 raster_task_states_[task] = UNSCHEDULED; 258 raster_task_states_[task] = UNSCHEDULED;
256 return; 259 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 372 }
370 } 373 }
371 374
372 // Release shared memory and move tasks with completed uploads 375 // Release shared memory and move tasks with completed uploads
373 // to |completed_raster_tasks_|. 376 // to |completed_raster_tasks_|.
374 while (!tasks_with_completed_uploads.empty()) { 377 while (!tasks_with_completed_uploads.empty()) {
375 internal::RasterWorkerPoolTask* task = 378 internal::RasterWorkerPoolTask* task =
376 tasks_with_completed_uploads.front().get(); 379 tasks_with_completed_uploads.front().get();
377 380
378 // It's now safe to release the pixel buffer and the shared memory. 381 // It's now safe to release the pixel buffer and the shared memory.
379 resource_provider()->ReleasePixelBuffer(task->resource()->id()); 382 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id());
380 383
381 bytes_pending_upload_ -= task->resource()->bytes(); 384 bytes_pending_upload_ -= task->resource()->bytes();
382 385
383 DCHECK(std::find(completed_raster_tasks_.begin(), 386 DCHECK(std::find(completed_raster_tasks_.begin(),
384 completed_raster_tasks_.end(), 387 completed_raster_tasks_.end(),
385 task) == completed_raster_tasks_.end()); 388 task) == completed_raster_tasks_.end());
386 completed_raster_tasks_.push_back(task); 389 completed_raster_tasks_.push_back(task);
387 raster_task_states_[task] = COMPLETED; 390 raster_task_states_[task] = COMPLETED;
388 391
389 raster_tasks_required_for_activation_.erase(task); 392 raster_tasks_required_for_activation_.erase(task);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 660
658 throttle_state->SetInteger("bytes_available_for_upload", 661 throttle_state->SetInteger("bytes_available_for_upload",
659 max_bytes_pending_upload_ - bytes_pending_upload_); 662 max_bytes_pending_upload_ - bytes_pending_upload_);
660 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 663 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
661 throttle_state->SetInteger("scheduled_raster_task_count", 664 throttle_state->SetInteger("scheduled_raster_task_count",
662 scheduled_raster_task_count_); 665 scheduled_raster_task_count_);
663 return throttle_state.PassAs<base::Value>(); 666 return throttle_state.PassAs<base::Value>();
664 } 667 }
665 668
666 } // namespace cc 669 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698