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 "chrome/browser/gpu/gl_string_manager.h" | 5 #include "chrome/browser/gpu/gl_string_manager.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
9 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
10 #include "components/prefs/pref_registry_simple.h" | 11 #include "components/prefs/pref_registry_simple.h" |
11 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
12 #include "content/public/browser/gpu_data_manager.h" | 13 #include "content/public/browser/gpu_data_manager.h" |
| 14 #include "gpu/config/gpu_switches.h" |
13 | 15 |
14 // static | 16 // static |
15 void GLStringManager::RegisterPrefs(PrefRegistrySimple* registry) { | 17 void GLStringManager::RegisterPrefs(PrefRegistrySimple* registry) { |
16 registry->RegisterStringPref(prefs::kGLVendorString, std::string()); | 18 registry->RegisterStringPref(prefs::kGLVendorString, std::string()); |
17 registry->RegisterStringPref(prefs::kGLRendererString, std::string()); | 19 registry->RegisterStringPref(prefs::kGLRendererString, std::string()); |
18 registry->RegisterStringPref(prefs::kGLVersionString, std::string()); | 20 registry->RegisterStringPref(prefs::kGLVersionString, std::string()); |
19 } | 21 } |
20 | 22 |
21 GLStringManager::GLStringManager() { | 23 GLStringManager::GLStringManager() { |
22 } | 24 } |
23 | 25 |
24 GLStringManager::~GLStringManager() { | 26 GLStringManager::~GLStringManager() { |
25 } | 27 } |
26 | 28 |
27 void GLStringManager::Initialize() { | 29 void GLStringManager::Initialize() { |
28 // On MacOSX or Windows, preliminary GPUInfo is enough. | 30 // On MacOSX or Windows, preliminary GPUInfo is enough. |
29 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
30 // We never remove this observer from GpuDataManager. | 32 // We never remove this observer from GpuDataManager. |
31 content::GpuDataManager::GetInstance()->AddObserver(this); | 33 content::GpuDataManager::GetInstance()->AddObserver(this); |
32 | 34 |
33 PrefService* local_state = g_browser_process->local_state(); | 35 PrefService* local_state = g_browser_process->local_state(); |
34 if (!local_state) | 36 if (!local_state) |
35 return; | 37 return; |
36 | 38 |
37 gl_vendor_ = local_state->GetString(prefs::kGLVendorString); | 39 gl_vendor_ = local_state->GetString(prefs::kGLVendorString); |
38 gl_renderer_ = local_state->GetString(prefs::kGLRendererString); | 40 gl_renderer_ = local_state->GetString(prefs::kGLRendererString); |
39 gl_version_ = local_state->GetString(prefs::kGLVersionString); | 41 gl_version_ = local_state->GetString(prefs::kGLVersionString); |
40 | 42 |
| 43 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 44 |
| 45 if (command_line->HasSwitch(switches::kGpuTestingGLVendor)) { |
| 46 gl_vendor_ = |
| 47 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVendor); |
| 48 } |
| 49 |
| 50 if (command_line->HasSwitch(switches::kGpuTestingGLRenderer)) { |
| 51 gl_renderer_ = |
| 52 command_line->GetSwitchValueASCII(switches::kGpuTestingGLRenderer); |
| 53 } |
| 54 |
| 55 if (command_line->HasSwitch(switches::kGpuTestingGLVersion)) { |
| 56 gl_version_ = |
| 57 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVersion); |
| 58 } |
| 59 |
41 if (!gl_vendor_.empty() || !gl_renderer_.empty() || !gl_version_.empty()) { | 60 if (!gl_vendor_.empty() || !gl_renderer_.empty() || !gl_version_.empty()) { |
42 content::GpuDataManager::GetInstance()->SetGLStrings( | 61 content::GpuDataManager::GetInstance()->SetGLStrings( |
43 gl_vendor_, gl_renderer_, gl_version_); | 62 gl_vendor_, gl_renderer_, gl_version_); |
44 } | 63 } |
45 #endif | 64 #endif |
46 } | 65 } |
47 | 66 |
48 void GLStringManager::OnGpuInfoUpdate() { | 67 void GLStringManager::OnGpuInfoUpdate() { |
49 std::string gl_vendor, gl_renderer, gl_version; | 68 std::string gl_vendor, gl_renderer, gl_version; |
50 content::GpuDataManager::GetInstance()->GetGLStrings( | 69 content::GpuDataManager::GetInstance()->GetGLStrings( |
(...skipping 10 matching lines...) Expand all Loading... |
61 if (!gl_renderer.empty() && gl_renderer != gl_renderer_) { | 80 if (!gl_renderer.empty() && gl_renderer != gl_renderer_) { |
62 gl_renderer_ = gl_renderer; | 81 gl_renderer_ = gl_renderer; |
63 local_state->SetString(prefs::kGLRendererString, gl_renderer_); | 82 local_state->SetString(prefs::kGLRendererString, gl_renderer_); |
64 } | 83 } |
65 if (!gl_version.empty() && gl_version != gl_version_) { | 84 if (!gl_version.empty() && gl_version != gl_version_) { |
66 gl_version_ = gl_version; | 85 gl_version_ = gl_version; |
67 local_state->SetString(prefs::kGLVersionString, gl_version_); | 86 local_state->SetString(prefs::kGLVersionString, gl_version_); |
68 } | 87 } |
69 } | 88 } |
70 | 89 |
OLD | NEW |