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

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

Issue 176843022: Move UTF16ToASCII, remove WideToASCII. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « device/serial/serial_device_enumerator_win.cc ('k') | net/cert/x509_certificate_win.cc » ('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 "gpu/config/gpu_info_collector.h" 5 #include "gpu/config/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_util.h" 18 #include "base/file_util.h"
19 #include "base/files/file_enumerator.h" 19 #include "base/files/file_enumerator.h"
20 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/metrics/field_trial.h" 23 #include "base/metrics/field_trial.h"
24 #include "base/metrics/histogram.h" 24 #include "base/metrics/histogram.h"
25 #include "base/scoped_native_library.h" 25 #include "base/scoped_native_library.h"
26 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
27 #include "base/strings/string_number_conversions.h" 27 #include "base/strings/string_number_conversions.h"
28 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
29 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
30 #include "base/strings/utf_string_conversions.h"
30 #include "base/threading/thread.h" 31 #include "base/threading/thread.h"
31 #include "base/threading/worker_pool.h" 32 #include "base/threading/worker_pool.h"
32 #include "base/win/registry.h" 33 #include "base/win/registry.h"
33 #include "base/win/scoped_com_initializer.h" 34 #include "base/win/scoped_com_initializer.h"
34 #include "base/win/scoped_comptr.h" 35 #include "base/win/scoped_comptr.h"
35 #include "base/win/windows_version.h" 36 #include "base/win/windows_version.h"
36 #include "third_party/libxml/chromium/libxml_utils.h" 37 #include "third_party/libxml/chromium/libxml_utils.h"
37 #include "ui/gl/gl_implementation.h" 38 #include "ui/gl/gl_implementation.h"
38 #include "ui/gl/gl_surface_egl.h" 39 #include "ui/gl/gl_surface_egl.h"
39 40
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (key.OpenKey(L"DisplayLink", KEY_READ | KEY_WOW64_64KEY)) 180 if (key.OpenKey(L"DisplayLink", KEY_READ | KEY_WOW64_64KEY))
180 return Version(); 181 return Version();
181 182
182 if (key.OpenKey(L"Core", KEY_READ | KEY_WOW64_64KEY)) 183 if (key.OpenKey(L"Core", KEY_READ | KEY_WOW64_64KEY))
183 return Version(); 184 return Version();
184 185
185 base::string16 version; 186 base::string16 version;
186 if (key.ReadValue(L"Version", &version)) 187 if (key.ReadValue(L"Version", &version))
187 return Version(); 188 return Version();
188 189
189 return Version(WideToASCII(version)); 190 return Version(base::UTF16ToASCII(version));
190 } 191 }
191 192
192 // Returns whether Lenovo dCute is installed. 193 // Returns whether Lenovo dCute is installed.
193 bool IsLenovoDCuteInstalled() { 194 bool IsLenovoDCuteInstalled() {
194 base::win::RegKey key; 195 base::win::RegKey key;
195 196
196 if (key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE", KEY_READ | KEY_WOW64_64KEY)) 197 if (key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE", KEY_READ | KEY_WOW64_64KEY))
197 return false; 198 return false;
198 199
199 if (key.OpenKey(L"Lenovo", KEY_READ | KEY_WOW64_64KEY)) 200 if (key.OpenKey(L"Lenovo", KEY_READ | KEY_WOW64_64KEY))
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 driver_key += value; 401 driver_key += value;
401 LONG result = RegOpenKeyExW( 402 LONG result = RegOpenKeyExW(
402 HKEY_LOCAL_MACHINE, driver_key.c_str(), 0, KEY_QUERY_VALUE, &key); 403 HKEY_LOCAL_MACHINE, driver_key.c_str(), 0, KEY_QUERY_VALUE, &key);
403 if (result == ERROR_SUCCESS) { 404 if (result == ERROR_SUCCESS) {
404 DWORD dwcb_data = sizeof(value); 405 DWORD dwcb_data = sizeof(value);
405 std::string driver_version; 406 std::string driver_version;
406 result = RegQueryValueExW( 407 result = RegQueryValueExW(
407 key, L"DriverVersion", NULL, NULL, 408 key, L"DriverVersion", NULL, NULL,
408 reinterpret_cast<LPBYTE>(value), &dwcb_data); 409 reinterpret_cast<LPBYTE>(value), &dwcb_data);
409 if (result == ERROR_SUCCESS) 410 if (result == ERROR_SUCCESS)
410 driver_version = WideToASCII(std::wstring(value)); 411 driver_version = base::UTF16ToASCII(std::wstring(value));
411 412
412 std::string driver_date; 413 std::string driver_date;
413 dwcb_data = sizeof(value); 414 dwcb_data = sizeof(value);
414 result = RegQueryValueExW( 415 result = RegQueryValueExW(
415 key, L"DriverDate", NULL, NULL, 416 key, L"DriverDate", NULL, NULL,
416 reinterpret_cast<LPBYTE>(value), &dwcb_data); 417 reinterpret_cast<LPBYTE>(value), &dwcb_data);
417 if (result == ERROR_SUCCESS) 418 if (result == ERROR_SUCCESS)
418 driver_date = WideToASCII(std::wstring(value)); 419 driver_date = base::UTF16ToASCII(std::wstring(value));
419 420
420 std::string driver_vendor; 421 std::string driver_vendor;
421 dwcb_data = sizeof(value); 422 dwcb_data = sizeof(value);
422 result = RegQueryValueExW( 423 result = RegQueryValueExW(
423 key, L"ProviderName", NULL, NULL, 424 key, L"ProviderName", NULL, NULL,
424 reinterpret_cast<LPBYTE>(value), &dwcb_data); 425 reinterpret_cast<LPBYTE>(value), &dwcb_data);
425 if (result == ERROR_SUCCESS) { 426 if (result == ERROR_SUCCESS) {
426 driver_vendor = WideToASCII(std::wstring(value)); 427 driver_vendor = base::UTF16ToASCII(std::wstring(value));
427 if (driver_vendor == "Advanced Micro Devices, Inc." || 428 if (driver_vendor == "Advanced Micro Devices, Inc." ||
428 driver_vendor == "ATI Technologies Inc.") { 429 driver_vendor == "ATI Technologies Inc.") {
429 // We are conservative and assume that in the absence of a clear 430 // We are conservative and assume that in the absence of a clear
430 // signal the videocard is assumed to be switchable. Additionally, 431 // signal the videocard is assumed to be switchable. Additionally,
431 // some switchable systems with Intel GPUs aren't correctly 432 // some switchable systems with Intel GPUs aren't correctly
432 // detected, so always count them. 433 // detected, so always count them.
433 AMDVideoCardType amd_card_type = GetAMDVideocardType(); 434 AMDVideoCardType amd_card_type = GetAMDVideocardType();
434 gpu_info->amd_switchable = (gpu_info->gpu.vendor_id == 0x8086) || 435 gpu_info->amd_switchable = (gpu_info->gpu.vendor_id == 0x8086) ||
435 (amd_card_type != STANDALONE); 436 (amd_card_type != STANDALONE);
436 } 437 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { 531 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
531 id = dd.DeviceID; 532 id = dd.DeviceID;
532 break; 533 break;
533 } 534 }
534 } 535 }
535 536
536 if (id.length() > 20) { 537 if (id.length() > 20) {
537 int vendor = 0, device = 0; 538 int vendor = 0, device = 0;
538 std::wstring vendor_string = id.substr(8, 4); 539 std::wstring vendor_string = id.substr(8, 4);
539 std::wstring device_string = id.substr(17, 4); 540 std::wstring device_string = id.substr(17, 4);
540 base::HexStringToInt(WideToASCII(vendor_string), &vendor); 541 base::HexStringToInt(base::UTF16ToASCII(vendor_string), &vendor);
541 base::HexStringToInt(WideToASCII(device_string), &device); 542 base::HexStringToInt(base::UTF16ToASCII(device_string), &device);
542 *vendor_id = vendor; 543 *vendor_id = vendor;
543 *device_id = device; 544 *device_id = device;
544 return kGpuIDSuccess; 545 return kGpuIDSuccess;
545 } 546 }
546 return kGpuIDFailure; 547 return kGpuIDFailure;
547 } 548 }
548 549
549 bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) { 550 bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
550 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo"); 551 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo");
551 552
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 break; 586 break;
586 } 587 }
587 } 588 }
588 589
589 if (id.length() <= 20) 590 if (id.length() <= 20)
590 return false; 591 return false;
591 592
592 int vendor_id = 0, device_id = 0; 593 int vendor_id = 0, device_id = 0;
593 base::string16 vendor_id_string = id.substr(8, 4); 594 base::string16 vendor_id_string = id.substr(8, 4);
594 base::string16 device_id_string = id.substr(17, 4); 595 base::string16 device_id_string = id.substr(17, 4);
595 base::HexStringToInt(WideToASCII(vendor_id_string), &vendor_id); 596 base::HexStringToInt(base::UTF16ToASCII(vendor_id_string), &vendor_id);
596 base::HexStringToInt(WideToASCII(device_id_string), &device_id); 597 base::HexStringToInt(base::UTF16ToASCII(device_id_string), &device_id);
597 gpu_info->gpu.vendor_id = vendor_id; 598 gpu_info->gpu.vendor_id = vendor_id;
598 gpu_info->gpu.device_id = device_id; 599 gpu_info->gpu.device_id = device_id;
599 // TODO(zmo): we only need to call CollectDriverInfoD3D() if we use ANGLE. 600 // TODO(zmo): we only need to call CollectDriverInfoD3D() if we use ANGLE.
600 if (!CollectDriverInfoD3D(id, gpu_info)) 601 if (!CollectDriverInfoD3D(id, gpu_info))
601 return false; 602 return false;
602 603
603 // Collect basic information about supported D3D11 features. Delay for 45 604 // Collect basic information about supported D3D11 features. Delay for 45
604 // seconds so as not to regress performance tests. 605 // seconds so as not to regress performance tests.
605 if (D3D11ShouldWork(*gpu_info)) { 606 if (D3D11ShouldWork(*gpu_info)) {
606 // This is on a field trial so we can turn it off easily if it blows up 607 // This is on a field trial so we can turn it off easily if it blows up
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 basic_gpu_info->software_rendering = true; 645 basic_gpu_info->software_rendering = true;
645 return; 646 return;
646 } 647 }
647 648
648 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); 649 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
649 650
650 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; 651 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics;
651 } 652 }
652 653
653 } // namespace gpu 654 } // namespace gpu
OLDNEW
« no previous file with comments | « device/serial/serial_device_enumerator_win.cc ('k') | net/cert/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698