| 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" |
| 11 #include "cc/resources/resource.h" | 11 #include "cc/resources/resource.h" |
| 12 #include "third_party/skia/include/core/SkDevice.h" | 12 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 13 | 13 |
| 14 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
| 15 #include "base/android/sys_utils.h" | 15 #include "base/android/sys_utils.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class PixelBufferWorkerPoolTaskImpl : public internal::WorkerPoolTask { | 22 class PixelBufferWorkerPoolTaskImpl : public internal::WorkerPoolTask { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 SkBitmap bitmap; |
| 45 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 45 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 46 task_->resource()->size().width(), | 46 task_->resource()->size().width(), |
| 47 task_->resource()->size().height()); | 47 task_->resource()->size().height()); |
| 48 bitmap.setPixels(buffer_); | 48 bitmap.setPixels(buffer_); |
| 49 SkDevice device(bitmap); | 49 SkBitmapDevice device(bitmap); |
| 50 needs_upload_ = task_->RunOnWorkerThread(&device, thread_index); | 50 needs_upload_ = task_->RunOnWorkerThread(&device, thread_index); |
| 51 } | 51 } |
| 52 virtual void CompleteOnOriginThread() OVERRIDE { | 52 virtual void CompleteOnOriginThread() OVERRIDE { |
| 53 // |needs_upload_| must be be false if task didn't run. | 53 // |needs_upload_| must be be false if task didn't run. |
| 54 DCHECK(HasFinishedRunning() || !needs_upload_); | 54 DCHECK(HasFinishedRunning() || !needs_upload_); |
| 55 reply_.Run(!HasFinishedRunning(), needs_upload_); | 55 reply_.Run(!HasFinishedRunning(), needs_upload_); |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 virtual ~PixelBufferWorkerPoolTaskImpl() {} | 59 virtual ~PixelBufferWorkerPoolTaskImpl() {} |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 690 |
| 691 throttle_state->SetInteger("bytes_available_for_upload", | 691 throttle_state->SetInteger("bytes_available_for_upload", |
| 692 max_bytes_pending_upload_ - bytes_pending_upload_); | 692 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 693 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 693 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 694 throttle_state->SetInteger("scheduled_raster_task_count", | 694 throttle_state->SetInteger("scheduled_raster_task_count", |
| 695 scheduled_raster_task_count_); | 695 scheduled_raster_task_count_); |
| 696 return throttle_state.PassAs<base::Value>(); | 696 return throttle_state.PassAs<base::Value>(); |
| 697 } | 697 } |
| 698 | 698 |
| 699 } // namespace cc | 699 } // namespace cc |
| OLD | NEW |