| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #ifndef GrGLUtil_DEFINED | 8 #ifndef GrGLUtil_DEFINED |
| 9 #define GrGLUtil_DEFINED | 9 #define GrGLUtil_DEFINED |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // compile-time and run-time flags. | 165 // compile-time and run-time flags. |
| 166 #if GR_GL_LOG_CALLS | 166 #if GR_GL_LOG_CALLS |
| 167 extern bool gLogCallsGL; | 167 extern bool gLogCallsGL; |
| 168 #define GR_GL_LOG_CALLS_IMPL(X) \ | 168 #define GR_GL_LOG_CALLS_IMPL(X) \ |
| 169 if (gLogCallsGL) \ | 169 if (gLogCallsGL) \ |
| 170 SkDebugf(GR_FILE_AND_LINE_STR "GL: " #X "\n") | 170 SkDebugf(GR_FILE_AND_LINE_STR "GL: " #X "\n") |
| 171 #else | 171 #else |
| 172 #define GR_GL_LOG_CALLS_IMPL(X) | 172 #define GR_GL_LOG_CALLS_IMPL(X) |
| 173 #endif | 173 #endif |
| 174 | 174 |
| 175 // internal macro that does the per-GL-call callback (if necessary) | |
| 176 #if GR_GL_PER_GL_FUNC_CALLBACK | |
| 177 #define GR_GL_CALLBACK_IMPL(IFACE) (IFACE)->fCallback(IFACE) | |
| 178 #else | |
| 179 #define GR_GL_CALLBACK_IMPL(IFACE) | |
| 180 #endif | |
| 181 | |
| 182 // makes a GL call on the interface and does any error checking and logging | 175 // makes a GL call on the interface and does any error checking and logging |
| 183 #define GR_GL_CALL(IFACE, X) \ | 176 #define GR_GL_CALL(IFACE, X) \ |
| 184 do { \ | 177 do { \ |
| 185 GR_GL_CALL_NOERRCHECK(IFACE, X); \ | 178 GR_GL_CALL_NOERRCHECK(IFACE, X); \ |
| 186 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \ | 179 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \ |
| 187 } while (false) | 180 } while (false) |
| 188 | 181 |
| 189 // Variant of above that always skips the error check. This is useful when | 182 // Variant of above that always skips the error check. This is useful when |
| 190 // the caller wants to do its own glGetError() call and examine the error value. | 183 // the caller wants to do its own glGetError() call and examine the error value. |
| 191 #define GR_GL_CALL_NOERRCHECK(IFACE, X) \ | 184 #define GR_GL_CALL_NOERRCHECK(IFACE, X) \ |
| 192 do { \ | 185 do { \ |
| 193 GR_GL_CALLBACK_IMPL(IFACE); \ | |
| 194 (IFACE)->fFunctions.f##X; \ | 186 (IFACE)->fFunctions.f##X; \ |
| 195 GR_GL_LOG_CALLS_IMPL(X); \ | 187 GR_GL_LOG_CALLS_IMPL(X); \ |
| 196 } while (false) | 188 } while (false) |
| 197 | 189 |
| 198 // same as GR_GL_CALL but stores the return value of the gl call in RET | 190 // same as GR_GL_CALL but stores the return value of the gl call in RET |
| 199 #define GR_GL_CALL_RET(IFACE, RET, X) \ | 191 #define GR_GL_CALL_RET(IFACE, RET, X) \ |
| 200 do { \ | 192 do { \ |
| 201 GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \ | 193 GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \ |
| 202 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \ | 194 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \ |
| 203 } while (false) | 195 } while (false) |
| 204 | 196 |
| 205 // same as GR_GL_CALL_RET but always skips the error check. | 197 // same as GR_GL_CALL_RET but always skips the error check. |
| 206 #define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \ | 198 #define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \ |
| 207 do { \ | 199 do { \ |
| 208 GR_GL_CALLBACK_IMPL(IFACE); \ | |
| 209 (RET) = (IFACE)->fFunctions.f##X; \ | 200 (RET) = (IFACE)->fFunctions.f##X; \ |
| 210 GR_GL_LOG_CALLS_IMPL(X); \ | 201 GR_GL_LOG_CALLS_IMPL(X); \ |
| 211 } while (false) | 202 } while (false) |
| 212 | 203 |
| 213 // call glGetError without doing a redundant error check or logging. | 204 // call glGetError without doing a redundant error check or logging. |
| 214 #define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError() | 205 #define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError() |
| 215 | 206 |
| 216 GrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc); | 207 GrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc); |
| 217 | 208 |
| 218 | 209 |
| 219 #endif | 210 #endif |
| OLD | NEW |