| OLD | NEW |
| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 raster_task_states_.erase(task); | 233 raster_task_states_.erase(task); |
| 234 | 234 |
| 235 task->RunReplyOnOriginThread(); | 235 task->RunReplyOnOriginThread(); |
| 236 | 236 |
| 237 completed_raster_tasks_.pop_front(); | 237 completed_raster_tasks_.pop_front(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 CheckForCompletedGpuRasterTasks(); | 240 CheckForCompletedGpuRasterTasks(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void* PixelBufferRasterWorkerPool::AcquireBufferForRaster( | 243 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster( |
| 244 internal::RasterWorkerPoolTask* task, | 244 internal::RasterWorkerPoolTask* task) { |
| 245 int* stride) { | 245 if (task->use_gpu_rasterization()) |
| 246 // Request a pixel buffer. This will reserve shared memory. | 246 return resource_provider()->MapDirectRasterBuffer(task->resource()->id()); |
| 247 resource_provider()->AcquirePixelBuffer(task->resource()->id()); | |
| 248 | 247 |
| 249 *stride = 0; | 248 resource_provider()->AcquirePixelRasterBuffer(task->resource()->id()); |
| 250 return resource_provider()->MapPixelBuffer(task->resource()->id()); | 249 return resource_provider()->MapPixelRasterBuffer(task->resource()->id()); |
| 251 } | 250 } |
| 252 | 251 |
| 253 void PixelBufferRasterWorkerPool::OnRasterCompleted( | 252 void PixelBufferRasterWorkerPool::OnRasterCompleted( |
| 254 internal::RasterWorkerPoolTask* task, | 253 internal::RasterWorkerPoolTask* task, |
| 255 const PicturePileImpl::Analysis& analysis) { | 254 const PicturePileImpl::Analysis& analysis) { |
| 255 if (task->use_gpu_rasterization()) { |
| 256 resource_provider()->UnmapDirectRasterBuffer(task->resource()->id()); |
| 257 return; |
| 258 } |
| 259 |
| 256 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), | 260 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), |
| 257 "PixelBufferRasterWorkerPool::OnRasterCompleted", | 261 "PixelBufferRasterWorkerPool::OnRasterCompleted", |
| 258 "was_canceled", | 262 "was_canceled", |
| 259 !task->HasFinishedRunning(), | 263 !task->HasFinishedRunning(), |
| 260 "needs_upload", | 264 "needs_upload", |
| 261 task->HasFinishedRunning() && !analysis.is_solid_color); | 265 task->HasFinishedRunning() && !analysis.is_solid_color); |
| 262 | 266 |
| 263 DCHECK(raster_task_states_.find(task) != raster_task_states_.end()); | 267 DCHECK(raster_task_states_.find(task) != raster_task_states_.end()); |
| 264 DCHECK_EQ(SCHEDULED, raster_task_states_[task]); | 268 DCHECK_EQ(SCHEDULED, raster_task_states_[task]); |
| 265 | 269 |
| 266 // Balanced with MapPixelBuffer() call in AcquireBufferForRaster(). | 270 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster(). |
| 267 resource_provider()->UnmapPixelBuffer(task->resource()->id()); | 271 resource_provider()->UnmapPixelRasterBuffer(task->resource()->id()); |
| 268 | 272 |
| 269 if (!task->HasFinishedRunning() || analysis.is_solid_color) { | 273 if (!task->HasFinishedRunning() || analysis.is_solid_color) { |
| 270 resource_provider()->ReleasePixelBuffer(task->resource()->id()); | 274 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id()); |
| 271 | 275 |
| 272 if (!task->HasFinishedRunning()) { | 276 if (!task->HasFinishedRunning()) { |
| 273 // When priorites change, a raster task can be canceled as a result of | 277 // When priorites change, a raster task can be canceled as a result of |
| 274 // no longer being of high enough priority to fit in our throttled | 278 // no longer being of high enough priority to fit in our throttled |
| 275 // raster task budget. The task has not yet completed in this case. | 279 // raster task budget. The task has not yet completed in this case. |
| 276 RasterTaskVector::const_iterator it = | 280 RasterTaskVector::const_iterator it = |
| 277 std::find(raster_tasks().begin(), raster_tasks().end(), task); | 281 std::find(raster_tasks().begin(), raster_tasks().end(), task); |
| 278 if (it != raster_tasks().end()) { | 282 if (it != raster_tasks().end()) { |
| 279 raster_task_states_[task] = UNSCHEDULED; | 283 raster_task_states_[task] = UNSCHEDULED; |
| 280 return; | 284 return; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 397 } |
| 394 } | 398 } |
| 395 | 399 |
| 396 // Release shared memory and move tasks with completed uploads | 400 // Release shared memory and move tasks with completed uploads |
| 397 // to |completed_raster_tasks_|. | 401 // to |completed_raster_tasks_|. |
| 398 while (!tasks_with_completed_uploads.empty()) { | 402 while (!tasks_with_completed_uploads.empty()) { |
| 399 internal::RasterWorkerPoolTask* task = | 403 internal::RasterWorkerPoolTask* task = |
| 400 tasks_with_completed_uploads.front().get(); | 404 tasks_with_completed_uploads.front().get(); |
| 401 | 405 |
| 402 // It's now safe to release the pixel buffer and the shared memory. | 406 // It's now safe to release the pixel buffer and the shared memory. |
| 403 resource_provider()->ReleasePixelBuffer(task->resource()->id()); | 407 resource_provider()->ReleasePixelRasterBuffer(task->resource()->id()); |
| 404 | 408 |
| 405 bytes_pending_upload_ -= task->resource()->bytes(); | 409 bytes_pending_upload_ -= task->resource()->bytes(); |
| 406 | 410 |
| 407 DCHECK(std::find(completed_raster_tasks_.begin(), | 411 DCHECK(std::find(completed_raster_tasks_.begin(), |
| 408 completed_raster_tasks_.end(), | 412 completed_raster_tasks_.end(), |
| 409 task) == completed_raster_tasks_.end()); | 413 task) == completed_raster_tasks_.end()); |
| 410 completed_raster_tasks_.push_back(task); | 414 completed_raster_tasks_.push_back(task); |
| 411 raster_task_states_[task] = COMPLETED; | 415 raster_task_states_[task] = COMPLETED; |
| 412 | 416 |
| 413 raster_tasks_required_for_activation_.erase(task); | 417 raster_tasks_required_for_activation_.erase(task); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 710 |
| 707 throttle_state->SetInteger("bytes_available_for_upload", | 711 throttle_state->SetInteger("bytes_available_for_upload", |
| 708 max_bytes_pending_upload_ - bytes_pending_upload_); | 712 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 709 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 713 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 710 throttle_state->SetInteger("scheduled_raster_task_count", | 714 throttle_state->SetInteger("scheduled_raster_task_count", |
| 711 scheduled_raster_task_count_); | 715 scheduled_raster_task_count_); |
| 712 return throttle_state.PassAs<base::Value>(); | 716 return throttle_state.PassAs<base::Value>(); |
| 713 } | 717 } |
| 714 | 718 |
| 715 } // namespace cc | 719 } // namespace cc |
| OLD | NEW |