Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 // Overridden from internal::WorkerPoolTask: | 35 // Overridden from internal::WorkerPoolTask: |
| 36 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 36 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
| 37 // |buffer_| can be NULL in lost context situations. | 37 // |buffer_| can be NULL in lost context situations. |
| 38 if (!buffer_) { | 38 if (!buffer_) { |
| 39 // |needs_upload_| still needs to be true as task has not | 39 // |needs_upload_| still needs to be true as task has not |
| 40 // been canceled. | 40 // been canceled. |
| 41 needs_upload_ = true; | 41 needs_upload_ = true; |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 SkBitmap bitmap; | 44 needs_upload_ = task_->RunOnWorkerThread(thread_index, |
| 45 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 45 buffer_, |
| 46 task_->resource()->size().width(), | 46 task_->resource()->size(), |
| 47 task_->resource()->size().height()); | 47 0); |
| 48 bitmap.setPixels(buffer_); | |
| 49 SkBitmapDevice device(bitmap); | |
| 50 needs_upload_ = task_->RunOnWorkerThread(&device, thread_index); | |
| 51 } | 48 } |
| 52 virtual void CompleteOnOriginThread() OVERRIDE { | 49 virtual void CompleteOnOriginThread() OVERRIDE { |
| 53 // |needs_upload_| must be be false if task didn't run. | 50 // |needs_upload_| must be be false if task didn't run. |
| 54 DCHECK(HasFinishedRunning() || !needs_upload_); | 51 DCHECK(HasFinishedRunning() || !needs_upload_); |
| 55 reply_.Run(!HasFinishedRunning(), needs_upload_); | 52 reply_.Run(!HasFinishedRunning(), needs_upload_); |
| 56 } | 53 } |
| 57 | 54 |
| 58 private: | 55 private: |
| 59 virtual ~PixelBufferWorkerPoolTaskImpl() {} | 56 virtual ~PixelBufferWorkerPoolTaskImpl() {} |
| 60 | 57 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 88 // Only used as std::find_if predicate for DCHECKs. | 85 // Only used as std::find_if predicate for DCHECKs. |
| 89 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { | 86 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { |
| 90 return task->WasCanceled(); | 87 return task->WasCanceled(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 } // namespace | 90 } // namespace |
| 94 | 91 |
| 95 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( | 92 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( |
| 96 ResourceProvider* resource_provider, | 93 ResourceProvider* resource_provider, |
| 97 size_t num_threads, | 94 size_t num_threads, |
| 98 size_t max_transfer_buffer_usage_bytes) | 95 size_t max_transfer_buffer_usage_bytes, |
| 96 ResourceFormat format) | |
| 99 : RasterWorkerPool(resource_provider, num_threads), | 97 : RasterWorkerPool(resource_provider, num_threads), |
| 100 shutdown_(false), | 98 shutdown_(false), |
| 101 scheduled_raster_task_count_(0), | 99 scheduled_raster_task_count_(0), |
| 102 bytes_pending_upload_(0), | 100 bytes_pending_upload_(0), |
| 103 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), | 101 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), |
| 104 has_performed_uploads_since_last_flush_(false), | 102 has_performed_uploads_since_last_flush_(false), |
| 105 check_for_completed_raster_tasks_pending_(false), | 103 check_for_completed_raster_tasks_pending_(false), |
| 106 should_notify_client_if_no_tasks_are_pending_(false), | 104 should_notify_client_if_no_tasks_are_pending_(false), |
| 107 should_notify_client_if_no_tasks_required_for_activation_are_pending_( | 105 should_notify_client_if_no_tasks_required_for_activation_are_pending_( |
| 108 false) { | 106 false), |
| 107 format_(format) { | |
| 109 } | 108 } |
| 110 | 109 |
| 111 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { | 110 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { |
| 112 DCHECK(shutdown_); | 111 DCHECK(shutdown_); |
| 113 DCHECK(!check_for_completed_raster_tasks_pending_); | 112 DCHECK(!check_for_completed_raster_tasks_pending_); |
| 114 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); | 113 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); |
| 115 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); | 114 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); |
| 116 DCHECK_EQ(0u, completed_tasks_.size()); | 115 DCHECK_EQ(0u, completed_tasks_.size()); |
| 117 } | 116 } |
| 118 | 117 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 // another check. | 218 // another check. |
| 220 check_for_completed_raster_tasks_callback_.Cancel(); | 219 check_for_completed_raster_tasks_callback_.Cancel(); |
| 221 check_for_completed_raster_tasks_pending_ = false; | 220 check_for_completed_raster_tasks_pending_ = false; |
| 222 ScheduleCheckForCompletedRasterTasks(); | 221 ScheduleCheckForCompletedRasterTasks(); |
| 223 | 222 |
| 224 TRACE_EVENT_ASYNC_STEP1( | 223 TRACE_EVENT_ASYNC_STEP1( |
| 225 "cc", "ScheduledTasks", this, StateName(), | 224 "cc", "ScheduledTasks", this, StateName(), |
| 226 "state", TracedValue::FromValue(StateAsValue().release())); | 225 "state", TracedValue::FromValue(StateAsValue().release())); |
| 227 } | 226 } |
| 228 | 227 |
| 229 GLenum PixelBufferRasterWorkerPool::GetResourceFormat() const { | 228 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { |
| 230 return resource_provider()->best_texture_format(); | 229 return format_; |
|
reveman
2013/09/14 00:58:39
resource_provider()->best_tile_texture_format()
kaanb
2013/09/16 07:22:25
Done.
| |
| 231 } | 230 } |
| 232 | 231 |
| 233 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { | 232 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { |
| 234 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); | 233 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); |
| 235 | 234 |
| 236 RasterWorkerPool::CheckForCompletedTasks(); | 235 RasterWorkerPool::CheckForCompletedTasks(); |
| 237 CheckForCompletedUploads(); | 236 CheckForCompletedUploads(); |
| 238 FlushUploads(); | 237 FlushUploads(); |
| 239 | 238 |
| 240 TaskDeque completed_tasks; | 239 TaskDeque completed_tasks; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 | 672 |
| 674 throttle_state->SetInteger("bytes_available_for_upload", | 673 throttle_state->SetInteger("bytes_available_for_upload", |
| 675 max_bytes_pending_upload_ - bytes_pending_upload_); | 674 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 676 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 675 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 677 throttle_state->SetInteger("scheduled_raster_task_count", | 676 throttle_state->SetInteger("scheduled_raster_task_count", |
| 678 scheduled_raster_task_count_); | 677 scheduled_raster_task_count_); |
| 679 return throttle_state.PassAs<base::Value>(); | 678 return throttle_state.PassAs<base::Value>(); |
| 680 } | 679 } |
| 681 | 680 |
| 682 } // namespace cc | 681 } // namespace cc |
| OLD | NEW |