Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: content/gpu/gpu_info_collector_win.cc

Issue 12632009: Merge 186345 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/gpu_internals_ui.cc ('k') | content/public/common/gpu_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/gpu/gpu_info_collector.h" 5 #include "content/gpu/gpu_info_collector.h"
6 6
7 // This has to be included before windows.h. 7 // This has to be included before windows.h.
8 #include "third_party/re2/re2/re2.h" 8 #include "third_party/re2/re2/re2.h"
9 9
10 #include <windows.h> 10 #include <windows.h>
11 #include <d3d9.h> 11 #include <d3d9.h>
12 #include <d3d11.h> 12 #include <d3d11.h>
13 #include <dxgi.h> 13 #include <dxgi.h>
14 #include <setupapi.h> 14 #include <setupapi.h>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/debug/trace_event.h" 17 #include "base/debug/trace_event.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/message_loop.h" 21 #include "base/message_loop.h"
22 #include "base/metrics/histogram.h" 22 #include "base/metrics/histogram.h"
23 #include "base/scoped_native_library.h" 23 #include "base/scoped_native_library.h"
24 #include "base/stringprintf.h" 24 #include "base/stringprintf.h"
25 #include "base/string_number_conversions.h" 25 #include "base/string_number_conversions.h"
26 #include "base/string_util.h" 26 #include "base/string_util.h"
27 #include "base/threading/worker_pool.h" 27 #include "base/threading/worker_pool.h"
28 #include "base/win/registry.h"
28 #include "base/win/scoped_com_initializer.h" 29 #include "base/win/scoped_com_initializer.h"
29 #include "base/win/scoped_comptr.h" 30 #include "base/win/scoped_comptr.h"
30 #include "base/win/windows_version.h" 31 #include "base/win/windows_version.h"
31 #include "third_party/libxml/chromium/libxml_utils.h" 32 #include "third_party/libxml/chromium/libxml_utils.h"
32 #include "ui/gl/gl_implementation.h" 33 #include "ui/gl/gl_implementation.h"
33 #include "ui/gl/gl_surface_egl.h" 34 #include "ui/gl/gl_surface_egl.h"
34 35
35 namespace { 36 namespace {
36 37
38 // This must be kept in sync with histograms.xml.
39 enum DisplayLinkInstallationStatus {
40 DISPLAY_LINK_NOT_INSTALLED,
41 DISPLAY_LINK_7_1_OR_EARLIER,
42 DISPLAY_LINK_7_2_OR_LATER,
43 DISPLAY_LINK_INSTALLATION_STATUS_MAX
44 };
45
37 float ReadXMLFloatValue(XmlReader* reader) { 46 float ReadXMLFloatValue(XmlReader* reader) {
38 std::string score_string; 47 std::string score_string;
39 if (!reader->ReadElementContent(&score_string)) 48 if (!reader->ReadElementContent(&score_string))
40 return 0.0; 49 return 0.0;
41 50
42 double score; 51 double score;
43 if (!base::StringToDouble(score_string, &score)) 52 if (!base::StringToDouble(score_string, &score))
44 return 0.0; 53 return 0.0;
45 54
46 return static_cast<float>(score); 55 return static_cast<float>(score);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 stats.graphics * 10, 10, 200, 50); 155 stats.graphics * 10, 10, 200, 50);
147 UMA_HISTOGRAM_CUSTOM_COUNTS("GPU.WinSAT.GamingScore2", 156 UMA_HISTOGRAM_CUSTOM_COUNTS("GPU.WinSAT.GamingScore2",
148 stats.gaming * 10, 10, 200, 50); 157 stats.gaming * 10, 10, 200, 50);
149 UMA_HISTOGRAM_BOOLEAN( 158 UMA_HISTOGRAM_BOOLEAN(
150 "GPU.WinSAT.HasResults", 159 "GPU.WinSAT.HasResults",
151 stats.overall != 0.0 && stats.graphics != 0.0 && stats.gaming != 0.0); 160 stats.overall != 0.0 && stats.graphics != 0.0 && stats.gaming != 0.0);
152 161
153 return stats; 162 return stats;
154 } 163 }
155 164
165 // Returns the display link driver version or an invalid version if it is
166 // not installed.
167 Version DisplayLinkVersion() {
168 base::win::RegKey key;
169
170 if (FAILED(key.Open(
171 HKEY_LOCAL_MACHINE, L"SOFTWARE", KEY_READ | KEY_WOW64_64KEY))) {
172 return Version();
173 }
174
175 if (FAILED(key.OpenKey(L"DisplayLink", KEY_READ | KEY_WOW64_64KEY)))
176 return Version();
177
178 if (FAILED(key.OpenKey(L"Core", KEY_READ | KEY_WOW64_64KEY)))
179 return Version();
180
181 string16 version;
182 if (FAILED(key.ReadValue(L"Version", &version)))
183 return Version();
184
185 return Version(WideToASCII(version));
186 }
156 } // namespace anonymous 187 } // namespace anonymous
157 188
158 namespace gpu_info_collector { 189 namespace gpu_info_collector {
159 190
160 #if !defined(GOOGLE_CHROME_BUILD) 191 #if !defined(GOOGLE_CHROME_BUILD)
161 AMDVideoCardType GetAMDVideocardType() { 192 AMDVideoCardType GetAMDVideocardType() {
162 return UNKNOWN; 193 return UNKNOWN;
163 } 194 }
164 #else 195 #else
165 // This function has a real implementation for official builds that can 196 // This function has a real implementation for official builds that can
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo"); 501 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo");
471 502
472 DCHECK(gpu_info); 503 DCHECK(gpu_info);
473 504
474 gpu_info->performance_stats = RetrieveGpuPerformanceStatsWithHistograms(); 505 gpu_info->performance_stats = RetrieveGpuPerformanceStatsWithHistograms();
475 506
476 // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled. 507 // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled.
477 HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll"); 508 HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll");
478 gpu_info->optimus = nvd3d9wrap != NULL; 509 gpu_info->optimus = nvd3d9wrap != NULL;
479 510
511 gpu_info->display_link_version = DisplayLinkVersion();
512
513 if (!gpu_info->display_link_version .IsValid()) {
514 UMA_HISTOGRAM_ENUMERATION("GPU.DisplayLinkInstallationStatus",
515 DISPLAY_LINK_NOT_INSTALLED,
516 DISPLAY_LINK_INSTALLATION_STATUS_MAX);
517 } else if (gpu_info->display_link_version.IsOlderThan("7.2")) {
518 UMA_HISTOGRAM_ENUMERATION("GPU.DisplayLinkInstallationStatus",
519 DISPLAY_LINK_7_1_OR_EARLIER,
520 DISPLAY_LINK_INSTALLATION_STATUS_MAX);
521 } else {
522 UMA_HISTOGRAM_ENUMERATION("GPU.DisplayLinkInstallationStatus",
523 DISPLAY_LINK_7_2_OR_LATER,
524 DISPLAY_LINK_INSTALLATION_STATUS_MAX);
525 }
526
480 // Taken from http://developer.nvidia.com/object/device_ids.html 527 // Taken from http://developer.nvidia.com/object/device_ids.html
481 DISPLAY_DEVICE dd; 528 DISPLAY_DEVICE dd;
482 dd.cb = sizeof(DISPLAY_DEVICE); 529 dd.cb = sizeof(DISPLAY_DEVICE);
483 std::wstring id; 530 std::wstring id;
484 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { 531 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) {
485 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { 532 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
486 id = dd.DeviceID; 533 id = dd.DeviceID;
487 break; 534 break;
488 } 535 }
489 } 536 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 basic_gpu_info->software_rendering = true; 570 basic_gpu_info->software_rendering = true;
524 return; 571 return;
525 } 572 }
526 573
527 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); 574 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
528 575
529 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; 576 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics;
530 } 577 }
531 578
532 } // namespace gpu_info_collector 579 } // namespace gpu_info_collector
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_internals_ui.cc ('k') | content/public/common/gpu_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698