| 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 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->fStandard = kGLES_GrGLStandard; | 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; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 interface->fMapBuffer = glMapBufferOES; | 185 interface->fMapBuffer = glMapBufferOES; |
| 186 interface->fUnmapBuffer = glUnmapBufferOES; | 186 interface->fUnmapBuffer = glUnmapBufferOES; |
| 187 #else | 187 #else |
| 188 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); | 188 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); |
| 189 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); | 189 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); |
| 190 #endif | 190 #endif |
| 191 | 191 |
| 192 return interface; | 192 return interface; |
| 193 } | 193 } |
| 194 | 194 |
| 195 static const GrGLInterface* create_desktop_interface(GrGLVersion version, | 195 static GrGLInterface* create_desktop_interface(GrGLVersion version, |
| 196 const GrGLExtensions& exten
sions) { | 196 const GrGLExtensions& extensions)
{ |
| 197 // Currently this assumes a 4.4 context or later. Supporting lower GL versio
ns would require | 197 // Currently this assumes a 4.4 context or later. Supporting lower GL versio
ns would require |
| 198 // getting suffixed versions of pointers for supported extensions. | 198 // getting suffixed versions of pointers for supported extensions. |
| 199 if (version < GR_GL_VER(4,4)) { | 199 if (version < GR_GL_VER(4,4)) { |
| 200 return NULL; | 200 return NULL; |
| 201 } | 201 } |
| 202 | 202 |
| 203 GrGLInterface* interface = SkNEW(GrGLInterface); | 203 GrGLInterface* interface = SkNEW(GrGLInterface); |
| 204 interface->fStandard = kGL_GrGLStandard; | 204 interface->fStandard = kGL_GrGLStandard; |
| 205 | 205 |
| 206 interface->fActiveTexture = (GrGLActiveTextureProc) eglGetProcAddress("glAct
iveTexture"); | 206 interface->fActiveTexture = (GrGLActiveTextureProc) eglGetProcAddress("glAct
iveTexture"); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 396 |
| 397 const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION
)); | 397 const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION
)); |
| 398 GrGLVersion version = GrGLGetVersionFromString(verStr); | 398 GrGLVersion version = GrGLGetVersionFromString(verStr); |
| 399 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); | 399 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); |
| 400 | 400 |
| 401 GrGLExtensions extensions; | 401 GrGLExtensions extensions; |
| 402 if (!extensions.init(standard, glGetString, getStringi, glGetIntegerv)) { | 402 if (!extensions.init(standard, glGetString, getStringi, glGetIntegerv)) { |
| 403 return NULL; | 403 return NULL; |
| 404 } | 404 } |
| 405 | 405 |
| 406 GrGLInterface* interface = NULL; |
| 406 if (kGLES_GrGLStandard == standard) { | 407 if (kGLES_GrGLStandard == standard) { |
| 407 return create_es_interface(version, extensions); | 408 interface = create_es_interface(version, extensions); |
| 408 } else if (kGL_GrGLStandard == standard) { | 409 } else if (kGL_GrGLStandard == standard) { |
| 409 return create_desktop_interface(version, extensions); | 410 interface = create_desktop_interface(version, extensions); |
| 410 } else { | |
| 411 return NULL; | |
| 412 } | 411 } |
| 412 |
| 413 if (NULL != interface) { |
| 414 interface->fExtensions.swap(&extensions); |
| 415 } |
| 416 |
| 417 return interface; |
| 413 } | 418 } |
| OLD | NEW |