| Index: src/gpu/gl/GrGLAssembleInterface.cpp
|
| diff --git a/src/gpu/gl/GrGLAssembleInterface.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp
|
| index 8fd173d9f433b6fe4bb0e136866f808624304c0f..da88547f9bd738fd30af95077644d1577a023f97 100644
|
| --- a/src/gpu/gl/GrGLAssembleInterface.cpp
|
| +++ b/src/gpu/gl/GrGLAssembleInterface.cpp
|
| @@ -14,6 +14,27 @@
|
| #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F #S)
|
| #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
|
|
|
| +const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) {
|
| + GET_PROC_LOCAL(GetString);
|
| + if (NULL == GetString) {
|
| + return NULL;
|
| + }
|
| +
|
| + const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
|
| + if (NULL == verStr) {
|
| + return NULL;
|
| + }
|
| +
|
| + GrGLStandard standard = GrGLGetStandardInUseFromString(verStr);
|
| +
|
| + if (kGLES_GrGLStandard == standard) {
|
| + return GrGLAssembleGLESInterface(ctx, get);
|
| + } else if (kGL_GrGLStandard == standard) {
|
| + return GrGLAssembleGLInterface(ctx, get);
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
| GET_PROC_LOCAL(GetString);
|
| GET_PROC_LOCAL(GetStringi);
|
| @@ -272,3 +293,220 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
|
|
| return interface;
|
| }
|
| +
|
| +const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
|
| + GET_PROC_LOCAL(GetString);
|
| + if (NULL == GetString) {
|
| + return NULL;
|
| + }
|
| +
|
| + const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
|
| + GrGLVersion version = GrGLGetVersionFromString(verStr);
|
| +
|
| + if (version < GR_GL_VER(2,0)) {
|
| + return NULL;
|
| + }
|
| +
|
| + GET_PROC_LOCAL(GetIntegerv);
|
| + GET_PROC_LOCAL(GetStringi);
|
| + GrGLExtensions extensions;
|
| + if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv)) {
|
| + return NULL;
|
| + }
|
| +
|
| + GrGLInterface* interface = SkNEW(GrGLInterface);
|
| + GrGLInterface::Functions* functions = &interface->fFunctions;
|
| +
|
| + GET_PROC(ActiveTexture);
|
| + GET_PROC(AttachShader);
|
| + GET_PROC(BindAttribLocation);
|
| + GET_PROC(BindBuffer);
|
| + GET_PROC(BindTexture);
|
| + GET_PROC_SUFFIX(BindVertexArray, OES);
|
| + GET_PROC(BlendColor);
|
| + GET_PROC(BlendFunc);
|
| + GET_PROC(BufferData);
|
| + GET_PROC(BufferSubData);
|
| + GET_PROC(Clear);
|
| + GET_PROC(ClearColor);
|
| + GET_PROC(ClearStencil);
|
| + GET_PROC(ColorMask);
|
| + GET_PROC(CompileShader);
|
| + GET_PROC(CompressedTexImage2D);
|
| + GET_PROC(CompressedTexSubImage2D);
|
| + GET_PROC(CopyTexSubImage2D);
|
| + GET_PROC(CreateProgram);
|
| + GET_PROC(CreateShader);
|
| + GET_PROC(CullFace);
|
| + GET_PROC(DeleteBuffers);
|
| + GET_PROC(DeleteProgram);
|
| + GET_PROC(DeleteShader);
|
| + GET_PROC(DeleteTextures);
|
| + GET_PROC_SUFFIX(DeleteVertexArrays, OES);
|
| + GET_PROC(DepthMask);
|
| + GET_PROC(Disable);
|
| + GET_PROC(DisableVertexAttribArray);
|
| + GET_PROC(DrawArrays);
|
| + GET_PROC(DrawElements);
|
| + GET_PROC(Enable);
|
| + GET_PROC(EnableVertexAttribArray);
|
| + GET_PROC(Finish);
|
| + GET_PROC(Flush);
|
| + GET_PROC(FrontFace);
|
| + GET_PROC(GenBuffers);
|
| + GET_PROC(GenerateMipmap);
|
| + GET_PROC(GenTextures);
|
| + GET_PROC_SUFFIX(GenVertexArrays, OES);
|
| + GET_PROC(GetBufferParameteriv);
|
| + GET_PROC(GetError);
|
| + GET_PROC(GetIntegerv);
|
| + GET_PROC(GetProgramInfoLog);
|
| + GET_PROC(GetProgramiv);
|
| + GET_PROC(GetShaderInfoLog);
|
| + GET_PROC(GetShaderiv);
|
| + GET_PROC(GetString);
|
| + GET_PROC(GetStringi);
|
| + GET_PROC(GetUniformLocation);
|
| + GET_PROC(LineWidth);
|
| + GET_PROC(LinkProgram);
|
| + GET_PROC(PixelStorei);
|
| + GET_PROC(ReadPixels);
|
| + GET_PROC(Scissor);
|
| + GET_PROC(ShaderSource);
|
| + GET_PROC(StencilFunc);
|
| + GET_PROC(StencilFuncSeparate);
|
| + GET_PROC(StencilMask);
|
| + GET_PROC(StencilMaskSeparate);
|
| + GET_PROC(StencilOp);
|
| + GET_PROC(StencilOpSeparate);
|
| + GET_PROC(TexImage2D);
|
| + GET_PROC(TexParameteri);
|
| + GET_PROC(TexParameteriv);
|
| + GET_PROC(TexSubImage2D);
|
| +
|
| + if (version >= GR_GL_VER(3,0)) {
|
| + GET_PROC(TexStorage2D);
|
| + } else {
|
| + GET_PROC_SUFFIX(TexStorage2D, EXT);
|
| + }
|
| +
|
| + GET_PROC_SUFFIX(DiscardFramebuffer, EXT);
|
| + GET_PROC(Uniform1f);
|
| + GET_PROC(Uniform1i);
|
| + GET_PROC(Uniform1fv);
|
| + GET_PROC(Uniform1iv);
|
| + GET_PROC(Uniform2f);
|
| + GET_PROC(Uniform2i);
|
| + GET_PROC(Uniform2fv);
|
| + GET_PROC(Uniform2iv);
|
| + GET_PROC(Uniform3f);
|
| + GET_PROC(Uniform3i);
|
| + GET_PROC(Uniform3fv);
|
| + GET_PROC(Uniform3iv);
|
| + GET_PROC(Uniform4f);
|
| + GET_PROC(Uniform4i);
|
| + GET_PROC(Uniform4fv);
|
| + GET_PROC(Uniform4iv);
|
| + GET_PROC(UniformMatrix2fv);
|
| + GET_PROC(UniformMatrix3fv);
|
| + GET_PROC(UniformMatrix4fv);
|
| + GET_PROC(UseProgram);
|
| + GET_PROC(VertexAttrib4fv);
|
| + GET_PROC(VertexAttribPointer);
|
| + GET_PROC(Viewport);
|
| + GET_PROC(BindFramebuffer);
|
| + GET_PROC(BindRenderbuffer);
|
| + GET_PROC(CheckFramebufferStatus);
|
| + GET_PROC(DeleteFramebuffers);
|
| + GET_PROC(DeleteRenderbuffers);
|
| + GET_PROC(FramebufferRenderbuffer);
|
| + GET_PROC(FramebufferTexture2D);
|
| +
|
| + if (version >= GR_GL_VER(3,0)) {
|
| + GET_PROC(RenderbufferStorageMultisample);
|
| + GET_PROC(BlitFramebuffer);
|
| + }
|
| +
|
| + if (extensions.has("GL_EXT_multisampled_render_to_texture")) {
|
| + GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT);
|
| + functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT");
|
| + } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) {
|
| + GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG);
|
| + functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG");
|
| + } else if (extensions.has("GL_APPLE_framebuffer_multisample")) {
|
| + functions->fRenderbufferStorageMultisampleES2APPLE = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleAPPLE");
|
| + GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE);
|
| + }
|
| +
|
| + GET_PROC(GenFramebuffers);
|
| + GET_PROC(GenRenderbuffers);
|
| + GET_PROC(GetFramebufferAttachmentParameteriv);
|
| + GET_PROC(GetRenderbufferParameteriv);
|
| + GET_PROC(RenderbufferStorage);
|
| +
|
| + GET_PROC_SUFFIX(MapBuffer, OES);
|
| + GET_PROC_SUFFIX(UnmapBuffer, OES);
|
| +
|
| + if (version >= GR_GL_VER(3,0)) {
|
| + GET_PROC(MapBufferRange);
|
| + GET_PROC(FlushMappedBufferRange);
|
| + } else if (extensions.has("GL_EXT_map_buffer_range")) {
|
| + GET_PROC_SUFFIX(MapBufferRange, EXT);
|
| + GET_PROC_SUFFIX(FlushMappedBufferRange, EXT);
|
| + }
|
| +
|
| + if (extensions.has("GL_EXT_debug_marker")) {
|
| + GET_PROC(InsertEventMarker);
|
| + GET_PROC(PushGroupMarker);
|
| + GET_PROC(PopGroupMarker);
|
| + // The below check is here because a device has been found that has the extension string but
|
| + // returns NULL from the eglGetProcAddress for the functions
|
| + if (NULL == functions->fInsertEventMarker ||
|
| + NULL == functions->fPushGroupMarker ||
|
| + NULL == functions->fPopGroupMarker) {
|
| + extensions.remove("GL_EXT_debug_marker");
|
| + }
|
| + }
|
| +
|
| + GET_PROC(InvalidateFramebuffer);
|
| + GET_PROC(InvalidateSubFramebuffer);
|
| + GET_PROC(InvalidateBufferData);
|
| + GET_PROC(InvalidateBufferSubData);
|
| + GET_PROC(InvalidateTexImage);
|
| + GET_PROC(InvalidateTexSubImage);
|
| +
|
| + if (version >= GR_GL_VER(3,1)) {
|
| + GET_PROC(GetProgramResourceLocation);
|
| + }
|
| +
|
| + if (extensions.has("GL_NV_path_rendering")) {
|
| + GET_PROC_SUFFIX(MatrixLoadf, EXT);
|
| + GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
|
| + GET_PROC_SUFFIX(PathCommands, NV);
|
| + GET_PROC_SUFFIX(PathCoords, NV);
|
| + GET_PROC_SUFFIX(PathParameteri, NV);
|
| + GET_PROC_SUFFIX(PathParameterf, NV);
|
| + GET_PROC_SUFFIX(GenPaths, NV);
|
| + GET_PROC_SUFFIX(DeletePaths, NV);
|
| + GET_PROC_SUFFIX(IsPath, NV);
|
| + GET_PROC_SUFFIX(PathStencilFunc, NV);
|
| + GET_PROC_SUFFIX(StencilFillPath, NV);
|
| + GET_PROC_SUFFIX(StencilStrokePath, NV);
|
| + GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
|
| + GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
|
| + GET_PROC_SUFFIX(CoverFillPath, NV);
|
| + GET_PROC_SUFFIX(CoverStrokePath, NV);
|
| + GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
|
| + GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
|
| + GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
|
| + GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
|
| + GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
|
| + GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
|
| + GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
|
| + }
|
| +
|
| + interface->fStandard = kGLES_GrGLStandard;
|
| + interface->fExtensions.swap(&extensions);
|
| +
|
| + return interface;
|
| +}
|
|
|