| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "gl/GrGLInterface.h" | 10 #include "gl/GrGLInterface.h" |
| 11 | 11 |
| 12 #ifndef GL_GLEXT_PROTOTYPES | 12 #ifndef GL_GLEXT_PROTOTYPES |
| 13 #define GL_GLEXT_PROTOTYPES | 13 #define GL_GLEXT_PROTOTYPES |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #include "GLES2/gl2.h" | 16 #include "GLES2/gl2.h" |
| 17 #include "GLES2/gl2ext.h" | 17 #include "GLES2/gl2ext.h" |
| 18 #include "EGL/egl.h" | 18 #include "EGL/egl.h" |
| 19 | 19 |
| 20 #define GET_PROC(name) \ | 20 #define GET_PROC(name) \ |
| 21 interface->f ## name = (GrGL ## name ## Proc) GetProcAddress(ghANGLELib, "gl
" #name); | 21 interface->f ## name = (GrGL ## name ## Proc) GetProcAddress(ghANGLELib, "gl
" #name); |
| 22 | 22 |
| 23 const GrGLInterface* GrGLCreateANGLEInterface() { | 23 const GrGLInterface* GrGLCreateANGLEInterface() { |
| 24 | 24 |
| 25 static SkAutoTUnref<GrGLInterface> glInterface; | |
| 26 static HMODULE ghANGLELib = NULL; | 25 static HMODULE ghANGLELib = NULL; |
| 27 | 26 |
| 28 if (NULL == ghANGLELib) { | 27 if (NULL == ghANGLELib) { |
| 29 // We load the ANGLE library and never let it go | 28 // We load the ANGLE library and never let it go |
| 30 ghANGLELib = LoadLibrary("libGLESv2.dll"); | 29 ghANGLELib = LoadLibrary("libGLESv2.dll"); |
| 31 } | 30 } |
| 32 if (NULL == ghANGLELib) { | 31 if (NULL == ghANGLELib) { |
| 33 // We can't setup the interface correctly w/o the DLL | 32 // We can't setup the interface correctly w/o the DLL |
| 34 return NULL; | 33 return NULL; |
| 35 } | 34 } |
| 36 | 35 |
| 37 if (!glInterface.get()) { | 36 GrGLInterface* interface = SkNEW(GrGLInterface); |
| 38 GrGLInterface* interface = new GrGLInterface; | 37 interface->fBindingsExported = kES_GrGLBinding; |
| 39 glInterface.reset(interface); | |
| 40 interface->fBindingsExported = kES_GrGLBinding; | |
| 41 | 38 |
| 42 GET_PROC(ActiveTexture); | 39 GET_PROC(ActiveTexture); |
| 43 GET_PROC(AttachShader); | 40 GET_PROC(AttachShader); |
| 44 GET_PROC(BindAttribLocation); | 41 GET_PROC(BindAttribLocation); |
| 45 GET_PROC(BindBuffer); | 42 GET_PROC(BindBuffer); |
| 46 GET_PROC(BindTexture); | 43 GET_PROC(BindTexture); |
| 47 interface->fBindVertexArray = | 44 interface->fBindVertexArray = |
| 48 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES"); | 45 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES"); |
| 49 GET_PROC(BlendColor); | 46 GET_PROC(BlendColor); |
| 50 GET_PROC(BlendFunc); | 47 GET_PROC(BlendFunc); |
| 51 GET_PROC(BufferData); | 48 GET_PROC(BufferData); |
| 52 GET_PROC(BufferSubData); | 49 GET_PROC(BufferSubData); |
| 53 GET_PROC(Clear); | 50 GET_PROC(Clear); |
| 54 GET_PROC(ClearColor); | 51 GET_PROC(ClearColor); |
| 55 GET_PROC(ClearStencil); | 52 GET_PROC(ClearStencil); |
| 56 GET_PROC(ColorMask); | 53 GET_PROC(ColorMask); |
| 57 GET_PROC(CompileShader); | 54 GET_PROC(CompileShader); |
| 58 GET_PROC(CompressedTexImage2D); | 55 GET_PROC(CompressedTexImage2D); |
| 59 GET_PROC(CopyTexSubImage2D); | 56 GET_PROC(CopyTexSubImage2D); |
| 60 GET_PROC(CreateProgram); | 57 GET_PROC(CreateProgram); |
| 61 GET_PROC(CreateShader); | 58 GET_PROC(CreateShader); |
| 62 GET_PROC(CullFace); | 59 GET_PROC(CullFace); |
| 63 GET_PROC(DeleteBuffers); | 60 GET_PROC(DeleteBuffers); |
| 64 GET_PROC(DeleteProgram); | 61 GET_PROC(DeleteProgram); |
| 65 GET_PROC(DeleteShader); | 62 GET_PROC(DeleteShader); |
| 66 GET_PROC(DeleteTextures); | 63 GET_PROC(DeleteTextures); |
| 67 interface->fDeleteVertexArrays = | 64 interface->fDeleteVertexArrays = |
| 68 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArrays
OES"); | 65 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES"
); |
| 69 GET_PROC(DepthMask); | 66 GET_PROC(DepthMask); |
| 70 GET_PROC(Disable); | 67 GET_PROC(Disable); |
| 71 GET_PROC(DisableVertexAttribArray); | 68 GET_PROC(DisableVertexAttribArray); |
| 72 GET_PROC(DrawArrays); | 69 GET_PROC(DrawArrays); |
| 73 GET_PROC(DrawElements); | 70 GET_PROC(DrawElements); |
| 74 GET_PROC(Enable); | 71 GET_PROC(Enable); |
| 75 GET_PROC(EnableVertexAttribArray); | 72 GET_PROC(EnableVertexAttribArray); |
| 76 GET_PROC(Finish); | 73 GET_PROC(Finish); |
| 77 GET_PROC(Flush); | 74 GET_PROC(Flush); |
| 78 GET_PROC(FrontFace); | 75 GET_PROC(FrontFace); |
| 79 GET_PROC(GenBuffers); | 76 GET_PROC(GenBuffers); |
| 80 GET_PROC(GenerateMipmap); | 77 GET_PROC(GenerateMipmap); |
| 81 GET_PROC(GenTextures); | 78 GET_PROC(GenTextures); |
| 82 interface->fGenVertexArrays = | 79 interface->fGenVertexArrays = |
| 83 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); | 80 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); |
| 84 GET_PROC(GetBufferParameteriv); | 81 GET_PROC(GetBufferParameteriv); |
| 85 GET_PROC(GetError); | 82 GET_PROC(GetError); |
| 86 GET_PROC(GetIntegerv); | 83 GET_PROC(GetIntegerv); |
| 87 GET_PROC(GetProgramInfoLog); | 84 GET_PROC(GetProgramInfoLog); |
| 88 GET_PROC(GetProgramiv); | 85 GET_PROC(GetProgramiv); |
| 89 GET_PROC(GetShaderInfoLog); | 86 GET_PROC(GetShaderInfoLog); |
| 90 GET_PROC(GetShaderiv); | 87 GET_PROC(GetShaderiv); |
| 91 GET_PROC(GetString); | 88 GET_PROC(GetString); |
| 92 GET_PROC(GetUniformLocation); | 89 GET_PROC(GetUniformLocation); |
| 93 GET_PROC(LineWidth); | 90 GET_PROC(LineWidth); |
| 94 GET_PROC(LinkProgram); | 91 GET_PROC(LinkProgram); |
| 95 GET_PROC(PixelStorei); | 92 GET_PROC(PixelStorei); |
| 96 GET_PROC(ReadPixels); | 93 GET_PROC(ReadPixels); |
| 97 GET_PROC(Scissor); | 94 GET_PROC(Scissor); |
| 98 GET_PROC(ShaderSource); | 95 GET_PROC(ShaderSource); |
| 99 GET_PROC(StencilFunc); | 96 GET_PROC(StencilFunc); |
| 100 GET_PROC(StencilFuncSeparate); | 97 GET_PROC(StencilFuncSeparate); |
| 101 GET_PROC(StencilMask); | 98 GET_PROC(StencilMask); |
| 102 GET_PROC(StencilMaskSeparate); | 99 GET_PROC(StencilMaskSeparate); |
| 103 GET_PROC(StencilOp); | 100 GET_PROC(StencilOp); |
| 104 GET_PROC(StencilOpSeparate); | 101 GET_PROC(StencilOpSeparate); |
| 105 GET_PROC(TexImage2D); | 102 GET_PROC(TexImage2D); |
| 106 GET_PROC(TexParameteri); | 103 GET_PROC(TexParameteri); |
| 107 GET_PROC(TexParameteriv); | 104 GET_PROC(TexParameteriv); |
| 108 GET_PROC(TexSubImage2D); | 105 GET_PROC(TexSubImage2D); |
| 109 #if GL_ARB_texture_storage | 106 #if GL_ARB_texture_storage |
| 110 GET_PROC(TexStorage2D); | 107 GET_PROC(TexStorage2D); |
| 111 #elif GL_EXT_texture_storage | 108 #elif GL_EXT_texture_storage |
| 112 interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glT
exStorage2DEXT"); | 109 interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexSt
orage2DEXT"); |
| 113 #endif | 110 #endif |
| 114 GET_PROC(Uniform1f); | 111 GET_PROC(Uniform1f); |
| 115 GET_PROC(Uniform1i); | 112 GET_PROC(Uniform1i); |
| 116 GET_PROC(Uniform1fv); | 113 GET_PROC(Uniform1fv); |
| 117 GET_PROC(Uniform1iv); | 114 GET_PROC(Uniform1iv); |
| 118 | 115 |
| 119 GET_PROC(Uniform2f); | 116 GET_PROC(Uniform2f); |
| 120 GET_PROC(Uniform2i); | 117 GET_PROC(Uniform2i); |
| 121 GET_PROC(Uniform2fv); | 118 GET_PROC(Uniform2fv); |
| 122 GET_PROC(Uniform2iv); | 119 GET_PROC(Uniform2iv); |
| 123 | 120 |
| 124 GET_PROC(Uniform3f); | 121 GET_PROC(Uniform3f); |
| 125 GET_PROC(Uniform3i); | 122 GET_PROC(Uniform3i); |
| 126 GET_PROC(Uniform3fv); | 123 GET_PROC(Uniform3fv); |
| 127 GET_PROC(Uniform3iv); | 124 GET_PROC(Uniform3iv); |
| 128 | 125 |
| 129 GET_PROC(Uniform4f); | 126 GET_PROC(Uniform4f); |
| 130 GET_PROC(Uniform4i); | 127 GET_PROC(Uniform4i); |
| 131 GET_PROC(Uniform4fv); | 128 GET_PROC(Uniform4fv); |
| 132 GET_PROC(Uniform4iv); | 129 GET_PROC(Uniform4iv); |
| 133 | 130 |
| 134 GET_PROC(UniformMatrix2fv); | 131 GET_PROC(UniformMatrix2fv); |
| 135 GET_PROC(UniformMatrix3fv); | 132 GET_PROC(UniformMatrix3fv); |
| 136 GET_PROC(UniformMatrix4fv); | 133 GET_PROC(UniformMatrix4fv); |
| 137 GET_PROC(UseProgram); | 134 GET_PROC(UseProgram); |
| 138 GET_PROC(VertexAttrib4fv); | 135 GET_PROC(VertexAttrib4fv); |
| 139 GET_PROC(VertexAttribPointer); | 136 GET_PROC(VertexAttribPointer); |
| 140 GET_PROC(Viewport); | 137 GET_PROC(Viewport); |
| 141 GET_PROC(BindFramebuffer); | 138 GET_PROC(BindFramebuffer); |
| 142 GET_PROC(BindRenderbuffer); | 139 GET_PROC(BindRenderbuffer); |
| 143 GET_PROC(CheckFramebufferStatus); | 140 GET_PROC(CheckFramebufferStatus); |
| 144 GET_PROC(DeleteFramebuffers); | 141 GET_PROC(DeleteFramebuffers); |
| 145 GET_PROC(DeleteRenderbuffers); | 142 GET_PROC(DeleteRenderbuffers); |
| 146 GET_PROC(FramebufferRenderbuffer); | 143 GET_PROC(FramebufferRenderbuffer); |
| 147 GET_PROC(FramebufferTexture2D); | 144 GET_PROC(FramebufferTexture2D); |
| 148 GET_PROC(GenFramebuffers); | 145 GET_PROC(GenFramebuffers); |
| 149 GET_PROC(GenRenderbuffers); | 146 GET_PROC(GenRenderbuffers); |
| 150 GET_PROC(GetFramebufferAttachmentParameteriv); | 147 GET_PROC(GetFramebufferAttachmentParameteriv); |
| 151 GET_PROC(GetRenderbufferParameteriv); | 148 GET_PROC(GetRenderbufferParameteriv); |
| 152 GET_PROC(RenderbufferStorage); | 149 GET_PROC(RenderbufferStorage); |
| 153 | 150 |
| 154 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBuff
erOES"); | 151 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); |
| 155 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnm
apBufferOES"); | 152 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); |
| 156 } | 153 return interface; |
| 157 glInterface.get()->ref(); | |
| 158 return glInterface.get(); | |
| 159 } | 154 } |
| OLD | NEW |