OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/gpu/compositor_util.h" | 5 #include "content/browser/gpu/compositor_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 int num_processors = base::SysInfo::NumberOfProcessors(); | 184 int num_processors = base::SysInfo::NumberOfProcessors(); |
185 | 185 |
186 #if defined(OS_ANDROID) | 186 #if defined(OS_ANDROID) |
187 // Android may report 6 to 8 CPUs for big.LITTLE configurations. | 187 // Android may report 6 to 8 CPUs for big.LITTLE configurations. |
188 // Limit the number of raster threads based on maximum of 4 big cores. | 188 // Limit the number of raster threads based on maximum of 4 big cores. |
189 num_processors = std::min(num_processors, 4); | 189 num_processors = std::min(num_processors, 4); |
190 #endif | 190 #endif |
191 | 191 |
192 int num_raster_threads = num_processors / 2; | 192 int num_raster_threads = num_processors / 2; |
193 | 193 |
194 // Async uploads is used when neither zero-copy nor one-copy is enabled and | |
195 // it uses its own thread, so reduce the number of raster threads when async | |
196 // uploads is in use. | |
197 bool async_uploads_is_used = | |
198 !IsZeroCopyUploadEnabled() && !IsOneCopyUploadEnabled(); | |
199 if (async_uploads_is_used) | |
200 --num_raster_threads; | |
201 | |
202 #if defined(OS_ANDROID) | 194 #if defined(OS_ANDROID) |
203 // Limit the number of raster threads to 1 on Android. | 195 // Limit the number of raster threads to 1 on Android. |
204 // TODO(reveman): Remove this when we have a better mechanims to prevent | 196 // TODO(reveman): Remove this when we have a better mechanims to prevent |
205 // pre-paint raster work from slowing down non-raster work. crbug.com/504515 | 197 // pre-paint raster work from slowing down non-raster work. crbug.com/504515 |
206 num_raster_threads = 1; | 198 num_raster_threads = 1; |
207 #endif | 199 #endif |
208 | 200 |
209 const base::CommandLine& command_line = | 201 const base::CommandLine& command_line = |
210 *base::CommandLine::ForCurrentProcess(); | 202 *base::CommandLine::ForCurrentProcess(); |
211 | 203 |
212 if (command_line.HasSwitch(switches::kNumRasterThreads)) { | 204 if (command_line.HasSwitch(switches::kNumRasterThreads)) { |
213 std::string string_value = command_line.GetSwitchValueASCII( | 205 std::string string_value = command_line.GetSwitchValueASCII( |
214 switches::kNumRasterThreads); | 206 switches::kNumRasterThreads); |
215 if (!base::StringToInt(string_value, &num_raster_threads)) { | 207 if (!base::StringToInt(string_value, &num_raster_threads)) { |
216 DLOG(WARNING) << "Failed to parse switch " << | 208 DLOG(WARNING) << "Failed to parse switch " << |
217 switches::kNumRasterThreads << ": " << string_value; | 209 switches::kNumRasterThreads << ": " << string_value; |
218 } | 210 } |
219 } | 211 } |
220 | 212 |
221 return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads, | 213 return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads, |
222 kMaxRasterThreads); | 214 kMaxRasterThreads); |
223 } | 215 } |
224 | 216 |
225 bool IsOneCopyUploadEnabled() { | |
226 if (IsZeroCopyUploadEnabled()) | |
227 return false; | |
228 | |
229 const base::CommandLine& command_line = | |
230 *base::CommandLine::ForCurrentProcess(); | |
231 return !command_line.HasSwitch(switches::kDisableOneCopy); | |
232 } | |
233 | |
234 bool IsZeroCopyUploadEnabled() { | 217 bool IsZeroCopyUploadEnabled() { |
235 const base::CommandLine& command_line = | 218 const base::CommandLine& command_line = |
236 *base::CommandLine::ForCurrentProcess(); | 219 *base::CommandLine::ForCurrentProcess(); |
237 return command_line.HasSwitch(switches::kEnableZeroCopy); | 220 return command_line.HasSwitch(switches::kEnableZeroCopy); |
238 } | 221 } |
239 | 222 |
240 bool IsPersistentGpuMemoryBufferEnabled() { | 223 bool IsPersistentGpuMemoryBufferEnabled() { |
241 // Zero copy currently doesn't take advantage of persistent buffers. | 224 // Zero copy currently doesn't take advantage of persistent buffers. |
242 if (IsZeroCopyUploadEnabled()) | 225 if (IsZeroCopyUploadEnabled()) |
243 return false; | 226 return false; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 393 } |
411 } | 394 } |
412 return problem_list; | 395 return problem_list; |
413 } | 396 } |
414 | 397 |
415 std::vector<std::string> GetDriverBugWorkarounds() { | 398 std::vector<std::string> GetDriverBugWorkarounds() { |
416 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 399 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
417 } | 400 } |
418 | 401 |
419 } // namespace content | 402 } // namespace content |
OLD | NEW |