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 "content/public/browser/gpu_utils.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/strings/string_number_conversions.h" | |
9 #include "content/public/common/content_switches.h" | |
10 #include "gpu/command_buffer/service/gpu_switches.h" | |
11 #include "gpu/config/gpu_switches.h" | |
12 #include "ui/gl/gl_switches.h" | |
13 | |
14 namespace { | |
15 | |
16 bool GetUintFromSwitch(const base::CommandLine* command_line, | |
17 const base::StringPiece& switch_string, | |
18 uint32_t* value) { | |
19 if (!command_line->HasSwitch(switch_string)) | |
20 return false; | |
21 std::string switch_value(command_line->GetSwitchValueASCII(switch_string)); | |
22 return base::StringToUint(switch_value, value); | |
23 } | |
24 | |
25 } // namespace | |
26 | |
27 namespace content { | |
28 | |
29 const gpu::GpuPreferences GetGpuPreferencesFromCommandLine() { | |
30 DCHECK(base::CommandLine::InitializedForCurrentProcess()); | |
31 const base::CommandLine* command_line = | |
32 base::CommandLine::ForCurrentProcess(); | |
33 gpu::GpuPreferences gpu_preferences; | |
34 gpu_preferences.single_process = | |
35 command_line->HasSwitch(switches::kSingleProcess); | |
36 gpu_preferences.in_process_gpu = | |
37 command_line->HasSwitch(switches::kInProcessGPU); | |
38 gpu_preferences.ui_prioritize_in_gpu_process = | |
39 command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess); | |
40 gpu_preferences.compile_shader_always_succeeds = | |
41 command_line->HasSwitch(switches::kCompileShaderAlwaysSucceeds); | |
42 gpu_preferences.disable_gl_error_limit = | |
43 command_line->HasSwitch(switches::kDisableGLErrorLimit); | |
44 gpu_preferences.disable_glsl_translator = | |
45 command_line->HasSwitch(switches::kDisableGLSLTranslator); | |
46 gpu_preferences.disable_gpu_driver_bug_workarounds = | |
47 command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds); | |
48 gpu_preferences.disable_shader_name_hashing = | |
49 command_line->HasSwitch(switches::kDisableShaderNameHashing); | |
50 gpu_preferences.enable_gpu_command_logging = | |
51 command_line->HasSwitch(switches::kEnableGPUCommandLogging); | |
52 gpu_preferences.enable_gpu_debugging = | |
53 command_line->HasSwitch(switches::kEnableGPUDebugging); | |
54 gpu_preferences.enable_gpu_service_logging_gpu = | |
55 command_line->HasSwitch(switches::kEnableGPUServiceLoggingGPU); | |
56 gpu_preferences.disable_gpu_program_cache = | |
57 command_line->HasSwitch(switches::kDisableGpuProgramCache); | |
58 gpu_preferences.enforce_gl_minimums = | |
59 command_line->HasSwitch(switches::kEnforceGLMinimums); | |
60 if (GetUintFromSwitch(command_line, switches::kForceGpuMemAvailableMb, | |
61 &gpu_preferences.force_gpu_mem_available)) { | |
62 gpu_preferences.force_gpu_mem_available *= 1024 * 1024; | |
63 } | |
64 if (GetUintFromSwitch(command_line, switches::kGpuProgramCacheSizeKb, | |
65 &gpu_preferences.gpu_program_cache_size)) { | |
66 gpu_preferences.gpu_program_cache_size *= 1024; | |
67 } | |
68 gpu_preferences.enable_share_group_async_texture_upload = | |
69 command_line->HasSwitch(switches::kEnableShareGroupAsyncTextureUpload); | |
70 gpu_preferences.enable_subscribe_uniform_extension = | |
71 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); | |
72 gpu_preferences.enable_threaded_texture_mailboxes = | |
73 command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); | |
74 gpu_preferences.gl_shader_interm_output = | |
75 command_line->HasSwitch(switches::kGLShaderIntermOutput); | |
76 gpu_preferences.emulate_shader_precision = | |
77 command_line->HasSwitch(switches::kEmulateShaderPrecision); | |
78 gpu_preferences.enable_gpu_service_logging = | |
79 command_line->HasSwitch(switches::kEnableGPUServiceLogging); | |
80 gpu_preferences.enable_gpu_service_tracing = | |
81 command_line->HasSwitch(switches::kEnableGPUServiceTracing); | |
82 gpu_preferences.enable_unsafe_es3_apis = | |
83 command_line->HasSwitch(switches::kEnableUnsafeES3APIs); | |
84 return gpu_preferences; | |
85 } | |
86 | |
87 } // namespace content | |
OLD | NEW |