gfx/skia/trunk/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

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

mercurial