diff options
author | 2013-02-26 21:46:32 +0000 | |
---|---|---|
committer | 2013-02-26 21:46:32 +0000 | |
commit | 1744f97ea73384b9f75b0ccee0a36a213c681d3a (patch) | |
tree | 984f3a6988234c1a797049b2a43705cf970c1866 /src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp | |
parent | 8d33a24cfe4540126ae00618cc691c610d398d8d (diff) |
Use glGetStringi to get extensions when available.
Review URL: https://codereview.chromium.org/12328111
git-svn-id: http://skia.googlecode.com/svn/trunk@7872 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp')
-rw-r--r-- | src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp index 04d35d1836..2965e7f19a 100644 --- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp +++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp @@ -7,6 +7,7 @@ */ +#include "gl/GrGLExtensions.h" #include "gl/GrGLInterface.h" #include "../GrGLUtil.h" @@ -22,10 +23,19 @@ const GrGLInterface* GrGLCreateNativeInterface() { if (NULL != glXGetCurrentContext()) { + const char* versionString = (const char*) glGetString(GL_VERSION); - const char* extString = (const char*) glGetString(GL_EXTENSIONS); GrGLVersion glVer = GrGLGetVersionFromString(versionString); + // This may or may not succeed depending on the gl version. + GrGLGetStringiProc glGetStringi = + (GrGLGetStringiProc) glXGetProcAddress(reinterpret_cast<const GLubyte*>("glGetStringi")); + + GrGLExtensions extensions; + if (!extensions.init(kDesktop_GrGLBinding, glGetString, glGetStringi, glGetIntegerv)) { + return NULL; + } + if (glVer < GR_GL_VER(1,5)) { // We must have array and element_array buffer objects. return NULL; @@ -43,8 +53,8 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fBlendFunc = glBlendFunc; if (glVer >= GR_GL_VER(1,4) || - GrGLHasExtensionFromString("GL_ARB_imaging", extString) || - GrGLHasExtensionFromString("GL_EXT_blend_color", extString)) { + extensions.has("GL_ARB_imaging") || + extensions.has("GL_EXT_blend_color")) { GR_GL_GET_PROC(BlendColor); } @@ -83,12 +93,11 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fGetIntegerv = glGetIntegerv; GR_GL_GET_PROC(GetQueryObjectiv); GR_GL_GET_PROC(GetQueryObjectuiv); - if (glVer >= GR_GL_VER(3,3) || - GrGLHasExtensionFromString("GL_ARB_timer_query", extString)) { + if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { GR_GL_GET_PROC(GetQueryObjecti64v); GR_GL_GET_PROC(GetQueryObjectui64v); GR_GL_GET_PROC(QueryCounter); - } else if (GrGLHasExtensionFromString("GL_EXT_timer_query", extString)) { + } else if (extensions.has("GL_EXT_timer_query")) { GR_GL_GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); GR_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); } @@ -98,6 +107,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { GR_GL_GET_PROC(GetShaderInfoLog); GR_GL_GET_PROC(GetShaderiv); interface->fGetString = glGetString; + GR_GL_GET_PROC(GetStringi); interface->fGetTexLevelParameteriv = glGetTexLevelParameteriv; GR_GL_GET_PROC(GenQueries); interface->fGenTextures = glGenTextures; @@ -108,8 +118,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fPixelStorei = glPixelStorei; interface->fReadBuffer = glReadBuffer; interface->fReadPixels = glReadPixels; - if (GrGLHasExtensionFromString("GL_NV_framebuffer_multisample_coverage", - extString)) { + if (extensions.has("GL_NV_framebuffer_multisample_coverage")) { GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisampleCoverage, NV); } interface->fScissor = glScissor; @@ -123,10 +132,9 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fTexImage2D = glTexImage2D; interface->fTexParameteri = glTexParameteri; interface->fTexParameteriv = glTexParameteriv; - if (glVer >= GR_GL_VER(4,2) || - GrGLHasExtensionFromString("GL_ARB_texture_storage", extString)) { + if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { GR_GL_GET_PROC(TexStorage2D); - } else if (GrGLHasExtensionFromString("GL_EXT_texture_storage", extString)) { + } else if (extensions.has("GL_EXT_texture_storage")) { GR_GL_GET_PROC_SUFFIX(TexStorage2D, EXT); } interface->fTexSubImage2D = glTexSubImage2D; @@ -158,9 +166,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // GL_ARB_framebuffer_object doesn't use ARB suffix.) - if (glVer >= GR_GL_VER(3,0) || - GrGLHasExtensionFromString("GL_ARB_framebuffer_object", - extString)) { + if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { GR_GL_GET_PROC(GenFramebuffers); GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv); GR_GL_GET_PROC(GetRenderbufferParameteriv); @@ -175,8 +181,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { GR_GL_GET_PROC(BindRenderbuffer); GR_GL_GET_PROC(RenderbufferStorageMultisample); GR_GL_GET_PROC(BlitFramebuffer); - } else if (GrGLHasExtensionFromString("GL_EXT_framebuffer_object", - extString)) { + } else if (extensions.has("GL_EXT_framebuffer_object")) { GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT); GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); @@ -189,12 +194,10 @@ const GrGLInterface* GrGLCreateNativeInterface() { GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT); - if (GrGLHasExtensionFromString("GL_EXT_framebuffer_multisample", - extString)) { + if (extensions.has("GL_EXT_framebuffer_multisample")) { GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); } - if (GrGLHasExtensionFromString("GL_EXT_framebuffer_blit", - extString)) { + if (extensions.has("GL_EXT_framebuffer_blit")) { GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT); } } else { |