Home | History | Annotate | Download | only in gl
      1 
      2 /*
      3  * Copyright 2011 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 
     11 #ifndef GrGLInterface_DEFINED
     12 #define GrGLInterface_DEFINED
     13 
     14 #include "GrGLConfig.h"
     15 #include "GrRefCnt.h"
     16 
     17 #if !defined(GR_GL_FUNCTION_TYPE)
     18     #define GR_GL_FUNCTION_TYPE
     19 #endif
     20 
     21 ////////////////////////////////////////////////////////////////////////////////
     22 
     23 /**
     24  * Classifies GL contexts (currently as Desktop vs. ES2). This is a bitfield.
     25  * A GrGLInterface (defined below) may support multiple bindings.
     26  */
     27 enum GrGLBinding {
     28     kNone_GrGLBinding = 0x0,
     29 
     30     kDesktop_GrGLBinding = 0x01,
     31     kES2_GrGLBinding = 0x02,
     32 
     33     // for iteration of GrGLBindings
     34     kFirstGrGLBinding = kDesktop_GrGLBinding,
     35     kLastGrGLBinding = kES2_GrGLBinding
     36 };
     37 
     38 ////////////////////////////////////////////////////////////////////////////////
     39 
     40 /**
     41  * Helpers for glGetString()
     42  */
     43 
     44 typedef uint32_t GrGLVersion;
     45 typedef uint32_t GrGLSLVersion;
     46 
     47 #define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
     48                                  static_cast<int>(minor))
     49 #define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
     50                                    static_cast<int>(minor))
     51 
     52 // these variants assume caller already has a string from glGetString()
     53 GrGLVersion GrGLGetVersionFromString(const char* versionString);
     54 GrGLBinding GrGLGetBindingInUseFromString(const char* versionString);
     55 GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
     56 bool GrGLHasExtensionFromString(const char* ext, const char* extensionString);
     57 
     58 // these variants call glGetString()
     59 bool GrGLHasExtension(const GrGLInterface*, const char* ext);
     60 GrGLBinding GrGLGetBindingInUse(const GrGLInterface*);
     61 GrGLVersion GrGLGetVersion(const GrGLInterface*);
     62 GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
     63 
     64 ////////////////////////////////////////////////////////////////////////////////
     65 
     66 /**
     67  * Rather than depend on platform-specific GL headers and libraries, we require
     68  * the client to provide a struct of GL function pointers. This struct can be
     69  * specified per-GrContext as a parameter to GrContext::Create. If NULL is
     70  * passed to Create then the "default" GL interface is used. If the default is
     71  * also NULL GrContext creation will fail.
     72  *
     73  * The default interface is returned by GrGLDefaultInterface. This function's
     74  * implementation is platform-specifc. Several have been provided, along with an
     75  * implementation that simply returns NULL. It is implementation-specific
     76  * whether the same GrGLInterface is returned or whether a new one is created
     77  * at each call. Some platforms may not be able to use a single GrGLInterface
     78  * because extension function ptrs vary across contexts. Note that GrGLInterface
     79  * is ref-counted. So if the same object is returned by multiple calls to
     80  * GrGLDefaultInterface, each should bump the ref count.
     81  *
     82  * By defining GR_GL_PER_GL_CALL_IFACE_CALLBACK to 1 the client can specify a
     83  * callback function that will be called prior to each GL function call. See
     84  * comments in GrGLConfig.h
     85  */
     86 
     87 struct GrGLInterface;
     88 
     89 const GrGLInterface* GrGLDefaultInterface();
     90 
     91 /**
     92  * Creates a GrGLInterface for a "native" GL context (e.g. WGL on windows,
     93  * GLX on linux, AGL on Mac). On platforms that have context-specific function
     94  * pointers for GL extensions (e.g. windows) the returned interface is only
     95  * valid for the context that was current at creation.
     96  */
     97 const GrGLInterface* GrGLCreateNativeInterface();
     98 
     99 /**
    100  * Creates a GrGLInterface for an OSMesa context.
    101  */
    102 const GrGLInterface* GrGLCreateMesaInterface();
    103 
    104 /**
    105  * Creates a null GrGLInterface that doesn't draw anything. Used for measuring
    106  * CPU overhead.
    107  */
    108 const GrGLInterface* GrGLCreateNullInterface();
    109 
    110 typedef unsigned int GrGLenum;
    111 typedef unsigned char GrGLboolean;
    112 typedef unsigned int GrGLbitfield;
    113 typedef signed char GrGLbyte;
    114 typedef char GrGLchar;
    115 typedef short GrGLshort;
    116 typedef int GrGLint;
    117 typedef int GrGLsizei;
    118 typedef int64_t GrGLint64;
    119 typedef unsigned char GrGLubyte;
    120 typedef unsigned short GrGLushort;
    121 typedef unsigned int GrGLuint;
    122 typedef uint64_t GrGLuint64;
    123 typedef float GrGLfloat;
    124 typedef float GrGLclampf;
    125 typedef double GrGLdouble;
    126 typedef double GrGLclampd;
    127 typedef void GrGLvoid;
    128 typedef long GrGLintptr;
    129 typedef long GrGLsizeiptr;
    130 
    131 extern "C" {
    132     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture);
    133     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader);
    134     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBeginQueryProc)(GrGLenum target, GrGLuint id);
    135     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name);
    136     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer);
    137     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
    138     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
    139     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name);
    140     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
    141     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
    142     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data);
    143     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask);
    144     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
    145     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s);
    146     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha);
    147     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
    148     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader);
    149     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data);
    150     typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void);
    151     typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type);
    152     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode);
    153     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers);
    154     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program);
    155     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteQueriesProc)(GrGLsizei n, const GrGLuint *ids);
    156     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader);
    157     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
    158     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag);
    159     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap);
    160     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index);
    161     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count);
    162     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBufferProc)(GrGLenum mode);
    163     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs);
    164     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
    165     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
    166     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
    167     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEndQueryProc)(GrGLenum target);
    168     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFinishProc)();
    169     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFlushProc)();
    170     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
    171     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
    172     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids);
    173     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
    174     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
    175     typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)();
    176     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
    177     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
    178     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
    179     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryivProc)(GrGLenum GLtarget, GrGLenum pname, GrGLint *params);
    180     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjecti64vProc)(GrGLuint id, GrGLenum pname, GrGLint64 *params);
    181     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectivProc)(GrGLuint id, GrGLenum pname, GrGLint *params);
    182     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectui64vProc)(GrGLuint id, GrGLenum pname, GrGLuint64 *params);
    183     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectuivProc)(GrGLuint id, GrGLenum pname, GrGLuint *params);
    184     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
    185     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
    186     typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
    187     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetTexLevelParameterivProc)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params);
    188     typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
    189     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width);
    190     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program);
    191     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
    192     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLQueryCounterProc)(GrGLuint id, GrGLenum target);
    193     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadBufferProc)(GrGLenum src);
    194     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
    195     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
    196     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length);
    197     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask);
    198     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask);
    199     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask);
    200     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
    201     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
    202     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
    203     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexImage2DProc)(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
    204     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
    205     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexStorage2DProc)(GrGLenum target, GrGLsizei levels, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
    206     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
    207     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
    208     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0);
    209     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
    210     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
    211     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1);
    212     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1);
    213     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
    214     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
    215     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2);
    216     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2);
    217     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
    218     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
    219     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3);
    220     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3);
    221     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
    222     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
    223     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
    224     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
    225     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
    226     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program);
    227     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values);
    228     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr);
    229     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
    230 
    231     // FBO Extension Functions
    232     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
    233     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
    234     typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target);
    235     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers);
    236     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
    237     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer);
    238     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level);
    239     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers);
    240     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
    241     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);
    242     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
    243     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
    244 
    245     // Multisampling Extension Functions
    246     // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
    247     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
    248     // desktop: ext_fbo_blit, arb_fbo, gl 3.0
    249     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter);
    250     // apple's es extension
    251     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
    252 
    253     // Buffer mapping (extension in ES).
    254     typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
    255     typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
    256 
    257     // Dual source blending
    258     typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
    259 }  // extern "C"
    260 
    261 #if GR_GL_PER_GL_FUNC_CALLBACK
    262 typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*);
    263 typedef intptr_t GrGLInterfaceCallbackData;
    264 #endif
    265 
    266 
    267 enum GrGLCapability {
    268     kProbe_GrGLCapability = -1
    269 };
    270 
    271 /*
    272  * The following interface exports the OpenGL entry points used by the system.
    273  * Use of OpenGL calls is disallowed.  All calls should be invoked through
    274  * the global instance of this struct, defined above.
    275  *
    276  * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
    277  * functions, and extensions.  The system assumes that the address of the
    278  * extension pointer will be valid across contexts.
    279  */
    280 struct GR_API GrGLInterface : public GrRefCnt {
    281 
    282     GrGLInterface();
    283 
    284     // Validates that the GrGLInterface supports a binding. This means that
    285     // the GrGLinterface advertises the binding in fBindingsExported and all
    286     // the necessary function pointers have been initialized.
    287     bool validate(GrGLBinding binding) const;
    288 
    289     // Indicator variable specifying the type of GL implementation
    290     // exported:  GLES{1|2} or Desktop.
    291     GrGLBinding fBindingsExported;
    292 
    293     GrGLActiveTextureProc fActiveTexture;
    294     GrGLAttachShaderProc fAttachShader;
    295     GrGLBeginQueryProc fBeginQuery;
    296     GrGLBindAttribLocationProc fBindAttribLocation;
    297     GrGLBindBufferProc fBindBuffer;
    298     GrGLBindFragDataLocationProc fBindFragDataLocation;
    299     GrGLBindTextureProc fBindTexture;
    300     GrGLBlendColorProc fBlendColor;
    301     GrGLBlendFuncProc fBlendFunc;
    302     GrGLBufferDataProc fBufferData;
    303     GrGLBufferSubDataProc fBufferSubData;
    304     GrGLClearProc fClear;
    305     GrGLClearColorProc fClearColor;
    306     GrGLClearStencilProc fClearStencil;
    307     GrGLColorMaskProc fColorMask;
    308     GrGLColorPointerProc fColorPointer;
    309     GrGLCompileShaderProc fCompileShader;
    310     GrGLCompressedTexImage2DProc fCompressedTexImage2D;
    311     GrGLCreateProgramProc fCreateProgram;
    312     GrGLCreateShaderProc fCreateShader;
    313     GrGLCullFaceProc fCullFace;
    314     GrGLDeleteBuffersProc fDeleteBuffers;
    315     GrGLDeleteProgramProc fDeleteProgram;
    316     GrGLDeleteQueriesProc fDeleteQueries;
    317     GrGLDeleteShaderProc fDeleteShader;
    318     GrGLDeleteTexturesProc fDeleteTextures;
    319     GrGLDepthMaskProc fDepthMask;
    320     GrGLDisableProc fDisable;
    321     GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
    322     GrGLDrawArraysProc fDrawArrays;
    323     GrGLDrawBufferProc fDrawBuffer;
    324     GrGLDrawBuffersProc fDrawBuffers;
    325     GrGLDrawElementsProc fDrawElements;
    326     GrGLEnableProc fEnable;
    327     GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
    328     GrGLEndQueryProc fEndQuery;
    329     GrGLFinishProc fFinish;
    330     GrGLFlushProc fFlush;
    331     GrGLFrontFaceProc fFrontFace;
    332     GrGLGenBuffersProc fGenBuffers;
    333     GrGLGenQueriesProc fGenQueries;
    334     GrGLGenTexturesProc fGenTextures;
    335     GrGLGetBufferParameterivProc fGetBufferParameteriv;
    336     GrGLGetErrorProc fGetError;
    337     GrGLGetIntegervProc fGetIntegerv;
    338     GrGLGetQueryObjecti64vProc fGetQueryObjecti64v;
    339     GrGLGetQueryObjectivProc fGetQueryObjectiv;
    340     GrGLGetQueryObjectui64vProc fGetQueryObjectui64v;
    341     GrGLGetQueryObjectuivProc fGetQueryObjectuiv;
    342     GrGLGetQueryivProc fGetQueryiv;
    343     GrGLGetProgramInfoLogProc fGetProgramInfoLog;
    344     GrGLGetProgramivProc fGetProgramiv;
    345     GrGLGetShaderInfoLogProc fGetShaderInfoLog;
    346     GrGLGetShaderivProc fGetShaderiv;
    347     GrGLGetStringProc fGetString;
    348     GrGLGetTexLevelParameterivProc fGetTexLevelParameteriv;
    349     GrGLGetUniformLocationProc fGetUniformLocation;
    350     GrGLLineWidthProc fLineWidth;
    351     GrGLLinkProgramProc fLinkProgram;
    352     GrGLPixelStoreiProc fPixelStorei;
    353     GrGLQueryCounterProc fQueryCounter;
    354     GrGLReadBufferProc fReadBuffer;
    355     GrGLReadPixelsProc fReadPixels;
    356     GrGLScissorProc fScissor;
    357     GrGLShaderSourceProc fShaderSource;
    358     GrGLStencilFuncProc fStencilFunc;
    359     GrGLStencilFuncSeparateProc fStencilFuncSeparate;
    360     GrGLStencilMaskProc fStencilMask;
    361     GrGLStencilMaskSeparateProc fStencilMaskSeparate;
    362     GrGLStencilOpProc fStencilOp;
    363     GrGLStencilOpSeparateProc fStencilOpSeparate;
    364     GrGLTexImage2DProc fTexImage2D;
    365     GrGLTexParameteriProc fTexParameteri;
    366     GrGLTexSubImage2DProc fTexSubImage2D;
    367     GrGLTexStorage2DProc fTexStorage2D;
    368     GrGLUniform1fProc fUniform1f;
    369     GrGLUniform1iProc fUniform1i;
    370     GrGLUniform1fvProc fUniform1fv;
    371     GrGLUniform1ivProc fUniform1iv;
    372     GrGLUniform2fProc fUniform2f;
    373     GrGLUniform2iProc fUniform2i;
    374     GrGLUniform2fvProc  fUniform2fv;
    375     GrGLUniform2ivProc fUniform2iv;
    376     GrGLUniform3fProc fUniform3f;
    377     GrGLUniform3iProc fUniform3i;
    378     GrGLUniform3fvProc fUniform3fv;
    379     GrGLUniform3ivProc fUniform3iv;
    380     GrGLUniform4fProc fUniform4f;
    381     GrGLUniform4iProc fUniform4i;
    382     GrGLUniform4fvProc fUniform4fv;
    383     GrGLUniform4ivProc fUniform4iv;
    384     GrGLUniformMatrix2fvProc fUniformMatrix2fv;
    385     GrGLUniformMatrix3fvProc fUniformMatrix3fv;
    386     GrGLUniformMatrix4fvProc fUniformMatrix4fv;
    387     GrGLUseProgramProc fUseProgram;
    388     GrGLVertexAttrib4fvProc fVertexAttrib4fv;
    389     GrGLVertexAttribPointerProc fVertexAttribPointer;
    390     GrGLViewportProc fViewport;
    391 
    392     // FBO Extension Functions
    393     GrGLBindFramebufferProc fBindFramebuffer;
    394     GrGLBindRenderbufferProc fBindRenderbuffer;
    395     GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
    396     GrGLDeleteFramebuffersProc fDeleteFramebuffers;
    397     GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
    398     GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
    399     GrGLFramebufferTexture2DProc fFramebufferTexture2D;
    400     GrGLGenFramebuffersProc fGenFramebuffers;
    401     GrGLGenRenderbuffersProc fGenRenderbuffers;
    402     GrGLGetFramebufferAttachmentParameterivProc fGetFramebufferAttachmentParameteriv;
    403     GrGLGetRenderbufferParameterivProc fGetRenderbufferParameteriv;
    404     GrGLRenderbufferStorageProc fRenderbufferStorage;
    405 
    406     // Multisampling Extension Functions
    407     // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
    408     GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
    409     // desktop: ext_fbo_blit, arb_fbo, gl 3.0
    410     GrGLBlitFramebufferProc fBlitFramebuffer;
    411     // apple's es extension
    412     GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
    413 
    414     // Buffer mapping (extension in ES).
    415     GrGLMapBufferProc fMapBuffer;
    416     GrGLUnmapBufferProc fUnmapBuffer;
    417 
    418     // Dual Source Blending
    419     GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
    420 
    421     // Per-GL func callback
    422 #if GR_GL_PER_GL_FUNC_CALLBACK
    423     GrGLInterfaceCallbackProc fCallback;
    424     GrGLInterfaceCallbackData fCallbackData;
    425 #endif
    426 
    427 };
    428 
    429 #endif
    430