Chromium Code Reviews| Index: content/browser/gpu/compositor_util.cc |
| diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc |
| index a96cdeae4138e43adcfdccc3760e963dc2cce6a9..86227475a6f4cdb3129e3ce707379574e5a322da 100644 |
| --- a/content/browser/gpu/compositor_util.cc |
| +++ b/content/browser/gpu/compositor_util.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/strings/string_number_conversions.h" |
| #include "base/sys_info.h" |
| #include "build/build_config.h" |
| +#include "cc/base/math_util.h" |
| #include "cc/base/switches.h" |
| #include "content/browser/gpu/gpu_data_manager_impl.h" |
| #include "content/public/common/content_switches.h" |
| @@ -32,7 +33,7 @@ const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; |
| const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
| const int kMinRasterThreads = 1; |
| -const int kMaxRasterThreads = 64; |
| +const int kMaxRasterThreads = 16; |
| const int kMinMSAASampleCount = 0; |
| @@ -210,20 +211,30 @@ bool IsImplSidePaintingEnabled() { |
| } |
| int NumberOfRendererRasterThreads() { |
| - int num_raster_threads = 1; |
| + int num_raster_threads = base::SysInfo::NumberOfProcessors() / 2; |
| - // Async uploads uses its own thread, so allow an extra thread when async |
| - // uploads is not in use. |
| - bool allow_extra_thread = |
| + // Async uploads is used when neither zero-copy nor one-copy is enabled and |
| + // it uses its own thread, so reduce the number of raster threads when async |
| + // uploads is in use. |
| + bool async_uploads_is_used = |
| IsZeroCopyUploadEnabled() || IsOneCopyUploadEnabled(); |
|
vmpstr
2015/05/19 16:37:04
Is this condition supposed to be negated?
reveman
2015/05/19 16:40:31
Oops. I'll revert and re-land a fixed version of t
|
| - if (base::SysInfo::NumberOfProcessors() >= 4 && allow_extra_thread) |
| - num_raster_threads = 2; |
| + if (async_uploads_is_used) |
| + --num_raster_threads; |
| - int force_num_raster_threads = ForceNumberOfRendererRasterThreads(); |
| - if (force_num_raster_threads) |
| - num_raster_threads = force_num_raster_threads; |
| + const base::CommandLine& command_line = |
| + *base::CommandLine::ForCurrentProcess(); |
| - return num_raster_threads; |
| + if (command_line.HasSwitch(switches::kNumRasterThreads)) { |
| + std::string string_value = command_line.GetSwitchValueASCII( |
| + switches::kNumRasterThreads); |
| + if (!base::StringToInt(string_value, &num_raster_threads)) { |
| + DLOG(WARNING) << "Failed to parse switch " << |
| + switches::kNumRasterThreads << ": " << string_value; |
| + } |
| + } |
| + |
| + return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads, |
| + kMaxRasterThreads); |
| } |
| bool IsOneCopyUploadEnabled() { |
| @@ -249,26 +260,6 @@ bool IsZeroCopyUploadEnabled() { |
| return command_line.HasSwitch(switches::kEnableZeroCopy); |
| } |
| -int ForceNumberOfRendererRasterThreads() { |
| - const base::CommandLine& command_line = |
| - *base::CommandLine::ForCurrentProcess(); |
| - |
| - if (!command_line.HasSwitch(switches::kNumRasterThreads)) |
| - return 0; |
| - std::string string_value = |
| - command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
| - int force_num_raster_threads = 0; |
| - if (base::StringToInt(string_value, &force_num_raster_threads) && |
| - force_num_raster_threads >= kMinRasterThreads && |
| - force_num_raster_threads <= kMaxRasterThreads) { |
| - return force_num_raster_threads; |
| - } else { |
| - DLOG(WARNING) << "Failed to parse switch " << |
| - switches::kNumRasterThreads << ": " << string_value; |
| - return 0; |
| - } |
| -} |
| - |
| bool IsGpuRasterizationEnabled() { |
| const base::CommandLine& command_line = |
| *base::CommandLine::ForCurrentProcess(); |
| @@ -383,7 +374,9 @@ base::DictionaryValue* GetFeatureStatus() { |
| status += "_force"; |
| } |
| if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { |
| - if (ForceNumberOfRendererRasterThreads() > 0) |
| + const base::CommandLine& command_line = |
| + *base::CommandLine::ForCurrentProcess(); |
| + if (command_line.HasSwitch(switches::kNumRasterThreads)) |
| status += "_force"; |
| } |
| if (gpu_feature_info.name == kThreadedRasterizationFeatureName || |