| 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 // Single-threaded mode in the renderer process (for layout tests) is | 220 // Single-threaded mode in the renderer process (for layout tests) is |
| 238 // synchronous, which depends on tiles being ready to draw when raster is | 221 // synchronous, which depends on tiles being ready to draw when raster is |
| 239 // complete. Therefore, it must use one of zero copy, software raster, or | 222 // complete. Therefore, it must use one of zero copy, software raster, or |
| 240 // GPU raster. So we force zero-copy on for the case where software/GPU raster | 223 // GPU raster. So we force zero-copy on for the case where software/GPU raster |
| 241 // is not used. | 224 // is not used. |
| 242 // TODO(reveman): One-copy can work with sync compositing: crbug.com/490295. | 225 // TODO(reveman): One-copy can work with sync compositing: crbug.com/490295. |
| 243 if (command_line.HasSwitch(switches::kDisableThreadedCompositing)) | 226 if (command_line.HasSwitch(switches::kDisableThreadedCompositing)) |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 } | 392 } |
| 410 } | 393 } |
| 411 return problem_list; | 394 return problem_list; |
| 412 } | 395 } |
| 413 | 396 |
| 414 std::vector<std::string> GetDriverBugWorkarounds() { | 397 std::vector<std::string> GetDriverBugWorkarounds() { |
| 415 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 398 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
| 416 } | 399 } |
| 417 | 400 |
| 418 } // namespace content | 401 } // namespace content |
| OLD | NEW |