2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
|
2012-10-28 00:47:58 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-07-29 23:31:40 +03:00
|
|
|
#include "skia/include/gpu/GrContext.h"
|
|
|
|
#include "skia/include/gpu/gl/GrGLInterface.h"
|
2013-06-17 06:07:18 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-06-17 23:45:56 +04:00
|
|
|
#include "mozilla/ThreadLocal.h"
|
|
|
|
#include "mozilla/DebugOnly.h"
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
/* SkPostConfig.h includes windows.h, which includes windef.h
|
|
|
|
* which redefines min/max. We don't want that. */
|
|
|
|
#ifdef _WIN32
|
|
|
|
# undef min
|
|
|
|
# undef max
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
2014-03-06 01:49:37 +04:00
|
|
|
#include "SkiaGLGlue.h"
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
using mozilla::gl::GLContext;
|
2014-01-10 23:50:25 +04:00
|
|
|
using mozilla::gl::GLFeature;
|
2014-03-06 01:49:37 +04:00
|
|
|
using mozilla::gl::SkiaGLGlue;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
template <typename R, typename... A>
|
|
|
|
static inline GrGLFunction<R (*)(A...)> WrapGL(RefPtr<GLContext> aContext,
|
|
|
|
R (GLContext::*aFunc)(A...)) {
|
|
|
|
return [aContext, aFunc](A... args) -> R {
|
|
|
|
aContext->MakeCurrent();
|
|
|
|
return (aContext->*aFunc)(args...);
|
|
|
|
};
|
2014-03-19 03:37:56 +04:00
|
|
|
}
|
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
template <typename R, typename... A>
|
|
|
|
static inline GrGLFunction<R (*)(A...)> WrapGL(RefPtr<GLContext> aContext,
|
|
|
|
R (*aFunc)(GLContext*, A...)) {
|
|
|
|
return [aContext, aFunc](A... args) -> R {
|
|
|
|
aContext->MakeCurrent();
|
|
|
|
return (*aFunc)(aContext, args...);
|
|
|
|
};
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Core GL functions required by Ganesh
|
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
static const GLubyte* glGetString_mozilla(GLContext* aContext, GrGLenum aName) {
|
2012-10-28 00:47:58 +04:00
|
|
|
// GLContext only exposes a OpenGL 2.0 style API, so we have to intercept a
|
|
|
|
// bunch of checks that Ganesh makes to determine which capabilities are
|
|
|
|
// present on the GL implementation and change them to match what GLContext
|
|
|
|
// actually exposes.
|
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aName == LOCAL_GL_VERSION) {
|
|
|
|
if (aContext->IsGLES()) {
|
2012-10-28 00:47:58 +04:00
|
|
|
return reinterpret_cast<const GLubyte*>("OpenGL ES 2.0");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2017-02-09 15:39:27 +03:00
|
|
|
return reinterpret_cast<const GLubyte*>("2.0");
|
2016-04-29 05:55:27 +03:00
|
|
|
} else if (aName == LOCAL_GL_EXTENSIONS) {
|
2012-10-28 00:47:58 +04:00
|
|
|
// Only expose the bare minimum extensions we want to support to ensure a
|
|
|
|
// functional Ganesh as GLContext only exposes certain extensions
|
|
|
|
static bool extensionsStringBuilt = false;
|
2013-08-01 04:10:55 +04:00
|
|
|
static char extensionsString[1024];
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
if (!extensionsStringBuilt) {
|
2013-08-01 04:10:55 +04:00
|
|
|
extensionsString[0] = '\0';
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aContext->IsGLES()) {
|
2013-08-01 04:10:55 +04:00
|
|
|
// OES is only applicable to GLES2
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aContext->IsExtensionSupported(
|
|
|
|
GLContext::OES_packed_depth_stencil)) {
|
2013-08-01 04:10:55 +04:00
|
|
|
strcat(extensionsString, "GL_OES_packed_depth_stencil ");
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aContext->IsExtensionSupported(GLContext::OES_rgb8_rgba8)) {
|
2013-08-01 04:10:55 +04:00
|
|
|
strcat(extensionsString, "GL_OES_rgb8_rgba8 ");
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-03-12 14:33:36 +04:00
|
|
|
if (aContext->IsExtensionSupported(GLContext::OES_texture_npot)) {
|
|
|
|
strcat(extensionsString, "GL_OES_texture_npot ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aContext->IsExtensionSupported(
|
|
|
|
GLContext::OES_vertex_array_object)) {
|
2012-10-28 00:47:58 +04:00
|
|
|
strcat(extensionsString, "GL_OES_vertex_array_object ");
|
|
|
|
}
|
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aContext->IsSupported(GLFeature::standard_derivatives)) {
|
2013-08-01 04:10:55 +04:00
|
|
|
strcat(extensionsString, "GL_OES_standard_derivatives ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
} else {
|
2016-04-29 05:55:27 +03:00
|
|
|
if (aContext->IsSupported(GLFeature::framebuffer_object)) {
|
|
|
|
strcat(extensionsString, "GL_ARB_framebuffer_object ");
|
2012-10-28 00:47:58 +04:00
|
|
|
} else if (aContext->IsExtensionSupported(
|
2016-04-29 05:55:27 +03:00
|
|
|
GLContext::EXT_framebuffer_object)) {
|
2015-12-18 21:53:25 +03:00
|
|
|
strcat(extensionsString, "GL_EXT_framebuffer_object ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
if (aContext->IsSupported(GLFeature::texture_rg)) {
|
|
|
|
strcat(extensionsString, "GL_ARB_texture_rg ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
if (aContext->IsExtensionSupported(
|
|
|
|
GLContext::EXT_texture_format_BGRA8888)) {
|
|
|
|
strcat(extensionsString, "GL_EXT_texture_format_BGRA8888 ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
if (aContext->IsExtensionSupported(GLContext::EXT_packed_depth_stencil)) {
|
2016-11-15 12:00:08 +03:00
|
|
|
strcat(extensionsString, "GL_EXT_packed_depth_stencil ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2014-03-19 03:37:56 +04:00
|
|
|
if (aContext->IsExtensionSupported(GLContext::EXT_bgra)) {
|
|
|
|
strcat(extensionsString, "GL_EXT_bgra ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-03-19 03:37:56 +04:00
|
|
|
|
2014-03-31 13:10:49 +04:00
|
|
|
if (aContext->IsExtensionSupported(GLContext::EXT_read_format_bgra)) {
|
2014-03-19 03:37:56 +04:00
|
|
|
strcat(extensionsString, "GL_EXT_read_format_bgra ");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2014-03-19 03:37:56 +04:00
|
|
|
extensionsStringBuilt = true;
|
2013-08-01 04:10:55 +04:00
|
|
|
#ifdef DEBUG
|
2014-03-19 03:37:56 +04:00
|
|
|
printf_stderr("Exported SkiaGL extensions: %s\n", extensionsString);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-10-31 05:17:35 +03:00
|
|
|
return reinterpret_cast<const GLubyte*>(extensionsString);
|
2016-04-29 05:55:27 +03:00
|
|
|
|
|
|
|
} else if (aName == LOCAL_GL_SHADING_LANGUAGE_VERSION) {
|
|
|
|
if (aContext->IsGLES()) {
|
|
|
|
return reinterpret_cast<const GLubyte*>("OpenGL ES GLSL ES 1.0");
|
2014-03-19 03:37:56 +04:00
|
|
|
}
|
2017-02-09 15:39:27 +03:00
|
|
|
return reinterpret_cast<const GLubyte*>("1.10");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-03-19 03:37:56 +04:00
|
|
|
|
2016-04-29 05:55:27 +03:00
|
|
|
return aContext->fGetString(aName);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
2014-03-06 01:49:37 +04:00
|
|
|
|
2016-10-25 05:40:59 +03:00
|
|
|
static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context) {
|
2018-10-31 05:17:35 +03:00
|
|
|
auto* i = new GrGLInterface();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-31 05:17:35 +03:00
|
|
|
context->MakeCurrent();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-31 05:17:35 +03:00
|
|
|
// We support both desktop GL and GLES2
|
2016-04-29 05:55:27 +03:00
|
|
|
if (context->IsGLES()) {
|
2014-03-19 03:37:56 +04:00
|
|
|
i->fStandard = kGLES_GrGLStandard;
|
2018-11-30 13:46:48 +03:00
|
|
|
} else {
|
2014-03-19 03:37:56 +04:00
|
|
|
i->fStandard = kGL_GrGLStandard;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2018-10-31 05:17:35 +03:00
|
|
|
GrGLFunction<GrGLGetStringFn> getString =
|
|
|
|
WrapGL(context, &glGetString_mozilla);
|
|
|
|
GrGLFunction<GrGLGetIntegervFn> getIntegerv =
|
|
|
|
WrapGL(context, &GLContext::fGetIntegerv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-03-19 03:37:56 +04:00
|
|
|
GrGLExtensions extensions;
|
2016-04-29 05:55:27 +03:00
|
|
|
if (!extensions.init(i->fStandard, getString, nullptr, getIntegerv)) {
|
2014-07-10 00:40:40 +04:00
|
|
|
delete i;
|
2014-03-19 03:37:56 +04:00
|
|
|
return nullptr;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2014-03-19 03:37:56 +04:00
|
|
|
i->fExtensions.swap(&extensions);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// Core GL functions required by Ganesh
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fActiveTexture = WrapGL(context, &GLContext::fActiveTexture);
|
|
|
|
i->fFunctions.fAttachShader = WrapGL(context, &GLContext::fAttachShader);
|
|
|
|
i->fFunctions.fBindAttribLocation =
|
|
|
|
WrapGL(context, &GLContext::fBindAttribLocation);
|
|
|
|
i->fFunctions.fBindBuffer = WrapGL(context, &GLContext::fBindBuffer);
|
|
|
|
i->fFunctions.fBindFramebuffer =
|
|
|
|
WrapGL(context, &GLContext::fBindFramebuffer);
|
|
|
|
i->fFunctions.fBindRenderbuffer =
|
|
|
|
WrapGL(context, &GLContext::fBindRenderbuffer);
|
|
|
|
i->fFunctions.fBindTexture = WrapGL(context, &GLContext::fBindTexture);
|
|
|
|
i->fFunctions.fBlendFunc = WrapGL(context, &GLContext::fBlendFunc);
|
|
|
|
i->fFunctions.fBlendColor = WrapGL(context, &GLContext::fBlendColor);
|
|
|
|
i->fFunctions.fBlendEquation = WrapGL(context, &GLContext::fBlendEquation);
|
|
|
|
i->fFunctions.fBufferData = WrapGL(context, &GLContext::fBufferData);
|
|
|
|
i->fFunctions.fBufferSubData = WrapGL(context, &GLContext::fBufferSubData);
|
|
|
|
i->fFunctions.fCheckFramebufferStatus =
|
|
|
|
WrapGL(context, &GLContext::fCheckFramebufferStatus);
|
|
|
|
i->fFunctions.fClear = WrapGL(context, &GLContext::fClear);
|
|
|
|
i->fFunctions.fClearColor = WrapGL(context, &GLContext::fClearColor);
|
|
|
|
i->fFunctions.fClearStencil = WrapGL(context, &GLContext::fClearStencil);
|
|
|
|
i->fFunctions.fColorMask = WrapGL(context, &GLContext::fColorMask);
|
|
|
|
i->fFunctions.fCompileShader = WrapGL(context, &GLContext::fCompileShader);
|
2018-03-12 23:37:10 +03:00
|
|
|
i->fFunctions.fCompressedTexImage2D =
|
|
|
|
WrapGL(context, &GLContext::fCompressedTexImage2D);
|
|
|
|
i->fFunctions.fCompressedTexSubImage2D =
|
|
|
|
WrapGL(context, &GLContext::fCompressedTexSubImage2D);
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fCopyTexSubImage2D =
|
|
|
|
WrapGL(context, &GLContext::fCopyTexSubImage2D);
|
|
|
|
i->fFunctions.fCreateProgram = WrapGL(context, &GLContext::fCreateProgram);
|
|
|
|
i->fFunctions.fCreateShader = WrapGL(context, &GLContext::fCreateShader);
|
|
|
|
i->fFunctions.fCullFace = WrapGL(context, &GLContext::fCullFace);
|
|
|
|
i->fFunctions.fDeleteBuffers = WrapGL(context, &GLContext::fDeleteBuffers);
|
|
|
|
i->fFunctions.fDeleteFramebuffers =
|
|
|
|
WrapGL(context, &GLContext::fDeleteFramebuffers);
|
|
|
|
i->fFunctions.fDeleteProgram = WrapGL(context, &GLContext::fDeleteProgram);
|
|
|
|
i->fFunctions.fDeleteRenderbuffers =
|
|
|
|
WrapGL(context, &GLContext::fDeleteRenderbuffers);
|
|
|
|
i->fFunctions.fDeleteShader = WrapGL(context, &GLContext::fDeleteShader);
|
|
|
|
i->fFunctions.fDeleteTextures = WrapGL(context, &GLContext::fDeleteTextures);
|
|
|
|
i->fFunctions.fDepthMask = WrapGL(context, &GLContext::fDepthMask);
|
|
|
|
i->fFunctions.fDisable = WrapGL(context, &GLContext::fDisable);
|
|
|
|
i->fFunctions.fDisableVertexAttribArray =
|
|
|
|
WrapGL(context, &GLContext::fDisableVertexAttribArray);
|
|
|
|
i->fFunctions.fDrawArrays = WrapGL(context, &GLContext::fDrawArrays);
|
|
|
|
i->fFunctions.fDrawElements = WrapGL(context, &GLContext::fDrawElements);
|
2016-10-25 05:40:59 +03:00
|
|
|
i->fFunctions.fDrawRangeElements =
|
|
|
|
WrapGL(context, &GLContext::fDrawRangeElements);
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fEnable = WrapGL(context, &GLContext::fEnable);
|
|
|
|
i->fFunctions.fEnableVertexAttribArray =
|
|
|
|
WrapGL(context, &GLContext::fEnableVertexAttribArray);
|
|
|
|
i->fFunctions.fFinish = WrapGL(context, &GLContext::fFinish);
|
|
|
|
i->fFunctions.fFlush = WrapGL(context, &GLContext::fFlush);
|
|
|
|
i->fFunctions.fFramebufferRenderbuffer =
|
|
|
|
WrapGL(context, &GLContext::fFramebufferRenderbuffer);
|
|
|
|
i->fFunctions.fFramebufferTexture2D =
|
|
|
|
WrapGL(context, &GLContext::fFramebufferTexture2D);
|
|
|
|
i->fFunctions.fFrontFace = WrapGL(context, &GLContext::fFrontFace);
|
|
|
|
i->fFunctions.fGenBuffers = WrapGL(context, &GLContext::fGenBuffers);
|
|
|
|
i->fFunctions.fGenFramebuffers =
|
|
|
|
WrapGL(context, &GLContext::fGenFramebuffers);
|
|
|
|
i->fFunctions.fGenRenderbuffers =
|
|
|
|
WrapGL(context, &GLContext::fGenRenderbuffers);
|
|
|
|
i->fFunctions.fGetFramebufferAttachmentParameteriv =
|
|
|
|
WrapGL(context, &GLContext::fGetFramebufferAttachmentParameteriv);
|
|
|
|
i->fFunctions.fGenTextures = WrapGL(context, &GLContext::fGenTextures);
|
|
|
|
i->fFunctions.fGenerateMipmap = WrapGL(context, &GLContext::fGenerateMipmap);
|
|
|
|
i->fFunctions.fGetBufferParameteriv =
|
|
|
|
WrapGL(context, &GLContext::fGetBufferParameteriv);
|
|
|
|
i->fFunctions.fGetError = WrapGL(context, &GLContext::fGetError);
|
|
|
|
i->fFunctions.fGetIntegerv = getIntegerv;
|
|
|
|
i->fFunctions.fGetProgramInfoLog =
|
|
|
|
WrapGL(context, &GLContext::fGetProgramInfoLog);
|
|
|
|
i->fFunctions.fGetProgramiv = WrapGL(context, &GLContext::fGetProgramiv);
|
|
|
|
i->fFunctions.fGetRenderbufferParameteriv =
|
|
|
|
WrapGL(context, &GLContext::fGetRenderbufferParameteriv);
|
|
|
|
i->fFunctions.fGetShaderInfoLog =
|
|
|
|
WrapGL(context, &GLContext::fGetShaderInfoLog);
|
|
|
|
i->fFunctions.fGetShaderiv = WrapGL(context, &GLContext::fGetShaderiv);
|
|
|
|
i->fFunctions.fGetShaderPrecisionFormat =
|
|
|
|
WrapGL(context, &GLContext::fGetShaderPrecisionFormat);
|
|
|
|
i->fFunctions.fGetString = getString;
|
|
|
|
i->fFunctions.fGetUniformLocation =
|
|
|
|
WrapGL(context, &GLContext::fGetUniformLocation);
|
2018-03-12 23:37:10 +03:00
|
|
|
i->fFunctions.fIsTexture = WrapGL(context, &GLContext::fIsTexture);
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fLineWidth = WrapGL(context, &GLContext::fLineWidth);
|
|
|
|
i->fFunctions.fLinkProgram = WrapGL(context, &GLContext::fLinkProgram);
|
|
|
|
i->fFunctions.fPixelStorei = WrapGL(context, &GLContext::fPixelStorei);
|
2017-05-10 05:31:07 +03:00
|
|
|
i->fFunctions.fPolygonMode = WrapGL(context, &GLContext::fPolygonMode);
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fReadPixels = WrapGL(context, &GLContext::fReadPixels);
|
|
|
|
i->fFunctions.fRenderbufferStorage =
|
|
|
|
WrapGL(context, &GLContext::fRenderbufferStorage);
|
|
|
|
i->fFunctions.fScissor = WrapGL(context, &GLContext::fScissor);
|
2018-10-31 05:17:35 +03:00
|
|
|
i->fFunctions.fShaderSource = WrapGL(context, &GLContext::fShaderSource);
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fStencilFunc = WrapGL(context, &GLContext::fStencilFunc);
|
|
|
|
i->fFunctions.fStencilFuncSeparate =
|
|
|
|
WrapGL(context, &GLContext::fStencilFuncSeparate);
|
|
|
|
i->fFunctions.fStencilMask = WrapGL(context, &GLContext::fStencilMask);
|
|
|
|
i->fFunctions.fStencilMaskSeparate =
|
|
|
|
WrapGL(context, &GLContext::fStencilMaskSeparate);
|
|
|
|
i->fFunctions.fStencilOp = WrapGL(context, &GLContext::fStencilOp);
|
|
|
|
i->fFunctions.fStencilOpSeparate =
|
|
|
|
WrapGL(context, &GLContext::fStencilOpSeparate);
|
|
|
|
i->fFunctions.fTexImage2D = WrapGL(context, &GLContext::fTexImage2D);
|
|
|
|
i->fFunctions.fTexParameteri = WrapGL(context, &GLContext::fTexParameteri);
|
|
|
|
i->fFunctions.fTexParameteriv = WrapGL(context, &GLContext::fTexParameteriv);
|
|
|
|
i->fFunctions.fTexSubImage2D = WrapGL(context, &GLContext::fTexSubImage2D);
|
|
|
|
i->fFunctions.fUniform1f = WrapGL(context, &GLContext::fUniform1f);
|
|
|
|
i->fFunctions.fUniform1i = WrapGL(context, &GLContext::fUniform1i);
|
|
|
|
i->fFunctions.fUniform1fv = WrapGL(context, &GLContext::fUniform1fv);
|
|
|
|
i->fFunctions.fUniform1iv = WrapGL(context, &GLContext::fUniform1iv);
|
|
|
|
i->fFunctions.fUniform2f = WrapGL(context, &GLContext::fUniform2f);
|
|
|
|
i->fFunctions.fUniform2i = WrapGL(context, &GLContext::fUniform2i);
|
|
|
|
i->fFunctions.fUniform2fv = WrapGL(context, &GLContext::fUniform2fv);
|
|
|
|
i->fFunctions.fUniform2iv = WrapGL(context, &GLContext::fUniform2iv);
|
|
|
|
i->fFunctions.fUniform3f = WrapGL(context, &GLContext::fUniform3f);
|
|
|
|
i->fFunctions.fUniform3i = WrapGL(context, &GLContext::fUniform3i);
|
|
|
|
i->fFunctions.fUniform3fv = WrapGL(context, &GLContext::fUniform3fv);
|
|
|
|
i->fFunctions.fUniform3iv = WrapGL(context, &GLContext::fUniform3iv);
|
|
|
|
i->fFunctions.fUniform4f = WrapGL(context, &GLContext::fUniform4f);
|
|
|
|
i->fFunctions.fUniform4i = WrapGL(context, &GLContext::fUniform4i);
|
|
|
|
i->fFunctions.fUniform4fv = WrapGL(context, &GLContext::fUniform4fv);
|
|
|
|
i->fFunctions.fUniform4iv = WrapGL(context, &GLContext::fUniform4iv);
|
|
|
|
i->fFunctions.fUniformMatrix2fv =
|
|
|
|
WrapGL(context, &GLContext::fUniformMatrix2fv);
|
|
|
|
i->fFunctions.fUniformMatrix3fv =
|
|
|
|
WrapGL(context, &GLContext::fUniformMatrix3fv);
|
|
|
|
i->fFunctions.fUniformMatrix4fv =
|
|
|
|
WrapGL(context, &GLContext::fUniformMatrix4fv);
|
|
|
|
i->fFunctions.fUseProgram = WrapGL(context, &GLContext::fUseProgram);
|
|
|
|
i->fFunctions.fVertexAttrib1f = WrapGL(context, &GLContext::fVertexAttrib1f);
|
|
|
|
i->fFunctions.fVertexAttrib2fv =
|
|
|
|
WrapGL(context, &GLContext::fVertexAttrib2fv);
|
|
|
|
i->fFunctions.fVertexAttrib3fv =
|
|
|
|
WrapGL(context, &GLContext::fVertexAttrib3fv);
|
|
|
|
i->fFunctions.fVertexAttrib4fv =
|
|
|
|
WrapGL(context, &GLContext::fVertexAttrib4fv);
|
|
|
|
i->fFunctions.fVertexAttribPointer =
|
|
|
|
WrapGL(context, &GLContext::fVertexAttribPointer);
|
|
|
|
i->fFunctions.fViewport = WrapGL(context, &GLContext::fViewport);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// Required for either desktop OpenGL 2.0 or OpenGL ES 2.0
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fStencilFuncSeparate =
|
|
|
|
WrapGL(context, &GLContext::fStencilFuncSeparate);
|
|
|
|
i->fFunctions.fStencilMaskSeparate =
|
|
|
|
WrapGL(context, &GLContext::fStencilMaskSeparate);
|
|
|
|
i->fFunctions.fStencilOpSeparate =
|
|
|
|
WrapGL(context, &GLContext::fStencilOpSeparate);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// GLContext supports glMapBuffer
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fMapBuffer = WrapGL(context, &GLContext::fMapBuffer);
|
|
|
|
i->fFunctions.fUnmapBuffer = WrapGL(context, &GLContext::fUnmapBuffer);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// GLContext supports glRenderbufferStorageMultisample/glBlitFramebuffer
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fRenderbufferStorageMultisample =
|
|
|
|
WrapGL(context, &GLContext::fRenderbufferStorageMultisample);
|
|
|
|
i->fFunctions.fBlitFramebuffer =
|
|
|
|
WrapGL(context, &GLContext::fBlitFramebuffer);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// GLContext supports glCompressedTexImage2D
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fCompressedTexImage2D =
|
|
|
|
WrapGL(context, &GLContext::fCompressedTexImage2D);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-08-01 04:10:55 +04:00
|
|
|
// GL_OES_vertex_array_object
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fBindVertexArray =
|
|
|
|
WrapGL(context, &GLContext::fBindVertexArray);
|
|
|
|
i->fFunctions.fDeleteVertexArrays =
|
|
|
|
WrapGL(context, &GLContext::fDeleteVertexArrays);
|
|
|
|
i->fFunctions.fGenVertexArrays =
|
|
|
|
WrapGL(context, &GLContext::fGenVertexArrays);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-08-08 05:27:14 +03:00
|
|
|
// Desktop GL
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fGetTexLevelParameteriv =
|
|
|
|
WrapGL(context, &GLContext::fGetTexLevelParameteriv);
|
|
|
|
i->fFunctions.fDrawBuffer = WrapGL(context, &GLContext::fDrawBuffer);
|
|
|
|
i->fFunctions.fReadBuffer = WrapGL(context, &GLContext::fReadBuffer);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// Desktop OpenGL > 1.5
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fGenQueries = WrapGL(context, &GLContext::fGenQueries);
|
|
|
|
i->fFunctions.fDeleteQueries = WrapGL(context, &GLContext::fDeleteQueries);
|
|
|
|
i->fFunctions.fBeginQuery = WrapGL(context, &GLContext::fBeginQuery);
|
|
|
|
i->fFunctions.fEndQuery = WrapGL(context, &GLContext::fEndQuery);
|
|
|
|
i->fFunctions.fGetQueryiv = WrapGL(context, &GLContext::fGetQueryiv);
|
|
|
|
i->fFunctions.fGetQueryObjectiv =
|
|
|
|
WrapGL(context, &GLContext::fGetQueryObjectiv);
|
|
|
|
i->fFunctions.fGetQueryObjectuiv =
|
|
|
|
WrapGL(context, &GLContext::fGetQueryObjectuiv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// Desktop OpenGL > 2.0
|
2016-04-29 05:55:27 +03:00
|
|
|
i->fFunctions.fDrawBuffers = WrapGL(context, &GLContext::fDrawBuffers);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-06-17 06:07:18 +04:00
|
|
|
return i;
|
2014-03-06 01:49:37 +04:00
|
|
|
}
|
2015-08-08 05:27:14 +03:00
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
SkiaGLGlue::SkiaGLGlue(GLContext* context) : mGLContext(context) {
|
2018-10-31 05:17:35 +03:00
|
|
|
mGrGLInterface.reset(CreateGrGLInterfaceFromGLContext(mGLContext));
|
|
|
|
mGrContext = GrContext::MakeGL(mGrGLInterface);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2015-08-08 05:27:14 +03:00
|
|
|
SkiaGLGlue::~SkiaGLGlue() {
|
|
|
|
/*
|
|
|
|
* These members have inter-dependencies, but do not keep each other alive, so
|
|
|
|
* destruction order is very important here: mGrContext uses mGrGLInterface,
|
|
|
|
* and through it, uses mGLContext
|
|
|
|
*/
|
|
|
|
mGrContext = nullptr;
|
2016-04-29 05:55:27 +03:00
|
|
|
if (mGrGLInterface) {
|
|
|
|
// Ensure that no references to the GLContext remain, even if the GrContext
|
|
|
|
// still lives.
|
|
|
|
mGrGLInterface->fFunctions = GrGLInterface::Functions();
|
|
|
|
mGrGLInterface = nullptr;
|
|
|
|
}
|
2015-08-08 05:27:14 +03:00
|
|
|
mGLContext = nullptr;
|
|
|
|
}
|