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

Side by Side Diff: src/gpu/gl/GrGLUtil.cpp

Issue 12328111: Use glGetStringi to get extensions when available. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | « src/gpu/gl/GrGLUtil.h ('k') | src/gpu/gl/SkGLContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGLUtil.h" 9 #include "GrGLUtil.h"
10 10
11
12 void GrGLClearErr(const GrGLInterface* gl) { 11 void GrGLClearErr(const GrGLInterface* gl) {
13 while (GR_GL_NO_ERROR != gl->fGetError()) {} 12 while (GR_GL_NO_ERROR != gl->fGetError()) {}
14 } 13 }
15 14
16 namespace { 15 namespace {
17 const char *get_error_string(uint32_t err) { 16 const char *get_error_string(uint32_t err) {
18 switch (err) { 17 switch (err) {
19 case GR_GL_NO_ERROR: 18 case GR_GL_NO_ERROR:
20 return ""; 19 return "";
21 case GR_GL_INVALID_ENUM: 20 case GR_GL_INVALID_ENUM:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // android hack until the gpu vender updates their drivers 141 // android hack until the gpu vender updates their drivers
143 n = sscanf(versionString, "OpenGL ES GLSL %d.%d", &major, &minor); 142 n = sscanf(versionString, "OpenGL ES GLSL %d.%d", &major, &minor);
144 if (2 == n) { 143 if (2 == n) {
145 return GR_GLSL_VER(major, minor); 144 return GR_GLSL_VER(major, minor);
146 } 145 }
147 #endif 146 #endif
148 147
149 return 0; 148 return 0;
150 } 149 }
151 150
152 bool GrGLHasExtensionFromString(const char* ext, const char* extensionString) {
153 int extLength = strlen(ext);
154
155 while (true) {
156 int n = strcspn(extensionString, " ");
157 if (n == extLength && 0 == strncmp(ext, extensionString, n)) {
158 return true;
159 }
160 if (0 == extensionString[n]) {
161 return false;
162 }
163 extensionString += n+1;
164 }
165
166 return false;
167 }
168
169 GrGLVendor GrGLGetVendorFromString(const char* vendorString) { 151 GrGLVendor GrGLGetVendorFromString(const char* vendorString) {
170 if (NULL != vendorString) { 152 if (NULL != vendorString) {
171 if (0 == strcmp(vendorString, "ARM")) { 153 if (0 == strcmp(vendorString, "ARM")) {
172 return kARM_GrGLVendor; 154 return kARM_GrGLVendor;
173 } 155 }
174 if (0 == strcmp(vendorString, "Imagination Technologies")) { 156 if (0 == strcmp(vendorString, "Imagination Technologies")) {
175 return kImagination_GrGLVendor; 157 return kImagination_GrGLVendor;
176 } 158 }
177 if (0 == strcmp(vendorString, "Intel")) { 159 if (0 == strcmp(vendorString, "Intel")) {
178 return kIntel_GrGLVendor; 160 return kIntel_GrGLVendor;
179 } 161 }
180 } 162 }
181 return kOther_GrGLVendor; 163 return kOther_GrGLVendor;
182 } 164 }
183 165
184 bool GrGLHasExtension(const GrGLInterface* gl, const char* ext) {
185 const GrGLubyte* glstr;
186 GR_GL_CALL_RET(gl, glstr, GetString(GR_GL_EXTENSIONS));
187 return GrGLHasExtensionFromString(ext, (const char*) glstr);
188 }
189
190 GrGLBinding GrGLGetBindingInUse(const GrGLInterface* gl) { 166 GrGLBinding GrGLGetBindingInUse(const GrGLInterface* gl) {
191 const GrGLubyte* v; 167 const GrGLubyte* v;
192 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION)); 168 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION));
193 return GrGLGetBindingInUseFromString((const char*) v); 169 return GrGLGetBindingInUseFromString((const char*) v);
194 } 170 }
195 171
196 GrGLVersion GrGLGetVersion(const GrGLInterface* gl) { 172 GrGLVersion GrGLGetVersion(const GrGLInterface* gl) {
197 const GrGLubyte* v; 173 const GrGLubyte* v;
198 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION)); 174 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION));
199 return GrGLGetVersionFromString((const char*) v); 175 return GrGLGetVersionFromString((const char*) v);
200 } 176 }
201 177
202 GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface* gl) { 178 GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface* gl) {
203 const GrGLubyte* v; 179 const GrGLubyte* v;
204 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); 180 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
205 return GrGLGetGLSLVersionFromString((const char*) v); 181 return GrGLGetGLSLVersionFromString((const char*) v);
206 } 182 }
207 183
208 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { 184 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) {
209 const GrGLubyte* v; 185 const GrGLubyte* v;
210 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); 186 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR));
211 return GrGLGetVendorFromString((const char*) v); 187 return GrGLGetVendorFromString((const char*) v);
212 } 188 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLUtil.h ('k') | src/gpu/gl/SkGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698