| 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 | 11 |
| 11 void GrGLClearErr(const GrGLInterface* gl) { | 12 void GrGLClearErr(const GrGLInterface* gl) { |
| 12 while (GR_GL_NO_ERROR != gl->fGetError()) {} | 13 while (GR_GL_NO_ERROR != gl->fGetError()) {} |
| 13 } | 14 } |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 const char *get_error_string(uint32_t err) { | 17 const char *get_error_string(uint32_t err) { |
| 17 switch (err) { | 18 switch (err) { |
| 18 case GR_GL_NO_ERROR: | 19 case GR_GL_NO_ERROR: |
| 19 return ""; | 20 return ""; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 const GrGLubyte* v; | 230 const GrGLubyte* v; |
| 230 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); | 231 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); |
| 231 return GrGLGetGLSLVersionFromString((const char*) v); | 232 return GrGLGetGLSLVersionFromString((const char*) v); |
| 232 } | 233 } |
| 233 | 234 |
| 234 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { | 235 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { |
| 235 const GrGLubyte* v; | 236 const GrGLubyte* v; |
| 236 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); | 237 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); |
| 237 return GrGLGetVendorFromString((const char*) v); | 238 return GrGLGetVendorFromString((const char*) v); |
| 238 } | 239 } |
| 240 |
| 241 template<> void GrGLGetMatrix<3>(GrGLfloat* dest, const SkMatrix& src) { |
| 242 // Col 0 |
| 243 dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]); |
| 244 dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]); |
| 245 dest[2] = SkScalarToFloat(src[SkMatrix::kMPersp0]); |
| 246 |
| 247 // Col 1 |
| 248 dest[3] = SkScalarToFloat(src[SkMatrix::kMSkewX]); |
| 249 dest[4] = SkScalarToFloat(src[SkMatrix::kMScaleY]); |
| 250 dest[5] = SkScalarToFloat(src[SkMatrix::kMPersp1]); |
| 251 |
| 252 // Col 2 |
| 253 dest[6] = SkScalarToFloat(src[SkMatrix::kMTransX]); |
| 254 dest[7] = SkScalarToFloat(src[SkMatrix::kMTransY]); |
| 255 dest[8] = SkScalarToFloat(src[SkMatrix::kMPersp2]); |
| 256 } |
| 257 |
| 258 template<> void GrGLGetMatrix<4>(GrGLfloat* dest, const SkMatrix& src) { |
| 259 // Col 0 |
| 260 dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]); |
| 261 dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]); |
| 262 dest[2] = 0; |
| 263 dest[3] = SkScalarToFloat(src[SkMatrix::kMPersp0]); |
| 264 |
| 265 // Col 1 |
| 266 dest[4] = SkScalarToFloat(src[SkMatrix::kMSkewX]); |
| 267 dest[5] = SkScalarToFloat(src[SkMatrix::kMScaleY]); |
| 268 dest[6] = 0; |
| 269 dest[7] = SkScalarToFloat(src[SkMatrix::kMPersp1]); |
| 270 |
| 271 // Col 2 |
| 272 dest[8] = 0; |
| 273 dest[9] = 0; |
| 274 dest[10] = 1; |
| 275 dest[11] = 0; |
| 276 |
| 277 // Col 3 |
| 278 dest[12] = SkScalarToFloat(src[SkMatrix::kMTransX]); |
| 279 dest[13] = SkScalarToFloat(src[SkMatrix::kMTransY]); |
| 280 dest[14] = 0; |
| 281 dest[15] = SkScalarToFloat(src[SkMatrix::kMPersp2]); |
| 282 } |
| OLD | NEW |