GrGLInterface.h revision d3b9fbbc48c13a1b2a664cf7e01374a44c201f51
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 */ 27enum 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 44typedef uint32_t GrGLVersion; 45typedef 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() 53GrGLVersion GrGLGetVersionFromString(const char* versionString); 54GrGLBinding GrGLGetBindingInUseFromString(const char* versionString); 55GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString); 56bool GrGLHasExtensionFromString(const char* ext, const char* extensionString); 57 58// these variants call glGetString() 59bool GrGLHasExtension(const GrGLInterface*, const char* ext); 60GrGLBinding GrGLGetBindingInUse(const GrGLInterface*); 61GrGLVersion GrGLGetVersion(const GrGLInterface*); 62GrGLSLVersion 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-specific. Several have been provided, along with 75 * an 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 87struct GrGLInterface; 88 89const 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 */ 97const GrGLInterface* GrGLCreateNativeInterface(); 98 99#if SK_MESA 100/** 101 * Creates a GrGLInterface for an OSMesa context. 102 */ 103const GrGLInterface* GrGLCreateMesaInterface(); 104#endif 105 106#if SK_ANGLE 107/** 108 * Creates a GrGLInterface for an ANGLE context. 109 */ 110const GrGLInterface* GrGLCreateANGLEInterface(); 111#endif 112 113/** 114 * Creates a null GrGLInterface that doesn't draw anything. Used for measuring 115 * CPU overhead. 116 */ 117const GrGLInterface* GrGLCreateNullInterface(); 118 119/** 120 * Creates a debugging GrGLInterface that doesn't draw anything. Used for 121 * finding memory leaks and invalid memory accesses. 122 */ 123const GrGLInterface* GrGLCreateDebugInterface(); 124 125typedef unsigned int GrGLenum; 126typedef unsigned char GrGLboolean; 127typedef unsigned int GrGLbitfield; 128typedef signed char GrGLbyte; 129typedef char GrGLchar; 130typedef short GrGLshort; 131typedef int GrGLint; 132typedef int GrGLsizei; 133typedef int64_t GrGLint64; 134typedef unsigned char GrGLubyte; 135typedef unsigned short GrGLushort; 136typedef unsigned int GrGLuint; 137typedef uint64_t GrGLuint64; 138typedef float GrGLfloat; 139typedef float GrGLclampf; 140typedef double GrGLdouble; 141typedef double GrGLclampd; 142typedef void GrGLvoid; 143typedef long GrGLintptr; 144typedef long GrGLsizeiptr; 145 146extern "C" { 147 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture); 148 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader); 149 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBeginQueryProc)(GrGLenum target, GrGLuint id); 150 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name); 151 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer); 152 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture); 153 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); 154 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name); 155 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor); 156 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage); 157 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data); 158 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask); 159 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); 160 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s); 161 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha); 162 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer); 163 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader); 164 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data); 165 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void); 166 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type); 167 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode); 168 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers); 169 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program); 170 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteQueriesProc)(GrGLsizei n, const GrGLuint *ids); 171 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader); 172 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures); 173 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag); 174 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap); 175 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index); 176 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count); 177 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBufferProc)(GrGLenum mode); 178 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs); 179 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); 180 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap); 181 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index); 182 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEndQueryProc)(GrGLenum target); 183 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFinishProc)(); 184 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFlushProc)(); 185 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode); 186 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers); 187 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids); 188 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures); 189 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params); 190 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(); 191 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params); 192 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog); 193 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params); 194 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryivProc)(GrGLenum GLtarget, GrGLenum pname, GrGLint *params); 195 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjecti64vProc)(GrGLuint id, GrGLenum pname, GrGLint64 *params); 196 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectivProc)(GrGLuint id, GrGLenum pname, GrGLint *params); 197 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectui64vProc)(GrGLuint id, GrGLenum pname, GrGLuint64 *params); 198 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectuivProc)(GrGLuint id, GrGLenum pname, GrGLuint *params); 199 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog); 200 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params); 201 typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name); 202 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetTexLevelParameterivProc)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params); 203 typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name); 204 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width); 205 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program); 206 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param); 207 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLQueryCounterProc)(GrGLuint id, GrGLenum target); 208 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadBufferProc)(GrGLenum src); 209 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels); 210 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); 211 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length); 212 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask); 213 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask); 214 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask); 215 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask); 216 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass); 217 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass); 218 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); 219 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param); 220 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexStorage2DProc)(GrGLenum target, GrGLsizei levels, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); 221 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); 222 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0); 223 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0); 224 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 225 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 226 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1); 227 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1); 228 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 229 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 230 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2); 231 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2); 232 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 233 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 234 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3); 235 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3); 236 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 237 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 238 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); 239 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); 240 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); 241 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program); 242 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values); 243 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr); 244 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); 245 246 // FBO Extension Functions 247 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer); 248 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer); 249 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target); 250 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers); 251 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers); 252 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer); 253 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level); 254 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers); 255 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers); 256 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params); 257 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params); 258 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); 259 260 // Multisampling Extension Functions 261 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension 262 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); 263 // desktop: ext_fbo_blit, arb_fbo, gl 3.0 264 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); 265 // apple's es extension 266 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)(); 267 268 // Buffer mapping (extension in ES). 269 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access); 270 typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target); 271 272 // Dual source blending 273 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name); 274} // extern "C" 275 276#if GR_GL_PER_GL_FUNC_CALLBACK 277typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*); 278typedef intptr_t GrGLInterfaceCallbackData; 279#endif 280 281 282enum GrGLCapability { 283 kProbe_GrGLCapability = -1 284}; 285 286/* 287 * The following interface exports the OpenGL entry points used by the system. 288 * Use of OpenGL calls is disallowed. All calls should be invoked through 289 * the global instance of this struct, defined above. 290 * 291 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL 292 * functions, and extensions. The system assumes that the address of the 293 * extension pointer will be valid across contexts. 294 */ 295struct GR_API GrGLInterface : public GrRefCnt { 296 297 GrGLInterface(); 298 299 // Validates that the GrGLInterface supports a binding. This means that 300 // the GrGLinterface advertises the binding in fBindingsExported and all 301 // the necessary function pointers have been initialized. 302 bool validate(GrGLBinding binding) const; 303 304 // Indicator variable specifying the type of GL implementation 305 // exported: GLES{1|2} or Desktop. 306 GrGLBinding fBindingsExported; 307 308 GrGLActiveTextureProc fActiveTexture; 309 GrGLAttachShaderProc fAttachShader; 310 GrGLBeginQueryProc fBeginQuery; 311 GrGLBindAttribLocationProc fBindAttribLocation; 312 GrGLBindBufferProc fBindBuffer; 313 GrGLBindFragDataLocationProc fBindFragDataLocation; 314 GrGLBindTextureProc fBindTexture; 315 GrGLBlendColorProc fBlendColor; 316 GrGLBlendFuncProc fBlendFunc; 317 GrGLBufferDataProc fBufferData; 318 GrGLBufferSubDataProc fBufferSubData; 319 GrGLClearProc fClear; 320 GrGLClearColorProc fClearColor; 321 GrGLClearStencilProc fClearStencil; 322 GrGLColorMaskProc fColorMask; 323 GrGLColorPointerProc fColorPointer; 324 GrGLCompileShaderProc fCompileShader; 325 GrGLCompressedTexImage2DProc fCompressedTexImage2D; 326 GrGLCreateProgramProc fCreateProgram; 327 GrGLCreateShaderProc fCreateShader; 328 GrGLCullFaceProc fCullFace; 329 GrGLDeleteBuffersProc fDeleteBuffers; 330 GrGLDeleteProgramProc fDeleteProgram; 331 GrGLDeleteQueriesProc fDeleteQueries; 332 GrGLDeleteShaderProc fDeleteShader; 333 GrGLDeleteTexturesProc fDeleteTextures; 334 GrGLDepthMaskProc fDepthMask; 335 GrGLDisableProc fDisable; 336 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray; 337 GrGLDrawArraysProc fDrawArrays; 338 GrGLDrawBufferProc fDrawBuffer; 339 GrGLDrawBuffersProc fDrawBuffers; 340 GrGLDrawElementsProc fDrawElements; 341 GrGLEnableProc fEnable; 342 GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray; 343 GrGLEndQueryProc fEndQuery; 344 GrGLFinishProc fFinish; 345 GrGLFlushProc fFlush; 346 GrGLFrontFaceProc fFrontFace; 347 GrGLGenBuffersProc fGenBuffers; 348 GrGLGenQueriesProc fGenQueries; 349 GrGLGenTexturesProc fGenTextures; 350 GrGLGetBufferParameterivProc fGetBufferParameteriv; 351 GrGLGetErrorProc fGetError; 352 GrGLGetIntegervProc fGetIntegerv; 353 GrGLGetQueryObjecti64vProc fGetQueryObjecti64v; 354 GrGLGetQueryObjectivProc fGetQueryObjectiv; 355 GrGLGetQueryObjectui64vProc fGetQueryObjectui64v; 356 GrGLGetQueryObjectuivProc fGetQueryObjectuiv; 357 GrGLGetQueryivProc fGetQueryiv; 358 GrGLGetProgramInfoLogProc fGetProgramInfoLog; 359 GrGLGetProgramivProc fGetProgramiv; 360 GrGLGetShaderInfoLogProc fGetShaderInfoLog; 361 GrGLGetShaderivProc fGetShaderiv; 362 GrGLGetStringProc fGetString; 363 GrGLGetTexLevelParameterivProc fGetTexLevelParameteriv; 364 GrGLGetUniformLocationProc fGetUniformLocation; 365 GrGLLineWidthProc fLineWidth; 366 GrGLLinkProgramProc fLinkProgram; 367 GrGLPixelStoreiProc fPixelStorei; 368 GrGLQueryCounterProc fQueryCounter; 369 GrGLReadBufferProc fReadBuffer; 370 GrGLReadPixelsProc fReadPixels; 371 GrGLScissorProc fScissor; 372 GrGLShaderSourceProc fShaderSource; 373 GrGLStencilFuncProc fStencilFunc; 374 GrGLStencilFuncSeparateProc fStencilFuncSeparate; 375 GrGLStencilMaskProc fStencilMask; 376 GrGLStencilMaskSeparateProc fStencilMaskSeparate; 377 GrGLStencilOpProc fStencilOp; 378 GrGLStencilOpSeparateProc fStencilOpSeparate; 379 GrGLTexImage2DProc fTexImage2D; 380 GrGLTexParameteriProc fTexParameteri; 381 GrGLTexSubImage2DProc fTexSubImage2D; 382 GrGLTexStorage2DProc fTexStorage2D; 383 GrGLUniform1fProc fUniform1f; 384 GrGLUniform1iProc fUniform1i; 385 GrGLUniform1fvProc fUniform1fv; 386 GrGLUniform1ivProc fUniform1iv; 387 GrGLUniform2fProc fUniform2f; 388 GrGLUniform2iProc fUniform2i; 389 GrGLUniform2fvProc fUniform2fv; 390 GrGLUniform2ivProc fUniform2iv; 391 GrGLUniform3fProc fUniform3f; 392 GrGLUniform3iProc fUniform3i; 393 GrGLUniform3fvProc fUniform3fv; 394 GrGLUniform3ivProc fUniform3iv; 395 GrGLUniform4fProc fUniform4f; 396 GrGLUniform4iProc fUniform4i; 397 GrGLUniform4fvProc fUniform4fv; 398 GrGLUniform4ivProc fUniform4iv; 399 GrGLUniformMatrix2fvProc fUniformMatrix2fv; 400 GrGLUniformMatrix3fvProc fUniformMatrix3fv; 401 GrGLUniformMatrix4fvProc fUniformMatrix4fv; 402 GrGLUseProgramProc fUseProgram; 403 GrGLVertexAttrib4fvProc fVertexAttrib4fv; 404 GrGLVertexAttribPointerProc fVertexAttribPointer; 405 GrGLViewportProc fViewport; 406 407 // FBO Extension Functions 408 GrGLBindFramebufferProc fBindFramebuffer; 409 GrGLBindRenderbufferProc fBindRenderbuffer; 410 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus; 411 GrGLDeleteFramebuffersProc fDeleteFramebuffers; 412 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers; 413 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer; 414 GrGLFramebufferTexture2DProc fFramebufferTexture2D; 415 GrGLGenFramebuffersProc fGenFramebuffers; 416 GrGLGenRenderbuffersProc fGenRenderbuffers; 417 GrGLGetFramebufferAttachmentParameterivProc fGetFramebufferAttachmentParameteriv; 418 GrGLGetRenderbufferParameterivProc fGetRenderbufferParameteriv; 419 GrGLRenderbufferStorageProc fRenderbufferStorage; 420 421 // Multisampling Extension Functions 422 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension 423 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample; 424 // desktop: ext_fbo_blit, arb_fbo, gl 3.0 425 GrGLBlitFramebufferProc fBlitFramebuffer; 426 // apple's es extension 427 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer; 428 429 // Buffer mapping (extension in ES). 430 GrGLMapBufferProc fMapBuffer; 431 GrGLUnmapBufferProc fUnmapBuffer; 432 433 // Dual Source Blending 434 GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed; 435 436 // Per-GL func callback 437#if GR_GL_PER_GL_FUNC_CALLBACK 438 GrGLInterfaceCallbackProc fCallback; 439 GrGLInterfaceCallbackData fCallbackData; 440#endif 441 442}; 443 444#endif 445