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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return s_found; | 74 return s_found; |
75 } | 75 } |
76 | 76 |
77 // Gets the numeric HLSL version. | 77 // Gets the numeric HLSL version. |
78 // You pass it the current GL major version, to give it a hint where to look. | 78 // You pass it the current GL major version, to give it a hint where to look. |
79 static int GetShaderNumericVersion(int gl_major_version) { | 79 static int GetShaderNumericVersion(int gl_major_version) { |
80 int gl_hlsl_major = 0, gl_hlsl_minor = 0; | 80 int gl_hlsl_major = 0, gl_hlsl_minor = 0; |
81 int shader_version = 0; | 81 int shader_version = 0; |
82 | 82 |
83 if (gl_major_version == 1) { | 83 if (gl_major_version == 1) { |
84 const char *gl_extensions_string = (const char*)glGetString(GL_EXTENSIONS); | 84 char *gl_extensions_string = (char*)glGetString(GL_EXTENSIONS); |
85 if (gl_extensions_string && | 85 if (strstr(gl_extensions_string, "GL_ARB_shading_language_100")) { |
86 strstr(gl_extensions_string, "GL_ARB_shading_language_100")) { | |
87 gl_hlsl_major = 1; | 86 gl_hlsl_major = 1; |
88 gl_hlsl_minor = 0; | 87 gl_hlsl_minor = 0; |
89 } | 88 } |
90 } else if (gl_major_version > 1) { | 89 } else if (gl_major_version > 1) { |
91 const char *glsl_version_string = | 90 char *glsl_version_string = (char*)glGetString(GL_SHADING_LANGUAGE_VERSION); |
92 (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); | |
93 if (glsl_version_string) | 91 if (glsl_version_string) |
94 sscanf(glsl_version_string, "%u.%u", &gl_hlsl_major, &gl_hlsl_minor); | 92 sscanf(glsl_version_string, "%u.%u", &gl_hlsl_major, &gl_hlsl_minor); |
95 } | 93 } |
96 | 94 |
97 shader_version = (gl_hlsl_major << 8) | (gl_hlsl_minor & 0xFF); | 95 shader_version = (gl_hlsl_major << 8) | (gl_hlsl_minor & 0xFF); |
98 return shader_version; | 96 return shader_version; |
99 } | 97 } |
100 | 98 |
101 | 99 |
102 static std::wstring CStringToWString(const char *s) { | 100 static std::wstring CStringToWString(const char *s) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 shader_version, | 162 shader_version, |
165 gl_version, | 163 gl_version, |
166 false); | 164 false); |
167 | 165 |
168 gpu_info->SetProgress(GPUInfo::kComplete); | 166 gpu_info->SetProgress(GPUInfo::kComplete); |
169 | 167 |
170 return true; | 168 return true; |
171 } | 169 } |
172 | 170 |
173 } // namespace gpu_info_collector | 171 } // namespace gpu_info_collector |
OLD | NEW |