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

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

Issue 15779009: Get correct GLVersion for Mesa to avoid GrContext creation failure (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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') | no next file » | 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
(...skipping 29 matching lines...) Expand all
40 GrPrintf("---- glGetError 0x%x(%s)", err, get_error_string(err)); 40 GrPrintf("---- glGetError 0x%x(%s)", err, get_error_string(err));
41 if (NULL != location) { 41 if (NULL != location) {
42 GrPrintf(" at\n\t%s", location); 42 GrPrintf(" at\n\t%s", location);
43 } 43 }
44 if (NULL != call) { 44 if (NULL != call) {
45 GrPrintf("\n\t\t%s", call); 45 GrPrintf("\n\t\t%s", call);
46 } 46 }
47 GrPrintf("\n"); 47 GrPrintf("\n");
48 } 48 }
49 } 49 }
50 50
robertphillips 2013/05/28 13:38:55 return bool rather than int? May be an informativ
51 int getMesaGLVersion(const int mesaMajorVersion, int* major, int* minor) {
52 switch (mesaMajorVersion) {
53 case 2:
54 case 3:
55 case 4:
56 case 5:
57 case 6:
58 *major = 1;
59 *minor = mesaMajorVersion - 1;
60 return 1;
61 case 7:
62 *major = 2;
63 *minor = 1;
64 return 1;
65 case 8:
66 *major = 3;
67 *minor = 0;
68 return 1;
69 case 9:
70 *major = 3;
71 *minor = 1;
72 return 1;
73 default:
robertphillips 2013/05/28 13:38:55 weird spacing here?
74 return 0;
75 }
76 }
77
51 /////////////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////////////
52 79
53 #if GR_GL_LOG_CALLS 80 #if GR_GL_LOG_CALLS
54 bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START); 81 bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START);
55 #endif 82 #endif
56 83
57 #if GR_GL_CHECK_ERROR 84 #if GR_GL_CHECK_ERROR
58 bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START); 85 bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START);
59 #endif 86 #endif
60 87
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 119 }
93 120
94 GrGLVersion GrGLGetVersionFromString(const char* versionString) { 121 GrGLVersion GrGLGetVersionFromString(const char* versionString) {
95 if (NULL == versionString) { 122 if (NULL == versionString) {
96 GrAssert(!"NULL GL version string."); 123 GrAssert(!"NULL GL version string.");
97 return 0; 124 return 0;
98 } 125 }
99 126
100 int major, minor; 127 int major, minor;
101 128
102 int n = sscanf(versionString, "%d.%d", &major, &minor); 129 // check for mesa
130 int mesaMajor, mesaMinor;
131 int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor,
132 &mesaMajor, &mesaMinor);
133 if (4 == n) {
134 if (getMesaGLVersion(mesaMajor, &major, &minor)) {
135 return GR_GL_VER(major, minor);
136 } else {
137 return 0;
138 }
139 }
140
141 n = sscanf(versionString, "%d.%d", &major, &minor);
103 if (2 == n) { 142 if (2 == n) {
104 return GR_GL_VER(major, minor); 143 return GR_GL_VER(major, minor);
105 } 144 }
106 145
107 char profile[2]; 146 char profile[2];
108 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, 147 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1,
109 &major, &minor); 148 &major, &minor);
110 if (4 == n) { 149 if (4 == n) {
111 return GR_GL_VER(major, minor); 150 return GR_GL_VER(major, minor);
112 } 151 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const GrGLubyte* v; 218 const GrGLubyte* v;
180 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); 219 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
181 return GrGLGetGLSLVersionFromString((const char*) v); 220 return GrGLGetGLSLVersionFromString((const char*) v);
182 } 221 }
183 222
184 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { 223 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) {
185 const GrGLubyte* v; 224 const GrGLubyte* v;
186 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); 225 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR));
187 return GrGLGetVendorFromString((const char*) v); 226 return GrGLGetVendorFromString((const char*) v);
188 } 227 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLUtil.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698