const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { GET_PROC_LOCAL(GetString); if (nullptr == GetString) { return nullptr; } const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); GrGLVersion version = GrGLGetVersionFromString(verStr); if (version < GR_GL_VER(2,0)) { return nullptr; } GET_PROC_LOCAL(GetIntegerv); GET_PROC_LOCAL(GetStringi); GrEGLQueryStringProc queryString; GrEGLDisplay display; get_egl_query_and_display(&queryString, &display, ctx, get); GrGLExtensions extensions; if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, display)) { return nullptr; } GrGLInterface* interface = new 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); if (version >= GR_GL_VER(3,0) && extensions.has("GL_EXT_blend_func_extended")) { GET_PROC_SUFFIX(BindFragDataLocation, EXT); GET_PROC_SUFFIX(BindFragDataLocationIndexed, EXT); } if (extensions.has("GL_KHR_blend_equation_advanced")) { GET_PROC_SUFFIX(BlendBarrier, KHR); } else if (extensions.has("GL_NV_blend_equation_advanced")) { GET_PROC_SUFFIX(BlendBarrier, NV); } GET_PROC(BlendColor); GET_PROC(BlendEquation); 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); if (version >= GR_GL_VER(3,0)) { GET_PROC(DrawArraysInstanced); GET_PROC(DrawElementsInstanced); } else if (extensions.has("GL_EXT_draw_instanced")) { GET_PROC_SUFFIX(DrawArraysInstanced, EXT); GET_PROC_SUFFIX(DrawElementsInstanced, EXT); } if (version >= GR_GL_VER(3,1)) { GET_PROC(DrawArraysIndirect); GET_PROC(DrawElementsIndirect); } 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(GetShaderPrecisionFormat); GET_PROC(GetShaderiv); GET_PROC(GetString); GET_PROC(GetStringi); GET_PROC(GetUniformLocation); GET_PROC(IsTexture); GET_PROC(LineWidth); GET_PROC(LinkProgram); GET_PROC(PixelStorei); if (extensions.has("GL_EXT_raster_multisample")) { GET_PROC_SUFFIX(RasterSamples, EXT); } 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); } if (extensions.has("GL_NV_texture_barrier")) { GET_PROC_SUFFIX(TextureBarrier, NV); } 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(VertexAttrib1f); GET_PROC(VertexAttrib2fv); GET_PROC(VertexAttrib3fv); GET_PROC(VertexAttrib4fv); if (version >= GR_GL_VER(3,0)) { GET_PROC(VertexAttribDivisor); } else if (extensions.has("GL_EXT_instanced_arrays")) { GET_PROC_SUFFIX(VertexAttribDivisor, EXT); } if (version >= GR_GL_VER(3,0)) { GET_PROC(VertexAttribIPointer); } 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 (extensions.has("GL_CHROMIUM_framebuffer_multisample")) { GET_PROC_SUFFIX(RenderbufferStorageMultisample, CHROMIUM); GET_PROC_SUFFIX(BlitFramebuffer, CHROMIUM); } else if (version >= GR_GL_VER(3,0)) { GET_PROC(RenderbufferStorageMultisample); GET_PROC(BlitFramebuffer); } if (extensions.has("GL_CHROMIUM_map_sub")) { GET_PROC_SUFFIX(MapBufferSubData, CHROMIUM); GET_PROC_SUFFIX(MapTexSubImage2D, CHROMIUM); GET_PROC_SUFFIX(UnmapBufferSubData, CHROMIUM); GET_PROC_SUFFIX(UnmapTexSubImage2D, CHROMIUM); } 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 nullptr from the eglGetProcAddress for the functions if (nullptr == functions->fInsertEventMarker || nullptr == functions->fPushGroupMarker || nullptr == 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(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); } if (extensions.has("GL_CHROMIUM_path_rendering")) { GET_PROC_SUFFIX(MatrixLoadf, CHROMIUM); GET_PROC_SUFFIX(MatrixLoadIdentity, CHROMIUM); GET_PROC_SUFFIX(PathCommands, CHROMIUM); GET_PROC_SUFFIX(PathParameteri, CHROMIUM); GET_PROC_SUFFIX(PathParameterf, CHROMIUM); GET_PROC_SUFFIX(GenPaths, CHROMIUM); GET_PROC_SUFFIX(DeletePaths, CHROMIUM); GET_PROC_SUFFIX(IsPath, CHROMIUM); GET_PROC_SUFFIX(PathStencilFunc, CHROMIUM); GET_PROC_SUFFIX(StencilFillPath, CHROMIUM); GET_PROC_SUFFIX(StencilStrokePath, CHROMIUM); GET_PROC_SUFFIX(StencilFillPathInstanced, CHROMIUM); GET_PROC_SUFFIX(StencilStrokePathInstanced, CHROMIUM); GET_PROC_SUFFIX(CoverFillPath, CHROMIUM); GET_PROC_SUFFIX(CoverStrokePath, CHROMIUM); GET_PROC_SUFFIX(CoverFillPathInstanced, CHROMIUM); GET_PROC_SUFFIX(CoverStrokePathInstanced, CHROMIUM); GET_PROC_SUFFIX(StencilThenCoverFillPath, CHROMIUM); GET_PROC_SUFFIX(StencilThenCoverStrokePath, CHROMIUM); GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, CHROMIUM); GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, CHROMIUM); GET_PROC_SUFFIX(ProgramPathFragmentInputGen, CHROMIUM); // GL_CHROMIUM_path_rendering additions: GET_PROC_SUFFIX(BindFragmentInputLocation, CHROMIUM); } if (extensions.has("GL_NV_framebuffer_mixed_samples")) { GET_PROC_SUFFIX(CoverageModulation, NV); } if (extensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) { GET_PROC_SUFFIX(CoverageModulation, CHROMIUM); } if (extensions.has("GL_EXT_multi_draw_indirect")) { GET_PROC_SUFFIX(MultiDrawArraysIndirect, EXT); GET_PROC_SUFFIX(MultiDrawElementsIndirect, EXT); } if (extensions.has("GL_NV_bindless_texture")) { GET_PROC_SUFFIX(GetTextureHandle, NV); GET_PROC_SUFFIX(GetTextureSamplerHandle, NV); GET_PROC_SUFFIX(MakeTextureHandleResident, NV); GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV); GET_PROC_SUFFIX(GetImageHandle, NV); GET_PROC_SUFFIX(MakeImageHandleResident, NV); GET_PROC_SUFFIX(MakeImageHandleNonResident, NV); GET_PROC_SUFFIX(IsTextureHandleResident, NV); GET_PROC_SUFFIX(IsImageHandleResident, NV); GET_PROC_SUFFIX(UniformHandleui64, NV); GET_PROC_SUFFIX(UniformHandleui64v, NV); GET_PROC_SUFFIX(ProgramUniformHandleui64, NV); GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV); } if (extensions.has("GL_KHR_debug")) { GET_PROC_SUFFIX(DebugMessageControl, KHR); GET_PROC_SUFFIX(DebugMessageInsert, KHR); GET_PROC_SUFFIX(DebugMessageCallback, KHR); GET_PROC_SUFFIX(GetDebugMessageLog, KHR); GET_PROC_SUFFIX(PushDebugGroup, KHR); GET_PROC_SUFFIX(PopDebugGroup, KHR); GET_PROC_SUFFIX(ObjectLabel, KHR); // In general we have a policy against removing extension strings when the driver does // not provide function pointers for an advertised extension. However, because there is a // known device that advertises GL_KHR_debug but fails to provide the functions and this is // a debugging- only extension we've made an exception. This also can happen when using // APITRACE. if (!interface->fFunctions.fDebugMessageControl) { extensions.remove("GL_KHR_debug"); } } if (extensions.has("GL_CHROMIUM_bind_uniform_location")) { GET_PROC_SUFFIX(BindUniformLocation, CHROMIUM); } if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) { GET_EGL_PROC_SUFFIX(CreateImage, KHR); GET_EGL_PROC_SUFFIX(DestroyImage, KHR); } interface->fStandard = kGLES_GrGLStandard; interface->fExtensions.swap(&extensions); return interface; }
const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { GET_PROC_LOCAL(GetString); GET_PROC_LOCAL(GetStringi); GET_PROC_LOCAL(GetIntegerv); // GetStringi may be nullptr depending on the GL version. if (nullptr == GetString || nullptr == GetIntegerv) { return nullptr; } const char* versionString = (const char*) GetString(GR_GL_VERSION); GrGLVersion glVer = GrGLGetVersionFromString(versionString); if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) { // We must have array and element_array buffer objects. return nullptr; } GrEGLQueryStringProc queryString; GrEGLDisplay display; get_egl_query_and_display(&queryString, &display, ctx, get); GrGLExtensions extensions; if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, display)) { return nullptr; } GrGLInterface* interface = new GrGLInterface(); GrGLInterface::Functions* functions = &interface->fFunctions; GET_PROC(ActiveTexture); GET_PROC(AttachShader); GET_PROC(BindAttribLocation); GET_PROC(BindBuffer); if (glVer >= GR_GL_VER(3,0)) { GET_PROC(BindFragDataLocation); } GET_PROC(BeginQuery); GET_PROC(BindTexture); if (extensions.has("GL_KHR_blend_equation_advanced")) { GET_PROC_SUFFIX(BlendBarrier, KHR); } else if (extensions.has("GL_NV_blend_equation_advanced")) { GET_PROC_SUFFIX(BlendBarrier, NV); } if (glVer >= GR_GL_VER(1,4) || extensions.has("GL_ARB_imaging")) { GET_PROC(BlendColor); } else if (extensions.has("GL_EXT_blend_color")) { GET_PROC_SUFFIX(BlendColor, EXT); } if (glVer >= GR_GL_VER(1,4) || extensions.has("GL_ARB_imaging")) { GET_PROC(BlendEquation); } else if (extensions.has("GL_EXT_blend_subtract")) { GET_PROC_SUFFIX(BlendEquation, EXT); } 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(DeleteQueries); GET_PROC(DeleteShader); GET_PROC(DeleteTextures); GET_PROC(DepthMask); GET_PROC(Disable); GET_PROC(DisableVertexAttribArray); GET_PROC(DrawArrays); GET_PROC(DrawBuffer); GET_PROC(DrawBuffers); GET_PROC(DrawElements); if (glVer >= GR_GL_VER(3,1) || extensions.has("GL_ARB_draw_instanced") || extensions.has("GL_EXT_draw_instanced")) { GET_PROC(DrawArraysInstanced); GET_PROC(DrawElementsInstanced); } if (glVer >= GR_GL_VER(4,0)) { // We don't use ARB_draw_indirect because it does not support a base instance. GET_PROC(DrawArraysIndirect); GET_PROC(DrawElementsIndirect); } GET_PROC(Enable); GET_PROC(EnableVertexAttribArray); GET_PROC(EndQuery); GET_PROC(Finish); GET_PROC(Flush); GET_PROC(FrontFace); GET_PROC(GenBuffers); GET_PROC(GenerateMipmap); GET_PROC(GetBufferParameteriv); GET_PROC(GetError); GET_PROC(GetIntegerv); GET_PROC(GetQueryObjectiv); GET_PROC(GetQueryObjectuiv); if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { GET_PROC(GetQueryObjecti64v); GET_PROC(GetQueryObjectui64v); GET_PROC(QueryCounter); } else if (extensions.has("GL_EXT_timer_query")) { GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); } GET_PROC(GetQueryiv); GET_PROC(GetProgramInfoLog); GET_PROC(GetProgramiv); GET_PROC(GetShaderInfoLog); GET_PROC(GetShaderiv); GET_PROC(GetString); GET_PROC(GetStringi); GET_PROC(GetShaderPrecisionFormat); GET_PROC(GetTexLevelParameteriv); GET_PROC(GenQueries); GET_PROC(GenTextures); GET_PROC(GetUniformLocation); GET_PROC(IsTexture); GET_PROC(LineWidth); GET_PROC(LinkProgram); GET_PROC(MapBuffer); GET_PROC(PixelStorei); if (extensions.has("GL_EXT_raster_multisample")) { GET_PROC_SUFFIX(RasterSamples, EXT); } GET_PROC(ReadBuffer); 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); if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { GET_PROC(TexStorage2D); } else if (extensions.has("GL_EXT_texture_storage")) { GET_PROC_SUFFIX(TexStorage2D, EXT); } GET_PROC(TexSubImage2D); if (glVer >= GR_GL_VER(4,5) || extensions.has("GL_ARB_texture_barrier")) { GET_PROC(TextureBarrier); } else if (extensions.has("GL_NV_texture_barrier")) { GET_PROC_SUFFIX(TextureBarrier, NV); } 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(UnmapBuffer); GET_PROC(UseProgram); GET_PROC(VertexAttrib1f); GET_PROC(VertexAttrib2fv); GET_PROC(VertexAttrib3fv); GET_PROC(VertexAttrib4fv); if (glVer >= GR_GL_VER(3,2) || extensions.has("GL_ARB_instanced_arrays")) { GET_PROC(VertexAttribDivisor); } if (glVer >= GR_GL_VER(3,0)) { GET_PROC(VertexAttribIPointer); } GET_PROC(VertexAttribPointer); GET_PROC(Viewport); GET_PROC(BindFragDataLocationIndexed); if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { // no ARB suffix for GL_ARB_vertex_array_object GET_PROC(BindVertexArray); GET_PROC(GenVertexArrays); GET_PROC(DeleteVertexArrays); } else if (extensions.has("GL_APPLE_vertex_array_object")) { GET_PROC_SUFFIX(BindVertexArray, APPLE); GET_PROC_SUFFIX(GenVertexArrays, APPLE); GET_PROC_SUFFIX(DeleteVertexArrays, APPLE); } if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) { GET_PROC(MapBufferRange); GET_PROC(FlushMappedBufferRange); } // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // GL_ARB_framebuffer_object doesn't use ARB suffix.) if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { GET_PROC(GenFramebuffers); GET_PROC(GetFramebufferAttachmentParameteriv); GET_PROC(GetRenderbufferParameteriv); GET_PROC(BindFramebuffer); GET_PROC(FramebufferTexture2D); GET_PROC(CheckFramebufferStatus); GET_PROC(DeleteFramebuffers); GET_PROC(RenderbufferStorage); GET_PROC(GenRenderbuffers); GET_PROC(DeleteRenderbuffers); GET_PROC(FramebufferRenderbuffer); GET_PROC(BindRenderbuffer); GET_PROC(RenderbufferStorageMultisample); GET_PROC(BlitFramebuffer); } else if (extensions.has("GL_EXT_framebuffer_object")) { GET_PROC_SUFFIX(GenFramebuffers, EXT); GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); GET_PROC_SUFFIX(BindFramebuffer, EXT); GET_PROC_SUFFIX(FramebufferTexture2D, EXT); GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); GET_PROC_SUFFIX(DeleteFramebuffers, EXT); GET_PROC_SUFFIX(RenderbufferStorage, EXT); GET_PROC_SUFFIX(GenRenderbuffers, EXT); GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); GET_PROC_SUFFIX(BindRenderbuffer, EXT); if (extensions.has("GL_EXT_framebuffer_multisample")) { GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); } if (extensions.has("GL_EXT_framebuffer_blit")) { GET_PROC_SUFFIX(BlitFramebuffer, EXT); } } else { // we must have FBOs delete interface; return nullptr; } 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(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); } if (extensions.has("GL_NV_framebuffer_mixed_samples")) { GET_PROC_SUFFIX(CoverageModulation, NV); } if (extensions.has("GL_EXT_debug_marker")) { GET_PROC_SUFFIX(InsertEventMarker, EXT); GET_PROC_SUFFIX(PushGroupMarker, EXT); GET_PROC_SUFFIX(PopGroupMarker, EXT); } if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) { GET_PROC(InvalidateBufferData); GET_PROC(InvalidateBufferSubData); GET_PROC(InvalidateFramebuffer); GET_PROC(InvalidateSubFramebuffer); GET_PROC(InvalidateTexImage); GET_PROC(InvalidateTexSubImage); } if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) { GET_PROC(GetProgramResourceLocation); } if (glVer >= GR_GL_VER(4,3)) { // We don't use ARB_multi_draw_indirect because it does not support GL_DRAW_INDIRECT_BUFFER. GET_PROC(MultiDrawArraysIndirect); GET_PROC(MultiDrawElementsIndirect); } if (extensions.has("GL_NV_bindless_texture")) { GET_PROC_SUFFIX(GetTextureHandle, NV); GET_PROC_SUFFIX(GetTextureSamplerHandle, NV); GET_PROC_SUFFIX(MakeTextureHandleResident, NV); GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV); GET_PROC_SUFFIX(GetImageHandle, NV); GET_PROC_SUFFIX(MakeImageHandleResident, NV); GET_PROC_SUFFIX(MakeImageHandleNonResident, NV); GET_PROC_SUFFIX(IsTextureHandleResident, NV); GET_PROC_SUFFIX(IsImageHandleResident, NV); GET_PROC_SUFFIX(UniformHandleui64, NV); GET_PROC_SUFFIX(UniformHandleui64v, NV); GET_PROC_SUFFIX(ProgramUniformHandleui64, NV); GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV); } if (extensions.has("GL_EXT_direct_state_access")) { GET_PROC_SUFFIX(TextureParameteri, EXT); GET_PROC_SUFFIX(TextureParameteriv, EXT); GET_PROC_SUFFIX(TextureParameterf, EXT); GET_PROC_SUFFIX(TextureParameterfv, EXT); GET_PROC_SUFFIX(TextureImage1D, EXT); GET_PROC_SUFFIX(TextureImage2D, EXT); GET_PROC_SUFFIX(TextureSubImage1D, EXT); GET_PROC_SUFFIX(TextureSubImage2D, EXT); GET_PROC_SUFFIX(CopyTextureImage1D, EXT); GET_PROC_SUFFIX(CopyTextureImage2D, EXT); GET_PROC_SUFFIX(CopyTextureSubImage1D, EXT); GET_PROC_SUFFIX(CopyTextureSubImage2D, EXT); GET_PROC_SUFFIX(GetTextureImage, EXT); GET_PROC_SUFFIX(GetTextureParameterfv, EXT); GET_PROC_SUFFIX(GetTextureParameteriv, EXT); GET_PROC_SUFFIX(GetTextureLevelParameterfv, EXT); GET_PROC_SUFFIX(GetTextureLevelParameteriv, EXT); if (glVer >= GR_GL_VER(1,2)) { GET_PROC_SUFFIX(TextureImage3D, EXT); GET_PROC_SUFFIX(TextureSubImage3D, EXT); GET_PROC_SUFFIX(CopyTextureSubImage3D, EXT); GET_PROC_SUFFIX(CompressedTextureImage3D, EXT); GET_PROC_SUFFIX(CompressedTextureImage2D, EXT); GET_PROC_SUFFIX(CompressedTextureImage1D, EXT); GET_PROC_SUFFIX(CompressedTextureSubImage3D, EXT); GET_PROC_SUFFIX(CompressedTextureSubImage2D, EXT); GET_PROC_SUFFIX(CompressedTextureSubImage1D, EXT); GET_PROC_SUFFIX(GetCompressedTextureImage, EXT); } if (glVer >= GR_GL_VER(1,5)) { GET_PROC_SUFFIX(NamedBufferData, EXT); GET_PROC_SUFFIX(NamedBufferSubData, EXT); GET_PROC_SUFFIX(MapNamedBuffer, EXT); GET_PROC_SUFFIX(UnmapNamedBuffer, EXT); GET_PROC_SUFFIX(GetNamedBufferParameteriv, EXT); GET_PROC_SUFFIX(GetNamedBufferPointerv, EXT); GET_PROC_SUFFIX(GetNamedBufferSubData, EXT); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC_SUFFIX(ProgramUniform1f, EXT); GET_PROC_SUFFIX(ProgramUniform2f, EXT); GET_PROC_SUFFIX(ProgramUniform3f, EXT); GET_PROC_SUFFIX(ProgramUniform4f, EXT); GET_PROC_SUFFIX(ProgramUniform1i, EXT); GET_PROC_SUFFIX(ProgramUniform2i, EXT); GET_PROC_SUFFIX(ProgramUniform3i, EXT); GET_PROC_SUFFIX(ProgramUniform4i, EXT); GET_PROC_SUFFIX(ProgramUniform1fv, EXT); GET_PROC_SUFFIX(ProgramUniform2fv, EXT); GET_PROC_SUFFIX(ProgramUniform3fv, EXT); GET_PROC_SUFFIX(ProgramUniform4fv, EXT); GET_PROC_SUFFIX(ProgramUniform1iv, EXT); GET_PROC_SUFFIX(ProgramUniform2iv, EXT); GET_PROC_SUFFIX(ProgramUniform3iv, EXT); GET_PROC_SUFFIX(ProgramUniform4iv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix2fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix3fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix4fv, EXT); } if (glVer >= GR_GL_VER(2,1)) { GET_PROC_SUFFIX(ProgramUniformMatrix2x3fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix3x2fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix2x4fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix4x2fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix3x4fv, EXT); GET_PROC_SUFFIX(ProgramUniformMatrix4x3fv, EXT); } if (glVer >= GR_GL_VER(3,0)) { GET_PROC_SUFFIX(NamedRenderbufferStorage, EXT); GET_PROC_SUFFIX(GetNamedRenderbufferParameteriv, EXT); GET_PROC_SUFFIX(NamedRenderbufferStorageMultisample, EXT); GET_PROC_SUFFIX(CheckNamedFramebufferStatus, EXT); GET_PROC_SUFFIX(NamedFramebufferTexture1D, EXT); GET_PROC_SUFFIX(NamedFramebufferTexture2D, EXT); GET_PROC_SUFFIX(NamedFramebufferTexture3D, EXT); GET_PROC_SUFFIX(NamedFramebufferRenderbuffer, EXT); GET_PROC_SUFFIX(GetNamedFramebufferAttachmentParameteriv, EXT); GET_PROC_SUFFIX(GenerateTextureMipmap, EXT); GET_PROC_SUFFIX(FramebufferDrawBuffer, EXT); GET_PROC_SUFFIX(FramebufferDrawBuffers, EXT); GET_PROC_SUFFIX(FramebufferReadBuffer, EXT); GET_PROC_SUFFIX(GetFramebufferParameteriv, EXT); GET_PROC_SUFFIX(NamedCopyBufferSubData, EXT); GET_PROC_SUFFIX(VertexArrayVertexOffset, EXT); GET_PROC_SUFFIX(VertexArrayColorOffset, EXT); GET_PROC_SUFFIX(VertexArrayEdgeFlagOffset, EXT); GET_PROC_SUFFIX(VertexArrayIndexOffset, EXT); GET_PROC_SUFFIX(VertexArrayNormalOffset, EXT); GET_PROC_SUFFIX(VertexArrayTexCoordOffset, EXT); GET_PROC_SUFFIX(VertexArrayMultiTexCoordOffset, EXT); GET_PROC_SUFFIX(VertexArrayFogCoordOffset, EXT); GET_PROC_SUFFIX(VertexArraySecondaryColorOffset, EXT); GET_PROC_SUFFIX(VertexArrayVertexAttribOffset, EXT); GET_PROC_SUFFIX(VertexArrayVertexAttribIOffset, EXT); GET_PROC_SUFFIX(EnableVertexArray, EXT); GET_PROC_SUFFIX(DisableVertexArray, EXT); GET_PROC_SUFFIX(EnableVertexArrayAttrib, EXT); GET_PROC_SUFFIX(DisableVertexArrayAttrib, EXT); GET_PROC_SUFFIX(GetVertexArrayIntegerv, EXT); GET_PROC_SUFFIX(GetVertexArrayPointerv, EXT); GET_PROC_SUFFIX(GetVertexArrayIntegeri_v, EXT); GET_PROC_SUFFIX(GetVertexArrayPointeri_v, EXT); GET_PROC_SUFFIX(MapNamedBufferRange, EXT); GET_PROC_SUFFIX(FlushMappedNamedBufferRange, EXT); } } if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_KHR_debug")) { // KHR_debug defines these methods to have no suffix in an OpenGL (not ES) context. GET_PROC(DebugMessageControl); GET_PROC(DebugMessageInsert); GET_PROC(DebugMessageCallback); GET_PROC(GetDebugMessageLog); GET_PROC(PushDebugGroup); GET_PROC(PopDebugGroup); GET_PROC(ObjectLabel); } if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) { GET_EGL_PROC_SUFFIX(CreateImage, KHR); GET_EGL_PROC_SUFFIX(DestroyImage, KHR); } interface->fStandard = kGL_GrGLStandard; interface->fExtensions.swap(&extensions); return interface; }
const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { GET_PROC_LOCAL(GetString); GET_PROC_LOCAL(GetStringi); GET_PROC_LOCAL(GetIntegerv); // GetStringi may be NULL depending on the GL version. if (NULL == GetString || NULL == GetIntegerv) { return NULL; } const char* versionString = (const char*) GetString(GR_GL_VERSION); GrGLVersion glVer = GrGLGetVersionFromString(versionString); if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) { // We must have array and element_array buffer objects. return NULL; } GrGLExtensions extensions; if (!extensions.init(kGL_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); if (glVer >= GR_GL_VER(3,0)) { GET_PROC(BindFragDataLocation); } GET_PROC(BeginQuery); GET_PROC(BindTexture); GET_PROC(BlendFunc); if (glVer >= GR_GL_VER(1,4) || extensions.has("GL_ARB_imaging") || extensions.has("GL_EXT_blend_color")) { GET_PROC(BlendColor); } 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(DeleteQueries); GET_PROC(DeleteShader); GET_PROC(DeleteTextures); GET_PROC(DepthMask); GET_PROC(Disable); GET_PROC(DisableVertexAttribArray); GET_PROC(DrawArrays); GET_PROC(DrawBuffer); GET_PROC(DrawBuffers); GET_PROC(DrawElements); GET_PROC(Enable); GET_PROC(EnableVertexAttribArray); GET_PROC(EndQuery); GET_PROC(Finish); GET_PROC(Flush); GET_PROC(FrontFace); GET_PROC(GenBuffers); GET_PROC(GenerateMipmap); GET_PROC(GetBufferParameteriv); GET_PROC(GetError); GET_PROC(GetIntegerv); GET_PROC(GetQueryObjectiv); GET_PROC(GetQueryObjectuiv); if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { GET_PROC(GetQueryObjecti64v); GET_PROC(GetQueryObjectui64v); GET_PROC(QueryCounter); } else if (extensions.has("GL_EXT_timer_query")) { GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); } GET_PROC(GetQueryiv); GET_PROC(GetProgramInfoLog); GET_PROC(GetProgramiv); GET_PROC(GetShaderInfoLog); GET_PROC(GetShaderiv); GET_PROC(GetString); GET_PROC(GetStringi); GET_PROC(GetTexLevelParameteriv); GET_PROC(GenQueries); GET_PROC(GenTextures); GET_PROC(GetUniformLocation); GET_PROC(LineWidth); GET_PROC(LinkProgram); GET_PROC(MapBuffer); if (extensions.has("GL_EXT_direct_state_access")) { GET_PROC_SUFFIX(MatrixLoadf, EXT); GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); } GET_PROC(PixelStorei); GET_PROC(ReadBuffer); 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); if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { GET_PROC(TexStorage2D); } else if (extensions.has("GL_EXT_texture_storage")) { GET_PROC_SUFFIX(TexStorage2D, EXT); } GET_PROC(TexSubImage2D); 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(UnmapBuffer); GET_PROC(UseProgram); GET_PROC(VertexAttrib1f); GET_PROC(VertexAttrib2fv); GET_PROC(VertexAttrib3fv); GET_PROC(VertexAttrib4fv); GET_PROC(VertexAttribPointer); GET_PROC(Viewport); GET_PROC(BindFragDataLocationIndexed); if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { // no ARB suffix for GL_ARB_vertex_array_object GET_PROC(BindVertexArray); GET_PROC(GenVertexArrays); GET_PROC(DeleteVertexArrays); } if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) { GET_PROC(MapBufferRange); GET_PROC(FlushMappedBufferRange); } // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // GL_ARB_framebuffer_object doesn't use ARB suffix.) if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { GET_PROC(GenFramebuffers); GET_PROC(GetFramebufferAttachmentParameteriv); GET_PROC(GetRenderbufferParameteriv); GET_PROC(BindFramebuffer); GET_PROC(FramebufferTexture2D); GET_PROC(CheckFramebufferStatus); GET_PROC(DeleteFramebuffers); GET_PROC(RenderbufferStorage); GET_PROC(GenRenderbuffers); GET_PROC(DeleteRenderbuffers); GET_PROC(FramebufferRenderbuffer); GET_PROC(BindRenderbuffer); GET_PROC(RenderbufferStorageMultisample); GET_PROC(BlitFramebuffer); } else if (extensions.has("GL_EXT_framebuffer_object")) { GET_PROC_SUFFIX(GenFramebuffers, EXT); GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); GET_PROC_SUFFIX(BindFramebuffer, EXT); GET_PROC_SUFFIX(FramebufferTexture2D, EXT); GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); GET_PROC_SUFFIX(DeleteFramebuffers, EXT); GET_PROC_SUFFIX(RenderbufferStorage, EXT); GET_PROC_SUFFIX(GenRenderbuffers, EXT); GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); GET_PROC_SUFFIX(BindRenderbuffer, EXT); if (extensions.has("GL_EXT_framebuffer_multisample")) { GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); } if (extensions.has("GL_EXT_framebuffer_blit")) { GET_PROC_SUFFIX(BlitFramebuffer, EXT); } } else { // we must have FBOs delete interface; return NULL; } if (extensions.has("GL_NV_path_rendering")) { 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(PathTexGen, NV); GET_PROC_SUFFIX(CoverFillPath, NV); GET_PROC_SUFFIX(CoverStrokePath, NV); GET_PROC_SUFFIX(CoverFillPathInstanced, NV); GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); // NV_path_rendering v1.2 (These methods may not be present) GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); // NV_path_rendering v1.3 (These methods may not be present) GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); GET_PROC_SUFFIX(PathMemoryGlyphIndexArray, NV); } if (extensions.has("GL_EXT_debug_marker")) { GET_PROC_SUFFIX(InsertEventMarker, EXT); GET_PROC_SUFFIX(PushGroupMarker, EXT); GET_PROC_SUFFIX(PopGroupMarker, EXT); } if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) { GET_PROC(InvalidateBufferData); GET_PROC(InvalidateBufferSubData); GET_PROC(InvalidateFramebuffer); GET_PROC(InvalidateSubFramebuffer); GET_PROC(InvalidateTexImage); GET_PROC(InvalidateTexSubImage); } if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) { GET_PROC(GetProgramResourceLocation); } interface->fStandard = kGL_GrGLStandard; interface->fExtensions.swap(&extensions); return interface; }
const GrGLInterface* GrGLCreateNativeInterface() { if (NULL != glXGetCurrentContext()) { const char* versionString = (const char*) glGetString(GL_VERSION); GrGLVersion glVer = GrGLGetVersionFromString(versionString); // This may or may not succeed depending on the gl version. GrGLGetStringiProc glGetStringi = (GrGLGetStringiProc) glXGetProcAddress(reinterpret_cast<const GLubyte*>("glGetStringi")); GrGLExtensions extensions; if (!extensions.init(kDesktop_GrGLBinding, glGetString, glGetStringi, glGetIntegerv)) { return NULL; } if (glVer < GR_GL_VER(1,5)) { // We must have array and element_array buffer objects. return NULL; } GrGLInterface* interface = new GrGLInterface(); interface->fActiveTexture = glActiveTexture; GR_GL_GET_PROC(AttachShader); GR_GL_GET_PROC(BindAttribLocation); GR_GL_GET_PROC(BindBuffer); GR_GL_GET_PROC(BindFragDataLocation); GR_GL_GET_PROC(BeginQuery); interface->fBindTexture = glBindTexture; interface->fBlendFunc = glBlendFunc; if (glVer >= GR_GL_VER(1,4) || extensions.has("GL_ARB_imaging") || extensions.has("GL_EXT_blend_color")) { GR_GL_GET_PROC(BlendColor); } GR_GL_GET_PROC(BufferData); GR_GL_GET_PROC(BufferSubData); interface->fClear = glClear; interface->fClearColor = glClearColor; interface->fClearStencil = glClearStencil; interface->fColorMask = glColorMask; GR_GL_GET_PROC(CompileShader); interface->fCompressedTexImage2D = glCompressedTexImage2D; interface->fCopyTexSubImage2D = glCopyTexSubImage2D; GR_GL_GET_PROC(CreateProgram); GR_GL_GET_PROC(CreateShader); interface->fCullFace = glCullFace; GR_GL_GET_PROC(DeleteBuffers); GR_GL_GET_PROC(DeleteProgram); GR_GL_GET_PROC(DeleteQueries); GR_GL_GET_PROC(DeleteShader); interface->fDeleteTextures = glDeleteTextures; interface->fDepthMask = glDepthMask; interface->fDisable = glDisable; GR_GL_GET_PROC(DisableVertexAttribArray); interface->fDrawArrays = glDrawArrays; interface->fDrawBuffer = glDrawBuffer; GR_GL_GET_PROC(DrawBuffers); interface->fDrawElements = glDrawElements; interface->fEnable = glEnable; GR_GL_GET_PROC(EnableVertexAttribArray); GR_GL_GET_PROC(EndQuery); interface->fFinish = glFinish; interface->fFlush = glFlush; interface->fFrontFace = glFrontFace; GR_GL_GET_PROC(GenBuffers); GR_GL_GET_PROC(GetBufferParameteriv); interface->fGetError = glGetError; interface->fGetIntegerv = glGetIntegerv; GR_GL_GET_PROC(GetQueryObjectiv); GR_GL_GET_PROC(GetQueryObjectuiv); if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { GR_GL_GET_PROC(GetQueryObjecti64v); GR_GL_GET_PROC(GetQueryObjectui64v); GR_GL_GET_PROC(QueryCounter); } else if (extensions.has("GL_EXT_timer_query")) { GR_GL_GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); GR_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); } GR_GL_GET_PROC(GetQueryiv); GR_GL_GET_PROC(GetProgramInfoLog); GR_GL_GET_PROC(GetProgramiv); GR_GL_GET_PROC(GetShaderInfoLog); GR_GL_GET_PROC(GetShaderiv); interface->fGetString = glGetString; GR_GL_GET_PROC(GetStringi); interface->fGetTexLevelParameteriv = glGetTexLevelParameteriv; GR_GL_GET_PROC(GenQueries); interface->fGenTextures = glGenTextures; GR_GL_GET_PROC(GetUniformLocation); interface->fLineWidth = glLineWidth; GR_GL_GET_PROC(LinkProgram); GR_GL_GET_PROC(MapBuffer); interface->fPixelStorei = glPixelStorei; interface->fReadBuffer = glReadBuffer; interface->fReadPixels = glReadPixels; if (extensions.has("GL_NV_framebuffer_multisample_coverage")) { GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisampleCoverage, NV); } interface->fScissor = glScissor; GR_GL_GET_PROC(ShaderSource); interface->fStencilFunc = glStencilFunc; GR_GL_GET_PROC(StencilFuncSeparate); interface->fStencilMask = glStencilMask; GR_GL_GET_PROC(StencilMaskSeparate); interface->fStencilOp = glStencilOp; GR_GL_GET_PROC(StencilOpSeparate); interface->fTexImage2D = glTexImage2D; interface->fTexParameteri = glTexParameteri; interface->fTexParameteriv = glTexParameteriv; if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { GR_GL_GET_PROC(TexStorage2D); } else if (extensions.has("GL_EXT_texture_storage")) { GR_GL_GET_PROC_SUFFIX(TexStorage2D, EXT); } interface->fTexSubImage2D = glTexSubImage2D; GR_GL_GET_PROC(Uniform1f); GR_GL_GET_PROC(Uniform1i); GR_GL_GET_PROC(Uniform1fv); GR_GL_GET_PROC(Uniform1iv); GR_GL_GET_PROC(Uniform2f); GR_GL_GET_PROC(Uniform2i); GR_GL_GET_PROC(Uniform2fv); GR_GL_GET_PROC(Uniform2iv); GR_GL_GET_PROC(Uniform3f); GR_GL_GET_PROC(Uniform3i); GR_GL_GET_PROC(Uniform3fv); GR_GL_GET_PROC(Uniform3iv); GR_GL_GET_PROC(Uniform4f); GR_GL_GET_PROC(Uniform4i); GR_GL_GET_PROC(Uniform4fv); GR_GL_GET_PROC(Uniform4iv); GR_GL_GET_PROC(UniformMatrix2fv); GR_GL_GET_PROC(UniformMatrix3fv); GR_GL_GET_PROC(UniformMatrix4fv); GR_GL_GET_PROC(UnmapBuffer); GR_GL_GET_PROC(UseProgram); GR_GL_GET_PROC(VertexAttrib4fv); GR_GL_GET_PROC(VertexAttribPointer); interface->fViewport = glViewport; GR_GL_GET_PROC(BindFragDataLocationIndexed); if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { // no ARB suffix for GL_ARB_vertex_array_object GR_GL_GET_PROC(BindVertexArray); GR_GL_GET_PROC(GenVertexArrays); GR_GL_GET_PROC(DeleteVertexArrays); } // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // GL_ARB_framebuffer_object doesn't use ARB suffix.) if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { GR_GL_GET_PROC(GenFramebuffers); GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv); GR_GL_GET_PROC(GetRenderbufferParameteriv); GR_GL_GET_PROC(BindFramebuffer); GR_GL_GET_PROC(FramebufferTexture2D); GR_GL_GET_PROC(CheckFramebufferStatus); GR_GL_GET_PROC(DeleteFramebuffers); GR_GL_GET_PROC(RenderbufferStorage); GR_GL_GET_PROC(GenRenderbuffers); GR_GL_GET_PROC(DeleteRenderbuffers); GR_GL_GET_PROC(FramebufferRenderbuffer); GR_GL_GET_PROC(BindRenderbuffer); GR_GL_GET_PROC(RenderbufferStorageMultisample); GR_GL_GET_PROC(BlitFramebuffer); } else if (extensions.has("GL_EXT_framebuffer_object")) { GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT); GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT); GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT); GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT); GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT); GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT); GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT); if (extensions.has("GL_EXT_framebuffer_multisample")) { GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); } if (extensions.has("GL_EXT_framebuffer_blit")) { GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT); } } else { // we must have FBOs delete interface; return NULL; } interface->fBindingsExported = kDesktop_GrGLBinding; return interface; } else { return NULL; } }
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(VertexAttrib1f); GET_PROC(VertexAttrib2fv); GET_PROC(VertexAttrib3fv); 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); GET_PROC_SUFFIX(PathMemoryGlyphIndexArray, NV); } interface->fStandard = kGLES_GrGLStandard; interface->fExtensions.swap(&extensions); return interface; }
const GrGLInterface* GrGLCreateMesaInterface() { if (NULL != OSMesaGetCurrentContext()) { GrGLGetStringProc getString = (GrGLGetStringProc) OSMesaGetProcAddress("glGetString"); GrGLGetStringiProc getStringi = (GrGLGetStringiProc) OSMesaGetProcAddress("glGetStringi"); GrGLGetIntegervProc getIntegerv = (GrGLGetIntegervProc) OSMesaGetProcAddress("glGetIntegerv"); GrGLExtensions extensions; if (!extensions.init(kDesktop_GrGLBinding, getString, getStringi, getIntegerv)) { return NULL; } const char* versionString = (const char*) getString(GL_VERSION); GrGLVersion glVer = GrGLGetVersionFromString(versionString); if (glVer < GR_GL_VER(1,5)) { // We must have array and element_array buffer objects. return NULL; } GrGLInterface* interface = new GrGLInterface(); GR_GL_GET_PROC(ActiveTexture); GR_GL_GET_PROC(BeginQuery); GR_GL_GET_PROC(AttachShader); GR_GL_GET_PROC(BindAttribLocation); GR_GL_GET_PROC(BindBuffer); GR_GL_GET_PROC(BindFragDataLocation); GR_GL_GET_PROC(BindTexture); GR_GL_GET_PROC(BlendFunc); if (glVer >= GR_GL_VER(1,4) || extensions.has("GL_ARB_imaging") || extensions.has("GL_EXT_blend_color")) { GR_GL_GET_PROC(BlendColor); } GR_GL_GET_PROC(BufferData); GR_GL_GET_PROC(BufferSubData); GR_GL_GET_PROC(Clear); GR_GL_GET_PROC(ClearColor); GR_GL_GET_PROC(ClearStencil); GR_GL_GET_PROC(ColorMask); GR_GL_GET_PROC(CompileShader); GR_GL_GET_PROC(CompressedTexImage2D); GR_GL_GET_PROC(CopyTexSubImage2D); GR_GL_GET_PROC(CreateProgram); GR_GL_GET_PROC(CreateShader); GR_GL_GET_PROC(CullFace); GR_GL_GET_PROC(DeleteBuffers); GR_GL_GET_PROC(DeleteProgram); GR_GL_GET_PROC(DeleteQueries); GR_GL_GET_PROC(DeleteShader); GR_GL_GET_PROC(DeleteTextures); GR_GL_GET_PROC(DepthMask); GR_GL_GET_PROC(Disable); GR_GL_GET_PROC(DisableVertexAttribArray); GR_GL_GET_PROC(DrawArrays); GR_GL_GET_PROC(DrawBuffer); GR_GL_GET_PROC(DrawBuffers); GR_GL_GET_PROC(DrawElements); GR_GL_GET_PROC(Enable); GR_GL_GET_PROC(EnableVertexAttribArray); GR_GL_GET_PROC(EndQuery); GR_GL_GET_PROC(Finish); GR_GL_GET_PROC(Flush); GR_GL_GET_PROC(FrontFace); GR_GL_GET_PROC(GenBuffers); GR_GL_GET_PROC(GenQueries); GR_GL_GET_PROC(GetBufferParameteriv); GR_GL_GET_PROC(GetError); GR_GL_GET_PROC(GetIntegerv); GR_GL_GET_PROC(GetProgramInfoLog); GR_GL_GET_PROC(GetProgramiv); if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { GR_GL_GET_PROC(GetQueryObjecti64v); GR_GL_GET_PROC(GetQueryObjectui64v) GR_GL_GET_PROC(QueryCounter); } else if (extensions.has("GL_EXT_timer_query")) { GR_GL_GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); GR_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); } GR_GL_GET_PROC(GetQueryObjectiv); GR_GL_GET_PROC(GetQueryObjectuiv); GR_GL_GET_PROC(GetQueryiv); GR_GL_GET_PROC(GetShaderInfoLog); GR_GL_GET_PROC(GetShaderiv); GR_GL_GET_PROC(GetString); GR_GL_GET_PROC(GetStringi); GR_GL_GET_PROC(GetTexLevelParameteriv); GR_GL_GET_PROC(GenTextures); GR_GL_GET_PROC(GetUniformLocation); GR_GL_GET_PROC(LineWidth); GR_GL_GET_PROC(LinkProgram); GR_GL_GET_PROC(MapBuffer); GR_GL_GET_PROC(PixelStorei); GR_GL_GET_PROC(ReadBuffer); GR_GL_GET_PROC(ReadPixels); GR_GL_GET_PROC(Scissor); GR_GL_GET_PROC(ShaderSource); GR_GL_GET_PROC(StencilFunc); GR_GL_GET_PROC(StencilFuncSeparate); GR_GL_GET_PROC(StencilMask); GR_GL_GET_PROC(StencilMaskSeparate); GR_GL_GET_PROC(StencilOp); GR_GL_GET_PROC(StencilOpSeparate); GR_GL_GET_PROC(TexImage2D) GR_GL_GET_PROC(TexParameteri); GR_GL_GET_PROC(TexParameteriv); GR_GL_GET_PROC(TexStorage2D); if (NULL == interface->fTexStorage2D) { GR_GL_GET_PROC_SUFFIX(TexStorage2D, EXT); } GR_GL_GET_PROC(TexSubImage2D); GR_GL_GET_PROC(Uniform1f); GR_GL_GET_PROC(Uniform1i); GR_GL_GET_PROC(Uniform1fv); GR_GL_GET_PROC(Uniform1iv); GR_GL_GET_PROC(Uniform2f); GR_GL_GET_PROC(Uniform2i); GR_GL_GET_PROC(Uniform2fv); GR_GL_GET_PROC(Uniform2iv); GR_GL_GET_PROC(Uniform3f); GR_GL_GET_PROC(Uniform3i); GR_GL_GET_PROC(Uniform3fv); GR_GL_GET_PROC(Uniform3iv); GR_GL_GET_PROC(Uniform4f); GR_GL_GET_PROC(Uniform4i); GR_GL_GET_PROC(Uniform4fv); GR_GL_GET_PROC(Uniform4iv); GR_GL_GET_PROC(UniformMatrix2fv); GR_GL_GET_PROC(UniformMatrix3fv); GR_GL_GET_PROC(UniformMatrix4fv); GR_GL_GET_PROC(UnmapBuffer); GR_GL_GET_PROC(UseProgram); GR_GL_GET_PROC(VertexAttrib4fv); GR_GL_GET_PROC(VertexAttribPointer); GR_GL_GET_PROC(Viewport); if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { // no ARB suffix for GL_ARB_vertex_array_object GR_GL_GET_PROC(BindVertexArray); GR_GL_GET_PROC(DeleteVertexArrays); GR_GL_GET_PROC(GenVertexArrays); } // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since // GL_ARB_framebuffer_object doesn't use ARB suffix.) if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { GR_GL_GET_PROC(GenFramebuffers); GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv); GR_GL_GET_PROC(GetRenderbufferParameteriv); GR_GL_GET_PROC(BindFramebuffer); GR_GL_GET_PROC(FramebufferTexture2D); GR_GL_GET_PROC(CheckFramebufferStatus); GR_GL_GET_PROC(DeleteFramebuffers); GR_GL_GET_PROC(RenderbufferStorage); GR_GL_GET_PROC(GenRenderbuffers); GR_GL_GET_PROC(DeleteRenderbuffers); GR_GL_GET_PROC(FramebufferRenderbuffer); GR_GL_GET_PROC(BindRenderbuffer); GR_GL_GET_PROC(RenderbufferStorageMultisample); GR_GL_GET_PROC(BlitFramebuffer); } else if (extensions.has("GL_EXT_framebuffer_object")) { GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT); GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT); GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT); GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT); GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT); GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT); GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT); if (extensions.has("GL_EXT_framebuffer_multisample")) { GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); } if (extensions.has("GL_EXT_framebuffer_blit")) { GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT); } } else { // we must have FBOs delete interface; return NULL; } GR_GL_GET_PROC(BindFragDataLocationIndexed); interface->fBindingsExported = kDesktop_GrGLBinding; return interface; } else { return NULL; } }
const GrGLInterface* GrGLCreateNativeInterface() { static SkAutoTUnref<GrGLInterface> glInterface; if (!glInterface.get()) { GrGLExtensions extensions; if (!extensions.init(kES2_GrGLBinding, glGetString, NULL, glGetIntegerv)) { return NULL; } GrGLInterface* interface = new GrGLInterface; glInterface.reset(interface); interface->fBindingsExported = kES2_GrGLBinding; interface->fActiveTexture = glActiveTexture; interface->fAttachShader = glAttachShader; interface->fBindAttribLocation = glBindAttribLocation; interface->fBindBuffer = glBindBuffer; interface->fBindTexture = glBindTexture; interface->fBindVertexArray = glBindVertexArrayOES; interface->fBlendColor = glBlendColor; interface->fBlendFunc = glBlendFunc; interface->fBufferData = glBufferData; interface->fBufferSubData = glBufferSubData; interface->fClear = glClear; interface->fClearColor = glClearColor; interface->fClearStencil = glClearStencil; interface->fColorMask = glColorMask; interface->fCompileShader = glCompileShader; interface->fCompressedTexImage2D = glCompressedTexImage2D; interface->fCopyTexSubImage2D = glCopyTexSubImage2D; interface->fCreateProgram = glCreateProgram; interface->fCreateShader = glCreateShader; interface->fCullFace = glCullFace; interface->fDeleteBuffers = glDeleteBuffers; interface->fDeleteProgram = glDeleteProgram; interface->fDeleteShader = glDeleteShader; interface->fDeleteTextures = glDeleteTextures; interface->fDeleteVertexArrays = glDeleteVertexArraysOES; interface->fDepthMask = glDepthMask; interface->fDisable = glDisable; interface->fDisableVertexAttribArray = glDisableVertexAttribArray; interface->fDrawArrays = glDrawArrays; interface->fDrawElements = glDrawElements; interface->fEnable = glEnable; interface->fEnableVertexAttribArray = glEnableVertexAttribArray; interface->fFinish = glFinish; interface->fFlush = glFlush; interface->fFrontFace = glFrontFace; interface->fGenBuffers = glGenBuffers; interface->fGenerateMipmap = glGenerateMipmap; interface->fGenTextures = glGenTextures; interface->fGenVertexArrays = glGenVertexArraysOES; interface->fGetBufferParameteriv = glGetBufferParameteriv; interface->fGetError = glGetError; interface->fGetIntegerv = glGetIntegerv; interface->fGetProgramInfoLog = glGetProgramInfoLog; interface->fGetProgramiv = glGetProgramiv; interface->fGetShaderInfoLog = glGetShaderInfoLog; interface->fGetShaderiv = glGetShaderiv; interface->fGetString = glGetString; interface->fGetUniformLocation = glGetUniformLocation; interface->fLineWidth = glLineWidth; interface->fLinkProgram = glLinkProgram; interface->fPixelStorei = glPixelStorei; interface->fReadPixels = glReadPixels; interface->fScissor = glScissor; #if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE interface->fShaderSource = (GrGLShaderSourceProc) glShaderSource; #else interface->fShaderSource = glShaderSource; #endif interface->fStencilFunc = glStencilFunc; interface->fStencilFuncSeparate = glStencilFuncSeparate; interface->fStencilMask = glStencilMask; interface->fStencilMaskSeparate = glStencilMaskSeparate; interface->fStencilOp = glStencilOp; interface->fStencilOpSeparate = glStencilOpSeparate; interface->fTexImage2D = glTexImage2D; interface->fTexParameteri = glTexParameteri; interface->fTexParameteriv = glTexParameteriv; interface->fTexSubImage2D = glTexSubImage2D; #if GL_ARB_texture_storage interface->fTexStorage2D = glTexStorage2D; #elif GL_EXT_texture_storage interface->fTexStorage2D = glTexStorage2DEXT; #else interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT"); #endif #if GL_EXT_discard_framebuffer interface->fDiscardFramebuffer = glDiscardFramebufferEXT; #endif interface->fUniform1f = glUniform1f; interface->fUniform1i = glUniform1i; interface->fUniform1fv = glUniform1fv; interface->fUniform1iv = glUniform1iv; interface->fUniform2f = glUniform2f; interface->fUniform2i = glUniform2i; interface->fUniform2fv = glUniform2fv; interface->fUniform2iv = glUniform2iv; interface->fUniform3f = glUniform3f; interface->fUniform3i = glUniform3i; interface->fUniform3fv = glUniform3fv; interface->fUniform3iv = glUniform3iv; interface->fUniform4f = glUniform4f; interface->fUniform4i = glUniform4i; interface->fUniform4fv = glUniform4fv; interface->fUniform4iv = glUniform4iv; interface->fUniformMatrix2fv = glUniformMatrix2fv; interface->fUniformMatrix3fv = glUniformMatrix3fv; interface->fUniformMatrix4fv = glUniformMatrix4fv; interface->fUseProgram = glUseProgram; interface->fVertexAttrib4fv = glVertexAttrib4fv; interface->fVertexAttribPointer = glVertexAttribPointer; interface->fViewport = glViewport; interface->fBindFramebuffer = glBindFramebuffer; interface->fBindRenderbuffer = glBindRenderbuffer; interface->fCheckFramebufferStatus = glCheckFramebufferStatus; interface->fDeleteFramebuffers = glDeleteFramebuffers; interface->fDeleteRenderbuffers = glDeleteRenderbuffers; interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer; interface->fFramebufferTexture2D = glFramebufferTexture2D; if (extensions.has("GL_EXT_multisampled_render_to_texture")) { #if GL_EXT_multisampled_render_to_texture interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleEXT; interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleEXT; #else interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleEXT"); interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleEXT"); #endif } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { #if GL_IMG_multisampled_render_to_texture interface->fFramebufferTexture2DMultisample = glFramebufferTexture2DMultisampleIMG; interface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleIMG; #else interface->fFramebufferTexture2DMultisample = (GrGLFramebufferTexture2DMultisampleProc) eglGetProcAddress("glFramebufferTexture2DMultisampleIMG"); interface->fRenderbufferStorageMultisample = (GrGLRenderbufferStorageMultisampleProc) eglGetProcAddress("glRenderbufferStorageMultisampleIMG"); #endif } interface->fGenFramebuffers = glGenFramebuffers; interface->fGenRenderbuffers = glGenRenderbuffers; interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; interface->fRenderbufferStorage = glRenderbufferStorage; #if GL_OES_mapbuffer interface->fMapBuffer = glMapBufferOES; interface->fUnmapBuffer = glUnmapBufferOES; #else interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES"); interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES"); #endif } glInterface.get()->ref(); return glInterface.get(); }
sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { GET_PROC_LOCAL(GetString); if (nullptr == GetString) { return nullptr; } const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); GrGLVersion glVer = GrGLGetVersionFromString(verStr); if (glVer < GR_GL_VER(1,0)) { return nullptr; } GET_PROC_LOCAL(GetIntegerv); GET_PROC_LOCAL(GetStringi); GrEGLQueryStringFn* queryString; GrEGLDisplay display; GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get); GrGLExtensions extensions; if (!extensions.init(kWebGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, display)) { return nullptr; } sk_sp<GrGLInterface> interface(new GrGLInterface); GrGLInterface::Functions* functions = &interface->fFunctions; // Autogenerated content follows GET_PROC(ActiveTexture); GET_PROC(AttachShader); GET_PROC(BindAttribLocation); GET_PROC(BindBuffer); GET_PROC(BindTexture); GET_PROC(BlendColor); GET_PROC(BlendEquation); 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(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(GenTextures); 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(GetUniformLocation); GET_PROC(IsTexture); 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(TexParameterf); GET_PROC(TexParameterfv); GET_PROC(TexParameteri); GET_PROC(TexParameteriv); GET_PROC(TexSubImage2D); GET_PROC(Uniform1f); GET_PROC(Uniform1fv); GET_PROC(Uniform1i); GET_PROC(Uniform1iv); GET_PROC(Uniform2f); GET_PROC(Uniform2fv); GET_PROC(Uniform2i); GET_PROC(Uniform2iv); GET_PROC(Uniform3f); GET_PROC(Uniform3fv); GET_PROC(Uniform3i); GET_PROC(Uniform3iv); GET_PROC(Uniform4f); GET_PROC(Uniform4fv); GET_PROC(Uniform4i); GET_PROC(Uniform4iv); GET_PROC(UniformMatrix2fv); GET_PROC(UniformMatrix3fv); GET_PROC(UniformMatrix4fv); GET_PROC(UseProgram); GET_PROC(VertexAttrib1f); GET_PROC(VertexAttrib2fv); GET_PROC(VertexAttrib3fv); GET_PROC(VertexAttrib4fv); GET_PROC(VertexAttribPointer); GET_PROC(Viewport); if (glVer >= GR_GL_VER(2,0)) { GET_PROC(GetStringi); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(BindVertexArray); GET_PROC(DeleteVertexArrays); GET_PROC(GenVertexArrays); } else if (extensions.has("GL_OES_vertex_array_object")) { GET_PROC_SUFFIX(BindVertexArray, OES); GET_PROC_SUFFIX(DeleteVertexArrays, OES); GET_PROC_SUFFIX(GenVertexArrays, OES); } else if (extensions.has("OES_vertex_array_object")) { GET_PROC_SUFFIX(BindVertexArray, OES); GET_PROC_SUFFIX(DeleteVertexArrays, OES); GET_PROC_SUFFIX(GenVertexArrays, OES); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(DrawArraysInstanced); GET_PROC(DrawElementsInstanced); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(DrawBuffers); GET_PROC(ReadBuffer); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(DrawRangeElements); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(TexStorage2D); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(VertexAttribIPointer); } GET_PROC(BindFramebuffer); GET_PROC(BindRenderbuffer); GET_PROC(CheckFramebufferStatus); GET_PROC(DeleteFramebuffers); GET_PROC(DeleteRenderbuffers); GET_PROC(FramebufferRenderbuffer); GET_PROC(FramebufferTexture2D); GET_PROC(GenFramebuffers); GET_PROC(GenRenderbuffers); GET_PROC(GenerateMipmap); GET_PROC(GetFramebufferAttachmentParameteriv); GET_PROC(GetRenderbufferParameteriv); GET_PROC(RenderbufferStorage); if (glVer >= GR_GL_VER(2,0)) { GET_PROC(RenderbufferStorageMultisample); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(ClientWaitSync); GET_PROC(DeleteSync); GET_PROC(FenceSync); GET_PROC(IsSync); GET_PROC(WaitSync); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(BindSampler); GET_PROC(DeleteSamplers); GET_PROC(GenSamplers); GET_PROC(SamplerParameteri); GET_PROC(SamplerParameteriv); } if (glVer >= GR_GL_VER(2,0)) { GET_PROC(InvalidateFramebuffer); GET_PROC(InvalidateSubFramebuffer); } GET_PROC(GetShaderPrecisionFormat); // End autogenerated content interface->fStandard = kWebGL_GrGLStandard; interface->fExtensions.swap(&extensions); return std::move(interface); }
bool GrGLInterface::validate(GrGLBinding binding) const { // kNone must be 0 so that the check we're about to do can never succeed if // binding == kNone. GR_STATIC_ASSERT(kNone_GrGLBinding == 0); if (0 == (binding & fBindingsExported)) { return false; } GrGLExtensions extensions; if (!extensions.init(binding, this)) { return false; } // functions that are always required if (NULL == fActiveTexture || NULL == fAttachShader || NULL == fBindAttribLocation || NULL == fBindBuffer || NULL == fBindTexture || NULL == fBlendFunc || NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension NULL == fBufferData || NULL == fBufferSubData || NULL == fClear || NULL == fClearColor || NULL == fClearStencil || NULL == fColorMask || NULL == fCompileShader || NULL == fCopyTexSubImage2D || NULL == fCreateProgram || NULL == fCreateShader || NULL == fCullFace || NULL == fDeleteBuffers || NULL == fDeleteProgram || NULL == fDeleteShader || NULL == fDeleteTextures || NULL == fDepthMask || NULL == fDisable || NULL == fDisableVertexAttribArray || NULL == fDrawArrays || NULL == fDrawElements || NULL == fEnable || NULL == fEnableVertexAttribArray || NULL == fFrontFace || NULL == fGenBuffers || NULL == fGenTextures || NULL == fGetBufferParameteriv || NULL == fGetError || NULL == fGetIntegerv || NULL == fGetProgramInfoLog || NULL == fGetProgramiv || NULL == fGetShaderInfoLog || NULL == fGetShaderiv || NULL == fGetString || NULL == fGetUniformLocation || NULL == fLinkProgram || NULL == fPixelStorei || NULL == fReadPixels || NULL == fScissor || NULL == fShaderSource || NULL == fStencilFunc || NULL == fStencilMask || NULL == fStencilOp || NULL == fTexImage2D || NULL == fTexParameteri || NULL == fTexParameteriv || NULL == fTexSubImage2D || NULL == fUniform1f || NULL == fUniform1i || NULL == fUniform1fv || NULL == fUniform1iv || NULL == fUniform2f || NULL == fUniform2i || NULL == fUniform2fv || NULL == fUniform2iv || NULL == fUniform3f || NULL == fUniform3i || NULL == fUniform3fv || NULL == fUniform3iv || NULL == fUniform4f || NULL == fUniform4i || NULL == fUniform4fv || NULL == fUniform4iv || NULL == fUniformMatrix2fv || NULL == fUniformMatrix3fv || NULL == fUniformMatrix4fv || NULL == fUseProgram || NULL == fVertexAttrib4fv || NULL == fVertexAttribPointer || NULL == fViewport || NULL == fBindFramebuffer || NULL == fBindRenderbuffer || NULL == fCheckFramebufferStatus || NULL == fDeleteFramebuffers || NULL == fDeleteRenderbuffers || NULL == fFinish || NULL == fFlush || NULL == fFramebufferRenderbuffer || NULL == fFramebufferTexture2D || NULL == fGetFramebufferAttachmentParameteriv || NULL == fGetRenderbufferParameteriv || NULL == fGenFramebuffers || NULL == fGenRenderbuffers || NULL == fRenderbufferStorage) { return false; } GrGLVersion glVer = GrGLGetVersion(this); // Now check that baseline ES/Desktop fns not covered above are present // and that we have fn pointers for any advertised extensions that we will // try to use. // these functions are part of ES2, we assume they are available // On the desktop we assume they are available if the extension // is present or GL version is high enough. if (kES2_GrGLBinding == binding) { if (NULL == fStencilFuncSeparate || NULL == fStencilMaskSeparate || NULL == fStencilOpSeparate) { return false; } } else if (kDesktop_GrGLBinding == binding) { if (glVer >= GR_GL_VER(2,0)) { if (NULL == fStencilFuncSeparate || NULL == fStencilMaskSeparate || NULL == fStencilOpSeparate) { return false; } } if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { return false; } if (glVer >= GR_GL_VER(2,0) || extensions.has("GL_ARB_draw_buffers")) { if (NULL == fDrawBuffers) { return false; } } if (glVer >= GR_GL_VER(1,5) || extensions.has("GL_ARB_occlusion_query")) { if (NULL == fGenQueries || NULL == fDeleteQueries || NULL == fBeginQuery || NULL == fEndQuery || NULL == fGetQueryiv || NULL == fGetQueryObjectiv || NULL == fGetQueryObjectuiv) { return false; } } if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query") || extensions.has("GL_EXT_timer_query")) { if (NULL == fGetQueryObjecti64v || NULL == fGetQueryObjectui64v) { return false; } } if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { if (NULL == fQueryCounter) { return false; } } // The below two blocks are checks for functions used with // GL_NV_path_rendering. We're not enforcing that they be non-NULL // because they aren't actually called at this time. if (false && (NULL == fMatrixMode || NULL == fLoadIdentity || NULL == fLoadMatrixf)) { return false; } if (false && extensions.has("GL_NV_path_rendering")) { if (NULL == fPathCommands || NULL == fPathCoords || NULL == fPathSubCommands || NULL == fPathSubCoords || NULL == fPathString || NULL == fPathGlyphs || NULL == fPathGlyphRange || NULL == fWeightPaths || NULL == fCopyPath || NULL == fInterpolatePaths || NULL == fTransformPath || NULL == fPathParameteriv || NULL == fPathParameteri || NULL == fPathParameterfv || NULL == fPathParameterf || NULL == fPathDashArray || NULL == fGenPaths || NULL == fDeletePaths || NULL == fIsPath || NULL == fPathStencilFunc || NULL == fPathStencilDepthOffset || NULL == fStencilFillPath || NULL == fStencilStrokePath || NULL == fStencilFillPathInstanced || NULL == fStencilStrokePathInstanced || NULL == fPathCoverDepthFunc || NULL == fPathColorGen || NULL == fPathTexGen || NULL == fPathFogGen || NULL == fCoverFillPath || NULL == fCoverStrokePath || NULL == fCoverFillPathInstanced || NULL == fCoverStrokePathInstanced || NULL == fGetPathParameteriv || NULL == fGetPathParameterfv || NULL == fGetPathCommands || NULL == fGetPathCoords || NULL == fGetPathDashArray || NULL == fGetPathMetrics || NULL == fGetPathMetricRange || NULL == fGetPathSpacing || NULL == fGetPathColorGeniv || NULL == fGetPathColorGenfv || NULL == fGetPathTexGeniv || NULL == fGetPathTexGenfv || NULL == fIsPointInFillPath || NULL == fIsPointInStrokePath || NULL == fGetPathLength || NULL == fPointAlongPath) { return false; } } } // optional function on desktop before 1.3 if (kDesktop_GrGLBinding != binding || (glVer >= GR_GL_VER(1,3)) || extensions.has("GL_ARB_texture_compression")) { if (NULL == fCompressedTexImage2D) { return false; } } // part of desktop GL, but not ES if (kDesktop_GrGLBinding == binding && (NULL == fLineWidth || NULL == fGetTexLevelParameteriv || NULL == fDrawBuffer || NULL == fReadBuffer)) { return false; } // GL_EXT_texture_storage is part of desktop 4.2 // There is a desktop ARB extension and an ES+desktop EXT extension if (kDesktop_GrGLBinding == binding) { if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage") || extensions.has("GL_EXT_texture_storage")) { if (NULL == fTexStorage2D) { return false; } } } else if (extensions.has("GL_EXT_texture_storage")) { if (NULL == fTexStorage2D) { return false; } } if (extensions.has("GL_EXT_discard_framebuffer")) { // FIXME: Remove this once Chromium is updated to provide this function #if 0 if (NULL == fDiscardFramebuffer) { return false; } #endif } // FBO MSAA if (kDesktop_GrGLBinding == binding) { // GL 3.0 and the ARB extension have multisample + blit if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { if (NULL == fRenderbufferStorageMultisample || NULL == fBlitFramebuffer) { return false; } } else { if (extensions.has("GL_EXT_framebuffer_blit") && NULL == fBlitFramebuffer) { return false; } if (extensions.has("GL_EXT_framebuffer_multisample") && NULL == fRenderbufferStorageMultisample) { return false; } } } else { if (extensions.has("GL_CHROMIUM_framebuffer_multisample")) { if (NULL == fRenderbufferStorageMultisample || NULL == fBlitFramebuffer) { return false; } } if (extensions.has("GL_APPLE_framebuffer_multisample")) { if (NULL == fRenderbufferStorageMultisample || NULL == fResolveMultisampleFramebuffer) { return false; } } if (extensions.has("GL_IMG_multisampled_render_to_texture")) { if (NULL == fRenderbufferStorageMultisample || NULL == fFramebufferTexture2DMultisample) { return false; } } } // On ES buffer mapping is an extension. On Desktop // buffer mapping was part of original VBO extension // which we require. if (kDesktop_GrGLBinding == binding || extensions.has("GL_OES_mapbuffer")) { if (NULL == fMapBuffer || NULL == fUnmapBuffer) { return false; } } // Dual source blending if (kDesktop_GrGLBinding == binding && (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended"))) { if (NULL == fBindFragDataLocationIndexed) { return false; } } if (kDesktop_GrGLBinding == binding && glVer >= GR_GL_VER(3, 0)) { if (NULL == fGetStringi) { return false; } } if (kDesktop_GrGLBinding == binding) { if (glVer >= GR_GL_VER(3, 0) || extensions.has("GL_ARB_vertex_array_object")) { if (NULL == fBindVertexArray || NULL == fDeleteVertexArrays || NULL == fGenVertexArrays) { return false; } } } else { if (extensions.has("GL_OES_vertex_array_object")) { if (NULL == fBindVertexArray || NULL == fDeleteVertexArrays || NULL == fGenVertexArrays) { return false; } } } return true; }