Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 22900018: cc: Set the mapped memory reclaim limit for the renderer compositor on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
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
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 ContextProvider* context_provider)
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),
102 has_performed_uploads_since_last_flush_(false), 105 has_performed_uploads_since_last_flush_(false),
103 check_for_completed_raster_tasks_pending_(false), 106 check_for_completed_raster_tasks_pending_(false),
104 should_notify_client_if_no_tasks_are_pending_(false), 107 should_notify_client_if_no_tasks_are_pending_(false),
105 should_notify_client_if_no_tasks_required_for_activation_are_pending_( 108 should_notify_client_if_no_tasks_required_for_activation_are_pending_(
106 false) { 109 false) {
107 // If we raster too fast we become upload bound, and pending 110 if (context_provider != NULL) {
108 // uploads consume memory. For maximum upload throughput, we would 111 max_bytes_pending_upload_ =
109 // want to allow for upload_throughput * pipeline_time of pending 112 context_provider->ContextCapabilities().max_transfer_buffer_usage_bytes;
110 // uploads, after which we are just wasting memory. Since we don't 113 } else {
111 // know our upload throughput yet, this just caps our memory usage. 114 // For unit tests:
danakj 2013/08/29 20:10:28 // Software compositing should not use this path i
danakj 2013/08/29 20:10:28 reveman@ can we #if !defined(UNIT_TEST) => NOT_REA
kaanb 2013/08/30 01:11:35 Done.
112 #if defined(OS_ANDROID) 115 // TODO(kaanb): make this a static const somewhere?
danakj 2013/08/29 20:10:28 No idea where. If reveman@ has an idea let's do th
kaanb 2013/08/30 01:11:35 Done.
113 size_t divider = 1; 116 max_bytes_pending_upload_ = std::numeric_limits<size_t>::max();
114 if (base::android::SysUtils::IsLowEndDevice()) 117 }
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 } 118 }
127 119
128 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { 120 PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() {
129 DCHECK(shutdown_); 121 DCHECK(shutdown_);
130 DCHECK(!check_for_completed_raster_tasks_pending_); 122 DCHECK(!check_for_completed_raster_tasks_pending_);
131 DCHECK_EQ(0u, pixel_buffer_tasks_.size()); 123 DCHECK_EQ(0u, pixel_buffer_tasks_.size());
132 DCHECK_EQ(0u, tasks_with_pending_upload_.size()); 124 DCHECK_EQ(0u, tasks_with_pending_upload_.size());
133 DCHECK_EQ(0u, completed_tasks_.size()); 125 DCHECK_EQ(0u, completed_tasks_.size());
134 } 126 }
135 127
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 682
691 throttle_state->SetInteger("bytes_available_for_upload", 683 throttle_state->SetInteger("bytes_available_for_upload",
692 max_bytes_pending_upload_ - bytes_pending_upload_); 684 max_bytes_pending_upload_ - bytes_pending_upload_);
693 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 685 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
694 throttle_state->SetInteger("scheduled_raster_task_count", 686 throttle_state->SetInteger("scheduled_raster_task_count",
695 scheduled_raster_task_count_); 687 scheduled_raster_task_count_);
696 return throttle_state.PassAs<base::Value>(); 688 return throttle_state.PassAs<base::Value>();
697 } 689 }
698 690
699 } // namespace cc 691 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698