diff options
author | 2014-06-22 22:56:53 -0700 | |
---|---|---|
committer | 2014-06-22 22:56:54 -0700 | |
commit | 74fc727dc88ee24d89f88cb1709f963e9073aeb3 (patch) | |
tree | c1bc9dd2101168a5fbb2b9d523aafac3828c7876 /src/gpu/gl/GrGLAssembleGLESInterface.h | |
parent | 32956400b4d8f33394e2cdef9b66e8369ba2a0f3 (diff) |
Support using OpenGL ES context on desktop
Support using OpenGL ES context on desktop for unix and Android platforms. This
is mainly useful in development.
Add --gpuAPI flag to gm, dm, bench, bench_pictures and render_pictures. The
possible parameters for the flag are "gl" and "gles".
R=bsalomon@google.com, mtklein@google.com, robertphillips@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/319043005
Diffstat (limited to 'src/gpu/gl/GrGLAssembleGLESInterface.h')
-rw-r--r-- | src/gpu/gl/GrGLAssembleGLESInterface.h | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLAssembleGLESInterface.h b/src/gpu/gl/GrGLAssembleGLESInterface.h new file mode 100644 index 0000000000..ddbc980929 --- /dev/null +++ b/src/gpu/gl/GrGLAssembleGLESInterface.h @@ -0,0 +1,240 @@ + +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { + GET_PROC_LOCAL(GetString); + 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_LINKED(ActiveTexture); + GET_LINKED(AttachShader); + GET_LINKED(BindAttribLocation); + GET_LINKED(BindBuffer); + GET_LINKED(BindTexture); + GET_LINKED_SUFFIX(BindVertexArray, OES); + GET_LINKED(BlendColor); + GET_LINKED(BlendFunc); + GET_LINKED(BufferData); + GET_LINKED(BufferSubData); + GET_LINKED(Clear); + GET_LINKED(ClearColor); + GET_LINKED(ClearStencil); + GET_LINKED(ColorMask); + GET_LINKED(CompileShader); + GET_LINKED(CompressedTexImage2D); + GET_LINKED(CompressedTexSubImage2D); + GET_LINKED(CopyTexSubImage2D); + GET_LINKED(CreateProgram); + GET_LINKED(CreateShader); + GET_LINKED(CullFace); + GET_LINKED(DeleteBuffers); + GET_LINKED(DeleteProgram); + GET_LINKED(DeleteShader); + GET_LINKED(DeleteTextures); + GET_LINKED_SUFFIX(DeleteVertexArrays, OES); + GET_LINKED(DepthMask); + GET_LINKED(Disable); + GET_LINKED(DisableVertexAttribArray); + GET_LINKED(DrawArrays); + GET_LINKED(DrawElements); + GET_LINKED(Enable); + GET_LINKED(EnableVertexAttribArray); + GET_LINKED(Finish); + GET_LINKED(Flush); + GET_LINKED(FrontFace); + GET_LINKED(GenBuffers); + GET_LINKED(GenerateMipmap); + GET_LINKED(GenTextures); + GET_LINKED_SUFFIX(GenVertexArrays, OES); + GET_LINKED(GetBufferParameteriv); + GET_LINKED(GetError); + GET_LINKED(GetIntegerv); + GET_LINKED(GetProgramInfoLog); + GET_LINKED(GetProgramiv); + GET_LINKED(GetShaderInfoLog); + GET_LINKED(GetShaderiv); + GET_LINKED(GetString); +#if USE_LINKED && GL_ES_VERSION_3_0 + GET_LINKED(GetStringi); +#else + GET_PROC(GetStringi); +#endif + GET_LINKED(GetUniformLocation); + GET_LINKED(LineWidth); + GET_LINKED(LinkProgram); + GET_LINKED(PixelStorei); + GET_LINKED(ReadPixels); + GET_LINKED(Scissor); +#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE + functions->fShaderSource = (GrGLShaderSourceProc) glShaderSource; +#else + GET_LINKED(ShaderSource); +#endif + GET_LINKED(StencilFunc); + GET_LINKED(StencilFuncSeparate); + GET_LINKED(StencilMask); + GET_LINKED(StencilMaskSeparate); + GET_LINKED(StencilOp); + GET_LINKED(StencilOpSeparate); + GET_LINKED(TexImage2D); + GET_LINKED(TexParameteri); + GET_LINKED(TexParameteriv); + GET_LINKED(TexSubImage2D); + + if (version >= GR_GL_VER(3,0)) { +#if USE_LINKED && GL_ES_VERSION_3_0 + GET_LINKED(TexStorage2D); +#else + GET_PROC(TexStorage2D); +#endif + } else { +#if USE_LINKED && GL_EXT_texture_storage + GET_LINKED_SUFFIX(TexStorage2D, EXT); +#else + GET_PROC_SUFFIX(TexStorage2D, EXT); +#endif + } + +#if USE_LINKED && GL_EXT_discard_framebuffer + GET_LINKED_SUFFIX(DiscardFramebuffer, EXT); +#endif + GET_LINKED(Uniform1f); + GET_LINKED(Uniform1i); + GET_LINKED(Uniform1fv); + GET_LINKED(Uniform1iv); + GET_LINKED(Uniform2f); + GET_LINKED(Uniform2i); + GET_LINKED(Uniform2fv); + GET_LINKED(Uniform2iv); + GET_LINKED(Uniform3f); + GET_LINKED(Uniform3i); + GET_LINKED(Uniform3fv); + GET_LINKED(Uniform3iv); + GET_LINKED(Uniform4f); + GET_LINKED(Uniform4i); + GET_LINKED(Uniform4fv); + GET_LINKED(Uniform4iv); + GET_LINKED(UniformMatrix2fv); + GET_LINKED(UniformMatrix3fv); + GET_LINKED(UniformMatrix4fv); + GET_LINKED(UseProgram); + GET_LINKED(VertexAttrib4fv); + GET_LINKED(VertexAttribPointer); + GET_LINKED(Viewport); + GET_LINKED(BindFramebuffer); + GET_LINKED(BindRenderbuffer); + GET_LINKED(CheckFramebufferStatus); + GET_LINKED(DeleteFramebuffers); + GET_LINKED(DeleteRenderbuffers); + GET_LINKED(FramebufferRenderbuffer); + GET_LINKED(FramebufferTexture2D); + + if (version >= GR_GL_VER(3,0)) { +#if USE_LINKED && GL_ES_VERSION_3_0 + GET_LINKED(RenderbufferStorageMultisample); + GET_LINKED(BlitFramebuffer); +#else + GET_PROC(RenderbufferStorageMultisample); + GET_PROC(BlitFramebuffer); +#endif + } + + if (extensions.has("GL_EXT_multisampled_render_to_texture")) { +#if USE_LINKED && GL_EXT_multisampled_render_to_texture + GET_LINKED_SUFFIX(FramebufferTexture2DMultisample, EXT); + functions->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorageMultisampleEXT; +#else + GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT); + functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT"); +#endif + } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { +#if USE_LINKED && GL_IMG_multisampled_render_to_texture + GET_LINKED_SUFFIX(FramebufferTexture2DMultisample, IMG); + functions->fRenderbufferStorageMultisampleES2EXT = glRenderbufferStorageMultisampleIMG; +#else + GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG); + functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG"); +#endif + } + + GET_LINKED(GenFramebuffers); + GET_LINKED(GenRenderbuffers); + GET_LINKED(GetFramebufferAttachmentParameteriv); + GET_LINKED(GetRenderbufferParameteriv); + GET_LINKED(RenderbufferStorage); + +#if USE_LINKED && GL_OES_mapbuffer + GET_LINKED_SUFFIX(MapBuffer, OES); + GET_LINKED_SUFFIX(UnmapBuffer, OES); +#else + GET_PROC_SUFFIX(MapBuffer, OES); + GET_PROC_SUFFIX(UnmapBuffer, OES); +#endif + + if (version >= GR_GL_VER(3,0)) { +#if USE_LINKED && GL_ES_VERSION_3_0 + GET_LINKED(MapBufferRange); + GET_LINKED(FlushMappedBufferRange); +#else + GET_PROC(MapBufferRange); + GET_PROC(FlushMappedBufferRange); +#endif + } else if (extensions.has("GL_EXT_map_buffer_range")) { +#if USE_LINKED && GL_EXT_map_buffer_range + GET_LINKED_SUFFIX(MapBufferRange, EXT); + GET_LINKED_SUFFIX(FlushMappedBufferRange, EXT); +#else + GET_PROC_SUFFIX(MapBufferRange, EXT); + GET_PROC_SUFFIX(FlushMappedBufferRange, EXT); +#endif + } + + 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"); + } + } + +#if USE_LINKED && GL_ES_VERSION_3_0 + GET_LINKED(InvalidateFramebuffer); + GET_LINKED(InvalidateSubFramebuffer); +#else + GET_PROC(InvalidateFramebuffer); + GET_PROC(InvalidateSubFramebuffer); +#endif + GET_PROC(InvalidateBufferData); + GET_PROC(InvalidateBufferSubData); + GET_PROC(InvalidateTexImage); + GET_PROC(InvalidateTexSubImage); + + interface->fStandard = kGLES_GrGLStandard; + interface->fExtensions.swap(&extensions); + + return interface; +} |