| OLD | NEW | 
|    1 // Modified from chromium/src/webkit/glue/gl_bindings_skia_cmd_buffer.cc |    1 // Modified from chromium/src/webkit/glue/gl_bindings_skia_cmd_buffer.cc | 
|    2  |    2  | 
|    3 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    3 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
|    4 // Use of this source code is governed by a BSD-style license that can be |    4 // Use of this source code is governed by a BSD-style license that can be | 
|    5 // found in the LICENSE file. |    5 // found in the LICENSE file. | 
|    6  |    6  | 
|    7 #include "gl/GrGLExtensions.h" |    7 #include "gl/GrGLExtensions.h" | 
|    8 #include "gl/GrGLInterface.h" |    8 #include "gl/GrGLInterface.h" | 
|    9 #include "gl/GrGLUtil.h" |    9 #include "gl/GrGLUtil.h" | 
|   10  |   10  | 
|   11 #ifndef GL_GLEXT_PROTOTYPES |   11 #ifndef GL_GLEXT_PROTOTYPES | 
|   12 #define GL_GLEXT_PROTOTYPES |   12 #define GL_GLEXT_PROTOTYPES | 
|   13 #endif |   13 #endif | 
|   14  |   14  | 
|   15 #include <GLES2/gl2.h> |   15 #include <GLES2/gl2.h> | 
|   16 #include <GLES2/gl2ext.h> |   16 #include <GLES2/gl2ext.h> | 
|   17  |   17  | 
|   18 #include <EGL/egl.h> |   18 #include <EGL/egl.h> | 
|   19  |   19  | 
|   20 static const GrGLInterface* create_es_interface(GrGLVersion version, |   20 static const GrGLInterface* create_es_interface(GrGLVersion version, | 
|   21                                                 const GrGLExtensions& extensions
     ) { |   21                                                 const GrGLExtensions& extensions
     ) { | 
|   22     if (version < GR_GL_VER(2,0)) { |   22     if (version < GR_GL_VER(2,0)) { | 
|   23         return NULL; |   23         return NULL; | 
|   24     } |   24     } | 
|   25  |   25  | 
|   26     GrGLInterface* interface = SkNEW(GrGLInterface); |   26     GrGLInterface* interface = SkNEW(GrGLInterface); | 
|   27     interface->fBindingsExported = kES_GrGLBinding; |   27     interface->fStandard = kGLES_GrGLStandard; | 
|   28  |   28  | 
|   29     interface->fActiveTexture = glActiveTexture; |   29     interface->fActiveTexture = glActiveTexture; | 
|   30     interface->fAttachShader = glAttachShader; |   30     interface->fAttachShader = glAttachShader; | 
|   31     interface->fBindAttribLocation = glBindAttribLocation; |   31     interface->fBindAttribLocation = glBindAttribLocation; | 
|   32     interface->fBindBuffer = glBindBuffer; |   32     interface->fBindBuffer = glBindBuffer; | 
|   33     interface->fBindTexture = glBindTexture; |   33     interface->fBindTexture = glBindTexture; | 
|   34     interface->fBindVertexArray = glBindVertexArrayOES; |   34     interface->fBindVertexArray = glBindVertexArrayOES; | 
|   35     interface->fBlendColor = glBlendColor; |   35     interface->fBlendColor = glBlendColor; | 
|   36     interface->fBlendFunc = glBlendFunc; |   36     interface->fBlendFunc = glBlendFunc; | 
|   37     interface->fBufferData = glBufferData; |   37     interface->fBufferData = glBufferData; | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  215  |  215  | 
|  216 static const GrGLInterface* create_desktop_interface(GrGLVersion version, |  216 static const GrGLInterface* create_desktop_interface(GrGLVersion version, | 
|  217                                                      const GrGLExtensions& exten
     sions) { |  217                                                      const GrGLExtensions& exten
     sions) { | 
|  218     // Currently this assumes a 4.4 context or later. Supporting lower GL versio
     ns would require |  218     // Currently this assumes a 4.4 context or later. Supporting lower GL versio
     ns would require | 
|  219     // getting suffixed versions of pointers for supported extensions. |  219     // getting suffixed versions of pointers for supported extensions. | 
|  220     if (version < GR_GL_VER(4,4)) { |  220     if (version < GR_GL_VER(4,4)) { | 
|  221         return NULL; |  221         return NULL; | 
|  222     } |  222     } | 
|  223  |  223  | 
|  224     GrGLInterface* interface = SkNEW(GrGLInterface); |  224     GrGLInterface* interface = SkNEW(GrGLInterface); | 
|  225     interface->fBindingsExported = kDesktop_GrGLBinding; |  225     interface->fStandard = kGL_GrGLStandard; | 
|  226  |  226  | 
|  227     interface->fActiveTexture = (GrGLActiveTextureProc) eglGetProcAddress("glAct
     iveTexture"); |  227     interface->fActiveTexture = (GrGLActiveTextureProc) eglGetProcAddress("glAct
     iveTexture"); | 
|  228     interface->fAttachShader = (GrGLAttachShaderProc) eglGetProcAddress("glAttac
     hShader"); |  228     interface->fAttachShader = (GrGLAttachShaderProc) eglGetProcAddress("glAttac
     hShader"); | 
|  229     interface->fBeginQuery = (GrGLBeginQueryProc) eglGetProcAddress("glBeginQuer
     y"); |  229     interface->fBeginQuery = (GrGLBeginQueryProc) eglGetProcAddress("glBeginQuer
     y"); | 
|  230     interface->fBindAttribLocation = (GrGLBindAttribLocationProc) eglGetProcAddr
     ess("glBindAttribLocation"); |  230     interface->fBindAttribLocation = (GrGLBindAttribLocationProc) eglGetProcAddr
     ess("glBindAttribLocation"); | 
|  231     interface->fBindBuffer = (GrGLBindBufferProc) eglGetProcAddress("glBindBuffe
     r"); |  231     interface->fBindBuffer = (GrGLBindBufferProc) eglGetProcAddress("glBindBuffe
     r"); | 
|  232     interface->fBindFragDataLocation = (GrGLBindFragDataLocationProc) eglGetProc
     Address("glBindFragDataLocation"); |  232     interface->fBindFragDataLocation = (GrGLBindFragDataLocationProc) eglGetProc
     Address("glBindFragDataLocation"); | 
|  233     interface->fBindFragDataLocationIndexed = (GrGLBindFragDataLocationIndexedPr
     oc) eglGetProcAddress("glBindFragDataLocationIndexed"); |  233     interface->fBindFragDataLocationIndexed = (GrGLBindFragDataLocationIndexedPr
     oc) eglGetProcAddress("glBindFragDataLocationIndexed"); | 
|  234     interface->fBindFramebuffer = (GrGLBindFramebufferProc) eglGetProcAddress("g
     lBindFramebuffer"); |  234     interface->fBindFramebuffer = (GrGLBindFramebufferProc) eglGetProcAddress("g
     lBindFramebuffer"); | 
|  235     interface->fBindRenderbuffer = (GrGLBindRenderbufferProc) eglGetProcAddress(
     "glBindRenderbuffer"); |  235     interface->fBindRenderbuffer = (GrGLBindRenderbufferProc) eglGetProcAddress(
     "glBindRenderbuffer"); | 
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  410  |  410  | 
|  411     return interface; |  411     return interface; | 
|  412 } |  412 } | 
|  413  |  413  | 
|  414 const GrGLInterface* GrGLCreateNativeInterface() { |  414 const GrGLInterface* GrGLCreateNativeInterface() { | 
|  415  |  415  | 
|  416     GrGLGetStringiProc getStringi = (GrGLGetStringiProc) eglGetProcAddress("glGe
     tStringi"); |  416     GrGLGetStringiProc getStringi = (GrGLGetStringiProc) eglGetProcAddress("glGe
     tStringi"); | 
|  417  |  417  | 
|  418     const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION
     )); |  418     const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION
     )); | 
|  419     GrGLVersion version = GrGLGetVersionFromString(verStr); |  419     GrGLVersion version = GrGLGetVersionFromString(verStr); | 
|  420     GrGLBinding binding = GrGLGetBindingInUseFromString(verStr); |  420     GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); | 
|  421  |  421  | 
|  422     GrGLExtensions extensions; |  422     GrGLExtensions extensions; | 
|  423     if (!extensions.init(binding, glGetString, getStringi, glGetIntegerv)) { |  423     if (!extensions.init(standard, glGetString, getStringi, glGetIntegerv)) { | 
|  424         return NULL; |  424         return NULL; | 
|  425     } |  425     } | 
|  426  |  426  | 
|  427     if (kES_GrGLBinding == binding) { |  427     if (kGLES_GrGLStandard == standard) { | 
|  428         return create_es_interface(version, extensions); |  428         return create_es_interface(version, extensions); | 
|  429     } else if (kDesktop_GrGLBinding == binding) { |  429     } else if (kGL_GrGLStandard == standard) { | 
|  430         return create_desktop_interface(version, extensions); |  430         return create_desktop_interface(version, extensions); | 
|  431     } else { |  431     } else { | 
|  432         return NULL; |  432         return NULL; | 
|  433     } |  433     } | 
|  434 } |  434 } | 
| OLD | NEW |