Add OpenGL 4.4 support to SkNativeGLContext and GrGLCreateNativeInterface android versions.
R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://chromiumcodereview.appspot.com/23702015 git-svn-id: http://skia.googlecode.com/svn/trunk@11060 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
6a64189d6c
commit
f5897f83e6
@ -220,7 +220,10 @@ public:
|
|||||||
GLPtr<GrGLGetUniformLocationProc> fGetUniformLocation;
|
GLPtr<GrGLGetUniformLocationProc> fGetUniformLocation;
|
||||||
GLPtr<GrGLLineWidthProc> fLineWidth;
|
GLPtr<GrGLLineWidthProc> fLineWidth;
|
||||||
GLPtr<GrGLLinkProgramProc> fLinkProgram;
|
GLPtr<GrGLLinkProgramProc> fLinkProgram;
|
||||||
|
GLPtr<GrGLLoadIdentityProc> fLoadIdentity;
|
||||||
|
GLPtr<GrGLLoadMatrixfProc> fLoadMatrixf;
|
||||||
GLPtr<GrGLMapBufferProc> fMapBuffer;
|
GLPtr<GrGLMapBufferProc> fMapBuffer;
|
||||||
|
GLPtr<GrGLMatrixModeProc> fMatrixMode;
|
||||||
GLPtr<GrGLPixelStoreiProc> fPixelStorei;
|
GLPtr<GrGLPixelStoreiProc> fPixelStorei;
|
||||||
GLPtr<GrGLQueryCounterProc> fQueryCounter;
|
GLPtr<GrGLQueryCounterProc> fQueryCounter;
|
||||||
GLPtr<GrGLReadBufferProc> fReadBuffer;
|
GLPtr<GrGLReadBufferProc> fReadBuffer;
|
||||||
@ -275,9 +278,6 @@ public:
|
|||||||
// Experimental: Functions for GL_NV_path_rendering. These will be
|
// Experimental: Functions for GL_NV_path_rendering. These will be
|
||||||
// alphabetized with the above functions once this is fully supported
|
// alphabetized with the above functions once this is fully supported
|
||||||
// (and functions we are unlikely to use will possibly be omitted).
|
// (and functions we are unlikely to use will possibly be omitted).
|
||||||
GLPtr<GrGLMatrixModeProc> fMatrixMode;
|
|
||||||
GLPtr<GrGLLoadIdentityProc> fLoadIdentity;
|
|
||||||
GLPtr<GrGLLoadMatrixfProc> fLoadMatrixf;
|
|
||||||
GLPtr<GrGLPathCommandsProc> fPathCommands;
|
GLPtr<GrGLPathCommandsProc> fPathCommands;
|
||||||
GLPtr<GrGLPathCoordsProc> fPathCoords;
|
GLPtr<GrGLPathCoordsProc> fPathCoords;
|
||||||
GLPtr<GrGLPathSubCommandsProc> fPathSubCommands;
|
GLPtr<GrGLPathSubCommandsProc> fPathSubCommands;
|
||||||
|
@ -17,176 +17,386 @@
|
|||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
static const GrGLInterface* create_es_interface(GrGLVersion version,
|
||||||
static SkAutoTUnref<GrGLInterface> glInterface;
|
const GrGLExtensions& extensions) {
|
||||||
if (!glInterface.get()) {
|
if (version < GR_GL_VER(2,0)) {
|
||||||
GrGLExtensions extensions;
|
return NULL;
|
||||||
GrGLGetStringiProc getStringi;
|
}
|
||||||
#if GL_ES_VERSION_3_0
|
|
||||||
getStringi = glGetStringi;
|
GrGLInterface* interface = SkNEW(GrGLInterface);
|
||||||
|
interface->fBindingsExported = kES_GrGLBinding;
|
||||||
|
|
||||||
|
interface->fActiveTexture = glActiveTexture;
|
||||||
|
interface->fAttachShader = glAttachShader;
|
||||||
|
interface->fBindAttribLocation = glBindAttribLocation;
|
||||||
|
interface->fBindBuffer = glBindBuffer;
|
||||||
|
interface->fBindTexture = glBindTexture;
|
||||||
|
interface->fBindVertexArray = glBindVertexArrayOES;
|
||||||
|
interface->fBlendColor = glBlendColor;
|
||||||
|
interface->fBlendFunc = glBlendFunc;
|
||||||
|
interface->fBufferData = glBufferData;
|
||||||
|
interface->fBufferSubData = glBufferSubData;
|
||||||
|
interface->fClear = glClear;
|
||||||
|
interface->fClearColor = glClearColor;
|
||||||
|
interface->fClearStencil = glClearStencil;
|
||||||
|
interface->fColorMask = glColorMask;
|
||||||
|
interface->fCompileShader = glCompileShader;
|
||||||
|
interface->fCompressedTexImage2D = glCompressedTexImage2D;
|
||||||
|
interface->fCopyTexSubImage2D = glCopyTexSubImage2D;
|
||||||
|
interface->fCreateProgram = glCreateProgram;
|
||||||
|
interface->fCreateShader = glCreateShader;
|
||||||
|
interface->fCullFace = glCullFace;
|
||||||
|
interface->fDeleteBuffers = glDeleteBuffers;
|
||||||
|
interface->fDeleteProgram = glDeleteProgram;
|
||||||
|
interface->fDeleteShader = glDeleteShader;
|
||||||
|
interface->fDeleteTextures = glDeleteTextures;
|
||||||
|
interface->fDeleteVertexArrays = glDeleteVertexArraysOES;
|
||||||
|
interface->fDepthMask = glDepthMask;
|
||||||
|
interface->fDisable = glDisable;
|
||||||
|
interface->fDisableVertexAttribArray = glDisableVertexAttribArray;
|
||||||
|
interface->fDrawArrays = glDrawArrays;
|
||||||
|
interface->fDrawElements = glDrawElements;
|
||||||
|
interface->fEnable = glEnable;
|
||||||
|
interface->fEnableVertexAttribArray = glEnableVertexAttribArray;
|
||||||
|
interface->fFinish = glFinish;
|
||||||
|
interface->fFlush = glFlush;
|
||||||
|
interface->fFrontFace = glFrontFace;
|
||||||
|
interface->fGenBuffers = glGenBuffers;
|
||||||
|
interface->fGenerateMipmap = glGenerateMipmap;
|
||||||
|
interface->fGenTextures = glGenTextures;
|
||||||
|
interface->fGenVertexArrays = glGenVertexArraysOES;
|
||||||
|
interface->fGetBufferParameteriv = glGetBufferParameteriv;
|
||||||
|
interface->fGetError = glGetError;
|
||||||
|
interface->fGetIntegerv = glGetIntegerv;
|
||||||
|
interface->fGetProgramInfoLog = glGetProgramInfoLog;
|
||||||
|
interface->fGetProgramiv = glGetProgramiv;
|
||||||
|
interface->fGetShaderInfoLog = glGetShaderInfoLog;
|
||||||
|
interface->fGetShaderiv = glGetShaderiv;
|
||||||
|
interface->fGetString = glGetString;
|
||||||
|
#if GL_ES_VERSION_30
|
||||||
|
interface->fGetStringi = glGetStringi;
|
||||||
#else
|
#else
|
||||||
getStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
|
interface->fGetStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
|
||||||
#endif
|
#endif
|
||||||
|
interface->fGetUniformLocation = glGetUniformLocation;
|
||||||
if (!extensions.init(kES_GrGLBinding, glGetString, getStringi, glGetIntegerv)) {
|
interface->fLineWidth = glLineWidth;
|
||||||
return NULL;
|
interface->fLinkProgram = glLinkProgram;
|
||||||
}
|
interface->fPixelStorei = glPixelStorei;
|
||||||
const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION));
|
interface->fReadPixels = glReadPixels;
|
||||||
GrGLVersion version = GrGLGetVersionFromString(verStr);
|
interface->fScissor = glScissor;
|
||||||
if (version < GR_GL_VER(2,0)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrGLInterface* interface = new GrGLInterface;
|
|
||||||
glInterface.reset(interface);
|
|
||||||
interface->fBindingsExported = kES_GrGLBinding;
|
|
||||||
interface->fActiveTexture = glActiveTexture;
|
|
||||||
interface->fAttachShader = glAttachShader;
|
|
||||||
interface->fBindAttribLocation = glBindAttribLocation;
|
|
||||||
interface->fBindBuffer = glBindBuffer;
|
|
||||||
interface->fBindTexture = glBindTexture;
|
|
||||||
interface->fBindVertexArray = glBindVertexArrayOES;
|
|
||||||
interface->fBlendColor = glBlendColor;
|
|
||||||
interface->fBlendFunc = glBlendFunc;
|
|
||||||
interface->fBufferData = glBufferData;
|
|
||||||
interface->fBufferSubData = glBufferSubData;
|
|
||||||
interface->fClear = glClear;
|
|
||||||
interface->fClearColor = glClearColor;
|
|
||||||
interface->fClearStencil = glClearStencil;
|
|
||||||
interface->fColorMask = glColorMask;
|
|
||||||
interface->fCompileShader = glCompileShader;
|
|
||||||
interface->fCompressedTexImage2D = glCompressedTexImage2D;
|
|
||||||
interface->fCopyTexSubImage2D = glCopyTexSubImage2D;
|
|
||||||
interface->fCreateProgram = glCreateProgram;
|
|
||||||
interface->fCreateShader = glCreateShader;
|
|
||||||
interface->fCullFace = glCullFace;
|
|
||||||
interface->fDeleteBuffers = glDeleteBuffers;
|
|
||||||
interface->fDeleteProgram = glDeleteProgram;
|
|
||||||
interface->fDeleteShader = glDeleteShader;
|
|
||||||
interface->fDeleteTextures = glDeleteTextures;
|
|
||||||
interface->fDeleteVertexArrays = glDeleteVertexArraysOES;
|
|
||||||
interface->fDepthMask = glDepthMask;
|
|
||||||
interface->fDisable = glDisable;
|
|
||||||
interface->fDisableVertexAttribArray = glDisableVertexAttribArray;
|
|
||||||
interface->fDrawArrays = glDrawArrays;
|
|
||||||
interface->fDrawElements = glDrawElements;
|
|
||||||
interface->fEnable = glEnable;
|
|
||||||
interface->fEnableVertexAttribArray = glEnableVertexAttribArray;
|
|
||||||
interface->fFinish = glFinish;
|
|
||||||
interface->fFlush = glFlush;
|
|
||||||
interface->fFrontFace = glFrontFace;
|
|
||||||
interface->fGenBuffers = glGenBuffers;
|
|
||||||
interface->fGenerateMipmap = glGenerateMipmap;
|
|
||||||
interface->fGenTextures = glGenTextures;
|
|
||||||
interface->fGenVertexArrays = glGenVertexArraysOES;
|
|
||||||
interface->fGetBufferParameteriv = glGetBufferParameteriv;
|
|
||||||
interface->fGetError = glGetError;
|
|
||||||
interface->fGetIntegerv = glGetIntegerv;
|
|
||||||
interface->fGetProgramInfoLog = glGetProgramInfoLog;
|
|
||||||
interface->fGetProgramiv = glGetProgramiv;
|
|
||||||
interface->fGetShaderInfoLog = glGetShaderInfoLog;
|
|
||||||
interface->fGetShaderiv = glGetShaderiv;
|
|
||||||
interface->fGetString = glGetString;
|
|
||||||
interface->fGetStringi = getStringi; // located above
|
|
||||||
interface->fGetUniformLocation = glGetUniformLocation;
|
|
||||||
interface->fLineWidth = glLineWidth;
|
|
||||||
interface->fLinkProgram = glLinkProgram;
|
|
||||||
interface->fPixelStorei = glPixelStorei;
|
|
||||||
interface->fReadPixels = glReadPixels;
|
|
||||||
interface->fScissor = glScissor;
|
|
||||||
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
|
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
|
||||||
interface->fShaderSource = (GrGLShaderSourceProc) glShaderSource;
|
interface->fShaderSource = (GrGLShaderSourceProc) glShaderSource;
|
||||||
#else
|
#else
|
||||||
interface->fShaderSource = glShaderSource;
|
interface->fShaderSource = glShaderSource;
|
||||||
#endif
|
#endif
|
||||||
interface->fStencilFunc = glStencilFunc;
|
interface->fStencilFunc = glStencilFunc;
|
||||||
interface->fStencilFuncSeparate = glStencilFuncSeparate;
|
interface->fStencilFuncSeparate = glStencilFuncSeparate;
|
||||||
interface->fStencilMask = glStencilMask;
|
interface->fStencilMask = glStencilMask;
|
||||||
interface->fStencilMaskSeparate = glStencilMaskSeparate;
|
interface->fStencilMaskSeparate = glStencilMaskSeparate;
|
||||||
interface->fStencilOp = glStencilOp;
|
interface->fStencilOp = glStencilOp;
|
||||||
interface->fStencilOpSeparate = glStencilOpSeparate;
|
interface->fStencilOpSeparate = glStencilOpSeparate;
|
||||||
interface->fTexImage2D = glTexImage2D;
|
interface->fTexImage2D = glTexImage2D;
|
||||||
interface->fTexParameteri = glTexParameteri;
|
interface->fTexParameteri = glTexParameteri;
|
||||||
interface->fTexParameteriv = glTexParameteriv;
|
interface->fTexParameteriv = glTexParameteriv;
|
||||||
interface->fTexSubImage2D = glTexSubImage2D;
|
interface->fTexSubImage2D = glTexSubImage2D;
|
||||||
|
|
||||||
if (version >= GR_GL_VER(3,0)) {
|
if (version >= GR_GL_VER(3,0)) {
|
||||||
#if GL_ES_VERSION_3_0
|
#if GL_ES_VERSION_3_0
|
||||||
interface->fTexStorage2D = glTexStorage2D;
|
interface->fTexStorage2D = glTexStorage2D;
|
||||||
#else
|
#else
|
||||||
interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2D");
|
interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2D");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if GL_EXT_texture_storage
|
#if GL_EXT_texture_storage
|
||||||
interface->fTexStorage2D = glTexStorage2DEXT;
|
interface->fTexStorage2D = glTexStorage2DEXT;
|
||||||
#else
|
#else
|
||||||
interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
|
interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GL_EXT_discard_framebuffer
|
|
||||||
interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
|
|
||||||
#endif
|
|
||||||
interface->fUniform1f = glUniform1f;
|
|
||||||
interface->fUniform1i = glUniform1i;
|
|
||||||
interface->fUniform1fv = glUniform1fv;
|
|
||||||
interface->fUniform1iv = glUniform1iv;
|
|
||||||
interface->fUniform2f = glUniform2f;
|
|
||||||
interface->fUniform2i = glUniform2i;
|
|
||||||
interface->fUniform2fv = glUniform2fv;
|
|
||||||
interface->fUniform2iv = glUniform2iv;
|
|
||||||
interface->fUniform3f = glUniform3f;
|
|
||||||
interface->fUniform3i = glUniform3i;
|
|
||||||
interface->fUniform3fv = glUniform3fv;
|
|
||||||
interface->fUniform3iv = glUniform3iv;
|
|
||||||
interface->fUniform4f = glUniform4f;
|
|
||||||
interface->fUniform4i = glUniform4i;
|
|
||||||
interface->fUniform4fv = glUniform4fv;
|
|
||||||
interface->fUniform4iv = glUniform4iv;
|
|
||||||
interface->fUniformMatrix2fv = glUniformMatrix2fv;
|
|
||||||
interface->fUniformMatrix3fv = glUniformMatrix3fv;
|
|
||||||
interface->fUniformMatrix4fv = glUniformMatrix4fv;
|
|
||||||
interface->fUseProgram = glUseProgram;
|
|
||||||
interface->fVertexAttrib4fv = glVertexAttrib4fv;
|
|
||||||
interface->fVertexAttribPointer = glVertexAttribPointer;
|
|
||||||
interface->fViewport = glViewport;
|
|
||||||
interface->fBindFramebuffer = glBindFramebuffer;
|
|
||||||
interface->fBindRenderbuffer = glBindRenderbuffer;
|
|
||||||
interface->fCheckFramebufferStatus = glCheckFramebufferStatus;
|
|
||||||
interface->fDeleteFramebuffers = glDeleteFramebuffers;
|
|
||||||
interface->fDeleteRenderbuffers = glDeleteRenderbuffers;
|
|
||||||
interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
|
||||||
interface->fFramebufferTexture2D = glFramebufferTexture2D;
|
|
||||||
if (extensions.has("GL_EXT_multisampled_render_to_texture")) {
|
|
||||||
#if GL_EXT_multisampled_render_to_texture
|
|
||||||
interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleEXT;
|
|
||||||
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleEXT;
|
|
||||||
#else
|
|
||||||
interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT");
|
|
||||||
interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT");
|
|
||||||
#endif
|
|
||||||
} else if (extensions.has("GL_IMG_multisampled_render_to_texture")) {
|
|
||||||
#if GL_IMG_multisampled_render_to_texture
|
|
||||||
interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleIMG;
|
|
||||||
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleIMG;
|
|
||||||
#else
|
|
||||||
interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG");
|
|
||||||
interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
interface->fGenFramebuffers = glGenFramebuffers;
|
|
||||||
interface->fGenRenderbuffers = glGenRenderbuffers;
|
|
||||||
interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
|
||||||
interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
|
||||||
interface->fRenderbufferStorage = glRenderbufferStorage;
|
|
||||||
#if GL_OES_mapbuffer
|
|
||||||
interface->fMapBuffer = glMapBufferOES;
|
|
||||||
interface->fUnmapBuffer = glUnmapBufferOES;
|
|
||||||
#else
|
|
||||||
interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
|
|
||||||
interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
glInterface.get()->ref();
|
|
||||||
return glInterface.get();
|
#if GL_EXT_discard_framebuffer
|
||||||
|
interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
|
||||||
|
#endif
|
||||||
|
interface->fUniform1f = glUniform1f;
|
||||||
|
interface->fUniform1i = glUniform1i;
|
||||||
|
interface->fUniform1fv = glUniform1fv;
|
||||||
|
interface->fUniform1iv = glUniform1iv;
|
||||||
|
interface->fUniform2f = glUniform2f;
|
||||||
|
interface->fUniform2i = glUniform2i;
|
||||||
|
interface->fUniform2fv = glUniform2fv;
|
||||||
|
interface->fUniform2iv = glUniform2iv;
|
||||||
|
interface->fUniform3f = glUniform3f;
|
||||||
|
interface->fUniform3i = glUniform3i;
|
||||||
|
interface->fUniform3fv = glUniform3fv;
|
||||||
|
interface->fUniform3iv = glUniform3iv;
|
||||||
|
interface->fUniform4f = glUniform4f;
|
||||||
|
interface->fUniform4i = glUniform4i;
|
||||||
|
interface->fUniform4fv = glUniform4fv;
|
||||||
|
interface->fUniform4iv = glUniform4iv;
|
||||||
|
interface->fUniformMatrix2fv = glUniformMatrix2fv;
|
||||||
|
interface->fUniformMatrix3fv = glUniformMatrix3fv;
|
||||||
|
interface->fUniformMatrix4fv = glUniformMatrix4fv;
|
||||||
|
interface->fUseProgram = glUseProgram;
|
||||||
|
interface->fVertexAttrib4fv = glVertexAttrib4fv;
|
||||||
|
interface->fVertexAttribPointer = glVertexAttribPointer;
|
||||||
|
interface->fViewport = glViewport;
|
||||||
|
interface->fBindFramebuffer = glBindFramebuffer;
|
||||||
|
interface->fBindRenderbuffer = glBindRenderbuffer;
|
||||||
|
interface->fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||||
|
interface->fDeleteFramebuffers = glDeleteFramebuffers;
|
||||||
|
interface->fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||||
|
interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
||||||
|
interface->fFramebufferTexture2D = glFramebufferTexture2D;
|
||||||
|
if (extensions.has("GL_EXT_multisampled_render_to_texture")) {
|
||||||
|
#if GL_EXT_multisampled_render_to_texture
|
||||||
|
interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleEXT;
|
||||||
|
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleEXT;
|
||||||
|
#else
|
||||||
|
interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT");
|
||||||
|
interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT");
|
||||||
|
#endif
|
||||||
|
} else if (extensions.has("GL_IMG_multisampled_render_to_texture")) {
|
||||||
|
#if GL_IMG_multisampled_render_to_texture
|
||||||
|
interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleIMG;
|
||||||
|
interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleIMG;
|
||||||
|
#else
|
||||||
|
interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG");
|
||||||
|
interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
interface->fGenFramebuffers = glGenFramebuffers;
|
||||||
|
interface->fGenRenderbuffers = glGenRenderbuffers;
|
||||||
|
interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||||
|
interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||||
|
interface->fRenderbufferStorage = glRenderbufferStorage;
|
||||||
|
#if GL_OES_mapbuffer
|
||||||
|
interface->fMapBuffer = glMapBufferOES;
|
||||||
|
interface->fUnmapBuffer = glUnmapBufferOES;
|
||||||
|
#else
|
||||||
|
interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
|
||||||
|
interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GrGLInterface* create_desktop_interface(GrGLVersion version,
|
||||||
|
const GrGLExtensions& extensions) {
|
||||||
|
// Currently this assumes a 4.4 context or later. Supporting lower GL versions would require
|
||||||
|
// getting suffixed versions of pointers for supported extensions.
|
||||||
|
if (version < GR_GL_VER(4,4)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GrGLInterface* interface = SkNEW(GrGLInterface);
|
||||||
|
interface->fBindingsExported = kDesktop_GrGLBinding;
|
||||||
|
|
||||||
|
interface->fActiveTexture = (GrGLActiveTextureProc) eglGetProcAddress("glActiveTexture");
|
||||||
|
interface->fAttachShader = (GrGLAttachShaderProc) eglGetProcAddress("glAttachShader");
|
||||||
|
interface->fBeginQuery = (GrGLBeginQueryProc) eglGetProcAddress("glBeginQuery");
|
||||||
|
interface->fBindAttribLocation = (GrGLBindAttribLocationProc) eglGetProcAddress("glBindAttribLocation");
|
||||||
|
interface->fBindBuffer = (GrGLBindBufferProc) eglGetProcAddress("glBindBuffer");
|
||||||
|
interface->fBindFragDataLocation = (GrGLBindFragDataLocationProc) eglGetProcAddress("glBindFragDataLocation");
|
||||||
|
interface->fBindFragDataLocationIndexed = (GrGLBindFragDataLocationIndexedProc) eglGetProcAddress("glBindFragDataLocationIndexed");
|
||||||
|
interface->fBindFramebuffer = (GrGLBindFramebufferProc) eglGetProcAddress("glBindFramebuffer");
|
||||||
|
interface->fBindRenderbuffer = (GrGLBindRenderbufferProc) eglGetProcAddress("glBindRenderbuffer");
|
||||||
|
interface->fBindTexture = (GrGLBindTextureProc) eglGetProcAddress("glBindTexture");
|
||||||
|
interface->fBindVertexArray = (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArray");
|
||||||
|
interface->fBlendColor = (GrGLBlendColorProc) eglGetProcAddress("glBlendColor");
|
||||||
|
interface->fBlendFunc = (GrGLBlendFuncProc) eglGetProcAddress("glBlendFunc");
|
||||||
|
interface->fBlitFramebuffer = (GrGLBlitFramebufferProc) eglGetProcAddress("glBlitFramebuffer");
|
||||||
|
interface->fBufferData = (GrGLBufferDataProc) eglGetProcAddress("glBufferData");
|
||||||
|
interface->fBufferSubData = (GrGLBufferSubDataProc) eglGetProcAddress("glBufferSubData");
|
||||||
|
interface->fCheckFramebufferStatus = (GrGLCheckFramebufferStatusProc) eglGetProcAddress("glCheckFramebufferStatus");
|
||||||
|
interface->fClear = (GrGLClearProc) eglGetProcAddress("glClear");
|
||||||
|
interface->fClearColor = (GrGLClearColorProc) eglGetProcAddress("glClearColor");
|
||||||
|
interface->fClearStencil = (GrGLClearStencilProc) eglGetProcAddress("glClearStencil");
|
||||||
|
interface->fClientActiveTexture = (GrGLClientActiveTextureProc) eglGetProcAddress("glClientActiveTexture");
|
||||||
|
interface->fColorMask = (GrGLColorMaskProc) eglGetProcAddress("glColorMask");
|
||||||
|
interface->fCompileShader = (GrGLCompileShaderProc) eglGetProcAddress("glCompileShader");
|
||||||
|
interface->fCompressedTexImage2D = (GrGLCompressedTexImage2DProc) eglGetProcAddress("glCompressedTexImage2D");
|
||||||
|
interface->fCopyTexSubImage2D = (GrGLCopyTexSubImage2DProc) eglGetProcAddress("glCopyTexSubImage2D");
|
||||||
|
interface->fCreateProgram = (GrGLCreateProgramProc) eglGetProcAddress("glCreateProgram");
|
||||||
|
interface->fCreateShader = (GrGLCreateShaderProc) eglGetProcAddress("glCreateShader");
|
||||||
|
interface->fCullFace = (GrGLCullFaceProc) eglGetProcAddress("glCullFace");
|
||||||
|
interface->fDeleteBuffers = (GrGLDeleteBuffersProc) eglGetProcAddress("glDeleteBuffers");
|
||||||
|
interface->fDeleteFramebuffers = (GrGLDeleteFramebuffersProc) eglGetProcAddress("glDeleteFramebuffers");
|
||||||
|
interface->fDeleteProgram = (GrGLDeleteProgramProc) eglGetProcAddress("glDeleteProgram");
|
||||||
|
interface->fDeleteQueries = (GrGLDeleteQueriesProc) eglGetProcAddress("glDeleteQueries");
|
||||||
|
interface->fDeleteRenderbuffers = (GrGLDeleteRenderbuffersProc) eglGetProcAddress("glDeleteRenderbuffers");
|
||||||
|
interface->fDeleteShader = (GrGLDeleteShaderProc) eglGetProcAddress("glDeleteShader");
|
||||||
|
interface->fDeleteTextures = (GrGLDeleteTexturesProc) eglGetProcAddress("glDeleteTextures");
|
||||||
|
interface->fDeleteVertexArrays = (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArrays");
|
||||||
|
interface->fDepthMask = (GrGLDepthMaskProc) eglGetProcAddress("glDepthMask");
|
||||||
|
interface->fDisable = (GrGLDisableProc) eglGetProcAddress("glDisable");
|
||||||
|
interface->fDisableClientState = (GrGLDisableClientStateProc) eglGetProcAddress("glDisableClientState");
|
||||||
|
interface->fDisableVertexAttribArray = (GrGLDisableVertexAttribArrayProc) eglGetProcAddress("glDisableVertexAttribArray");
|
||||||
|
interface->fDrawArrays = (GrGLDrawArraysProc) eglGetProcAddress("glDrawArrays");
|
||||||
|
interface->fDrawBuffer = (GrGLDrawBufferProc) eglGetProcAddress("glDrawBuffer");
|
||||||
|
interface->fDrawBuffers = (GrGLDrawBuffersProc) eglGetProcAddress("glDrawBuffers");
|
||||||
|
interface->fDrawElements = (GrGLDrawElementsProc) eglGetProcAddress("glDrawElements");
|
||||||
|
interface->fEnable = (GrGLEnableProc) eglGetProcAddress("glEnable");
|
||||||
|
interface->fEnableClientState = (GrGLEnableClientStateProc) eglGetProcAddress("glEnableClientState");
|
||||||
|
interface->fEnableVertexAttribArray = (GrGLEnableVertexAttribArrayProc) eglGetProcAddress("glEnableVertexAttribArray");
|
||||||
|
interface->fEndQuery = (GrGLEndQueryProc) eglGetProcAddress("glEndQuery");
|
||||||
|
interface->fFinish = (GrGLFinishProc) eglGetProcAddress("glFinish");
|
||||||
|
interface->fFlush = (GrGLFlushProc) eglGetProcAddress("glFlush");
|
||||||
|
interface->fFramebufferRenderbuffer = (GrGLFramebufferRenderbufferProc) eglGetProcAddress("glFramebufferRenderbuffer");
|
||||||
|
interface->fFramebufferTexture2D = (GrGLFramebufferTexture2DProc) eglGetProcAddress("glFramebufferTexture2D");
|
||||||
|
interface->fFrontFace = (GrGLFrontFaceProc) eglGetProcAddress("glFrontFace");
|
||||||
|
interface->fGenBuffers = (GrGLGenBuffersProc) eglGetProcAddress("glGenBuffers");
|
||||||
|
interface->fGenFramebuffers = (GrGLGenFramebuffersProc) eglGetProcAddress("glGenFramebuffers");
|
||||||
|
interface->fGenerateMipmap = (GrGLGenerateMipmapProc) eglGetProcAddress("glGenerateMipmap");
|
||||||
|
interface->fGenQueries = (GrGLGenQueriesProc) eglGetProcAddress("glGenQueries");
|
||||||
|
interface->fGenRenderbuffers = (GrGLGenRenderbuffersProc) eglGetProcAddress("glGenRenderbuffers");
|
||||||
|
interface->fGenTextures = (GrGLGenTexturesProc) eglGetProcAddress("glGenTextures");
|
||||||
|
interface->fGenVertexArrays = (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArrays");
|
||||||
|
interface->fGetBufferParameteriv = (GrGLGetBufferParameterivProc) eglGetProcAddress("glGetBufferParameteriv");
|
||||||
|
interface->fGetError = (GrGLGetErrorProc) eglGetProcAddress("glGetError");
|
||||||
|
interface->fGetFramebufferAttachmentParameteriv = (GrGLGetFramebufferAttachmentParameterivProc) eglGetProcAddress("glGetFramebufferAttachmentParameteriv");
|
||||||
|
interface->fGetIntegerv = (GrGLGetIntegervProc) eglGetProcAddress("glGetIntegerv");
|
||||||
|
interface->fGetQueryObjecti64v = (GrGLGetQueryObjecti64vProc) eglGetProcAddress("glGetQueryObjecti64v");
|
||||||
|
interface->fGetQueryObjectiv = (GrGLGetQueryObjectivProc) eglGetProcAddress("glGetQueryObjectiv");
|
||||||
|
interface->fGetQueryObjectui64v = (GrGLGetQueryObjectui64vProc) eglGetProcAddress("glGetQueryObjectui64v");
|
||||||
|
interface->fGetQueryObjectuiv = (GrGLGetQueryObjectuivProc) eglGetProcAddress("glGetQueryObjectuiv");
|
||||||
|
interface->fGetQueryiv = (GrGLGetQueryivProc) eglGetProcAddress("glGetQueryiv");
|
||||||
|
interface->fGetProgramInfoLog = (GrGLGetProgramInfoLogProc) eglGetProcAddress("glGetProgramInfoLog");
|
||||||
|
interface->fGetProgramiv = (GrGLGetProgramivProc) eglGetProcAddress("glGetProgramiv");
|
||||||
|
interface->fGetRenderbufferParameteriv = (GrGLGetRenderbufferParameterivProc) eglGetProcAddress("glGetRenderbufferParameteriv");
|
||||||
|
interface->fGetShaderInfoLog = (GrGLGetShaderInfoLogProc) eglGetProcAddress("glGetShaderInfoLog");
|
||||||
|
interface->fGetShaderiv = (GrGLGetShaderivProc) eglGetProcAddress("glGetShaderiv");
|
||||||
|
interface->fGetString = (GrGLGetStringProc) eglGetProcAddress("glGetString");
|
||||||
|
interface->fGetStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
|
||||||
|
interface->fGetTexLevelParameteriv = (GrGLGetTexLevelParameterivProc) eglGetProcAddress("glGetTexLevelParameteriv");
|
||||||
|
interface->fGetUniformLocation = (GrGLGetUniformLocationProc) eglGetProcAddress("glGetUniformLocation");
|
||||||
|
interface->fLineWidth = (GrGLLineWidthProc) eglGetProcAddress("glLineWidth");
|
||||||
|
interface->fLinkProgram = (GrGLLinkProgramProc) eglGetProcAddress("glLinkProgram");
|
||||||
|
interface->fLoadIdentity = (GrGLLoadIdentityProc) eglGetProcAddress("glLoadIdentity");
|
||||||
|
interface->fLoadMatrixf = (GrGLLoadMatrixfProc) eglGetProcAddress("glLoadMatrixf");
|
||||||
|
interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBuffer");
|
||||||
|
interface->fMatrixMode = (GrGLMatrixModeProc) eglGetProcAddress("glMatrixMode");
|
||||||
|
interface->fPixelStorei = (GrGLPixelStoreiProc) eglGetProcAddress("glPixelStorei");
|
||||||
|
interface->fQueryCounter = (GrGLQueryCounterProc) eglGetProcAddress("glQueryCounter");
|
||||||
|
interface->fReadBuffer = (GrGLReadBufferProc) eglGetProcAddress("glReadBuffer");
|
||||||
|
interface->fReadPixels = (GrGLReadPixelsProc) eglGetProcAddress("glReadPixels");
|
||||||
|
interface->fRenderbufferStorage = (GrGLRenderbufferStorageProc) eglGetProcAddress("glRenderbufferStorage");
|
||||||
|
interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisample");
|
||||||
|
interface->fRenderbufferStorageMultisampleCoverage = (GrGLRenderbufferStorageMultisampleCoverageProc) eglGetProcAddress("glRenderbufferStorageMultisampleCoverage");
|
||||||
|
interface->fScissor = (GrGLScissorProc) eglGetProcAddress("glScissor");
|
||||||
|
interface->fShaderSource = (GrGLShaderSourceProc) eglGetProcAddress("glShaderSource");
|
||||||
|
interface->fStencilFunc = (GrGLStencilFuncProc) eglGetProcAddress("glStencilFunc");
|
||||||
|
interface->fStencilFuncSeparate = (GrGLStencilFuncSeparateProc) eglGetProcAddress("glStencilFuncSeparate");
|
||||||
|
interface->fStencilMask = (GrGLStencilMaskProc) eglGetProcAddress("glStencilMask");
|
||||||
|
interface->fStencilMaskSeparate = (GrGLStencilMaskSeparateProc) eglGetProcAddress("glStencilMaskSeparate");
|
||||||
|
interface->fStencilOp = (GrGLStencilOpProc) eglGetProcAddress("glStencilOp");
|
||||||
|
interface->fStencilOpSeparate = (GrGLStencilOpSeparateProc) eglGetProcAddress("glStencilOpSeparate");
|
||||||
|
interface->fTexGenf = (GrGLTexGenfProc) eglGetProcAddress("glTexGenf");
|
||||||
|
interface->fTexGenfv = (GrGLTexGenfvProc) eglGetProcAddress("glTexGenfv");
|
||||||
|
interface->fTexGeni = (GrGLTexGeniProc) eglGetProcAddress("glTexGeni");
|
||||||
|
interface->fTexImage2D = (GrGLTexImage2DProc) eglGetProcAddress("glTexImage2D");
|
||||||
|
interface->fTexParameteri = (GrGLTexParameteriProc) eglGetProcAddress("glTexParameteri");
|
||||||
|
interface->fTexParameteriv = (GrGLTexParameterivProc) eglGetProcAddress("glTexParameteriv");
|
||||||
|
interface->fTexSubImage2D = (GrGLTexSubImage2DProc) eglGetProcAddress("glTexSubImage2D");
|
||||||
|
interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2D");
|
||||||
|
interface->fUniform1f = (GrGLUniform1fProc) eglGetProcAddress("glUniform1f");
|
||||||
|
interface->fUniform1i = (GrGLUniform1iProc) eglGetProcAddress("glUniform1i");
|
||||||
|
interface->fUniform1fv = (GrGLUniform1fvProc) eglGetProcAddress("glUniform1fv");
|
||||||
|
interface->fUniform1iv = (GrGLUniform1ivProc) eglGetProcAddress("glUniform1iv");
|
||||||
|
interface->fUniform2f = (GrGLUniform2fProc) eglGetProcAddress("glUniform2f");
|
||||||
|
interface->fUniform2i = (GrGLUniform2iProc) eglGetProcAddress("glUniform2i");
|
||||||
|
interface->fUniform2fv = (GrGLUniform2fvProc) eglGetProcAddress("glUniform2fv");
|
||||||
|
interface->fUniform2iv = (GrGLUniform2ivProc) eglGetProcAddress("glUniform2iv");
|
||||||
|
interface->fUniform3f = (GrGLUniform3fProc) eglGetProcAddress("glUniform3f");
|
||||||
|
interface->fUniform3i = (GrGLUniform3iProc) eglGetProcAddress("glUniform3i");
|
||||||
|
interface->fUniform3fv = (GrGLUniform3fvProc) eglGetProcAddress("glUniform3fv");
|
||||||
|
interface->fUniform3iv = (GrGLUniform3ivProc) eglGetProcAddress("glUniform3iv");
|
||||||
|
interface->fUniform4f = (GrGLUniform4fProc) eglGetProcAddress("glUniform4f");
|
||||||
|
interface->fUniform4i = (GrGLUniform4iProc) eglGetProcAddress("glUniform4i");
|
||||||
|
interface->fUniform4fv = (GrGLUniform4fvProc) eglGetProcAddress("glUniform4fv");
|
||||||
|
interface->fUniform4iv = (GrGLUniform4ivProc) eglGetProcAddress("glUniform4iv");
|
||||||
|
interface->fUniformMatrix2fv = (GrGLUniformMatrix2fvProc) eglGetProcAddress("glUniformMatrix2fv");
|
||||||
|
interface->fUniformMatrix3fv = (GrGLUniformMatrix3fvProc) eglGetProcAddress("glUniformMatrix3fv");
|
||||||
|
interface->fUniformMatrix4fv = (GrGLUniformMatrix4fvProc) eglGetProcAddress("glUniformMatrix4fv");
|
||||||
|
interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBuffer");
|
||||||
|
interface->fUseProgram = (GrGLUseProgramProc) eglGetProcAddress("glUseProgram");
|
||||||
|
interface->fVertexAttrib4fv = (GrGLVertexAttrib4fvProc) eglGetProcAddress("glVertexAttrib4fv");
|
||||||
|
interface->fVertexAttribPointer = (GrGLVertexAttribPointerProc) eglGetProcAddress("glVertexAttribPointer");
|
||||||
|
interface->fVertexPointer = (GrGLVertexPointerProc) eglGetProcAddress("glVertexPointer");
|
||||||
|
interface->fViewport = (GrGLViewportProc) eglGetProcAddress("glViewport");
|
||||||
|
|
||||||
|
if (extensions.has("GL_NV_path_rendering")) {
|
||||||
|
interface->fPathCommands = (GrGLPathCommandsProc) eglGetProcAddress("glPathCommandsNV");
|
||||||
|
interface->fPathCoords = (GrGLPathCoordsProc) eglGetProcAddress("glPathCoordsNV");
|
||||||
|
interface->fPathSubCommands = (GrGLPathSubCommandsProc) eglGetProcAddress("glPathSubCommandsNV");
|
||||||
|
interface->fPathSubCoords = (GrGLPathSubCoordsProc) eglGetProcAddress("glPathSubCoordsNV");
|
||||||
|
interface->fPathString = (GrGLPathStringProc) eglGetProcAddress("glPathStringNV");
|
||||||
|
interface->fPathGlyphs = (GrGLPathGlyphsProc) eglGetProcAddress("glPathGlyphsNV");
|
||||||
|
interface->fPathGlyphRange = (GrGLPathGlyphRangeProc) eglGetProcAddress("glPathGlyphRangeNV");
|
||||||
|
interface->fWeightPaths = (GrGLWeightPathsProc) eglGetProcAddress("glWeightPathsNV");
|
||||||
|
interface->fCopyPath = (GrGLCopyPathProc) eglGetProcAddress("glCopyPathNV");
|
||||||
|
interface->fInterpolatePaths = (GrGLInterpolatePathsProc) eglGetProcAddress("glInterpolatePathsNV");
|
||||||
|
interface->fTransformPath = (GrGLTransformPathProc) eglGetProcAddress("glTransformPathNV");
|
||||||
|
interface->fPathParameteriv = (GrGLPathParameterivProc) eglGetProcAddress("glPathParameterivNV");
|
||||||
|
interface->fPathParameteri = (GrGLPathParameteriProc) eglGetProcAddress("glPathParameteriNV");
|
||||||
|
interface->fPathParameterfv = (GrGLPathParameterfvProc) eglGetProcAddress("glPathParameterfvNV");
|
||||||
|
interface->fPathParameterf = (GrGLPathParameterfProc) eglGetProcAddress("glPathParameterfNV");
|
||||||
|
interface->fPathDashArray = (GrGLPathDashArrayProc) eglGetProcAddress("glPathDashArrayNV");
|
||||||
|
interface->fGenPaths = (GrGLGenPathsProc) eglGetProcAddress("glGenPathsNV");
|
||||||
|
interface->fDeletePaths = (GrGLDeletePathsProc) eglGetProcAddress("glDeletePathsNV");
|
||||||
|
interface->fIsPath = (GrGLIsPathProc) eglGetProcAddress("glIsPathNV");
|
||||||
|
interface->fPathStencilFunc = (GrGLPathStencilFuncProc) eglGetProcAddress("glPathStencilFuncNV");
|
||||||
|
interface->fPathStencilDepthOffset = (GrGLPathStencilDepthOffsetProc) eglGetProcAddress("glPathStencilDepthOffsetNV");
|
||||||
|
interface->fStencilFillPath = (GrGLStencilFillPathProc) eglGetProcAddress("glStencilFillPathNV");
|
||||||
|
interface->fStencilStrokePath = (GrGLStencilStrokePathProc) eglGetProcAddress("glStencilStrokePathNV");
|
||||||
|
interface->fStencilFillPathInstanced = (GrGLStencilFillPathInstancedProc) eglGetProcAddress("glStencilFillPathInstancedNV");
|
||||||
|
interface->fStencilStrokePathInstanced = (GrGLStencilStrokePathInstancedProc) eglGetProcAddress("glStencilStrokePathInstancedNV");
|
||||||
|
interface->fPathCoverDepthFunc = (GrGLPathCoverDepthFuncProc) eglGetProcAddress("glPathCoverDepthFuncNV");
|
||||||
|
interface->fPathColorGen = (GrGLPathColorGenProc) eglGetProcAddress("glPathColorGenNV");
|
||||||
|
interface->fPathTexGen = (GrGLPathTexGenProc) eglGetProcAddress("glPathTexGenNV");
|
||||||
|
interface->fPathFogGen = (GrGLPathFogGenProc) eglGetProcAddress("glPathFogGenNV");
|
||||||
|
interface->fCoverFillPath = (GrGLCoverFillPathProc) eglGetProcAddress("glCoverFillPathNV");
|
||||||
|
interface->fCoverStrokePath = (GrGLCoverStrokePathProc) eglGetProcAddress("glCoverStrokePathNV");
|
||||||
|
interface->fCoverFillPathInstanced = (GrGLCoverFillPathInstancedProc) eglGetProcAddress("glCoverFillPathInstancedNV");
|
||||||
|
interface->fCoverStrokePathInstanced = (GrGLCoverStrokePathInstancedProc) eglGetProcAddress("glCoverStrokePathInstancedNV");
|
||||||
|
interface->fGetPathParameteriv = (GrGLGetPathParameterivProc) eglGetProcAddress("glGetPathParameterivNV");
|
||||||
|
interface->fGetPathParameterfv = (GrGLGetPathParameterfvProc) eglGetProcAddress("glGetPathParameterfvNV");
|
||||||
|
interface->fGetPathCommands = (GrGLGetPathCommandsProc) eglGetProcAddress("glGetPathCommandsNV");
|
||||||
|
interface->fGetPathCoords = (GrGLGetPathCoordsProc) eglGetProcAddress("glGetPathCoordsNV");
|
||||||
|
interface->fGetPathDashArray = (GrGLGetPathDashArrayProc) eglGetProcAddress("glGetPathDashArrayNV");
|
||||||
|
interface->fGetPathMetrics = (GrGLGetPathMetricsProc) eglGetProcAddress("glGetPathMetricsNV");
|
||||||
|
interface->fGetPathMetricRange = (GrGLGetPathMetricRangeProc) eglGetProcAddress("glGetPathMetricRangeNV");
|
||||||
|
interface->fGetPathSpacing = (GrGLGetPathSpacingProc) eglGetProcAddress("glGetPathSpacingNV");
|
||||||
|
interface->fGetPathColorGeniv = (GrGLGetPathColorGenivProc) eglGetProcAddress("glGetPathColorGenivNV");
|
||||||
|
interface->fGetPathColorGenfv = (GrGLGetPathColorGenfvProc) eglGetProcAddress("glGetPathColorGenfvNV");
|
||||||
|
interface->fGetPathTexGeniv = (GrGLGetPathTexGenivProc) eglGetProcAddress("glGetPathTexGenivNV");
|
||||||
|
interface->fGetPathTexGenfv = (GrGLGetPathTexGenfvProc) eglGetProcAddress("glGetPathTexGenfvNV");
|
||||||
|
interface->fIsPointInFillPath = (GrGLIsPointInFillPathProc) eglGetProcAddress("glIsPointInFillPathNV");
|
||||||
|
interface->fIsPointInStrokePath = (GrGLIsPointInStrokePathProc) eglGetProcAddress("glIsPointInStrokePathNV");
|
||||||
|
interface->fGetPathLength = (GrGLGetPathLengthProc) eglGetProcAddress("glGetPathLengthNV");
|
||||||
|
interface->fPointAlongPath = (GrGLPointAlongPathProc) eglGetProcAddress("glPointAlongPathNV");
|
||||||
|
}
|
||||||
|
|
||||||
|
return interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||||
|
|
||||||
|
GrGLGetStringiProc getStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
|
||||||
|
|
||||||
|
const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION));
|
||||||
|
GrGLVersion version = GrGLGetVersionFromString(verStr);
|
||||||
|
GrGLBinding binding = GrGLGetBindingInUseFromString(verStr);
|
||||||
|
|
||||||
|
GrGLExtensions extensions;
|
||||||
|
if (!extensions.init(binding, glGetString, getStringi, glGetIntegerv)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kES_GrGLBinding == binding) {
|
||||||
|
return create_es_interface(version, extensions);
|
||||||
|
} else if (kDesktop_GrGLBinding == binding) {
|
||||||
|
return create_desktop_interface(version, extensions);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,30 @@ void SkNativeGLContext::destroyGLContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GrGLInterface* SkNativeGLContext::createGLContext() {
|
const GrGLInterface* SkNativeGLContext::createGLContext() {
|
||||||
|
static const EGLint kEGLContextAttribsForOpenGL[] = {
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
static const EGLint kEGLContextAttribsForOpenGLES[] = {
|
||||||
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
// Try first for OpenGL, then fall back to OpenGL ES.
|
||||||
|
EGLint renderableTypeBit = EGL_OPENGL_BIT;
|
||||||
|
const EGLint* contextAttribs = kEGLContextAttribsForOpenGL;
|
||||||
|
EGLBoolean apiBound = eglBindAPI(EGL_OPENGL_API);
|
||||||
|
|
||||||
|
if (!apiBound) {
|
||||||
|
apiBound = eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
|
renderableTypeBit = EGL_OPENGL_ES_BIT;
|
||||||
|
contextAttribs = kEGLContextAttribsForOpenGLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!apiBound) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
EGLint majorVersion;
|
EGLint majorVersion;
|
||||||
@ -59,9 +83,9 @@ const GrGLInterface* SkNativeGLContext::createGLContext() {
|
|||||||
eglInitialize(fDisplay, &majorVersion, &minorVersion);
|
eglInitialize(fDisplay, &majorVersion, &minorVersion);
|
||||||
|
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
static const EGLint configAttribs[] = {
|
const EGLint configAttribs[] = {
|
||||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
EGL_RENDERABLE_TYPE, renderableTypeBit,
|
||||||
EGL_RED_SIZE, 8,
|
EGL_RED_SIZE, 8,
|
||||||
EGL_GREEN_SIZE, 8,
|
EGL_GREEN_SIZE, 8,
|
||||||
EGL_BLUE_SIZE, 8,
|
EGL_BLUE_SIZE, 8,
|
||||||
@ -70,30 +94,43 @@ const GrGLInterface* SkNativeGLContext::createGLContext() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EGLConfig surfaceConfig;
|
EGLConfig surfaceConfig;
|
||||||
eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs);
|
if (!eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs)) {
|
||||||
|
SkDebugf("eglChooseConfig failed.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static const EGLint contextAttribs[] = {
|
fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, contextAttribs);
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
if (EGL_NO_CONTEXT == fContext) {
|
||||||
|
SkDebugf("eglCreateContext failed.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const EGLint kSurfaceAttribs[] = {
|
||||||
|
EGL_WIDTH, 1,
|
||||||
|
EGL_HEIGHT, 1,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, contextAttribs);
|
|
||||||
|
|
||||||
|
fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, kSurfaceAttribs);
|
||||||
static const EGLint surfaceAttribs[] = {
|
if (EGL_NO_SURFACE == fSurface) {
|
||||||
EGL_WIDTH, 1,
|
SkDebugf("eglCreatePbufferSurface failed.\n");
|
||||||
EGL_HEIGHT, 1,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs);
|
|
||||||
|
|
||||||
eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
|
|
||||||
|
|
||||||
const GrGLInterface* interface = GrGLCreateNativeInterface();
|
|
||||||
if (!interface) {
|
|
||||||
SkDebugf("Failed to create gl interface");
|
|
||||||
this->destroyGLContext();
|
this->destroyGLContext();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
|
||||||
|
SkDebugf("eglMakeCurrent failed.\n");
|
||||||
|
this->destroyGLContext();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GrGLInterface* interface = GrGLCreateNativeInterface();
|
||||||
|
if (!interface) {
|
||||||
|
SkDebugf("Failed to create gl interface.\n");
|
||||||
|
this->destroyGLContext();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return interface;
|
return interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user