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/sys_string_conversions.h" | 6 #include "base/sys_string_conversions.h" |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 #import <IOKit/IOKitLib.h> | 10 #import <IOKit/IOKitLib.h> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 CFTypeRef vendorIDRef = SearchPortForProperty(dspPort, CFSTR("vendor-id")); | 48 CFTypeRef vendorIDRef = SearchPortForProperty(dspPort, CFSTR("vendor-id")); |
49 if (vendorID) *vendorID = IntValueOfCFData((CFDataRef)vendorIDRef); | 49 if (vendorID) *vendorID = IntValueOfCFData((CFDataRef)vendorIDRef); |
50 | 50 |
51 CFTypeRef deviceIDRef = SearchPortForProperty(dspPort, CFSTR("device-id")); | 51 CFTypeRef deviceIDRef = SearchPortForProperty(dspPort, CFSTR("device-id")); |
52 if (deviceID) *deviceID = IntValueOfCFData((CFDataRef)deviceIDRef); | 52 if (deviceID) *deviceID = IntValueOfCFData((CFDataRef)deviceIDRef); |
53 | 53 |
54 CFReleaseIf(vendorIDRef); | 54 CFReleaseIf(vendorIDRef); |
55 CFReleaseIf(deviceIDRef); | 55 CFReleaseIf(deviceIDRef); |
56 } | 56 } |
57 | 57 |
| 58 // TODO(maf): uncomment when using code below is re-enabled. |
| 59 /* |
58 // Return a pointer to the last character with value c in string s. | 60 // Return a pointer to the last character with value c in string s. |
59 // Returns NULL if c is not found. | 61 // Returns NULL if c is not found. |
60 static char* FindLastChar(char *s, char c) { | 62 static char* FindLastChar(char *s, char c) { |
61 char *s_found = NULL; | 63 char *s_found = NULL; |
62 | 64 |
63 while (*s != '\0') { | 65 while (*s != '\0') { |
64 if (*s == c) | 66 if (*s == c) |
65 s_found = s; | 67 s_found = s; |
66 s++; | 68 s++; |
67 } | 69 } |
68 return s_found; | 70 return s_found; |
69 } | 71 } |
| 72 */ |
70 | 73 |
71 | 74 |
72 bool CollectGraphicsInfo(GPUInfo& gpu_info) { | 75 bool CollectGraphicsInfo(GPUInfo& gpu_info) { |
73 int vendor_id = 0; | 76 int vendor_id = 0; |
74 int device_id = 0; | 77 int device_id = 0; |
75 std::wstring driver_version = L""; | 78 std::wstring driver_version = L""; |
76 uint32 pixel_shader_version = 0u; | 79 uint32 pixel_shader_version = 0u; |
77 uint32 vertex_shader_version = 0u; | 80 uint32 vertex_shader_version = 0u; |
78 uint32 gl_version; | 81 uint32 gl_version = 0u; |
79 | 82 |
80 CollectVideoCardInfo(kCGDirectMainDisplay, &vendor_id, &device_id); | 83 CollectVideoCardInfo(kCGDirectMainDisplay, &vendor_id, &device_id); |
81 | 84 |
| 85 // TODO(maf): when this is called, there is no OpenGL context |
| 86 // current, so calls to glGetString crash. |
| 87 /* |
82 char *gl_version_string = (char*)glGetString(GL_VERSION); | 88 char *gl_version_string = (char*)glGetString(GL_VERSION); |
83 char *gl_extensions_string = (char*)glGetString(GL_EXTENSIONS); | 89 char *gl_extensions_string = (char*)glGetString(GL_EXTENSIONS); |
84 | 90 |
85 if ((gl_version_string == NULL) || (gl_extensions_string == NULL)) | 91 if ((gl_version_string == NULL) || (gl_extensions_string == NULL)) |
86 return false; | 92 return false; |
87 | 93 |
88 // Get the OpenGL version from the start of the string. | 94 // Get the OpenGL version from the start of the string. |
89 int gl_major = 0, gl_minor = 0; | 95 int gl_major = 0, gl_minor = 0; |
90 sscanf(gl_version_string, "%u.%u", &gl_major, &gl_minor); | 96 sscanf(gl_version_string, "%u.%u", &gl_major, &gl_minor); |
91 | 97 |
(...skipping 25 matching lines...) Expand all Loading... |
117 } | 123 } |
118 pixel_shader_version = ((gl_hlsl_major << 16) & 0xffff0000) | 124 pixel_shader_version = ((gl_hlsl_major << 16) & 0xffff0000) |
119 + (gl_hlsl_minor & 0x0000ffff); | 125 + (gl_hlsl_minor & 0x0000ffff); |
120 | 126 |
121 // OpenGL doesn't have separate versions for pixel and vertex shader | 127 // OpenGL doesn't have separate versions for pixel and vertex shader |
122 // languages, so set them both to the GL_SHADING_LANGUAGE_VERSION value. | 128 // languages, so set them both to the GL_SHADING_LANGUAGE_VERSION value. |
123 vertex_shader_version = pixel_shader_version; | 129 vertex_shader_version = pixel_shader_version; |
124 | 130 |
125 gl_version = ((gl_major << 16) & 0xffff0000) | 131 gl_version = ((gl_major << 16) & 0xffff0000) |
126 + (gl_minor & 0x0000ffff); | 132 + (gl_minor & 0x0000ffff); |
| 133 */ |
127 | 134 |
128 gpu_info.SetGraphicsInfo(vendor_id, device_id, driver_version, | 135 gpu_info.SetGraphicsInfo(vendor_id, device_id, driver_version, |
129 pixel_shader_version, vertex_shader_version, | 136 pixel_shader_version, vertex_shader_version, |
130 gl_version); | 137 gl_version); |
131 return true; | 138 return true; |
132 } | 139 } |
133 | 140 |
134 } // namespace gpu_info_collector | 141 } // namespace gpu_info_collector |
OLD | NEW |