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 "content/gpu/gpu_info_collector.h" | 5 #include "content/gpu/gpu_info_collector.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <d3d9.h> | 8 #include <d3d9.h> |
9 #include <setupapi.h> | 9 #include <setupapi.h> |
10 #include <winsatcominterfacei.h> | 10 #include <winsatcominterfacei.h> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 driver_version = WideToASCII(std::wstring(value)); | 329 driver_version = WideToASCII(std::wstring(value)); |
330 | 330 |
331 std::string driver_date; | 331 std::string driver_date; |
332 dwcb_data = sizeof(value); | 332 dwcb_data = sizeof(value); |
333 result = RegQueryValueExW( | 333 result = RegQueryValueExW( |
334 key, L"DriverDate", NULL, NULL, | 334 key, L"DriverDate", NULL, NULL, |
335 reinterpret_cast<LPBYTE>(value), &dwcb_data); | 335 reinterpret_cast<LPBYTE>(value), &dwcb_data); |
336 if (result == ERROR_SUCCESS) | 336 if (result == ERROR_SUCCESS) |
337 driver_date = WideToASCII(std::wstring(value)); | 337 driver_date = WideToASCII(std::wstring(value)); |
338 | 338 |
339 std::string driver_vendor; | |
340 dwcb_data = sizeof(value); | |
341 result = RegQueryValueExW( | |
342 key, L"ProviderName", NULL, NULL, | |
343 reinterpret_cast<LPBYTE>(value), &dwcb_data); | |
344 if (result == ERROR_SUCCESS) { | |
345 driver_vendor = WideToASCII(std::wstring(value)); | |
346 // If it's an Intel GPU with a driver provided by AMD then it's | |
347 // probably AMD's Dynamic Switchable Graphics. | |
348 // TODO: detect only AMD switchable | |
349 gpu_info->amd_switchable = | |
350 driver_vendor == "Advanced Micro Devices, Inc." || | |
351 driver_vendor == "ATI Technologies Inc."; | |
352 } | |
353 | |
354 gpu_info->driver_vendor = driver_vendor; | |
355 gpu_info->driver_version = driver_version; | 339 gpu_info->driver_version = driver_version; |
356 gpu_info->driver_date = driver_date; | 340 gpu_info->driver_date = driver_date; |
357 found = true; | 341 found = true; |
358 RegCloseKey(key); | 342 RegCloseKey(key); |
359 break; | 343 break; |
360 } | 344 } |
361 } | 345 } |
362 } | 346 } |
363 fp_destroy_device_info_list(device_info); | 347 fp_destroy_device_info_list(device_info); |
364 FreeLibrary(lib_setupapi); | 348 FreeLibrary(lib_setupapi); |
(...skipping 10 matching lines...) Expand all Loading... |
375 | 359 |
376 size_t pos = gl_version_string.find_last_not_of("0123456789."); | 360 size_t pos = gl_version_string.find_last_not_of("0123456789."); |
377 if (pos != std::string::npos && pos < gl_version_string.length() - 1) { | 361 if (pos != std::string::npos && pos < gl_version_string.length() - 1) { |
378 gpu_info->driver_version = gl_version_string.substr(pos + 1); | 362 gpu_info->driver_version = gl_version_string.substr(pos + 1); |
379 return true; | 363 return true; |
380 } | 364 } |
381 return false; | 365 return false; |
382 } | 366 } |
383 | 367 |
384 } // namespace gpu_info_collector | 368 } // namespace gpu_info_collector |
OLD | NEW |