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 <limits> | |
danakj
2013/09/03 17:18:57
not needed
kaanb
2013/09/03 20:43:11
Done.
| |
8 | |
7 #include "base/containers/stack_container.h" | 9 #include "base/containers/stack_container.h" |
8 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 #include "cc/debug/traced_value.h" | 12 #include "cc/debug/traced_value.h" |
11 #include "cc/resources/resource.h" | 13 #include "cc/resources/resource.h" |
12 #include "third_party/skia/include/core/SkBitmapDevice.h" | 14 #include "third_party/skia/include/core/SkBitmapDevice.h" |
13 | 15 |
14 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
15 #include "base/android/sys_utils.h" | 17 #include "base/android/sys_utils.h" |
16 #endif | 18 #endif |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 | 89 |
88 // Only used as std::find_if predicate for DCHECKs. | 90 // Only used as std::find_if predicate for DCHECKs. |
89 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { | 91 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { |
90 return task->WasCanceled(); | 92 return task->WasCanceled(); |
91 } | 93 } |
92 | 94 |
93 } // namespace | 95 } // namespace |
94 | 96 |
95 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( | 97 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( |
96 ResourceProvider* resource_provider, | 98 ResourceProvider* resource_provider, |
97 size_t num_threads) | 99 size_t num_threads, |
100 size_t max_bytes_pending_upload) | |
98 : RasterWorkerPool(resource_provider, num_threads), | 101 : RasterWorkerPool(resource_provider, num_threads), |
99 shutdown_(false), | 102 shutdown_(false), |
100 scheduled_raster_task_count_(0), | 103 scheduled_raster_task_count_(0), |
101 bytes_pending_upload_(0), | 104 bytes_pending_upload_(0), |
105 max_bytes_pending_upload_(max_bytes_pending_upload), | |
102 has_performed_uploads_since_last_flush_(false), | 106 has_performed_uploads_since_last_flush_(false), |
103 check_for_completed_raster_tasks_pending_(false), | 107 check_for_completed_raster_tasks_pending_(false), |
104 should_notify_client_if_no_tasks_are_pending_(false), | 108 should_notify_client_if_no_tasks_are_pending_(false), |
105 should_notify_client_if_no_tasks_required_for_activation_are_pending_( | 109 should_notify_client_if_no_tasks_required_for_activation_are_pending_( |
106 false) { | 110 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 } | 111 } |
127 | 112 |
128 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { | 113 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { |
129 DCHECK(shutdown_); | 114 DCHECK(shutdown_); |
130 DCHECK(!check_for_completed_raster_tasks_pending_); | 115 DCHECK(!check_for_completed_raster_tasks_pending_); |
131 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); | 116 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); |
132 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); | 117 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); |
133 DCHECK_EQ(0u, completed_tasks_.size()); | 118 DCHECK_EQ(0u, completed_tasks_.size()); |
134 } | 119 } |
135 | 120 |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 | 675 |
691 throttle_state->SetInteger("bytes_available_for_upload", | 676 throttle_state->SetInteger("bytes_available_for_upload", |
692 max_bytes_pending_upload_ - bytes_pending_upload_); | 677 max_bytes_pending_upload_ - bytes_pending_upload_); |
693 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 678 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
694 throttle_state->SetInteger("scheduled_raster_task_count", | 679 throttle_state->SetInteger("scheduled_raster_task_count", |
695 scheduled_raster_task_count_); | 680 scheduled_raster_task_count_); |
696 return throttle_state.PassAs<base::Value>(); | 681 return throttle_state.PassAs<base::Value>(); |
697 } | 682 } |
698 | 683 |
699 } // namespace cc | 684 } // namespace cc |
OLD | NEW |