19c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com/*
29c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com * Copyright 2012 Google Inc.
39c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com *
49c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com * Use of this source code is governed by a BSD-style license that can be
59c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com * found in the LICENSE file.
69c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com */
79c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
89c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#ifndef GrGLUtil_DEFINED
99c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#define GrGLUtil_DEFINED
109c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
119c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#include "gl/GrGLInterface.h"
1291bcc94e8710c1ec5126a31cd805a6c64bb3c39dbsalomon@google.com#include "GrGLDefines.h"
13ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen#include "GrStencil.h"
149c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
15215a682d2d561be69b7a28eb76a98849ad03cbc0commit-bot@chromium.orgclass SkMatrix;
16215a682d2d561be69b7a28eb76a98849ad03cbc0commit-bot@chromium.org
179c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com////////////////////////////////////////////////////////////////////////////////
189c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
199c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.comtypedef uint32_t GrGLVersion;
209c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.comtypedef uint32_t GrGLSLVersion;
211acea86914797bc33856ff62b5cdfbe82c58dd67cdaltontypedef uint32_t GrGLDriverVersion;
229c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
23f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org#define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
24f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org                                 static_cast<int>(minor))
25f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org#define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
26f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org                                   static_cast<int>(minor))
271acea86914797bc33856ff62b5cdfbe82c58dd67cdalton#define GR_GL_DRIVER_VER(major, minor) ((static_cast<int>(major) << 16) | \
281acea86914797bc33856ff62b5cdfbe82c58dd67cdalton                                        static_cast<int>(minor))
29f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org
30f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org#define GR_GL_INVALID_VER GR_GL_VER(0, 0)
311acea86914797bc33856ff62b5cdfbe82c58dd67cdalton#define GR_GLSL_INVALID_VER GR_GLSL_VER(0, 0)
321acea86914797bc33856ff62b5cdfbe82c58dd67cdalton#define GR_GL_DRIVER_UNKNOWN_VER GR_GL_DRIVER_VER(0, 0)
33f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org
340b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.com/**
350694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.org * The Vendor and Renderer enum values are lazily updated as required.
360b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.com */
370b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.comenum GrGLVendor {
3896966a5a1ffc2f03eef1b5523308299aa4195f50bsalomon@google.com    kARM_GrGLVendor,
393012ded0ffd152c41ef5c85d13e49116fee856ebbsalomon@google.com    kImagination_GrGLVendor,
403012ded0ffd152c41ef5c85d13e49116fee856ebbsalomon@google.com    kIntel_GrGLVendor,
417a434a28685fd045cf848b99b563dfcf978363bccommit-bot@chromium.org    kQualcomm_GrGLVendor,
42e904c09a3a9c701e8d91f2f6ee161feda7615d90bsalomon    kNVIDIA_GrGLVendor,
433012ded0ffd152c41ef5c85d13e49116fee856ebbsalomon@google.com
443012ded0ffd152c41ef5c85d13e49116fee856ebbsalomon@google.com    kOther_GrGLVendor
450b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.com};
460b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.com
470694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.orgenum GrGLRenderer {
486dee8759ab8c90dcffd76f114eec333405fd176ecommit-bot@chromium.org    kTegra2_GrGLRenderer,
490694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.org    kTegra3_GrGLRenderer,
5063b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon    kPowerVR54x_GrGLRenderer,
5163b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon    kPowerVRRogue_GrGLRenderer,
52a8fcea0cd09080de45143f2726059398cd8b8049bsalomon    kAdreno3xx_GrGLRenderer,
53a8fcea0cd09080de45143f2726059398cd8b8049bsalomon    kAdreno4xx_GrGLRenderer,
540694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.org    kOther_GrGLRenderer
550694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.org};
560694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.org
571acea86914797bc33856ff62b5cdfbe82c58dd67cdaltonenum GrGLDriver {
581acea86914797bc33856ff62b5cdfbe82c58dd67cdalton    kMesa_GrGLDriver,
591acea86914797bc33856ff62b5cdfbe82c58dd67cdalton    kChromium_GrGLDriver,
601acea86914797bc33856ff62b5cdfbe82c58dd67cdalton    kNVIDIA_GrGLDriver,
611dd0542ca37cf1b4a2ab0ea41f8009ded097fd47cdalton    kIntel_GrGLDriver,
6288c7b988ba7792e51e741567426069cd9cc852ddbsalomon    kANGLE_GrGLDriver,
631acea86914797bc33856ff62b5cdfbe82c58dd67cdalton    kUnknown_GrGLDriver
641acea86914797bc33856ff62b5cdfbe82c58dd67cdalton};
651acea86914797bc33856ff62b5cdfbe82c58dd67cdalton
669c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com////////////////////////////////////////////////////////////////////////////////
679c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
689c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com/**
699c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com *  Some drivers want the var-int arg to be zero-initialized on input.
709c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com */
719c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#define GR_GL_INIT_ZERO     0
729c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#define GR_GL_GetIntegerv(gl, e, p)                                            \
739c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    do {                                                                       \
749c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        *(p) = GR_GL_INIT_ZERO;                                                \
759c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        GR_GL_CALL(gl, GetIntegerv(e, p));                                     \
769c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    } while (0)
779c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
789c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p)          \
799c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    do {                                                                       \
809c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        *(p) = GR_GL_INIT_ZERO;                                                \
819c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p));   \
829c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    } while (0)
839c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
847354a4b193aaaeae43fb9ede90e1158fa46c372brobertphillips#define GR_GL_GetNamedFramebufferAttachmentParameteriv(gl, fb, a, pname, p)          \
857354a4b193aaaeae43fb9ede90e1158fa46c372brobertphillips    do {                                                                             \
867354a4b193aaaeae43fb9ede90e1158fa46c372brobertphillips        *(p) = GR_GL_INIT_ZERO;                                                      \
877354a4b193aaaeae43fb9ede90e1158fa46c372brobertphillips        GR_GL_CALL(gl, GetNamedFramebufferAttachmentParameteriv(fb, a, pname, p));   \
887354a4b193aaaeae43fb9ede90e1158fa46c372brobertphillips    } while (0)
897354a4b193aaaeae43fb9ede90e1158fa46c372brobertphillips
909c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p)                      \
919c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    do {                                                                       \
929c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        *(p) = GR_GL_INIT_ZERO;                                                \
939c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p));               \
949c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    } while (0)
9517168df7798d0d12684f18df0556dc19e65b32e6bsalomon
969c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p)                       \
979c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    do {                                                                       \
989c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        *(p) = GR_GL_INIT_ZERO;                                                \
999c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com        GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p));                \
1009c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com    } while (0)
1019c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
10217168df7798d0d12684f18df0556dc19e65b32e6bsalomon#define GR_GL_GetShaderPrecisionFormat(gl, st, pt, range, precision)           \
10317168df7798d0d12684f18df0556dc19e65b32e6bsalomon    do {                                                                       \
10417168df7798d0d12684f18df0556dc19e65b32e6bsalomon        (range)[0] = GR_GL_INIT_ZERO;                                          \
10517168df7798d0d12684f18df0556dc19e65b32e6bsalomon        (range)[1] = GR_GL_INIT_ZERO;                                          \
10617168df7798d0d12684f18df0556dc19e65b32e6bsalomon        (*precision) = GR_GL_INIT_ZERO;                                        \
10717168df7798d0d12684f18df0556dc19e65b32e6bsalomon        GR_GL_CALL(gl, GetShaderPrecisionFormat(st, pt, range, precision));    \
10817168df7798d0d12684f18df0556dc19e65b32e6bsalomon    } while (0)
10917168df7798d0d12684f18df0556dc19e65b32e6bsalomon
1109c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com////////////////////////////////////////////////////////////////////////////////
1119c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
1129c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com/**
1139c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com * Helpers for glGetString()
1149c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com */
1159c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
1169c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com// these variants assume caller already has a string from glGetString()
1179c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.comGrGLVersion GrGLGetVersionFromString(const char* versionString);
1189e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.orgGrGLStandard GrGLGetStandardInUseFromString(const char* versionString);
1199c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.comGrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
1200b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.comGrGLVendor GrGLGetVendorFromString(const char* vendorString);
1210694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.orgGrGLRenderer GrGLGetRendererFromString(const char* rendererString);
1221acea86914797bc33856ff62b5cdfbe82c58dd67cdalton
1231acea86914797bc33856ff62b5cdfbe82c58dd67cdaltonvoid GrGLGetDriverInfo(GrGLStandard standard,
1241acea86914797bc33856ff62b5cdfbe82c58dd67cdalton                       GrGLVendor vendor,
1251acea86914797bc33856ff62b5cdfbe82c58dd67cdalton                       const char* rendererString,
1261acea86914797bc33856ff62b5cdfbe82c58dd67cdalton                       const char* versionString,
1271acea86914797bc33856ff62b5cdfbe82c58dd67cdalton                       GrGLDriver* outDriver,
1281acea86914797bc33856ff62b5cdfbe82c58dd67cdalton                       GrGLDriverVersion* outVersion);
1299c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
1309c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com// these variants call glGetString()
1319c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.comGrGLVersion GrGLGetVersion(const GrGLInterface*);
1329c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.comGrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
1330b1e481709ef9b86261f46e9fd44d8cdec7c2d8ebsalomon@google.comGrGLVendor GrGLGetVendor(const GrGLInterface*);
1340694ea7f6a16e946972b9c625f434e80eb42bb5fcommit-bot@chromium.orgGrGLRenderer GrGLGetRenderer(const GrGLInterface*);
1359c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
136c9424b8e6dc204fc304c021480a04a468899aa34commit-bot@chromium.org
1379c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com/**
1389c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com * Helpers for glGetError()
1399c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com */
1409c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
1412717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.comvoid GrGLCheckErr(const GrGLInterface* gl,
1422717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com                  const char* location,
1432717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com                  const char* call);
1449c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
1452717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.comvoid GrGLClearErr(const GrGLInterface* gl);
1462717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1472717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com////////////////////////////////////////////////////////////////////////////////
1482717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1492717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com/**
1502717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com * Macros for using GrGLInterface to make GL calls
1512717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com */
1522717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1532717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// internal macro to conditionally call glGetError based on compile-time and
1542717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// run-time flags.
1552717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#if GR_GL_CHECK_ERROR
1562717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    extern bool gCheckErrorGL;
1572717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    #define GR_GL_CHECK_ERROR_IMPL(IFACE, X)                    \
1582717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        if (gCheckErrorGL)                                      \
1592717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com            GrGLCheckErr(IFACE, GR_FILE_AND_LINE_STR, #X)
1602717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#else
1612717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    #define GR_GL_CHECK_ERROR_IMPL(IFACE, X)
1622717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#endif
1632717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
16438406c82b913350e55fa04af8c1941cd9b4aff52tfarina// internal macro to conditionally log the gl call using SkDebugf based on
1652717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// compile-time and run-time flags.
1662717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#if GR_GL_LOG_CALLS
1672717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    extern bool gLogCallsGL;
1682717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    #define GR_GL_LOG_CALLS_IMPL(X)                             \
1692717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        if (gLogCallsGL)                                        \
17038406c82b913350e55fa04af8c1941cd9b4aff52tfarina            SkDebugf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
1712717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#else
1722717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    #define GR_GL_LOG_CALLS_IMPL(X)
1732717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#endif
1742717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1752717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// internal macro that does the per-GL-call callback (if necessary)
1762717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#if GR_GL_PER_GL_FUNC_CALLBACK
1772717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    #define GR_GL_CALLBACK_IMPL(IFACE) (IFACE)->fCallback(IFACE)
1782717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#else
1792717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    #define GR_GL_CALLBACK_IMPL(IFACE)
1802717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#endif
1812717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1822717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// makes a GL call on the interface and does any error checking and logging
1832717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#define GR_GL_CALL(IFACE, X)                                    \
1842717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    do {                                                        \
1852717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_CALL_NOERRCHECK(IFACE, X);                        \
1862717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_CHECK_ERROR_IMPL(IFACE, X);                       \
1872717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    } while (false)
1882717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1892717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// Variant of above that always skips the error check. This is useful when
1902717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// the caller wants to do its own glGetError() call and examine the error value.
1912717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#define GR_GL_CALL_NOERRCHECK(IFACE, X)                         \
1922717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    do {                                                        \
1932717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_CALLBACK_IMPL(IFACE);                             \
194c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        (IFACE)->fFunctions.f##X;                               \
1952717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_LOG_CALLS_IMPL(X);                                \
1962717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    } while (false)
1972717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
1982717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// same as GR_GL_CALL but stores the return value of the gl call in RET
1992717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#define GR_GL_CALL_RET(IFACE, RET, X)                           \
2002717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    do {                                                        \
2012717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X);               \
2022717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_CHECK_ERROR_IMPL(IFACE, X);                       \
2032717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    } while (false)
2042717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
2052717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// same as GR_GL_CALL_RET but always skips the error check.
2062717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com#define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X)                \
2072717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    do {                                                        \
2082717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_CALLBACK_IMPL(IFACE);                             \
209c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        (RET) = (IFACE)->fFunctions.f##X;                       \
2102717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com        GR_GL_LOG_CALLS_IMPL(X);                                \
2112717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com    } while (false)
2122717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com
2132717d56b22f14ce0de206cd695ca2855bc568fbcbsalomon@google.com// call glGetError without doing a redundant error check or logging.
214c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org#define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError()
2159c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com
216ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunenGrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc);
217ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen
218ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen
2199c1f1ac5d399c73f5f331bdf7b392ea7f0c44dafbsalomon@google.com#endif
220