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:
commit-bot@chromium.org 2013-09-03 17:50:50 +00:00
parent 6a64189d6c
commit f5897f83e6
3 changed files with 428 additions and 181 deletions

View File

@ -220,7 +220,10 @@ public:
GLPtr<GrGLGetUniformLocationProc> fGetUniformLocation;
GLPtr<GrGLLineWidthProc> fLineWidth;
GLPtr<GrGLLinkProgramProc> fLinkProgram;
GLPtr<GrGLLoadIdentityProc> fLoadIdentity;
GLPtr<GrGLLoadMatrixfProc> fLoadMatrixf;
GLPtr<GrGLMapBufferProc> fMapBuffer;
GLPtr<GrGLMatrixModeProc> fMatrixMode;
GLPtr<GrGLPixelStoreiProc> fPixelStorei;
GLPtr<GrGLQueryCounterProc> fQueryCounter;
GLPtr<GrGLReadBufferProc> fReadBuffer;
@ -275,9 +278,6 @@ public:
// Experimental: Functions for GL_NV_path_rendering. These will be
// alphabetized with the above functions once this is fully supported
// (and functions we are unlikely to use will possibly be omitted).
GLPtr<GrGLMatrixModeProc> fMatrixMode;
GLPtr<GrGLLoadIdentityProc> fLoadIdentity;
GLPtr<GrGLLoadMatrixfProc> fLoadMatrixf;
GLPtr<GrGLPathCommandsProc> fPathCommands;
GLPtr<GrGLPathCoordsProc> fPathCoords;
GLPtr<GrGLPathSubCommandsProc> fPathSubCommands;

View File

@ -17,29 +17,15 @@
#include <EGL/egl.h>
const GrGLInterface* GrGLCreateNativeInterface() {
static SkAutoTUnref<GrGLInterface> glInterface;
if (!glInterface.get()) {
GrGLExtensions extensions;
GrGLGetStringiProc getStringi;
#if GL_ES_VERSION_3_0
getStringi = glGetStringi;
#else
getStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
#endif
if (!extensions.init(kES_GrGLBinding, glGetString, getStringi, glGetIntegerv)) {
return NULL;
}
const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION));
GrGLVersion version = GrGLGetVersionFromString(verStr);
static const GrGLInterface* create_es_interface(GrGLVersion version,
const GrGLExtensions& extensions) {
if (version < GR_GL_VER(2,0)) {
return NULL;
}
GrGLInterface* interface = new GrGLInterface;
glInterface.reset(interface);
GrGLInterface* interface = SkNEW(GrGLInterface);
interface->fBindingsExported = kES_GrGLBinding;
interface->fActiveTexture = glActiveTexture;
interface->fAttachShader = glAttachShader;
interface->fBindAttribLocation = glBindAttribLocation;
@ -87,7 +73,11 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fGetShaderInfoLog = glGetShaderInfoLog;
interface->fGetShaderiv = glGetShaderiv;
interface->fGetString = glGetString;
interface->fGetStringi = getStringi; // located above
#if GL_ES_VERSION_30
interface->fGetStringi = glGetStringi;
#else
interface->fGetStringi = (GrGLGetStringiProc) eglGetProcAddress("glGetStringi");
#endif
interface->fGetUniformLocation = glGetUniformLocation;
interface->fLineWidth = glLineWidth;
interface->fLinkProgram = glLinkProgram;
@ -186,7 +176,227 @@ const GrGLInterface* GrGLCreateNativeInterface() {
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;
}
glInterface.get()->ref();
return glInterface.get();
}

View File

@ -52,6 +52,30 @@ void SkNativeGLContext::destroyGLContext() {
}
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);
EGLint majorVersion;
@ -59,9 +83,9 @@ const GrGLInterface* SkNativeGLContext::createGLContext() {
eglInitialize(fDisplay, &majorVersion, &minorVersion);
EGLint numConfigs;
static const EGLint configAttribs[] = {
const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_RENDERABLE_TYPE, renderableTypeBit,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@ -70,30 +94,43 @@ const GrGLInterface* SkNativeGLContext::createGLContext() {
};
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[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, contextAttribs);
if (EGL_NO_CONTEXT == fContext) {
SkDebugf("eglCreateContext failed.\n");
return NULL;
}
static const EGLint surfaceAttribs[] = {
static const EGLint kSurfaceAttribs[] = {
EGL_WIDTH, 1,
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");
fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, kSurfaceAttribs);
if (EGL_NO_SURFACE == fSurface) {
SkDebugf("eglCreatePbufferSurface failed.\n");
this->destroyGLContext();
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;
}