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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // another check. | 209 // another check. |
213 check_for_completed_raster_tasks_callback_.Cancel(); | 210 check_for_completed_raster_tasks_callback_.Cancel(); |
214 check_for_completed_raster_tasks_pending_ = false; | 211 check_for_completed_raster_tasks_pending_ = false; |
215 ScheduleCheckForCompletedRasterTasks(); | 212 ScheduleCheckForCompletedRasterTasks(); |
216 | 213 |
217 TRACE_EVENT_ASYNC_STEP1( | 214 TRACE_EVENT_ASYNC_STEP1( |
218 "cc", "ScheduledTasks", this, StateName(), | 215 "cc", "ScheduledTasks", this, StateName(), |
219 "state", TracedValue::FromValue(StateAsValue().release())); | 216 "state", TracedValue::FromValue(StateAsValue().release())); |
220 } | 217 } |
221 | 218 |
222 GLenum PixelBufferRasterWorkerPool::GetResourceFormat() const { | 219 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { |
223 return resource_provider()->best_texture_format(); | 220 return resource_provider()->memory_efficient_texture_format(); |
224 } | 221 } |
225 | 222 |
226 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { | 223 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { |
227 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); | 224 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); |
228 | 225 |
229 RasterWorkerPool::CheckForCompletedTasks(); | 226 RasterWorkerPool::CheckForCompletedTasks(); |
230 CheckForCompletedUploads(); | 227 CheckForCompletedUploads(); |
231 FlushUploads(); | 228 FlushUploads(); |
232 | 229 |
233 TaskDeque completed_tasks; | 230 TaskDeque completed_tasks; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 | 663 |
667 throttle_state->SetInteger("bytes_available_for_upload", | 664 throttle_state->SetInteger("bytes_available_for_upload", |
668 max_bytes_pending_upload_ - bytes_pending_upload_); | 665 max_bytes_pending_upload_ - bytes_pending_upload_); |
669 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 666 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
670 throttle_state->SetInteger("scheduled_raster_task_count", | 667 throttle_state->SetInteger("scheduled_raster_task_count", |
671 scheduled_raster_task_count_); | 668 scheduled_raster_task_count_); |
672 return throttle_state.PassAs<base::Value>(); | 669 return throttle_state.PassAs<base::Value>(); |
673 } | 670 } |
674 | 671 |
675 } // namespace cc | 672 } // namespace cc |
OLD | NEW |