OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/gpu/gpu_info_collector.h" | 5 #include "chrome/gpu/gpu_info_collector.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "app/gfx/gl/gl_bindings.h" | 10 #include "app/gfx/gl/gl_bindings.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 bool CollectGraphicsInfo(GPUInfo* gpu_info) { | 46 bool CollectGraphicsInfo(GPUInfo* gpu_info) { |
47 DCHECK(gpu_info); | 47 DCHECK(gpu_info); |
48 | 48 |
49 gpu_info->SetCanLoseContext( | 49 gpu_info->SetCanLoseContext( |
50 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); | 50 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); |
51 gpu_info->SetLevel(GPUInfo::kComplete); | 51 gpu_info->SetLevel(GPUInfo::kComplete); |
52 return CollectGraphicsInfoGL(gpu_info); | 52 return CollectGraphicsInfoGL(gpu_info); |
53 } | 53 } |
54 | 54 |
| 55 bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { |
| 56 DCHECK(gpu_info); |
| 57 |
| 58 gpu_info->SetLevel(GPUInfo::kPartial); |
| 59 |
| 60 bool rt = true; |
| 61 if (!CollectVideoCardInfo(gpu_info)) |
| 62 rt = false; |
| 63 |
| 64 return rt; |
| 65 } |
| 66 |
55 bool CollectVideoCardInfo(GPUInfo* gpu_info) { | 67 bool CollectVideoCardInfo(GPUInfo* gpu_info) { |
56 DCHECK(gpu_info); | 68 DCHECK(gpu_info); |
57 | 69 |
58 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) | |
59 return false; | |
60 | |
61 UInt32 vendor_id = 0, device_id = 0; | 70 UInt32 vendor_id = 0, device_id = 0; |
62 io_registry_entry_t dsp_port = CGDisplayIOServicePort(kCGDirectMainDisplay); | 71 io_registry_entry_t dsp_port = CGDisplayIOServicePort(kCGDirectMainDisplay); |
63 CFTypeRef vendor_id_ref = SearchPortForProperty(dsp_port, CFSTR("vendor-id")); | 72 CFTypeRef vendor_id_ref = SearchPortForProperty(dsp_port, CFSTR("vendor-id")); |
64 if (vendor_id_ref) { | 73 if (vendor_id_ref) { |
65 vendor_id = IntValueOfCFData((CFDataRef)vendor_id_ref); | 74 vendor_id = IntValueOfCFData((CFDataRef)vendor_id_ref); |
66 CFRelease(vendor_id_ref); | 75 CFRelease(vendor_id_ref); |
67 } | 76 } |
68 CFTypeRef device_id_ref = SearchPortForProperty(dsp_port, CFSTR("device-id")); | 77 CFTypeRef device_id_ref = SearchPortForProperty(dsp_port, CFSTR("device-id")); |
69 if (device_id_ref) { | 78 if (device_id_ref) { |
70 device_id = IntValueOfCFData((CFDataRef)device_id_ref); | 79 device_id = IntValueOfCFData((CFDataRef)device_id_ref); |
(...skipping 13 matching lines...) Expand all Loading... |
84 // Use some jiggery-pokery to turn that utf8 string into a std::wstring. | 93 // Use some jiggery-pokery to turn that utf8 string into a std::wstring. |
85 std::string gl_version_string = gpu_info->gl_version_string(); | 94 std::string gl_version_string = gpu_info->gl_version_string(); |
86 size_t pos = gl_version_string.find_last_of('-'); | 95 size_t pos = gl_version_string.find_last_of('-'); |
87 if (pos == std::string::npos) | 96 if (pos == std::string::npos) |
88 return false; | 97 return false; |
89 gpu_info->SetDriverInfo("", gl_version_string.substr(pos + 1)); | 98 gpu_info->SetDriverInfo("", gl_version_string.substr(pos + 1)); |
90 return true; | 99 return true; |
91 } | 100 } |
92 | 101 |
93 } // namespace gpu_info_collector | 102 } // namespace gpu_info_collector |
OLD | NEW |