| 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 GrGLInterface* create_es_interface(GrGLVersion version, | 20 static GrGLInterface* create_es_interface(GrGLVersion version, |
| 21 const GrGLExtensions& extensions) { | 21 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 GrGLInterface::Functions* functions = &interface->fFunctions; | 28 GrGLInterface::Functions* functions = &interface->fFunctions; |
| 29 | 29 |
| 30 functions->fActiveTexture = glActiveTexture; | 30 functions->fActiveTexture = glActiveTexture; |
| 31 functions->fAttachShader = glAttachShader; | 31 functions->fAttachShader = glAttachShader; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (version >= GR_GL_VER(3,0)) { | 152 if (version >= GR_GL_VER(3,0)) { |
| 153 #if GL_ES_VERSION_3_0 | 153 #if GL_ES_VERSION_3_0 |
| 154 functions->fRenderbufferStorageMultisample = glRenderbufferStorageMultis
ample; | 154 functions->fRenderbufferStorageMultisample = glRenderbufferStorageMultis
ample; |
| 155 functions->fBlitFramebuffer = glBlitFramebuffer; | 155 functions->fBlitFramebuffer = glBlitFramebuffer; |
| 156 #else | 156 #else |
| 157 functions->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMul
tisampleProc) eglGetProcAddress("glRenderbufferStorageMultisample"); | 157 functions->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMul
tisampleProc) eglGetProcAddress("glRenderbufferStorageMultisample"); |
| 158 functions->fBlitFramebuffer = (GrGLBlitFramebufferProc) eglGetProcAddres
s("glBlitFramebuffer"); | 158 functions->fBlitFramebuffer = (GrGLBlitFramebufferProc) eglGetProcAddres
s("glBlitFramebuffer"); |
| 159 #endif | 159 #endif |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (extensions.has("GL_EXT_multisampled_render_to_texture")) { | 162 if (extensions->has("GL_EXT_multisampled_render_to_texture")) { |
| 163 #if GL_EXT_multisampled_render_to_texture | 163 #if GL_EXT_multisampled_render_to_texture |
| 164 functions->fFramebufferTexture2DMultisample = glFramebufferTexture2DMult
isampleEXT; | 164 functions->fFramebufferTexture2DMultisample = glFramebufferTexture2DMult
isampleEXT; |
| 165 functions->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorage
MultisampleEXT; | 165 functions->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorage
MultisampleEXT; |
| 166 #else | 166 #else |
| 167 functions->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DM
ultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT"); | 167 functions->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DM
ultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT"); |
| 168 functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStor
ageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT"); | 168 functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStor
ageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT"); |
| 169 #endif | 169 #endif |
| 170 } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { | 170 } else if (extensions->has("GL_IMG_multisampled_render_to_texture")) { |
| 171 #if GL_IMG_multisampled_render_to_texture | 171 #if GL_IMG_multisampled_render_to_texture |
| 172 functions->fFramebufferTexture2DMultisample = glFramebufferTexture2DMult
isampleIMG; | 172 functions->fFramebufferTexture2DMultisample = glFramebufferTexture2DMult
isampleIMG; |
| 173 functions->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorage
MultisampleIMG; | 173 functions->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorage
MultisampleIMG; |
| 174 #else | 174 #else |
| 175 functions->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DM
ultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG"); | 175 functions->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DM
ultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG"); |
| 176 functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStor
ageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG"); | 176 functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStor
ageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG"); |
| 177 #endif | 177 #endif |
| 178 } | 178 } |
| 179 | 179 |
| 180 functions->fGenFramebuffers = glGenFramebuffers; | 180 functions->fGenFramebuffers = glGenFramebuffers; |
| 181 functions->fGenRenderbuffers = glGenRenderbuffers; | 181 functions->fGenRenderbuffers = glGenRenderbuffers; |
| 182 functions->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachment
Parameteriv; | 182 functions->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachment
Parameteriv; |
| 183 functions->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; | 183 functions->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; |
| 184 functions->fRenderbufferStorage = glRenderbufferStorage; | 184 functions->fRenderbufferStorage = glRenderbufferStorage; |
| 185 #if GL_OES_mapbuffer | 185 #if GL_OES_mapbuffer |
| 186 functions->fMapBuffer = glMapBufferOES; | 186 functions->fMapBuffer = glMapBufferOES; |
| 187 functions->fUnmapBuffer = glUnmapBufferOES; | 187 functions->fUnmapBuffer = glUnmapBufferOES; |
| 188 #else | 188 #else |
| 189 functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); | 189 functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); |
| 190 functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); | 190 functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); |
| 191 #endif | 191 #endif |
| 192 | 192 |
| 193 if (extensions.has("GL_EXT_debug_marker")) { | 193 if (extensions->has("GL_EXT_debug_marker")) { |
| 194 functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAd
dress("glInsertEventMarkerEXT"); | 194 functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAd
dress("glInsertEventMarker"); |
| 195 functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddr
ess("glPushGroupMarkerEXT"); | 195 functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddr
ess("glPushGroupMarker"); |
| 196 functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress(
"glPopGroupMarkerEXT"); | 196 functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress(
"glPopGroupMarker"); |
| 197 // The below check is here because a device has been found that has the
extension string but |
| 198 // returns NULL from the eglGetProcAddress for the functions |
| 199 if (NULL == functions->fInsertEventMarker || |
| 200 NULL == functions->fPushGroupMarker || |
| 201 NULL == functions->fPopGroupMarker) { |
| 202 extensions->remove("GL_EXT_debug_marker"); |
| 203 } |
| 197 } | 204 } |
| 198 | 205 |
| 199 return interface; | 206 return interface; |
| 200 } | 207 } |
| 201 | 208 |
| 202 static GrGLInterface* create_desktop_interface(GrGLVersion version, | 209 static GrGLInterface* create_desktop_interface(GrGLVersion version, |
| 203 const GrGLExtensions& extensions)
{ | 210 const GrGLExtensions& extensions)
{ |
| 204 // Currently this assumes a 4.4 context or later. Supporting lower GL versio
ns would require | 211 // Currently this assumes a 4.4 context or later. Supporting lower GL versio
ns would require |
| 205 // getting suffixed versions of pointers for supported extensions. | 212 // getting suffixed versions of pointers for supported extensions. |
| 206 if (version < GR_GL_VER(4,4)) { | 213 if (version < GR_GL_VER(4,4)) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 GrGLVersion version = GrGLGetVersionFromString(verStr); | 414 GrGLVersion version = GrGLGetVersionFromString(verStr); |
| 408 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); | 415 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); |
| 409 | 416 |
| 410 GrGLExtensions extensions; | 417 GrGLExtensions extensions; |
| 411 if (!extensions.init(standard, glGetString, getStringi, glGetIntegerv)) { | 418 if (!extensions.init(standard, glGetString, getStringi, glGetIntegerv)) { |
| 412 return NULL; | 419 return NULL; |
| 413 } | 420 } |
| 414 | 421 |
| 415 GrGLInterface* interface = NULL; | 422 GrGLInterface* interface = NULL; |
| 416 if (kGLES_GrGLStandard == standard) { | 423 if (kGLES_GrGLStandard == standard) { |
| 417 interface = create_es_interface(version, extensions); | 424 interface = create_es_interface(version, &extensions); |
| 418 } else if (kGL_GrGLStandard == standard) { | 425 } else if (kGL_GrGLStandard == standard) { |
| 419 interface = create_desktop_interface(version, extensions); | 426 interface = create_desktop_interface(version, extensions); |
| 420 } | 427 } |
| 421 | 428 |
| 422 if (NULL != interface) { | 429 if (NULL != interface) { |
| 423 interface->fExtensions.swap(&extensions); | 430 interface->fExtensions.swap(&extensions); |
| 424 } | 431 } |
| 425 | 432 |
| 426 return interface; | 433 return interface; |
| 427 } | 434 } |
| OLD | NEW |