OLD | NEW |
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 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return 4 == n; | 133 return 4 == n; |
134 } | 134 } |
135 | 135 |
136 bool GrGLIsChromiumFromRendererString(const char* rendererString) { | 136 bool GrGLIsChromiumFromRendererString(const char* rendererString) { |
137 return 0 == strcmp(rendererString, "Chromium"); | 137 return 0 == strcmp(rendererString, "Chromium"); |
138 } | 138 } |
139 | 139 |
140 GrGLVersion GrGLGetVersionFromString(const char* versionString) { | 140 GrGLVersion GrGLGetVersionFromString(const char* versionString) { |
141 if (NULL == versionString) { | 141 if (NULL == versionString) { |
142 SkDEBUGFAIL("NULL GL version string."); | 142 SkDEBUGFAIL("NULL GL version string."); |
143 return 0; | 143 return GR_GL_INVALID_VER; |
144 } | 144 } |
145 | 145 |
146 int major, minor; | 146 int major, minor; |
147 | 147 |
148 // check for mesa | 148 // check for mesa |
149 int mesaMajor, mesaMinor; | 149 int mesaMajor, mesaMinor; |
150 int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, &mesaMajor
, &mesaMinor); | 150 int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, &mesaMajor
, &mesaMinor); |
151 if (4 == n) { | 151 if (4 == n) { |
152 if (get_gl_version_for_mesa(mesaMajor, &major, &minor)) { | 152 if (get_gl_version_for_mesa(mesaMajor, &major, &minor)) { |
153 return GR_GL_VER(major, minor); | 153 return GR_GL_VER(major, minor); |
154 } else { | 154 } else { |
155 return 0; | 155 return GR_GL_INVALID_VER; |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 n = sscanf(versionString, "%d.%d", &major, &minor); | 159 n = sscanf(versionString, "%d.%d", &major, &minor); |
160 if (2 == n) { | 160 if (2 == n) { |
161 return GR_GL_VER(major, minor); | 161 return GR_GL_VER(major, minor); |
162 } | 162 } |
163 | 163 |
164 char profile[2]; | 164 char profile[2]; |
165 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, | 165 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, |
166 &major, &minor); | 166 &major, &minor); |
167 if (4 == n) { | 167 if (4 == n) { |
168 return GR_GL_VER(major, minor); | 168 return GR_GL_VER(major, minor); |
169 } | 169 } |
170 | 170 |
171 n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor); | 171 n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor); |
172 if (2 == n) { | 172 if (2 == n) { |
173 return GR_GL_VER(major, minor); | 173 return GR_GL_VER(major, minor); |
174 } | 174 } |
175 | 175 |
176 return 0; | 176 return GR_GL_INVALID_VER; |
177 } | 177 } |
178 | 178 |
179 GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) { | 179 GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) { |
180 if (NULL == versionString) { | 180 if (NULL == versionString) { |
181 SkDEBUGFAIL("NULL GLSL version string."); | 181 SkDEBUGFAIL("NULL GLSL version string."); |
182 return 0; | 182 return GR_GLSL_INVALID_VER; |
183 } | 183 } |
184 | 184 |
185 int major, minor; | 185 int major, minor; |
186 | 186 |
187 int n = sscanf(versionString, "%d.%d", &major, &minor); | 187 int n = sscanf(versionString, "%d.%d", &major, &minor); |
188 if (2 == n) { | 188 if (2 == n) { |
189 return GR_GLSL_VER(major, minor); | 189 return GR_GLSL_VER(major, minor); |
190 } | 190 } |
191 | 191 |
192 n = sscanf(versionString, "OpenGL ES GLSL ES %d.%d", &major, &minor); | 192 n = sscanf(versionString, "OpenGL ES GLSL ES %d.%d", &major, &minor); |
193 if (2 == n) { | 193 if (2 == n) { |
194 return GR_GLSL_VER(major, minor); | 194 return GR_GLSL_VER(major, minor); |
195 } | 195 } |
196 | 196 |
197 #ifdef SK_BUILD_FOR_ANDROID | 197 #ifdef SK_BUILD_FOR_ANDROID |
198 // android hack until the gpu vender updates their drivers | 198 // android hack until the gpu vender updates their drivers |
199 n = sscanf(versionString, "OpenGL ES GLSL %d.%d", &major, &minor); | 199 n = sscanf(versionString, "OpenGL ES GLSL %d.%d", &major, &minor); |
200 if (2 == n) { | 200 if (2 == n) { |
201 return GR_GLSL_VER(major, minor); | 201 return GR_GLSL_VER(major, minor); |
202 } | 202 } |
203 #endif | 203 #endif |
204 | 204 |
205 return 0; | 205 return GR_GLSL_INVALID_VER; |
206 } | 206 } |
207 | 207 |
208 GrGLVendor GrGLGetVendorFromString(const char* vendorString) { | 208 GrGLVendor GrGLGetVendorFromString(const char* vendorString) { |
209 if (NULL != vendorString) { | 209 if (NULL != vendorString) { |
210 if (0 == strcmp(vendorString, "ARM")) { | 210 if (0 == strcmp(vendorString, "ARM")) { |
211 return kARM_GrGLVendor; | 211 return kARM_GrGLVendor; |
212 } | 212 } |
213 if (0 == strcmp(vendorString, "Imagination Technologies")) { | 213 if (0 == strcmp(vendorString, "Imagination Technologies")) { |
214 return kImagination_GrGLVendor; | 214 return kImagination_GrGLVendor; |
215 } | 215 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 dest[9] = 0; | 293 dest[9] = 0; |
294 dest[10] = 1; | 294 dest[10] = 1; |
295 dest[11] = 0; | 295 dest[11] = 0; |
296 | 296 |
297 // Col 3 | 297 // Col 3 |
298 dest[12] = SkScalarToFloat(src[SkMatrix::kMTransX]); | 298 dest[12] = SkScalarToFloat(src[SkMatrix::kMTransX]); |
299 dest[13] = SkScalarToFloat(src[SkMatrix::kMTransY]); | 299 dest[13] = SkScalarToFloat(src[SkMatrix::kMTransY]); |
300 dest[14] = 0; | 300 dest[14] = 0; |
301 dest[15] = SkScalarToFloat(src[SkMatrix::kMPersp2]); | 301 dest[15] = SkScalarToFloat(src[SkMatrix::kMPersp2]); |
302 } | 302 } |
OLD | NEW |