| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 // Only used as std::find_if predicate for DCHECKs. | 88 // Only used as std::find_if predicate for DCHECKs. |
| 89 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { | 89 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { |
| 90 return task->WasCanceled(); | 90 return task->WasCanceled(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( | 95 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( |
| 96 ResourceProvider* resource_provider, | 96 ResourceProvider* resource_provider, |
| 97 size_t num_threads) | 97 size_t num_threads, |
| 98 size_t max_bytes_pending_upload) |
| 98 : RasterWorkerPool(resource_provider, num_threads), | 99 : RasterWorkerPool(resource_provider, num_threads), |
| 99 shutdown_(false), | 100 shutdown_(false), |
| 100 scheduled_raster_task_count_(0), | 101 scheduled_raster_task_count_(0), |
| 101 bytes_pending_upload_(0), | 102 bytes_pending_upload_(0), |
| 103 max_bytes_pending_upload_(max_bytes_pending_upload), |
| 102 has_performed_uploads_since_last_flush_(false), | 104 has_performed_uploads_since_last_flush_(false), |
| 103 check_for_completed_raster_tasks_pending_(false), | 105 check_for_completed_raster_tasks_pending_(false), |
| 104 should_notify_client_if_no_tasks_are_pending_(false), | 106 should_notify_client_if_no_tasks_are_pending_(false), |
| 105 should_notify_client_if_no_tasks_required_for_activation_are_pending_( | 107 should_notify_client_if_no_tasks_required_for_activation_are_pending_( |
| 106 false) { | 108 false) { |
| 107 // If we raster too fast we become upload bound, and pending | |
| 108 // uploads consume memory. For maximum upload throughput, we would | |
| 109 // want to allow for upload_throughput * pipeline_time of pending | |
| 110 // uploads, after which we are just wasting memory. Since we don't | |
| 111 // know our upload throughput yet, this just caps our memory usage. | |
| 112 #if defined(OS_ANDROID) | |
| 113 size_t divider = 1; | |
| 114 if (base::android::SysUtils::IsLowEndDevice()) | |
| 115 divider = 3; | |
| 116 | |
| 117 // For reference Nexus10 can upload 1MB in about 2.5ms. | |
| 118 const size_t kMaxBytesUploadedPerMs = (2 * 1024 * 1024) / (5 * divider); | |
| 119 #else | |
| 120 // For reference Chromebook Pixel can upload 1MB in about 0.5ms. | |
| 121 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; | |
| 122 #endif | |
| 123 | |
| 124 // Assuming a two frame deep pipeline. | |
| 125 max_bytes_pending_upload_ = 16 * 2 * kMaxBytesUploadedPerMs; | |
| 126 } | 109 } |
| 127 | 110 |
| 128 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { | 111 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { |
| 129 DCHECK(shutdown_); | 112 DCHECK(shutdown_); |
| 130 DCHECK(!check_for_completed_raster_tasks_pending_); | 113 DCHECK(!check_for_completed_raster_tasks_pending_); |
| 131 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); | 114 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); |
| 132 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); | 115 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); |
| 133 DCHECK_EQ(0u, completed_tasks_.size()); | 116 DCHECK_EQ(0u, completed_tasks_.size()); |
| 134 } | 117 } |
| 135 | 118 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 673 |
| 691 throttle_state->SetInteger("bytes_available_for_upload", | 674 throttle_state->SetInteger("bytes_available_for_upload", |
| 692 max_bytes_pending_upload_ - bytes_pending_upload_); | 675 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 693 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 676 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 694 throttle_state->SetInteger("scheduled_raster_task_count", | 677 throttle_state->SetInteger("scheduled_raster_task_count", |
| 695 scheduled_raster_task_count_); | 678 scheduled_raster_task_count_); |
| 696 return throttle_state.PassAs<base::Value>(); | 679 return throttle_state.PassAs<base::Value>(); |
| 697 } | 680 } |
| 698 | 681 |
| 699 } // namespace cc | 682 } // namespace cc |
| OLD | NEW |