1 // Modified from chromium/src/webkit/glue/gl_bindings_skia_cmd_buffer.cc 2 3 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style license that can be 5 // found in the LICENSE file. 6 7 #include "gl/GrGLExtensions.h" 8 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLUtil.h" 10 11 #ifndef GL_GLEXT_PROTOTYPES 12 #define GL_GLEXT_PROTOTYPES 13 #endif 14 15 #include <GLES2/gl2.h> 16 #include <GLES2/gl2ext.h> 17 18 #include <EGL/egl.h> 19 20 static const GrGLInterface* create_es_interface(GrGLVersion version, 21 const GrGLExtensions& extensions) { 22 if (version < GR_GL_VER(2,0)) { 23 return NULL; 24 } 25 26 GrGLInterface* interface = SkNEW(GrGLInterface); 27 interface->fBindingsExported = kES_GrGLBinding; 28 29 interface->fActiveTexture = glActiveTexture; 30 interface->fAttachShader = glAttachShader; 31 interface->fBindAttribLocation = glBindAttribLocation; 32 interface->fBindBuffer = glBindBuffer; 33 interface->fBindTexture = glBindTexture; 34 interface->fBindVertexArray = glBindVertexArrayOES; 35 interface->fBlendColor = glBlendColor; 36 interface->fBlendFunc = glBlendFunc; 37 interface->fBufferData = glBufferData; 38 interface->fBufferSubData = glBufferSubData; 39 interface->fClear = glClear; 40 interface->fClearColor = glClearColor; 41 interface->fClearStencil = glClearStencil; 42 interface->fColorMask = glColorMask; 43 interface->fCompileShader = glCompileShader; 44 interface->fCompressedTexImage2D = glCompressedTexImage2D; 45 interface->fCopyTexSubImage2D = glCopyTexSubImage2D; 46 interface->fCreateProgram = glCreateProgram; 47 interface->fCreateShader = glCreateShader; 48 interface->fCullFace = glCullFace; 49 interface->fDeleteBuffers = glDeleteBuffers; 50 interface->fDeleteProgram = glDeleteProgram; 51 interface->fDeleteShader = glDeleteShader; 52 interface->fDeleteTextures = glDeleteTextures; 53 interface->fDeleteVertexArrays = glDeleteVertexArraysOES; 54 interface->fDepthMask = glDepthMask; 55 interface->fDisable = glDisable; 56 interface->fDisableVertexAttribArray = glDisableVertexAttribArray; 57 interface->fDrawArrays = glDrawArrays; 58 interface->fDrawElements = glDrawElements; 59 interface->fEnable = glEnable; 60 interface->fEnableVertexAttribArray = glEnableVertexAttribArray; 61 interface->fFinish = glFinish; 62 interface->fFlush = glFlush; 63 interface->fFrontFace = glFrontFace; 64 interface->fGenBuffers = glGenBuffers; 65 interface->fGenerateMipmap = glGenerateMipmap; 66 interface->fGenTextures = glGenTextures; 67 interface->fGenVertexArrays = glGenVertexArraysOES; 68 interface->fGetBufferParameteriv = glGetBufferParameteriv; 69 interface->fGetError = glGetError; 70 interface->fGetIntegerv = glGetIntegerv; 71 interface->fGetProgramInfoLog = glGetProgramInfoLog; 72 interface->fGetProgramiv = glGetProgramiv; 73 interface->fGetShaderInfoLog = glGetShaderInfoLog; 74 interface->fGetShaderiv = glGetShaderiv; 75 interface->fGetString = glGetString; 76 #if GL_ES_VERSION_30 77 interface->fGetStringi = glGetStringi; 78 #else 79 interface->fGetStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi"); 80 #endif 81 interface->fGetUniformLocation = glGetUniformLocation; 82 interface->fLineWidth = glLineWidth; 83 interface->fLinkProgram = glLinkProgram; 84 interface->fPixelStorei = glPixelStorei; 85 interface->fReadPixels = glReadPixels; 86 interface->fScissor = glScissor; 87 #if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE 88 interface->fShaderSource = (GrGLShaderSourceProc) glShaderSource; 89 #else 90 interface->fShaderSource = glShaderSource; 91 #endif 92 interface->fStencilFunc = glStencilFunc; 93 interface->fStencilFuncSeparate = glStencilFuncSeparate; 94 interface->fStencilMask = glStencilMask; 95 interface->fStencilMaskSeparate = glStencilMaskSeparate; 96 interface->fStencilOp = glStencilOp; 97 interface->fStencilOpSeparate = glStencilOpSeparate; 98 interface->fTexImage2D = glTexImage2D; 99 interface->fTexParameteri = glTexParameteri; 100 interface->fTexParameteriv = glTexParameteriv; 101 interface->fTexSubImage2D = glTexSubImage2D; 102 103 if (version >= GR_GL_VER(3,0)) { 104 #if GL_ES_VERSION_3_0 105 interface->fTexStorage2D = glTexStorage2D; 106 #else 107 interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2D"); 108 #endif 109 } else { 110 #if GL_EXT_texture_storage 111 interface->fTexStorage2D = glTexStorage2DEXT; 112 #else 113 interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT"); 114 #endif 115 } 116 117 #if GL_EXT_discard_framebuffer 118 interface->fDiscardFramebuffer = glDiscardFramebufferEXT; 119 #endif 120 interface->fUniform1f = glUniform1f; 121 interface->fUniform1i = glUniform1i; 122 interface->fUniform1fv = glUniform1fv; 123 interface->fUniform1iv = glUniform1iv; 124 interface->fUniform2f = glUniform2f; 125 interface->fUniform2i = glUniform2i; 126 interface->fUniform2fv = glUniform2fv; 127 interface->fUniform2iv = glUniform2iv; 128 interface->fUniform3f = glUniform3f; 129 interface->fUniform3i = glUniform3i; 130 interface->fUniform3fv = glUniform3fv; 131 interface->fUniform3iv = glUniform3iv; 132 interface->fUniform4f = glUniform4f; 133 interface->fUniform4i = glUniform4i; 134 interface->fUniform4fv = glUniform4fv; 135 interface->fUniform4iv = glUniform4iv; 136 interface->fUniformMatrix2fv = glUniformMatrix2fv; 137 interface->fUniformMatrix3fv = glUniformMatrix3fv; 138 interface->fUniformMatrix4fv = glUniformMatrix4fv; 139 interface->fUseProgram = glUseProgram; 140 interface->fVertexAttrib4fv = glVertexAttrib4fv; 141 interface->fVertexAttribPointer = glVertexAttribPointer; 142 interface->fViewport = glViewport; 143 interface->fBindFramebuffer = glBindFramebuffer; 144 interface->fBindRenderbuffer = glBindRenderbuffer; 145 interface->fCheckFramebufferStatus = glCheckFramebufferStatus; 146 interface->fDeleteFramebuffers = glDeleteFramebuffers; 147 interface->fDeleteRenderbuffers = glDeleteRenderbuffers; 148 interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer; 149 interface->fFramebufferTexture2D = glFramebufferTexture2D; 150 #if GR_GL_IGNORE_ES3_MSAA 151 152 if (extensions.has("GL_EXT_multisampled_render_to_texture")) { 153 #if GL_EXT_multisampled_render_to_texture 154 interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleEXT; 155 interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleEXT; 156 #else 157 interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT"); 158 interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT"); 159 #endif 160 } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { 161 #if GL_IMG_multisampled_render_to_texture 162 interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleIMG; 163 interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleIMG; 164 #else 165 interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG"); 166 interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG"); 167 #endif 168 } 169 170 #else // GR_GL_IGNORE_ES3_MSAA 171 172 if (version >= GR_GL_VER(3,0)) { 173 #if GL_ES_VERSION_3_0 174 interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisample; 175 interface->fBlitFramebuffer = glBlitFramebuffer; 176 #else 177 interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisample"); 178 interface->fBlitFramebuffer = (GrGLBlitFramebufferProc) eglGetProcAddress("glBlitFramebuffer"); 179 #endif 180 } 181 if (extensions.has("GL_EXT_multisampled_render_to_texture")) { 182 #if GL_EXT_multisampled_render_to_texture 183 interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleEXT; 184 interface->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorageMultisampleEXT; 185 #else 186 interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT"); 187 interface->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT"); 188 #endif 189 } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { 190 #if GL_IMG_multisampled_render_to_texture 191 interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleIMG; 192 interface->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorageMultisampleIMG; 193 #else 194 interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG"); 195 interface->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG"); 196 #endif 197 } 198 199 #endif // GR_GL_IGNORE_ES3_MSAA 200 interface->fGenFramebuffers = glGenFramebuffers; 201 interface->fGenRenderbuffers = glGenRenderbuffers; 202 interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; 203 interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; 204 interface->fRenderbufferStorage = glRenderbufferStorage; 205 #if GL_OES_mapbuffer 206 interface->fMapBuffer = glMapBufferOES; 207 interface->fUnmapBuffer = glUnmapBufferOES; 208 #else 209 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES"); 210 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES"); 211 #endif 212 213 return interface; 214 } 215 216 static const GrGLInterface* create_desktop_interface(GrGLVersion version, 217 const GrGLExtensions& extensions) { 218 // Currently this assumes a 4.4 context or later. Supporting lower GL versions would require 219 // getting suffixed versions of pointers for supported extensions. 220 if (version < GR_GL_VER(4,4)) { 221 return NULL; 222 } 223 224 GrGLInterface* interface = SkNEW(GrGLInterface); 225 interface->fBindingsExported = kDesktop_GrGLBinding; 226 227 interface->fActiveTexture = (GrGLActiveTextureProc) eglGetProcAddress("glActiveTexture"); 228 interface->fAttachShader = (GrGLAttachShaderProc) eglGetProcAddress("glAttachShader"); 229 interface->fBeginQuery = (GrGLBeginQueryProc) eglGetProcAddress("glBeginQuery"); 230 interface->fBindAttribLocation = (GrGLBindAttribLocationProc) eglGetProcAddress("glBindAttribLocation"); 231 interface->fBindBuffer = (GrGLBindBufferProc) eglGetProcAddress("glBindBuffer"); 232 interface->fBindFragDataLocation = (GrGLBindFragDataLocationProc) eglGetProcAddress("glBindFragDataLocation"); 233 interface->fBindFragDataLocationIndexed = (GrGLBindFragDataLocationIndexedProc) eglGetProcAddress("glBindFragDataLocationIndexed"); 234 interface->fBindFramebuffer = (GrGLBindFramebufferProc) eglGetProcAddress("glBindFramebuffer"); 235 interface->fBindRenderbuffer = (GrGLBindRenderbufferProc) eglGetProcAddress("glBindRenderbuffer"); 236 interface->fBindTexture = (GrGLBindTextureProc) eglGetProcAddress("glBindTexture"); 237 interface->fBindVertexArray = (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArray"); 238 interface->fBlendColor = (GrGLBlendColorProc) eglGetProcAddress("glBlendColor"); 239 interface->fBlendFunc = (GrGLBlendFuncProc) eglGetProcAddress("glBlendFunc"); 240 interface->fBlitFramebuffer = (GrGLBlitFramebufferProc) eglGetProcAddress("glBlitFramebuffer"); 241 interface->fBufferData = (GrGLBufferDataProc) eglGetProcAddress("glBufferData"); 242 interface->fBufferSubData = (GrGLBufferSubDataProc) eglGetProcAddress("glBufferSubData"); 243 interface->fCheckFramebufferStatus = (GrGLCheckFramebufferStatusProc) eglGetProcAddress("glCheckFramebufferStatus"); 244 interface->fClear = (GrGLClearProc) eglGetProcAddress("glClear"); 245 interface->fClearColor = (GrGLClearColorProc) eglGetProcAddress("glClearColor"); 246 interface->fClearStencil = (GrGLClearStencilProc) eglGetProcAddress("glClearStencil"); 247 interface->fClientActiveTexture = (GrGLClientActiveTextureProc) eglGetProcAddress("glClientActiveTexture"); 248 interface->fColorMask = (GrGLColorMaskProc) eglGetProcAddress("glColorMask"); 249 interface->fCompileShader = (GrGLCompileShaderProc) eglGetProcAddress("glCompileShader"); 250 interface->fCompressedTexImage2D = (GrGLCompressedTexImage2DProc) eglGetProcAddress("glCompressedTexImage2D"); 251 interface->fCopyTexSubImage2D = (GrGLCopyTexSubImage2DProc) eglGetProcAddress("glCopyTexSubImage2D"); 252 interface->fCreateProgram = (GrGLCreateProgramProc) eglGetProcAddress("glCreateProgram"); 253 interface->fCreateShader = (GrGLCreateShaderProc) eglGetProcAddress("glCreateShader"); 254 interface->fCullFace = (GrGLCullFaceProc) eglGetProcAddress("glCullFace"); 255 interface->fDeleteBuffers = (GrGLDeleteBuffersProc) eglGetProcAddress("glDeleteBuffers"); 256 interface->fDeleteFramebuffers = (GrGLDeleteFramebuffersProc) eglGetProcAddress("glDeleteFramebuffers"); 257 interface->fDeleteProgram = (GrGLDeleteProgramProc) eglGetProcAddress("glDeleteProgram"); 258 interface->fDeleteQueries = (GrGLDeleteQueriesProc) eglGetProcAddress("glDeleteQueries"); 259 interface->fDeleteRenderbuffers = (GrGLDeleteRenderbuffersProc) eglGetProcAddress("glDeleteRenderbuffers"); 260 interface->fDeleteShader = (GrGLDeleteShaderProc) eglGetProcAddress("glDeleteShader"); 261 interface->fDeleteTextures = (GrGLDeleteTexturesProc) eglGetProcAddress("glDeleteTextures"); 262 interface->fDeleteVertexArrays = (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArrays"); 263 interface->fDepthMask = (GrGLDepthMaskProc) eglGetProcAddress("glDepthMask"); 264 interface->fDisable = (GrGLDisableProc) eglGetProcAddress("glDisable"); 265 interface->fDisableClientState = (GrGLDisableClientStateProc) eglGetProcAddress("glDisableClientState"); 266 interface->fDisableVertexAttribArray = (GrGLDisableVertexAttribArrayProc) eglGetProcAddress("glDisableVertexAttribArray"); 267 interface->fDrawArrays = (GrGLDrawArraysProc) eglGetProcAddress("glDrawArrays"); 268 interface->fDrawBuffer = (GrGLDrawBufferProc) eglGetProcAddress("glDrawBuffer"); 269 interface->fDrawBuffers = (GrGLDrawBuffersProc) eglGetProcAddress("glDrawBuffers"); 270 interface->fDrawElements = (GrGLDrawElementsProc) eglGetProcAddress("glDrawElements"); 271 interface->fEnable = (GrGLEnableProc) eglGetProcAddress("glEnable"); 272 interface->fEnableClientState = (GrGLEnableClientStateProc) eglGetProcAddress("glEnableClientState"); 273 interface->fEnableVertexAttribArray = (GrGLEnableVertexAttribArrayProc) eglGetProcAddress("glEnableVertexAttribArray"); 274 interface->fEndQuery = (GrGLEndQueryProc) eglGetProcAddress("glEndQuery"); 275 interface->fFinish = (GrGLFinishProc) eglGetProcAddress("glFinish"); 276 interface->fFlush = (GrGLFlushProc) eglGetProcAddress("glFlush"); 277 interface->fFramebufferRenderbuffer = (GrGLFramebufferRenderbufferProc) eglGetProcAddress("glFramebufferRenderbuffer"); 278 interface->fFramebufferTexture2D = (GrGLFramebufferTexture2DProc) eglGetProcAddress("glFramebufferTexture2D"); 279 interface->fFrontFace = (GrGLFrontFaceProc) eglGetProcAddress("glFrontFace"); 280 interface->fGenBuffers = (GrGLGenBuffersProc) eglGetProcAddress("glGenBuffers"); 281 interface->fGenFramebuffers = (GrGLGenFramebuffersProc) eglGetProcAddress("glGenFramebuffers"); 282 interface->fGenerateMipmap = (GrGLGenerateMipmapProc) eglGetProcAddress("glGenerateMipmap"); 283 interface->fGenQueries = (GrGLGenQueriesProc) eglGetProcAddress("glGenQueries"); 284 interface->fGenRenderbuffers = (GrGLGenRenderbuffersProc) eglGetProcAddress("glGenRenderbuffers"); 285 interface->fGenTextures = (GrGLGenTexturesProc) eglGetProcAddress("glGenTextures"); 286 interface->fGenVertexArrays = (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArrays"); 287 interface->fGetBufferParameteriv = (GrGLGetBufferParameterivProc) eglGetProcAddress("glGetBufferParameteriv"); 288 interface->fGetError = (GrGLGetErrorProc) eglGetProcAddress("glGetError"); 289 interface->fGetFramebufferAttachmentParameteriv = (GrGLGetFramebufferAttachmentParameterivProc) eglGetProcAddress("glGetFramebufferAttachmentParameteriv"); 290 interface->fGetIntegerv = (GrGLGetIntegervProc) eglGetProcAddress("glGetIntegerv"); 291 interface->fGetQueryObjecti64v = (GrGLGetQueryObjecti64vProc) eglGetProcAddress("glGetQueryObjecti64v"); 292 interface->fGetQueryObjectiv = (GrGLGetQueryObjectivProc) eglGetProcAddress("glGetQueryObjectiv"); 293 interface->fGetQueryObjectui64v = (GrGLGetQueryObjectui64vProc) eglGetProcAddress("glGetQueryObjectui64v"); 294 interface->fGetQueryObjectuiv = (GrGLGetQueryObjectuivProc) eglGetProcAddress("glGetQueryObjectuiv"); 295 interface->fGetQueryiv = (GrGLGetQueryivProc) eglGetProcAddress("glGetQueryiv"); 296 interface->fGetProgramInfoLog = (GrGLGetProgramInfoLogProc) eglGetProcAddress("glGetProgramInfoLog"); 297 interface->fGetProgramiv = (GrGLGetProgramivProc) eglGetProcAddress("glGetProgramiv"); 298 interface->fGetRenderbufferParameteriv = (GrGLGetRenderbufferParameterivProc) eglGetProcAddress("glGetRenderbufferParameteriv"); 299 interface->fGetShaderInfoLog = (GrGLGetShaderInfoLogProc) eglGetProcAddress("glGetShaderInfoLog"); 300 interface->fGetShaderiv = (GrGLGetShaderivProc) eglGetProcAddress("glGetShaderiv"); 301 interface->fGetString = (GrGLGetStringProc) eglGetProcAddress("glGetString"); 302 interface->fGetStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi"); 303 interface->fGetTexLevelParameteriv = (GrGLGetTexLevelParameterivProc) eglGetProcAddress("glGetTexLevelParameteriv"); 304 interface->fGetUniformLocation = (GrGLGetUniformLocationProc) eglGetProcAddress("glGetUniformLocation"); 305 interface->fLineWidth = (GrGLLineWidthProc) eglGetProcAddress("glLineWidth"); 306 interface->fLinkProgram = (GrGLLinkProgramProc) eglGetProcAddress("glLinkProgram"); 307 interface->fLoadIdentity = (GrGLLoadIdentityProc) eglGetProcAddress("glLoadIdentity"); 308 interface->fLoadMatrixf = (GrGLLoadMatrixfProc) eglGetProcAddress("glLoadMatrixf"); 309 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBuffer"); 310 interface->fMatrixMode = (GrGLMatrixModeProc) eglGetProcAddress("glMatrixMode"); 311 interface->fPixelStorei = (GrGLPixelStoreiProc) eglGetProcAddress("glPixelStorei"); 312 interface->fQueryCounter = (GrGLQueryCounterProc) eglGetProcAddress("glQueryCounter"); 313 interface->fReadBuffer = (GrGLReadBufferProc) eglGetProcAddress("glReadBuffer"); 314 interface->fReadPixels = (GrGLReadPixelsProc) eglGetProcAddress("glReadPixels"); 315 interface->fRenderbufferStorage = (GrGLRenderbufferStorageProc) eglGetProcAddress("glRenderbufferStorage"); 316 interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisample"); 317 interface->fScissor = (GrGLScissorProc) eglGetProcAddress("glScissor"); 318 interface->fShaderSource = (GrGLShaderSourceProc) eglGetProcAddress("glShaderSource"); 319 interface->fStencilFunc = (GrGLStencilFuncProc) eglGetProcAddress("glStencilFunc"); 320 interface->fStencilFuncSeparate = (GrGLStencilFuncSeparateProc) eglGetProcAddress("glStencilFuncSeparate"); 321 interface->fStencilMask = (GrGLStencilMaskProc) eglGetProcAddress("glStencilMask"); 322 interface->fStencilMaskSeparate = (GrGLStencilMaskSeparateProc) eglGetProcAddress("glStencilMaskSeparate"); 323 interface->fStencilOp = (GrGLStencilOpProc) eglGetProcAddress("glStencilOp"); 324 interface->fStencilOpSeparate = (GrGLStencilOpSeparateProc) eglGetProcAddress("glStencilOpSeparate"); 325 interface->fTexGenf = (GrGLTexGenfProc) eglGetProcAddress("glTexGenf"); 326 interface->fTexGenfv = (GrGLTexGenfvProc) eglGetProcAddress("glTexGenfv"); 327 interface->fTexGeni = (GrGLTexGeniProc) eglGetProcAddress("glTexGeni"); 328 interface->fTexImage2D = (GrGLTexImage2DProc) eglGetProcAddress("glTexImage2D"); 329 interface->fTexParameteri = (GrGLTexParameteriProc) eglGetProcAddress("glTexParameteri"); 330 interface->fTexParameteriv = (GrGLTexParameterivProc) eglGetProcAddress("glTexParameteriv"); 331 interface->fTexSubImage2D = (GrGLTexSubImage2DProc) eglGetProcAddress("glTexSubImage2D"); 332 interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2D"); 333 interface->fUniform1f = (GrGLUniform1fProc) eglGetProcAddress("glUniform1f"); 334 interface->fUniform1i = (GrGLUniform1iProc) eglGetProcAddress("glUniform1i"); 335 interface->fUniform1fv = (GrGLUniform1fvProc) eglGetProcAddress("glUniform1fv"); 336 interface->fUniform1iv = (GrGLUniform1ivProc) eglGetProcAddress("glUniform1iv"); 337 interface->fUniform2f = (GrGLUniform2fProc) eglGetProcAddress("glUniform2f"); 338 interface->fUniform2i = (GrGLUniform2iProc) eglGetProcAddress("glUniform2i"); 339 interface->fUniform2fv = (GrGLUniform2fvProc) eglGetProcAddress("glUniform2fv"); 340 interface->fUniform2iv = (GrGLUniform2ivProc) eglGetProcAddress("glUniform2iv"); 341 interface->fUniform3f = (GrGLUniform3fProc) eglGetProcAddress("glUniform3f"); 342 interface->fUniform3i = (GrGLUniform3iProc) eglGetProcAddress("glUniform3i"); 343 interface->fUniform3fv = (GrGLUniform3fvProc) eglGetProcAddress("glUniform3fv"); 344 interface->fUniform3iv = (GrGLUniform3ivProc) eglGetProcAddress("glUniform3iv"); 345 interface->fUniform4f = (GrGLUniform4fProc) eglGetProcAddress("glUniform4f"); 346 interface->fUniform4i = (GrGLUniform4iProc) eglGetProcAddress("glUniform4i"); 347 interface->fUniform4fv = (GrGLUniform4fvProc) eglGetProcAddress("glUniform4fv"); 348 interface->fUniform4iv = (GrGLUniform4ivProc) eglGetProcAddress("glUniform4iv"); 349 interface->fUniformMatrix2fv = (GrGLUniformMatrix2fvProc) eglGetProcAddress("glUniformMatrix2fv"); 350 interface->fUniformMatrix3fv = (GrGLUniformMatrix3fvProc) eglGetProcAddress("glUniformMatrix3fv"); 351 interface->fUniformMatrix4fv = (GrGLUniformMatrix4fvProc) eglGetProcAddress("glUniformMatrix4fv"); 352 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBuffer"); 353 interface->fUseProgram = (GrGLUseProgramProc) eglGetProcAddress("glUseProgram"); 354 interface->fVertexAttrib4fv = (GrGLVertexAttrib4fvProc) eglGetProcAddress("glVertexAttrib4fv"); 355 interface->fVertexAttribPointer = (GrGLVertexAttribPointerProc) eglGetProcAddress("glVertexAttribPointer"); 356 interface->fVertexPointer = (GrGLVertexPointerProc) eglGetProcAddress("glVertexPointer"); 357 interface->fViewport = (GrGLViewportProc) eglGetProcAddress("glViewport"); 358 359 if (extensions.has("GL_NV_path_rendering")) { 360 interface->fPathCommands = (GrGLPathCommandsProc) eglGetProcAddress("glPathCommandsNV"); 361 interface->fPathCoords = (GrGLPathCoordsProc) eglGetProcAddress("glPathCoordsNV"); 362 interface->fPathSubCommands = (GrGLPathSubCommandsProc) eglGetProcAddress("glPathSubCommandsNV"); 363 interface->fPathSubCoords = (GrGLPathSubCoordsProc) eglGetProcAddress("glPathSubCoordsNV"); 364 interface->fPathString = (GrGLPathStringProc) eglGetProcAddress("glPathStringNV"); 365 interface->fPathGlyphs = (GrGLPathGlyphsProc) eglGetProcAddress("glPathGlyphsNV"); 366 interface->fPathGlyphRange = (GrGLPathGlyphRangeProc) eglGetProcAddress("glPathGlyphRangeNV"); 367 interface->fWeightPaths = (GrGLWeightPathsProc) eglGetProcAddress("glWeightPathsNV"); 368 interface->fCopyPath = (GrGLCopyPathProc) eglGetProcAddress("glCopyPathNV"); 369 interface->fInterpolatePaths = (GrGLInterpolatePathsProc) eglGetProcAddress("glInterpolatePathsNV"); 370 interface->fTransformPath = (GrGLTransformPathProc) eglGetProcAddress("glTransformPathNV"); 371 interface->fPathParameteriv = (GrGLPathParameterivProc) eglGetProcAddress("glPathParameterivNV"); 372 interface->fPathParameteri = (GrGLPathParameteriProc) eglGetProcAddress("glPathParameteriNV"); 373 interface->fPathParameterfv = (GrGLPathParameterfvProc) eglGetProcAddress("glPathParameterfvNV"); 374 interface->fPathParameterf = (GrGLPathParameterfProc) eglGetProcAddress("glPathParameterfNV"); 375 interface->fPathDashArray = (GrGLPathDashArrayProc) eglGetProcAddress("glPathDashArrayNV"); 376 interface->fGenPaths = (GrGLGenPathsProc) eglGetProcAddress("glGenPathsNV"); 377 interface->fDeletePaths = (GrGLDeletePathsProc) eglGetProcAddress("glDeletePathsNV"); 378 interface->fIsPath = (GrGLIsPathProc) eglGetProcAddress("glIsPathNV"); 379 interface->fPathStencilFunc = (GrGLPathStencilFuncProc) eglGetProcAddress("glPathStencilFuncNV"); 380 interface->fPathStencilDepthOffset = (GrGLPathStencilDepthOffsetProc) eglGetProcAddress("glPathStencilDepthOffsetNV"); 381 interface->fStencilFillPath = (GrGLStencilFillPathProc) eglGetProcAddress("glStencilFillPathNV"); 382 interface->fStencilStrokePath = (GrGLStencilStrokePathProc) eglGetProcAddress("glStencilStrokePathNV"); 383 interface->fStencilFillPathInstanced = (GrGLStencilFillPathInstancedProc) eglGetProcAddress("glStencilFillPathInstancedNV"); 384 interface->fStencilStrokePathInstanced = (GrGLStencilStrokePathInstancedProc) eglGetProcAddress("glStencilStrokePathInstancedNV"); 385 interface->fPathCoverDepthFunc = (GrGLPathCoverDepthFuncProc) eglGetProcAddress("glPathCoverDepthFuncNV"); 386 interface->fPathColorGen = (GrGLPathColorGenProc) eglGetProcAddress("glPathColorGenNV"); 387 interface->fPathTexGen = (GrGLPathTexGenProc) eglGetProcAddress("glPathTexGenNV"); 388 interface->fPathFogGen = (GrGLPathFogGenProc) eglGetProcAddress("glPathFogGenNV"); 389 interface->fCoverFillPath = (GrGLCoverFillPathProc) eglGetProcAddress("glCoverFillPathNV"); 390 interface->fCoverStrokePath = (GrGLCoverStrokePathProc) eglGetProcAddress("glCoverStrokePathNV"); 391 interface->fCoverFillPathInstanced = (GrGLCoverFillPathInstancedProc) eglGetProcAddress("glCoverFillPathInstancedNV"); 392 interface->fCoverStrokePathInstanced = (GrGLCoverStrokePathInstancedProc) eglGetProcAddress("glCoverStrokePathInstancedNV"); 393 interface->fGetPathParameteriv = (GrGLGetPathParameterivProc) eglGetProcAddress("glGetPathParameterivNV"); 394 interface->fGetPathParameterfv = (GrGLGetPathParameterfvProc) eglGetProcAddress("glGetPathParameterfvNV"); 395 interface->fGetPathCommands = (GrGLGetPathCommandsProc) eglGetProcAddress("glGetPathCommandsNV"); 396 interface->fGetPathCoords = (GrGLGetPathCoordsProc) eglGetProcAddress("glGetPathCoordsNV"); 397 interface->fGetPathDashArray = (GrGLGetPathDashArrayProc) eglGetProcAddress("glGetPathDashArrayNV"); 398 interface->fGetPathMetrics = (GrGLGetPathMetricsProc) eglGetProcAddress("glGetPathMetricsNV"); 399 interface->fGetPathMetricRange = (GrGLGetPathMetricRangeProc) eglGetProcAddress("glGetPathMetricRangeNV"); 400 interface->fGetPathSpacing = (GrGLGetPathSpacingProc) eglGetProcAddress("glGetPathSpacingNV"); 401 interface->fGetPathColorGeniv = (GrGLGetPathColorGenivProc) eglGetProcAddress("glGetPathColorGenivNV"); 402 interface->fGetPathColorGenfv = (GrGLGetPathColorGenfvProc) eglGetProcAddress("glGetPathColorGenfvNV"); 403 interface->fGetPathTexGeniv = (GrGLGetPathTexGenivProc) eglGetProcAddress("glGetPathTexGenivNV"); 404 interface->fGetPathTexGenfv = (GrGLGetPathTexGenfvProc) eglGetProcAddress("glGetPathTexGenfvNV"); 405 interface->fIsPointInFillPath = (GrGLIsPointInFillPathProc) eglGetProcAddress("glIsPointInFillPathNV"); 406 interface->fIsPointInStrokePath = (GrGLIsPointInStrokePathProc) eglGetProcAddress("glIsPointInStrokePathNV"); 407 interface->fGetPathLength = (GrGLGetPathLengthProc) eglGetProcAddress("glGetPathLengthNV"); 408 interface->fPointAlongPath = (GrGLPointAlongPathProc) eglGetProcAddress("glPointAlongPathNV"); 409 } 410 411 return interface; 412 } 413 414 const GrGLInterface* GrGLCreateNativeInterface() { 415 416 GrGLGetStringiProc getStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi"); 417 418 const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION)); 419 GrGLVersion version = GrGLGetVersionFromString(verStr); 420 GrGLBinding binding = GrGLGetBindingInUseFromString(verStr); 421 422 GrGLExtensions extensions; 423 if (!extensions.init(binding, glGetString, getStringi, glGetIntegerv)) { 424 return NULL; 425 } 426 427 if (kES_GrGLBinding == binding) { 428 return create_es_interface(version, extensions); 429 } else if (kDesktop_GrGLBinding == binding) { 430 return create_desktop_interface(version, extensions); 431 } else { 432 return NULL; 433 } 434 } 435