1 2 /* 3 * Copyright 2012 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 #ifndef GrGLFunctions_DEFINED 10 #define GrGLFunctions_DEFINED 11 12 #include "GrGLTypes.h" 13 #include "../private/SkTLogic.h" 14 15 extern "C" { 16 17 /////////////////////////////////////////////////////////////////////////////// 18 19 typedef GrGLvoid (* GrGLActiveTextureProc)(GrGLenum texture); 20 typedef GrGLvoid (* GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader); 21 typedef GrGLvoid (* GrGLBeginQueryProc)(GrGLenum target, GrGLuint id); 22 typedef GrGLvoid (* GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name); 23 typedef GrGLvoid (* GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer); 24 typedef GrGLvoid (* GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer); 25 typedef GrGLvoid (* GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer); 26 typedef GrGLvoid (* GrGLBindTextureProc)(GrGLenum target, GrGLuint texture); 27 typedef GrGLvoid (* GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name); 28 typedef GrGLvoid (* GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name); 29 typedef GrGLvoid (* GrGLBindVertexArrayProc)(GrGLuint array); 30 typedef GrGLvoid (* GrGLBlendBarrierProc)(); 31 typedef GrGLvoid (* GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); 32 typedef GrGLvoid (* GrGLBlendEquationProc)(GrGLenum mode); 33 typedef GrGLvoid (* GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor); 34 typedef GrGLvoid (* GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter); 35 typedef GrGLvoid (* GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage); 36 typedef GrGLvoid (* GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data); 37 typedef GrGLenum (* GrGLCheckFramebufferStatusProc)(GrGLenum target); 38 typedef GrGLvoid (* GrGLClearProc)(GrGLbitfield mask); 39 typedef GrGLvoid (* GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); 40 typedef GrGLvoid (* GrGLClearStencilProc)(GrGLint s); 41 typedef GrGLvoid (* GrGLClearTexImageProc)(GrGLuint texture, GrGLint level, GrGLenum format, GrGLenum type,const GrGLvoid * data); 42 typedef GrGLvoid (* GrGLClearTexSubImageProc)(GrGLuint texture, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint zoffset, GrGLsizei width, GrGLsizei height, GrGLsizei depth, GrGLenum format, GrGLenum type,const GrGLvoid * data); 43 typedef GrGLvoid (* GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha); 44 typedef GrGLvoid (* GrGLCompileShaderProc)(GrGLuint shader); 45 typedef GrGLvoid (* GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data); 46 typedef GrGLvoid (* GrGLCompressedTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLsizei imageSize, const GrGLvoid* data); 47 typedef GrGLvoid (* GrGLCopyTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); 48 typedef GrGLuint (* GrGLCreateProgramProc)(); 49 typedef GrGLuint (* GrGLCreateShaderProc)(GrGLenum type); 50 typedef GrGLvoid (* GrGLCullFaceProc)(GrGLenum mode); 51 typedef GrGLvoid (* GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers); 52 typedef GrGLvoid (* GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers); 53 typedef GrGLvoid (* GrGLDeleteProgramProc)(GrGLuint program); 54 typedef GrGLvoid (* GrGLDeleteQueriesProc)(GrGLsizei n, const GrGLuint *ids); 55 typedef GrGLvoid (* GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers); 56 typedef GrGLvoid (* GrGLDeleteShaderProc)(GrGLuint shader); 57 typedef GrGLvoid (* GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures); 58 typedef GrGLvoid (* GrGLDeleteVertexArraysProc)(GrGLsizei n, const GrGLuint *arrays); 59 typedef GrGLvoid (* GrGLDepthMaskProc)(GrGLboolean flag); 60 typedef GrGLvoid (* GrGLDisableProc)(GrGLenum cap); 61 typedef GrGLvoid (* GrGLDisableVertexAttribArrayProc)(GrGLuint index); 62 typedef GrGLvoid (* GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count); 63 typedef GrGLvoid (* GrGLDrawArraysInstancedProc)(GrGLenum mode, GrGLint first, GrGLsizei count, GrGLsizei primcount); 64 typedef GrGLvoid (* GrGLDrawArraysIndirectProc)(GrGLenum mode, const GrGLvoid* indirect); 65 typedef GrGLvoid (* GrGLDrawBufferProc)(GrGLenum mode); 66 typedef GrGLvoid (* GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs); 67 typedef GrGLvoid (* GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); 68 typedef GrGLvoid (* GrGLDrawElementsInstancedProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid *indices, GrGLsizei primcount); 69 typedef GrGLvoid (* GrGLDrawElementsIndirectProc)(GrGLenum mode, GrGLenum type, const GrGLvoid* indirect); 70 typedef GrGLvoid (* GrGLDrawRangeElementsProc)(GrGLenum mode, GrGLuint start, GrGLuint end, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); 71 typedef GrGLvoid (* GrGLEnableProc)(GrGLenum cap); 72 typedef GrGLvoid (* GrGLEnableVertexAttribArrayProc)(GrGLuint index); 73 typedef GrGLvoid (* GrGLEndQueryProc)(GrGLenum target); 74 typedef GrGLvoid (* GrGLFinishProc)(); 75 typedef GrGLvoid (* GrGLFlushProc)(); 76 typedef GrGLvoid (* GrGLFlushMappedBufferRangeProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr length); 77 typedef GrGLvoid (* GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer); 78 typedef GrGLvoid (* GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level); 79 typedef GrGLvoid (* GrGLFramebufferTexture2DMultisampleProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level, GrGLsizei samples); 80 typedef GrGLvoid (* GrGLFrontFaceProc)(GrGLenum mode); 81 typedef GrGLvoid (* GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers); 82 typedef GrGLvoid (* GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers); 83 typedef GrGLvoid (* GrGLGenerateMipmapProc)(GrGLenum target); 84 typedef GrGLvoid (* GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids); 85 typedef GrGLvoid (* GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers); 86 typedef GrGLvoid (* GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures); 87 typedef GrGLvoid (* GrGLGenVertexArraysProc)(GrGLsizei n, GrGLuint *arrays); 88 typedef GrGLvoid (* GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params); 89 typedef GrGLenum (* GrGLGetErrorProc)(); 90 typedef GrGLvoid (* GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params); 91 typedef GrGLvoid (* GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params); 92 typedef GrGLvoid (* GrGLGetMultisamplefvProc)(GrGLenum pname, GrGLuint index, GrGLfloat* val); 93 typedef GrGLvoid (* GrGLGetProgramBinaryProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, GrGLenum *binaryFormat, void *binary); 94 typedef GrGLvoid (* GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog); 95 typedef GrGLvoid (* GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params); 96 typedef GrGLvoid (* GrGLGetQueryivProc)(GrGLenum GLtarget, GrGLenum pname, GrGLint *params); 97 typedef GrGLvoid (* GrGLGetQueryObjecti64vProc)(GrGLuint id, GrGLenum pname, GrGLint64 *params); 98 typedef GrGLvoid (* GrGLGetQueryObjectivProc)(GrGLuint id, GrGLenum pname, GrGLint *params); 99 typedef GrGLvoid (* GrGLGetQueryObjectui64vProc)(GrGLuint id, GrGLenum pname, GrGLuint64 *params); 100 typedef GrGLvoid (* GrGLGetQueryObjectuivProc)(GrGLuint id, GrGLenum pname, GrGLuint *params); 101 typedef GrGLvoid (* GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params); 102 typedef GrGLvoid (* GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog); 103 typedef GrGLvoid (* GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params); 104 typedef GrGLvoid (* GrGLGetShaderPrecisionFormatProc)(GrGLenum shadertype, GrGLenum precisiontype, GrGLint *range, GrGLint *precision); 105 typedef const GrGLubyte* (* GrGLGetStringProc)(GrGLenum name); 106 typedef const GrGLubyte* (* GrGLGetStringiProc)(GrGLenum name, GrGLuint index); 107 typedef GrGLvoid (* GrGLGetTexLevelParameterivProc)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params); 108 typedef GrGLint (* GrGLGetUniformLocationProc)(GrGLuint program, const char* name); 109 typedef GrGLvoid (* GrGLInsertEventMarkerProc)(GrGLsizei length, const char* marker); 110 typedef GrGLvoid (* GrGLInvalidateBufferDataProc)(GrGLuint buffer); 111 typedef GrGLvoid (* GrGLInvalidateBufferSubDataProc)(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length); 112 typedef GrGLvoid (* GrGLInvalidateFramebufferProc)(GrGLenum target, GrGLsizei numAttachments, const GrGLenum *attachments); 113 typedef GrGLvoid (* GrGLInvalidateSubFramebufferProc)(GrGLenum target, GrGLsizei numAttachments, const GrGLenum *attachments, GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); 114 typedef GrGLvoid (* GrGLInvalidateTexImageProc)(GrGLuint texture, GrGLint level); 115 typedef GrGLvoid (* GrGLInvalidateTexSubImageProc)(GrGLuint texture, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint zoffset, GrGLsizei width, GrGLsizei height, GrGLsizei depth); 116 typedef GrGLboolean (* GrGLIsTextureProc)(GrGLuint texture); 117 typedef GrGLvoid (* GrGLLineWidthProc)(GrGLfloat width); 118 typedef GrGLvoid (* GrGLLinkProgramProc)(GrGLuint program); 119 typedef GrGLvoid* (* GrGLMapBufferProc)(GrGLenum target, GrGLenum access); 120 typedef GrGLvoid* (* GrGLMapBufferRangeProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr length, GrGLbitfield access); 121 typedef GrGLvoid* (* GrGLMapBufferSubDataProc)(GrGLuint target, GrGLintptr offset, GrGLsizeiptr size, GrGLenum access); 122 typedef GrGLvoid* (* GrGLMapTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLenum access); 123 typedef GrGLvoid (* GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param); 124 typedef GrGLvoid (* GrGLPolygonModeProc)(GrGLenum face, GrGLenum mode); 125 typedef GrGLvoid (* GrGLPopGroupMarkerProc)(); 126 typedef GrGLvoid (* GrGLProgramBinaryProc)(GrGLuint program, GrGLenum binaryFormat, void *binary, GrGLsizei length); 127 typedef GrGLvoid (* GrGLProgramParameteriProc)(GrGLuint program, GrGLenum pname, GrGLint value); 128 typedef GrGLvoid (* GrGLPushGroupMarkerProc)(GrGLsizei length, const char* marker); 129 typedef GrGLvoid (* GrGLQueryCounterProc)(GrGLuint id, GrGLenum target); 130 typedef GrGLvoid (* GrGLRasterSamplesProc)(GrGLuint samples, GrGLboolean fixedsamplelocations); 131 typedef GrGLvoid (* GrGLReadBufferProc)(GrGLenum src); 132 typedef GrGLvoid (* GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels); 133 typedef GrGLvoid (* GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); 134 typedef GrGLvoid (* GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); 135 typedef GrGLvoid (* GrGLResolveMultisampleFramebufferProc)(); 136 typedef GrGLvoid (* GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); 137 // GL_CHROMIUM_bind_uniform_location 138 typedef GrGLvoid (* GrGLBindUniformLocationProc)(GrGLuint program, GrGLint location, const char* name); 139 140 #if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE 141 typedef GrGLvoid (* GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char* const * str, const GrGLint* length); 142 #else 143 typedef GrGLvoid (* GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length); 144 #endif 145 typedef GrGLvoid (* GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask); 146 typedef GrGLvoid (* GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask); 147 typedef GrGLvoid (* GrGLStencilMaskProc)(GrGLuint mask); 148 typedef GrGLvoid (* GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask); 149 typedef GrGLvoid (* GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass); 150 typedef GrGLvoid (* GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass); 151 typedef GrGLvoid (* GrGLTexBufferProc)(GrGLenum target, GrGLenum internalformat, GrGLuint buffer); 152 typedef GrGLvoid (* GrGLTexBufferRangeProc)(GrGLenum target, GrGLenum internalformat, GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr size); 153 typedef GrGLvoid (* GrGLTexImage2DProc)(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels); 154 typedef GrGLvoid (* GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param); 155 typedef GrGLvoid (* GrGLTexParameterivProc)(GrGLenum target, GrGLenum pname, const GrGLint* params); 156 typedef GrGLvoid (* GrGLTexStorage2DProc)(GrGLenum target, GrGLsizei levels, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); 157 typedef GrGLvoid (* GrGLDiscardFramebufferProc)(GrGLenum target, GrGLsizei numAttachments, const GrGLenum* attachments); 158 typedef GrGLvoid (* GrGLTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, const GrGLvoid* pixels); 159 typedef GrGLvoid (* GrGLTextureBarrierProc)(); 160 typedef GrGLvoid (* GrGLUniform1fProc)(GrGLint location, GrGLfloat v0); 161 typedef GrGLvoid (* GrGLUniform1iProc)(GrGLint location, GrGLint v0); 162 typedef GrGLvoid (* GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 163 typedef GrGLvoid (* GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 164 typedef GrGLvoid (* GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1); 165 typedef GrGLvoid (* GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1); 166 typedef GrGLvoid (* GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 167 typedef GrGLvoid (* GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 168 typedef GrGLvoid (* GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2); 169 typedef GrGLvoid (* GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2); 170 typedef GrGLvoid (* GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 171 typedef GrGLvoid (* GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 172 typedef GrGLvoid (* GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3); 173 typedef GrGLvoid (* GrGLUniform4iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3); 174 typedef GrGLvoid (* GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); 175 typedef GrGLvoid (* GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v); 176 typedef GrGLvoid (* GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); 177 typedef GrGLvoid (* GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); 178 typedef GrGLvoid (* GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); 179 typedef GrGLboolean (* GrGLUnmapBufferProc)(GrGLenum target); 180 typedef GrGLvoid (* GrGLUnmapBufferSubDataProc)(const GrGLvoid* mem); 181 typedef GrGLvoid (* GrGLUnmapTexSubImage2DProc)(const GrGLvoid* mem); 182 typedef GrGLvoid (* GrGLUseProgramProc)(GrGLuint program); 183 typedef GrGLvoid (* GrGLVertexAttrib1fProc)(GrGLuint indx, const GrGLfloat value); 184 typedef GrGLvoid (* GrGLVertexAttrib2fvProc)(GrGLuint indx, const GrGLfloat* values); 185 typedef GrGLvoid (* GrGLVertexAttrib3fvProc)(GrGLuint indx, const GrGLfloat* values); 186 typedef GrGLvoid (* GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values); 187 typedef GrGLvoid (* GrGLVertexAttribDivisorProc)(GrGLuint index, GrGLuint divisor); 188 typedef GrGLvoid (* GrGLVertexAttribIPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* ptr); 189 typedef GrGLvoid (* GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr); 190 typedef GrGLvoid (* GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); 191 192 /* GL_NV_path_rendering */ 193 typedef GrGLvoid (* GrGLMatrixLoadfProc)(GrGLenum matrixMode, const GrGLfloat* m); 194 typedef GrGLvoid (* GrGLMatrixLoadIdentityProc)(GrGLenum); 195 typedef GrGLvoid (* GrGLPathCommandsProc)(GrGLuint path, GrGLsizei numCommands, const GrGLubyte *commands, GrGLsizei numCoords, GrGLenum coordType, const GrGLvoid *coords); 196 typedef GrGLvoid (* GrGLPathParameteriProc)(GrGLuint path, GrGLenum pname, GrGLint value); 197 typedef GrGLvoid (* GrGLPathParameterfProc)(GrGLuint path, GrGLenum pname, GrGLfloat value); 198 typedef GrGLuint (* GrGLGenPathsProc)(GrGLsizei range); 199 typedef GrGLvoid (* GrGLDeletePathsProc)(GrGLuint path, GrGLsizei range); 200 typedef GrGLboolean (* GrGLIsPathProc)(GrGLuint path); 201 typedef GrGLvoid (* GrGLPathStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask); 202 typedef GrGLvoid (* GrGLStencilFillPathProc)(GrGLuint path, GrGLenum fillMode, GrGLuint mask); 203 typedef GrGLvoid (* GrGLStencilStrokePathProc)(GrGLuint path, GrGLint reference, GrGLuint mask); 204 typedef GrGLvoid (* GrGLStencilFillPathInstancedProc)(GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths, GrGLuint pathBase, GrGLenum fillMode, GrGLuint mask, GrGLenum transformType, const GrGLfloat *transformValues); 205 typedef GrGLvoid (* GrGLStencilStrokePathInstancedProc)(GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths, GrGLuint pathBase, GrGLint reference, GrGLuint mask, GrGLenum transformType, const GrGLfloat *transformValues); 206 typedef GrGLvoid (* GrGLCoverFillPathProc)(GrGLuint path, GrGLenum coverMode); 207 typedef GrGLvoid (* GrGLCoverStrokePathProc)(GrGLuint name, GrGLenum coverMode); 208 typedef GrGLvoid (* GrGLCoverFillPathInstancedProc)(GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths, GrGLuint pathBase, GrGLenum coverMode, GrGLenum transformType, const GrGLfloat *transformValues); 209 typedef GrGLvoid (* GrGLCoverStrokePathInstancedProc)(GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths, GrGLuint pathBase, GrGLenum coverMode, GrGLenum transformType, const GrGLfloat* transformValues); 210 // NV_path_rendering v1.2 211 typedef GrGLvoid (* GrGLStencilThenCoverFillPathProc)(GrGLuint path, GrGLenum fillMode, GrGLuint mask, GrGLenum coverMode); 212 typedef GrGLvoid (* GrGLStencilThenCoverStrokePathProc)(GrGLuint path, GrGLint reference, GrGLuint mask, GrGLenum coverMode); 213 typedef GrGLvoid (* GrGLStencilThenCoverFillPathInstancedProc)(GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths, GrGLuint pathBase, GrGLenum fillMode, GrGLuint mask, GrGLenum coverMode, GrGLenum transformType, const GrGLfloat *transformValues); 214 typedef GrGLvoid (* GrGLStencilThenCoverStrokePathInstancedProc)(GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths, GrGLuint pathBase, GrGLint reference, GrGLuint mask, GrGLenum coverMode, GrGLenum transformType, const GrGLfloat *transformValues); 215 // NV_path_rendering v1.3 216 typedef GrGLvoid (* GrGLProgramPathFragmentInputGenProc)(GrGLuint program, GrGLint location, GrGLenum genMode, GrGLint components,const GrGLfloat *coeffs); 217 // CHROMIUM_path_rendering 218 typedef GrGLvoid (* GrGLBindFragmentInputLocationProc)(GrGLuint program, GrGLint location, const GrGLchar* name); 219 220 /* ARB_program_interface_query */ 221 typedef GrGLint (* GrGLGetProgramResourceLocationProc)(GrGLuint program, GrGLenum programInterface, const GrGLchar *name); 222 223 /* GL_NV_framebuffer_mixed_samples */ 224 typedef GrGLvoid (* GrGLCoverageModulationProc)(GrGLenum components); 225 226 /* EXT_multi_draw_indirect */ 227 typedef GrGLvoid (* GrGLMultiDrawArraysIndirectProc)(GrGLenum mode, const GrGLvoid *indirect, GrGLsizei drawcount, GrGLsizei stride); 228 typedef GrGLvoid (* GrGLMultiDrawElementsIndirectProc)(GrGLenum mode, GrGLenum type, const GrGLvoid *indirect, GrGLsizei drawcount, GrGLsizei stride); 229 230 /* ARB_sample_shading */ 231 typedef GrGLvoid (* GrGLMinSampleShadingProc)(GrGLfloat value); 232 233 /* ARB_sync */ 234 typedef GrGLsync (* GrGLFenceSyncProc)(GrGLenum condition, GrGLbitfield flags); 235 typedef GrGLboolean (* GrGLIsSyncProc)(GrGLsync sync); 236 typedef GrGLenum (* GrGLClientWaitSyncProc)(GrGLsync sync, GrGLbitfield flags, GrGLuint64 timeout); 237 typedef GrGLvoid (* GrGLWaitSyncProc)(GrGLsync sync, GrGLbitfield flags, GrGLuint64 timeout); 238 typedef GrGLvoid (* GrGLDeleteSyncProc)(GrGLsync sync); 239 240 /* ARB_internalformat_query */ 241 typedef GrGLvoid (* GrGLGetInternalformativProc)(GrGLenum target, GrGLenum internalformat, GrGLenum pname, GrGLsizei bufSize, GrGLint *params); 242 243 /* KHR_debug */ 244 typedef GrGLvoid (* GrGLDebugMessageControlProc)(GrGLenum source, GrGLenum type, GrGLenum severity, GrGLsizei count, const GrGLuint* ids, GrGLboolean enabled); 245 typedef GrGLvoid (* GrGLDebugMessageInsertProc)(GrGLenum source, GrGLenum type, GrGLuint id, GrGLenum severity, GrGLsizei length, const GrGLchar* buf); 246 typedef GrGLvoid (* GrGLDebugMessageCallbackProc)(GRGLDEBUGPROC callback, const GrGLvoid* userParam); 247 typedef GrGLuint (* GrGLGetDebugMessageLogProc)(GrGLuint count, GrGLsizei bufSize, GrGLenum* sources, GrGLenum* types, GrGLuint* ids, GrGLenum* severities, GrGLsizei* lengths, GrGLchar* messageLog); 248 typedef GrGLvoid (* GrGLPushDebugGroupProc)(GrGLenum source, GrGLuint id, GrGLsizei length, const GrGLchar * message); 249 typedef GrGLvoid (* GrGLPopDebugGroupProc)(); 250 typedef GrGLvoid (* GrGLObjectLabelProc)(GrGLenum identifier, GrGLuint name, GrGLsizei length, const GrGLchar *label); 251 252 /** EXT_window_rectangles */ 253 typedef GrGLvoid (* GrGLWindowRectanglesProc)(GrGLenum mode, GrGLsizei count, const GrGLint box[]); 254 255 /** EGL functions */ 256 typedef const char* (* GrEGLQueryStringProc)(GrEGLDisplay dpy, GrEGLint name); 257 typedef GrEGLDisplay (* GrEGLGetCurrentDisplayProc)(); 258 typedef GrEGLImage (* GrEGLCreateImageProc)(GrEGLDisplay dpy, GrEGLContext ctx, GrEGLenum target, GrEGLClientBuffer buffer, const GrEGLint *attrib_list); 259 typedef GrEGLBoolean (* GrEGLDestroyImageProc)(GrEGLDisplay dpy, GrEGLImage image); 260 } // extern "C" 261 262 // This is a lighter-weight std::function, trying to reduce code size and compile time 263 // by only supporting the exact use cases we require. 264 template <typename T> class GrGLFunction; 265 266 template <typename R, typename... Args> 267 class GrGLFunction<R(*)(Args...)>{ 268 public: 269 // Construct empty. GrGLFunction()270 GrGLFunction() : fCall(nullptr) {} GrGLFunction(std::nullptr_t)271 GrGLFunction(std::nullptr_t) : GrGLFunction() {} 272 273 // Construct from a simple function pointer. GrGLFunction(R (GR_GL_FUNCTION_TYPE * fn_ptr)(Args...))274 GrGLFunction(R (GR_GL_FUNCTION_TYPE* fn_ptr)(Args...)) : GrGLFunction() { 275 if (fn_ptr) { 276 memcpy(fBuf, &fn_ptr, sizeof(fn_ptr)); 277 fCall = [](const void* buf, Args... args) { 278 auto fn_ptr = *(R (GR_GL_FUNCTION_TYPE**)(Args...))buf; 279 return fn_ptr(args...); 280 }; 281 } 282 } 283 284 // Construct from a small closure. 285 template <typename Closure> GrGLFunction(Closure closure)286 GrGLFunction(Closure closure) : GrGLFunction() { 287 static_assert(sizeof(Closure) <= sizeof(fBuf), "fBuf is too small"); 288 #if defined(__APPLE__) // I am having serious trouble getting these to work with all STLs... 289 static_assert(std::is_trivially_copyable<Closure>::value, ""); 290 static_assert(std::is_trivially_destructible<Closure>::value, ""); 291 #endif 292 293 memcpy(fBuf, &closure, sizeof(closure)); 294 fCall = [](const void* buf, Args... args) { 295 auto closure = (const Closure*)buf; 296 return (*closure)(args...); 297 }; 298 } 299 operator()300 R operator()(Args... args) const { 301 SkASSERT(fCall); 302 return fCall(fBuf, args...); 303 } 304 305 explicit operator bool() const { 306 return fCall != nullptr; 307 } 308 309 private: 310 R (*fCall)(const void*, Args...); 311 size_t fBuf[4]; 312 }; 313 314 #endif 315