Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "gpu/command_buffer/service/gpu_preferences.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/strings/string_number_conversions.h" | |
| 10 #include "gpu/command_buffer/service/gpu_switches.h" | |
| 11 #include "gpu/config/gpu_switches.h" | |
| 12 #include "gpu/config/gpu_util.h" | |
| 13 #include "ui/gl/gl_switches.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 bool GetSizeTFromSwitch(const base::CommandLine* command_line, | |
| 18 const base::StringPiece& switch_string, | |
| 19 size_t* value) { | |
| 20 if (!command_line->HasSwitch(switch_string)) | |
| 21 return false; | |
| 22 std::string switch_value(command_line->GetSwitchValueASCII(switch_string)); | |
| 23 return base::StringToSizeT(switch_value, value); | |
| 24 } | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 namespace gpu { | |
| 29 | |
| 30 GpuPreferences* GpuPreferences::GetInstance() { | |
| 31 return base::Singleton<GpuPreferences>::get(); | |
| 32 } | |
| 33 | |
| 34 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.
| |
| 35 if (!base::CommandLine::InitializedForCurrentProcess()) | |
| 36 return; | |
| 37 | |
| 38 const base::CommandLine* command_line = | |
| 39 base::CommandLine::ForCurrentProcess(); | |
| 40 | |
| 41 StringToFeatureSet( | |
| 42 command_line->GetSwitchValueASCII(switches::kGpuDriverBugWorkarounds), | |
| 43 &gpu_driver_bug_workarounds); | |
| 44 compile_shader_always_succeeds = | |
| 45 command_line->HasSwitch(switches::kCompileShaderAlwaysSucceeds); | |
| 46 disable_gl_error_limit = | |
| 47 command_line->HasSwitch(switches::kDisableGLErrorLimit); | |
| 48 disable_glsl_translator = | |
| 49 command_line->HasSwitch(switches::kDisableGLSLTranslator); | |
| 50 disable_gpu_driver_bug_workarounds = | |
| 51 command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds); | |
| 52 disable_shader_name_hashing = | |
| 53 command_line->HasSwitch(switches::kDisableShaderNameHashing); | |
| 54 enable_gpu_command_logging = | |
| 55 command_line->HasSwitch(switches::kEnableGPUCommandLogging); | |
| 56 enable_gpu_debugging = | |
| 57 command_line->HasSwitch(switches::kEnableGPUDebugging); | |
| 58 enable_gpu_service_logging_gpu = | |
| 59 command_line->HasSwitch(switches::kEnableGPUServiceLoggingGPU); | |
| 60 disable_gpu_program_cache = | |
| 61 command_line->HasSwitch(switches::kDisableGpuProgramCache); | |
| 62 enforce_gl_minimums = | |
| 63 command_line->HasSwitch(switches::kEnforceGLMinimums); | |
| 64 if (GetSizeTFromSwitch(command_line, switches::kForceGpuMemAvailableMb, | |
| 65 &force_gpu_mem_available)) { | |
| 66 force_gpu_mem_available *= 1024 * 1024; | |
| 67 } | |
| 68 if (GetSizeTFromSwitch(command_line, switches::kGpuProgramCacheSizeKb, | |
| 69 &gpu_program_cache_size)) { | |
| 70 gpu_program_cache_size *= 1024; | |
| 71 } | |
| 72 enable_share_group_async_texture_upload = | |
| 73 command_line->HasSwitch(switches::kEnableShareGroupAsyncTextureUpload); | |
| 74 enable_subscribe_uniform_extension = | |
| 75 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); | |
| 76 enable_threaded_texture_mailboxes = | |
| 77 command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); | |
| 78 gl_shader_interm_output = | |
| 79 command_line->HasSwitch(switches::kGLShaderIntermOutput); | |
| 80 emulate_shader_precision = | |
| 81 command_line->HasSwitch(switches::kEmulateShaderPrecision); | |
| 82 enable_gl_path_rendering = | |
| 83 command_line->HasSwitch(switches::kEnableGLPathRendering); | |
| 84 enable_unsafe_es3_apis = | |
| 85 command_line->HasSwitch(switches::kEnableUnsafeES3APIs); | |
| 86 } | |
| 87 | |
| 88 GpuPreferences::~GpuPreferences() {} | |
| 89 | |
| 90 } // namespace gpu | |
| OLD | NEW |