Chromium Code Reviews| Index: gpu/command_buffer/service/gpu_preferences.cc |
| diff --git a/gpu/command_buffer/service/gpu_preferences.cc b/gpu/command_buffer/service/gpu_preferences.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f9b45480d8b41e5190ec4bed6290023777840677 |
| --- /dev/null |
| +++ b/gpu/command_buffer/service/gpu_preferences.cc |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "gpu/command_buffer/service/gpu_preferences.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/memory/singleton.h" |
| +#include "base/strings/string_number_conversions.h" |
| +#include "gpu/command_buffer/service/gpu_switches.h" |
| +#include "gpu/config/gpu_switches.h" |
| +#include "gpu/config/gpu_util.h" |
| +#include "ui/gl/gl_switches.h" |
| + |
| +namespace { |
| + |
| +bool GetSizeTFromSwitch(const base::CommandLine* command_line, |
| + const base::StringPiece& switch_string, |
| + size_t* value) { |
| + if (!command_line->HasSwitch(switch_string)) |
| + return false; |
| + std::string switch_value(command_line->GetSwitchValueASCII(switch_string)); |
| + return base::StringToSizeT(switch_value, value); |
| +} |
| + |
| +} // namespace |
| + |
| +namespace gpu { |
| + |
| +GpuPreferences* GpuPreferences::GetInstance() { |
| + return base::Singleton<GpuPreferences>::get(); |
| +} |
| + |
| +GpuPreferences::GpuPreferences() { |
|
Fady Samuel
2016/02/22 17:14:16
Drive-by: I don't think we want a global object he
Peng
2016/02/24 20:48:32
Done.
|
| + if (!base::CommandLine::InitializedForCurrentProcess()) |
| + return; |
| + |
| + const base::CommandLine* command_line = |
| + base::CommandLine::ForCurrentProcess(); |
| + |
| + StringToFeatureSet( |
| + command_line->GetSwitchValueASCII(switches::kGpuDriverBugWorkarounds), |
| + &gpu_driver_bug_workarounds); |
| + compile_shader_always_succeeds = |
| + command_line->HasSwitch(switches::kCompileShaderAlwaysSucceeds); |
| + disable_gl_error_limit = |
| + command_line->HasSwitch(switches::kDisableGLErrorLimit); |
| + disable_glsl_translator = |
| + command_line->HasSwitch(switches::kDisableGLSLTranslator); |
| + disable_gpu_driver_bug_workarounds = |
| + command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds); |
| + disable_shader_name_hashing = |
| + command_line->HasSwitch(switches::kDisableShaderNameHashing); |
| + enable_gpu_command_logging = |
| + command_line->HasSwitch(switches::kEnableGPUCommandLogging); |
| + enable_gpu_debugging = |
| + command_line->HasSwitch(switches::kEnableGPUDebugging); |
| + enable_gpu_service_logging_gpu = |
| + command_line->HasSwitch(switches::kEnableGPUServiceLoggingGPU); |
| + disable_gpu_program_cache = |
| + command_line->HasSwitch(switches::kDisableGpuProgramCache); |
| + enforce_gl_minimums = |
| + command_line->HasSwitch(switches::kEnforceGLMinimums); |
| + if (GetSizeTFromSwitch(command_line, switches::kForceGpuMemAvailableMb, |
| + &force_gpu_mem_available)) { |
| + force_gpu_mem_available *= 1024 * 1024; |
| + } |
| + if (GetSizeTFromSwitch(command_line, switches::kGpuProgramCacheSizeKb, |
| + &gpu_program_cache_size)) { |
| + gpu_program_cache_size *= 1024; |
| + } |
| + enable_share_group_async_texture_upload = |
| + command_line->HasSwitch(switches::kEnableShareGroupAsyncTextureUpload); |
| + enable_subscribe_uniform_extension = |
| + command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); |
| + enable_threaded_texture_mailboxes = |
| + command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); |
| + gl_shader_interm_output = |
| + command_line->HasSwitch(switches::kGLShaderIntermOutput); |
| + emulate_shader_precision = |
| + command_line->HasSwitch(switches::kEmulateShaderPrecision); |
| + enable_gl_path_rendering = |
| + command_line->HasSwitch(switches::kEnableGLPathRendering); |
| + enable_unsafe_es3_apis = |
| + command_line->HasSwitch(switches::kEnableUnsafeES3APIs); |
| +} |
| + |
| +GpuPreferences::~GpuPreferences() {} |
| + |
| +} // namespace gpu |