diff options
Diffstat (limited to '')
-rw-r--r-- | src/deps/skia/include/gpu/gl/BUILD.bazel | 70 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLAssembleHelpers.h | 11 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLAssembleInterface.h | 39 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLConfig.h | 79 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLConfig_chrome.h | 14 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLExtensions.h | 78 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLFunctions.h | 304 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLInterface.h | 342 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/GrGLTypes.h | 207 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/egl/BUILD.bazel | 11 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/egl/GrGLMakeEGLInterface.h | 14 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/glx/BUILD.bazel | 11 | ||||
-rw-r--r-- | src/deps/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h | 14 |
13 files changed, 1194 insertions, 0 deletions
diff --git a/src/deps/skia/include/gpu/gl/BUILD.bazel b/src/deps/skia/include/gpu/gl/BUILD.bazel new file mode 100644 index 000000000..c2dcf89d8 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/BUILD.bazel @@ -0,0 +1,70 @@ +load("//bazel:macros.bzl", "generated_cc_atom") + +generated_cc_atom( + name = "GrGLAssembleHelpers_hdr", + hdrs = ["GrGLAssembleHelpers.h"], + visibility = ["//:__subpackages__"], + deps = [":GrGLAssembleInterface_hdr"], +) + +generated_cc_atom( + name = "GrGLAssembleInterface_hdr", + hdrs = ["GrGLAssembleInterface.h"], + visibility = ["//:__subpackages__"], + deps = [":GrGLInterface_hdr"], +) + +generated_cc_atom( + name = "GrGLConfig_chrome_hdr", + hdrs = ["GrGLConfig_chrome.h"], + visibility = ["//:__subpackages__"], +) + +generated_cc_atom( + name = "GrGLConfig_hdr", + hdrs = ["GrGLConfig.h"], + visibility = ["//:__subpackages__"], + deps = ["//include/gpu:GrTypes_hdr"], +) + +generated_cc_atom( + name = "GrGLExtensions_hdr", + hdrs = ["GrGLExtensions.h"], + visibility = ["//:__subpackages__"], + deps = [ + ":GrGLFunctions_hdr", + "//include/core:SkString_hdr", + "//include/private:SkTArray_hdr", + ], +) + +generated_cc_atom( + name = "GrGLFunctions_hdr", + hdrs = ["GrGLFunctions.h"], + visibility = ["//:__subpackages__"], + deps = [ + ":GrGLTypes_hdr", + "//include/private:SkTLogic_hdr", + ], +) + +generated_cc_atom( + name = "GrGLInterface_hdr", + hdrs = ["GrGLInterface.h"], + visibility = ["//:__subpackages__"], + deps = [ + ":GrGLExtensions_hdr", + ":GrGLFunctions_hdr", + "//include/core:SkRefCnt_hdr", + ], +) + +generated_cc_atom( + name = "GrGLTypes_hdr", + hdrs = ["GrGLTypes.h"], + visibility = ["//:__subpackages__"], + deps = [ + ":GrGLConfig_hdr", + "//include/core:SkRefCnt_hdr", + ], +) diff --git a/src/deps/skia/include/gpu/gl/GrGLAssembleHelpers.h b/src/deps/skia/include/gpu/gl/GrGLAssembleHelpers.h new file mode 100644 index 000000000..bfa2aea37 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLAssembleHelpers.h @@ -0,0 +1,11 @@ +/* + * Copyright 2019 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/gpu/gl/GrGLAssembleInterface.h" + +void GrGetEGLQueryAndDisplay(GrEGLQueryStringFn** queryString, GrEGLDisplay* display, + void* ctx, GrGLGetProc get); diff --git a/src/deps/skia/include/gpu/gl/GrGLAssembleInterface.h b/src/deps/skia/include/gpu/gl/GrGLAssembleInterface.h new file mode 100644 index 000000000..4f9f9f9ee --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLAssembleInterface.h @@ -0,0 +1,39 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/gpu/gl/GrGLInterface.h" + +typedef GrGLFuncPtr (*GrGLGetProc)(void* ctx, const char name[]); + +/** + * Generic function for creating a GrGLInterface for an either OpenGL or GLES. It calls + * get() to get each function address. ctx is a generic ptr passed to and interpreted by get(). + */ +SK_API sk_sp<const GrGLInterface> GrGLMakeAssembledInterface(void *ctx, GrGLGetProc get); + +/** + * Generic function for creating a GrGLInterface for an OpenGL (but not GLES) context. It calls + * get() to get each function address. ctx is a generic ptr passed to and interpreted by get(). + */ +SK_API sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get); + +/** + * Generic function for creating a GrGLInterface for an OpenGL ES (but not Open GL) context. It + * calls get() to get each function address. ctx is a generic ptr passed to and interpreted by + * get(). + */ +SK_API sk_sp<const GrGLInterface> GrGLMakeAssembledGLESInterface(void *ctx, GrGLGetProc get); + +/** + * Generic function for creating a GrGLInterface for a WebGL (similar to OpenGL ES) context. It + * calls get() to get each function address. ctx is a generic ptr passed to and interpreted by + * get(). + */ +SK_API sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get); + +/** Deprecated version of GrGLMakeAssembledInterface() that returns a bare pointer. */ +SK_API const GrGLInterface* GrGLAssembleInterface(void *ctx, GrGLGetProc get); diff --git a/src/deps/skia/include/gpu/gl/GrGLConfig.h b/src/deps/skia/include/gpu/gl/GrGLConfig.h new file mode 100644 index 000000000..e3573486c --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLConfig.h @@ -0,0 +1,79 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + + +#ifndef GrGLConfig_DEFINED +#define GrGLConfig_DEFINED + +#include "include/gpu/GrTypes.h" + +/** + * Optional GL config file. + */ +#ifdef GR_GL_CUSTOM_SETUP_HEADER + #include GR_GL_CUSTOM_SETUP_HEADER +#endif + +#if !defined(GR_GL_FUNCTION_TYPE) + #if defined(SK_BUILD_FOR_WIN) + #define GR_GL_FUNCTION_TYPE __stdcall + #else + #define GR_GL_FUNCTION_TYPE + #endif +#endif + +/** + * The following are optional defines that can be enabled at the compiler + * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom + * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can + * also be placed there. + * + * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using SkDebugf. Defaults to + * 0. Logging can be enabled and disabled at runtime using a debugger via to + * global gLogCallsGL. The initial value of gLogCallsGL is controlled by + * GR_GL_LOG_CALLS_START. + * + * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when + * GR_GL_LOG_CALLS is 1. Defaults to 0. + * + * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call. + * Defaults to 1 if SK_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1 + * this can be toggled in a debugger using the gCheckErrorGL global. The initial + * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START. + * + * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL + * when GR_GL_CHECK_ERROR is 1. Defaults to 1. + * + */ + +#if !defined(GR_GL_LOG_CALLS) + #ifdef SK_DEBUG + #define GR_GL_LOG_CALLS 1 + #else + #define GR_GL_LOG_CALLS 0 + #endif +#endif + +#if !defined(GR_GL_LOG_CALLS_START) + #define GR_GL_LOG_CALLS_START 0 +#endif + +#if !defined(GR_GL_CHECK_ERROR) + #ifdef SK_DEBUG + #define GR_GL_CHECK_ERROR 1 + #else + #define GR_GL_CHECK_ERROR 0 + #endif +#endif + +#if !defined(GR_GL_CHECK_ERROR_START) + #define GR_GL_CHECK_ERROR_START 1 +#endif + +#endif diff --git a/src/deps/skia/include/gpu/gl/GrGLConfig_chrome.h b/src/deps/skia/include/gpu/gl/GrGLConfig_chrome.h new file mode 100644 index 000000000..40127d170 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLConfig_chrome.h @@ -0,0 +1,14 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef GrGLConfig_chrome_DEFINED +#define GrGLConfig_chrome_DEFINED + +// glGetError() forces a sync with gpu process on chrome +#define GR_GL_CHECK_ERROR_START 0 + +#endif diff --git a/src/deps/skia/include/gpu/gl/GrGLExtensions.h b/src/deps/skia/include/gpu/gl/GrGLExtensions.h new file mode 100644 index 000000000..1e2823f71 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLExtensions.h @@ -0,0 +1,78 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGLExtensions_DEFINED +#define GrGLExtensions_DEFINED + +#include "include/core/SkString.h" +#include "include/gpu/gl/GrGLFunctions.h" +#include "include/private/SkTArray.h" + +#include <utility> + +struct GrGLInterface; +class SkJSONWriter; + +/** + * This helper queries the current GL context for its extensions, remembers them, and can be + * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will + * use the latter if it is available. It also will query for EGL extensions if a eglQueryString + * implementation is provided. + */ +class SK_API GrGLExtensions { +public: + GrGLExtensions() {} + + GrGLExtensions(const GrGLExtensions&); + + GrGLExtensions& operator=(const GrGLExtensions&); + + void swap(GrGLExtensions* that) { + using std::swap; + swap(fStrings, that->fStrings); + swap(fInitialized, that->fInitialized); + } + + /** + * We sometimes need to use this class without having yet created a GrGLInterface. This version + * of init expects that getString is always non-NULL while getIntegerv and getStringi are non- + * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. + */ + bool init(GrGLStandard standard, + GrGLFunction<GrGLGetStringFn> getString, + GrGLFunction<GrGLGetStringiFn> getStringi, + GrGLFunction<GrGLGetIntegervFn> getIntegerv, + GrGLFunction<GrEGLQueryStringFn> queryString = nullptr, + GrEGLDisplay eglDisplay = nullptr); + + bool isInitialized() const { return fInitialized; } + + /** + * Queries whether an extension is present. This will fail if init() has not been called. + */ + bool has(const char[]) const; + + /** + * Removes an extension if present. Returns true if the extension was present before the call. + */ + bool remove(const char[]); + + /** + * Adds an extension to list + */ + void add(const char[]); + + void reset() { fStrings.reset(); } + + void dumpJSON(SkJSONWriter*) const; + +private: + bool fInitialized = false; + SkTArray<SkString> fStrings; +}; + +#endif diff --git a/src/deps/skia/include/gpu/gl/GrGLFunctions.h b/src/deps/skia/include/gpu/gl/GrGLFunctions.h new file mode 100644 index 000000000..aef61e065 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLFunctions.h @@ -0,0 +1,304 @@ + +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGLFunctions_DEFINED +#define GrGLFunctions_DEFINED + +#include <cstring> +#include "include/gpu/gl/GrGLTypes.h" +#include "include/private/SkTLogic.h" + + +extern "C" { + +/////////////////////////////////////////////////////////////////////////////// + +using GrGLActiveTextureFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum texture); +using GrGLAttachShaderFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLuint shader); +using GrGLBeginQueryFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLuint id); +using GrGLBindAttribLocationFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLuint index, const char* name); +using GrGLBindBufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLuint buffer); +using GrGLBindFramebufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLuint framebuffer); +using GrGLBindRenderbufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLuint renderbuffer); +using GrGLBindTextureFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLuint texture); +using GrGLBindFragDataLocationFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name); +using GrGLBindFragDataLocationIndexedFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar* name); +using GrGLBindSamplerFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint unit, GrGLuint sampler); +using GrGLBindVertexArrayFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint array); +using GrGLBlendBarrierFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLBlendColorFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); +using GrGLBlendEquationFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode); +using GrGLBlendFuncFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum sfactor, GrGLenum dfactor); +using GrGLBlitFramebufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter); +using GrGLBufferDataFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage); +using GrGLBufferSubDataFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data); +using GrGLCheckFramebufferStatusFn = GrGLenum GR_GL_FUNCTION_TYPE(GrGLenum target); +using GrGLClearFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLbitfield mask); +using GrGLClearColorFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); +using GrGLClearStencilFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint s); +using GrGLClearTexImageFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint texture, GrGLint level, GrGLenum format, GrGLenum type, const GrGLvoid* data); +using GrGLClearTexSubImageFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint texture, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint zoffset, GrGLsizei width, GrGLsizei height, GrGLsizei depth, GrGLenum format, GrGLenum type, const GrGLvoid* data); +using GrGLColorMaskFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha); +using GrGLCompileShaderFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint shader); +using GrGLCompressedTexImage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data); +using GrGLCompressedTexSubImage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLsizei imageSize, const GrGLvoid* data); +using GrGLCopyTexSubImage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); +using GrGLCreateProgramFn = GrGLuint GR_GL_FUNCTION_TYPE(); +using GrGLCreateShaderFn = GrGLuint GR_GL_FUNCTION_TYPE(GrGLenum type); +using GrGLCullFaceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode); +using GrGLDeleteBuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* buffers); +using GrGLDeleteFencesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* fences); +using GrGLDeleteFramebuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* framebuffers); +using GrGLDeleteProgramFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program); +using GrGLDeleteQueriesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* ids); +using GrGLDeleteRenderbuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* renderbuffers); +using GrGLDeleteSamplersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei count, const GrGLuint* samplers); +using GrGLDeleteShaderFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint shader); +using GrGLDeleteTexturesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* textures); +using GrGLDeleteVertexArraysFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLuint* arrays); +using GrGLDepthMaskFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLboolean flag); +using GrGLDisableFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum cap); +using GrGLDisableVertexAttribArrayFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint index); +using GrGLDrawArraysFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLint first, GrGLsizei count); +using GrGLDrawArraysInstancedFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLint first, GrGLsizei count, GrGLsizei primcount); +using GrGLDrawArraysIndirectFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, const GrGLvoid* indirect); +using GrGLDrawBufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode); +using GrGLDrawBuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, const GrGLenum* bufs); +using GrGLDrawElementsFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); +using GrGLDrawElementsInstancedFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices, GrGLsizei primcount); +using GrGLDrawElementsIndirectFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLenum type, const GrGLvoid* indirect); +using GrGLDrawRangeElementsFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLuint start, GrGLuint end, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); +using GrGLEnableFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum cap); +using GrGLEnableVertexAttribArrayFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint index); +using GrGLEndQueryFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target); +using GrGLFinishFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLFinishFenceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint fence); +using GrGLFlushFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLFlushMappedBufferRangeFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLintptr offset, GrGLsizeiptr length); +using GrGLFramebufferRenderbufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer); +using GrGLFramebufferTexture2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level); +using GrGLFramebufferTexture2DMultisampleFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level, GrGLsizei samples); +using GrGLFrontFaceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode); +using GrGLGenBuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* buffers); +using GrGLGenFencesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* fences); +using GrGLGenFramebuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* framebuffers); +using GrGLGenerateMipmapFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target); +using GrGLGenQueriesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* ids); +using GrGLGenRenderbuffersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* renderbuffers); +using GrGLGenSamplersFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei count, GrGLuint* samplers); +using GrGLGenTexturesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* textures); +using GrGLGenVertexArraysFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei n, GrGLuint* arrays); +using GrGLGetBufferParameterivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum pname, GrGLint* params); +using GrGLGetErrorFn = GrGLenum GR_GL_FUNCTION_TYPE(); +using GrGLGetFramebufferAttachmentParameterivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params); +using GrGLGetIntegervFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum pname, GrGLint* params); +using GrGLGetMultisamplefvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum pname, GrGLuint index, GrGLfloat* val); +using GrGLGetProgramBinaryFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, GrGLenum* binaryFormat, void* binary); +using GrGLGetProgramInfoLogFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog); +using GrGLGetProgramivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLenum pname, GrGLint* params); +using GrGLGetQueryivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum GLtarget, GrGLenum pname, GrGLint* params); +using GrGLGetQueryObjecti64vFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint id, GrGLenum pname, GrGLint64* params); +using GrGLGetQueryObjectivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint id, GrGLenum pname, GrGLint* params); +using GrGLGetQueryObjectui64vFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint id, GrGLenum pname, GrGLuint64* params); +using GrGLGetQueryObjectuivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint id, GrGLenum pname, GrGLuint* params); +using GrGLGetRenderbufferParameterivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum pname, GrGLint* params); +using GrGLGetShaderInfoLogFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog); +using GrGLGetShaderivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint shader, GrGLenum pname, GrGLint* params); +using GrGLGetShaderPrecisionFormatFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum shadertype, GrGLenum precisiontype, GrGLint* range, GrGLint* precision); +using GrGLGetStringFn = const GrGLubyte* GR_GL_FUNCTION_TYPE(GrGLenum name); +using GrGLGetStringiFn = const GrGLubyte* GR_GL_FUNCTION_TYPE(GrGLenum name, GrGLuint index); +using GrGLGetTexLevelParameterivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params); +using GrGLGetUniformLocationFn = GrGLint GR_GL_FUNCTION_TYPE(GrGLuint program, const char* name); +using GrGLInsertEventMarkerFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei length, const char* marker); +using GrGLInvalidateBufferDataFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint buffer); +using GrGLInvalidateBufferSubDataFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length); +using GrGLInvalidateFramebufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLsizei numAttachments, const GrGLenum* attachments); +using GrGLInvalidateSubFramebufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLsizei numAttachments, const GrGLenum* attachments, GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); +using GrGLInvalidateTexImageFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint texture, GrGLint level); +using GrGLInvalidateTexSubImageFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint texture, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLint zoffset, GrGLsizei width, GrGLsizei height, GrGLsizei depth); +using GrGLIsTextureFn = GrGLboolean GR_GL_FUNCTION_TYPE(GrGLuint texture); +using GrGLLineWidthFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLfloat width); +using GrGLLinkProgramFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program); +using GrGLMapBufferFn = GrGLvoid* GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum access); +using GrGLMapBufferRangeFn = GrGLvoid* GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLintptr offset, GrGLsizeiptr length, GrGLbitfield access); +using GrGLMapBufferSubDataFn = GrGLvoid* GR_GL_FUNCTION_TYPE(GrGLuint target, GrGLintptr offset, GrGLsizeiptr size, GrGLenum access); +using GrGLMapTexSubImage2DFn = GrGLvoid* GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLenum access); +using GrGLMemoryBarrierFn = GrGLvoid* GR_GL_FUNCTION_TYPE(GrGLbitfield barriers); +using GrGLPatchParameteriFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum pname, GrGLint value); +using GrGLPixelStoreiFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum pname, GrGLint param); +using GrGLPolygonModeFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum face, GrGLenum mode); +using GrGLPopGroupMarkerFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLProgramBinaryFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLenum binaryFormat, void* binary, GrGLsizei length); +using GrGLProgramParameteriFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLenum pname, GrGLint value); +using GrGLPushGroupMarkerFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsizei length, const char* marker); +using GrGLQueryCounterFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint id, GrGLenum target); +using GrGLReadBufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum src); +using GrGLReadPixelsFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels); +using GrGLRenderbufferStorageFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); +using GrGLRenderbufferStorageMultisampleFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); +using GrGLResolveMultisampleFramebufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLSamplerParameteriFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint sampler, GrGLenum pname, GrGLint params); +using GrGLSamplerParameterivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint sampler, GrGLenum pname, const GrGLint* params); +using GrGLScissorFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); +// GL_CHROMIUM_bind_uniform_location +using GrGLBindUniformLocationFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program, GrGLint location, const char* name); +using GrGLSetFenceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint fence, GrGLenum condition); +using GrGLShaderSourceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint shader, GrGLsizei count, const char* const* str, const GrGLint* length); +using GrGLStencilFuncFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum func, GrGLint ref, GrGLuint mask); +using GrGLStencilFuncSeparateFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask); +using GrGLStencilMaskFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint mask); +using GrGLStencilMaskSeparateFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum face, GrGLuint mask); +using GrGLStencilOpFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum fail, GrGLenum zfail, GrGLenum zpass); +using GrGLStencilOpSeparateFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass); +using GrGLTexBufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum internalformat, GrGLuint buffer); +using GrGLTexBufferRangeFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum internalformat, GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr size); +using GrGLTexImage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels); +using GrGLTexParameterfFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum pname, GrGLfloat param); +using GrGLTexParameterfvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum pname, const GrGLfloat* params); +using GrGLTexParameteriFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum pname, GrGLint param); +using GrGLTexParameterivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum pname, const GrGLint* params); +using GrGLTexStorage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLsizei levels, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); +using GrGLDiscardFramebufferFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLsizei numAttachments, const GrGLenum* attachments); +using GrGLTestFenceFn = GrGLboolean GR_GL_FUNCTION_TYPE(GrGLuint fence); +using GrGLTexSubImage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, const GrGLvoid* pixels); +using GrGLTextureBarrierFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLUniform1fFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLfloat v0); +using GrGLUniform1iFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLint v0); +using GrGLUniform1fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLfloat* v); +using GrGLUniform1ivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLint* v); +using GrGLUniform2fFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLfloat v0, GrGLfloat v1); +using GrGLUniform2iFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLint v0, GrGLint v1); +using GrGLUniform2fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLfloat* v); +using GrGLUniform2ivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLint* v); +using GrGLUniform3fFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2); +using GrGLUniform3iFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2); +using GrGLUniform3fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLfloat* v); +using GrGLUniform3ivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLint* v); +using GrGLUniform4fFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3); +using GrGLUniform4iFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3); +using GrGLUniform4fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLfloat* v); +using GrGLUniform4ivFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, const GrGLint* v); +using GrGLUniformMatrix2fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); +using GrGLUniformMatrix3fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); +using GrGLUniformMatrix4fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); +using GrGLUnmapBufferFn = GrGLboolean GR_GL_FUNCTION_TYPE(GrGLenum target); +using GrGLUnmapBufferSubDataFn = GrGLvoid GR_GL_FUNCTION_TYPE(const GrGLvoid* mem); +using GrGLUnmapTexSubImage2DFn = GrGLvoid GR_GL_FUNCTION_TYPE(const GrGLvoid* mem); +using GrGLUseProgramFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint program); +using GrGLVertexAttrib1fFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint indx, const GrGLfloat value); +using GrGLVertexAttrib2fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint indx, const GrGLfloat* values); +using GrGLVertexAttrib3fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint indx, const GrGLfloat* values); +using GrGLVertexAttrib4fvFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint indx, const GrGLfloat* values); +using GrGLVertexAttribDivisorFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint index, GrGLuint divisor); +using GrGLVertexAttribIPointerFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint indx, GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* ptr); +using GrGLVertexAttribPointerFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr); +using GrGLViewportFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); + +/* GL_NV_framebuffer_mixed_samples */ +using GrGLCoverageModulationFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum components); + +/* EXT_base_instance */ +using GrGLDrawArraysInstancedBaseInstanceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLint first, GrGLsizei count, GrGLsizei instancecount, GrGLuint baseinstance); +using GrGLDrawElementsInstancedBaseVertexBaseInstanceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLsizei count, GrGLenum type, const void *indices, GrGLsizei instancecount, GrGLint basevertex, GrGLuint baseinstance); + +/* EXT_multi_draw_indirect */ +using GrGLMultiDrawArraysIndirectFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, const GrGLvoid* indirect, GrGLsizei drawcount, GrGLsizei stride); +using GrGLMultiDrawElementsIndirectFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLenum type, const GrGLvoid* indirect, GrGLsizei drawcount, GrGLsizei stride); + +/* ANGLE_base_vertex_base_instance */ +using GrGLMultiDrawArraysInstancedBaseInstanceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, const GrGLint* firsts, const GrGLsizei* counts, const GrGLsizei* instanceCounts, const GrGLuint* baseInstances, const GrGLsizei drawcount); +using GrGLMultiDrawElementsInstancedBaseVertexBaseInstanceFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, const GrGLint* counts, GrGLenum type, const GrGLvoid* const* indices, const GrGLsizei* instanceCounts, const GrGLint* baseVertices, const GrGLuint* baseInstances, const GrGLsizei drawcount); + +/* ARB_sync */ +using GrGLFenceSyncFn = GrGLsync GR_GL_FUNCTION_TYPE(GrGLenum condition, GrGLbitfield flags); +using GrGLIsSyncFn = GrGLboolean GR_GL_FUNCTION_TYPE(GrGLsync sync); +using GrGLClientWaitSyncFn = GrGLenum GR_GL_FUNCTION_TYPE(GrGLsync sync, GrGLbitfield flags, GrGLuint64 timeout); +using GrGLWaitSyncFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsync sync, GrGLbitfield flags, GrGLuint64 timeout); +using GrGLDeleteSyncFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLsync sync); + +/* ARB_internalformat_query */ +using GrGLGetInternalformativFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum target, GrGLenum internalformat, GrGLenum pname, GrGLsizei bufSize, GrGLint* params); + +/* KHR_debug */ +using GrGLDebugMessageControlFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum source, GrGLenum type, GrGLenum severity, GrGLsizei count, const GrGLuint* ids, GrGLboolean enabled); +using GrGLDebugMessageInsertFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum source, GrGLenum type, GrGLuint id, GrGLenum severity, GrGLsizei length, const GrGLchar* buf); +using GrGLDebugMessageCallbackFn = GrGLvoid GR_GL_FUNCTION_TYPE(GRGLDEBUGPROC callback, const GrGLvoid* userParam); +using GrGLGetDebugMessageLogFn = GrGLuint GR_GL_FUNCTION_TYPE(GrGLuint count, GrGLsizei bufSize, GrGLenum* sources, GrGLenum* types, GrGLuint* ids, GrGLenum* severities, GrGLsizei* lengths, GrGLchar* messageLog); +using GrGLPushDebugGroupFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum source, GrGLuint id, GrGLsizei length, const GrGLchar* message); +using GrGLPopDebugGroupFn = GrGLvoid GR_GL_FUNCTION_TYPE(); +using GrGLObjectLabelFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum identifier, GrGLuint name, GrGLsizei length, const GrGLchar* label); + +/** EXT_window_rectangles */ +using GrGLWindowRectanglesFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLenum mode, GrGLsizei count, const GrGLint box[]); + +/** GL_QCOM_tiled_rendering */ +using GrGLStartTilingFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLuint x, GrGLuint y, GrGLuint width, GrGLuint height, GrGLbitfield preserveMask); +using GrGLEndTilingFn = GrGLvoid GR_GL_FUNCTION_TYPE(GrGLbitfield preserveMask); + +/** EGL functions */ +using GrEGLQueryStringFn = const char* GR_GL_FUNCTION_TYPE(GrEGLDisplay dpy, GrEGLint name); +using GrEGLGetCurrentDisplayFn = GrEGLDisplay GR_GL_FUNCTION_TYPE(); +using GrEGLCreateImageFn = GrEGLImage GR_GL_FUNCTION_TYPE(GrEGLDisplay dpy, GrEGLContext ctx, GrEGLenum target, GrEGLClientBuffer buffer, const GrEGLint* attrib_list); +using GrEGLDestroyImageFn = GrEGLBoolean GR_GL_FUNCTION_TYPE(GrEGLDisplay dpy, GrEGLImage image); +} // extern "C" + +// This is a lighter-weight std::function, trying to reduce code size and compile time +// by only supporting the exact use cases we require. +template <typename T> class GrGLFunction; + +template <typename R, typename... Args> +class GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> { +public: + using Fn = R GR_GL_FUNCTION_TYPE(Args...); + // Construct empty. + GrGLFunction() = default; + GrGLFunction(std::nullptr_t) {} + + // Construct from a simple function pointer. + GrGLFunction(Fn* fn_ptr) { + static_assert(sizeof(fn_ptr) <= sizeof(fBuf), "fBuf is too small"); + if (fn_ptr) { + memcpy(fBuf, &fn_ptr, sizeof(fn_ptr)); + fCall = [](const void* buf, Args... args) { + return (*(Fn**)buf)(std::forward<Args>(args)...); + }; + } + } + + // Construct from a small closure. + template <typename Closure> + GrGLFunction(Closure closure) : GrGLFunction() { + static_assert(sizeof(Closure) <= sizeof(fBuf), "fBuf is too small"); +#if defined(__APPLE__) // I am having serious trouble getting these to work with all STLs... + static_assert(std::is_trivially_copyable<Closure>::value, ""); + static_assert(std::is_trivially_destructible<Closure>::value, ""); +#endif + + memcpy(fBuf, &closure, sizeof(closure)); + fCall = [](const void* buf, Args... args) { + auto closure = (const Closure*)buf; + return (*closure)(args...); + }; + } + + R operator()(Args... args) const { + SkASSERT(fCall); + return fCall(fBuf, std::forward<Args>(args)...); + } + + explicit operator bool() const { return fCall != nullptr; } + + void reset() { fCall = nullptr; } + +private: + using Call = R(const void* buf, Args...); + Call* fCall = nullptr; + size_t fBuf[4]; +}; + +#endif diff --git a/src/deps/skia/include/gpu/gl/GrGLInterface.h b/src/deps/skia/include/gpu/gl/GrGLInterface.h new file mode 100644 index 000000000..af3ca67dc --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLInterface.h @@ -0,0 +1,342 @@ +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGLInterface_DEFINED +#define GrGLInterface_DEFINED + +#include "include/core/SkRefCnt.h" +#include "include/gpu/gl/GrGLExtensions.h" +#include "include/gpu/gl/GrGLFunctions.h" + +//////////////////////////////////////////////////////////////////////////////// + +typedef void(*GrGLFuncPtr)(); +struct GrGLInterface; + + +/** + * Rather than depend on platform-specific GL headers and libraries, we require + * the client to provide a struct of GL function pointers. This struct can be + * specified per-GrContext as a parameter to GrContext::MakeGL. If no interface is + * passed to MakeGL then a default GL interface is created using GrGLMakeNativeInterface(). + * If this returns nullptr then GrContext::MakeGL() will fail. + * + * The implementation of GrGLMakeNativeInterface is platform-specific. Several + * implementations have been provided (for GLX, WGL, EGL, etc), along with an + * implementation that simply returns nullptr. Clients should select the most + * appropriate one to build. + */ +SK_API sk_sp<const GrGLInterface> GrGLMakeNativeInterface(); +// Deprecated alternative to GrGLMakeNativeInterface(). +SK_API const GrGLInterface* GrGLCreateNativeInterface(); + +/** + * GrContext uses the following interface to make all calls into OpenGL. When a + * GrContext is created it is given a GrGLInterface. The interface's function + * pointers must be valid for the OpenGL context associated with the GrContext. + * On some platforms, such as Windows, function pointers for OpenGL extensions + * may vary between OpenGL contexts. So the caller must be careful to use a + * GrGLInterface initialized for the correct context. All functions that should + * be available based on the OpenGL's version and extension string must be + * non-NULL or GrContext creation will fail. This can be tested with the + * validate() method when the OpenGL context has been made current. + */ +struct SK_API GrGLInterface : public SkRefCnt { +private: + using INHERITED = SkRefCnt; + +#if GR_GL_CHECK_ERROR + // This is here to avoid having our debug code that checks for a GL error after most GL calls + // accidentally swallow an OOM that should be reported. + mutable bool fOOMed = false; + bool fSuppressErrorLogging = false; +#endif + +public: + GrGLInterface(); + + // Validates that the GrGLInterface supports its advertised standard. This means the necessary + // function pointers have been initialized for both the GL version and any advertised + // extensions. + bool validate() const; + +#if GR_GL_CHECK_ERROR + GrGLenum checkError(const char* location, const char* call) const; + bool checkAndResetOOMed() const; + void suppressErrorLogging(); +#endif + +#if GR_TEST_UTILS + GrGLInterface(const GrGLInterface& that) + : fStandard(that.fStandard) + , fExtensions(that.fExtensions) + , fFunctions(that.fFunctions) {} +#endif + + // Indicates the type of GL implementation + union { + GrGLStandard fStandard; + GrGLStandard fBindingsExported; // Legacy name, will be remove when Chromium is updated. + }; + + GrGLExtensions fExtensions; + + bool hasExtension(const char ext[]) const { return fExtensions.has(ext); } + + /** + * The function pointers are in a struct so that we can have a compiler generated assignment + * operator. + */ + struct Functions { + GrGLFunction<GrGLActiveTextureFn> fActiveTexture; + GrGLFunction<GrGLAttachShaderFn> fAttachShader; + GrGLFunction<GrGLBeginQueryFn> fBeginQuery; + GrGLFunction<GrGLBindAttribLocationFn> fBindAttribLocation; + GrGLFunction<GrGLBindBufferFn> fBindBuffer; + GrGLFunction<GrGLBindFragDataLocationFn> fBindFragDataLocation; + GrGLFunction<GrGLBindFragDataLocationIndexedFn> fBindFragDataLocationIndexed; + GrGLFunction<GrGLBindFramebufferFn> fBindFramebuffer; + GrGLFunction<GrGLBindRenderbufferFn> fBindRenderbuffer; + GrGLFunction<GrGLBindSamplerFn> fBindSampler; + GrGLFunction<GrGLBindTextureFn> fBindTexture; + GrGLFunction<GrGLBindVertexArrayFn> fBindVertexArray; + GrGLFunction<GrGLBlendBarrierFn> fBlendBarrier; + GrGLFunction<GrGLBlendColorFn> fBlendColor; + GrGLFunction<GrGLBlendEquationFn> fBlendEquation; + GrGLFunction<GrGLBlendFuncFn> fBlendFunc; + GrGLFunction<GrGLBlitFramebufferFn> fBlitFramebuffer; + GrGLFunction<GrGLBufferDataFn> fBufferData; + GrGLFunction<GrGLBufferSubDataFn> fBufferSubData; + GrGLFunction<GrGLCheckFramebufferStatusFn> fCheckFramebufferStatus; + GrGLFunction<GrGLClearFn> fClear; + GrGLFunction<GrGLClearColorFn> fClearColor; + GrGLFunction<GrGLClearStencilFn> fClearStencil; + GrGLFunction<GrGLClearTexImageFn> fClearTexImage; + GrGLFunction<GrGLClearTexSubImageFn> fClearTexSubImage; + GrGLFunction<GrGLColorMaskFn> fColorMask; + GrGLFunction<GrGLCompileShaderFn> fCompileShader; + GrGLFunction<GrGLCompressedTexImage2DFn> fCompressedTexImage2D; + GrGLFunction<GrGLCompressedTexSubImage2DFn> fCompressedTexSubImage2D; + GrGLFunction<GrGLCopyTexSubImage2DFn> fCopyTexSubImage2D; + GrGLFunction<GrGLCreateProgramFn> fCreateProgram; + GrGLFunction<GrGLCreateShaderFn> fCreateShader; + GrGLFunction<GrGLCullFaceFn> fCullFace; + GrGLFunction<GrGLDeleteBuffersFn> fDeleteBuffers; + GrGLFunction<GrGLDeleteFencesFn> fDeleteFences; + GrGLFunction<GrGLDeleteFramebuffersFn> fDeleteFramebuffers; + GrGLFunction<GrGLDeleteProgramFn> fDeleteProgram; + GrGLFunction<GrGLDeleteQueriesFn> fDeleteQueries; + GrGLFunction<GrGLDeleteRenderbuffersFn> fDeleteRenderbuffers; + GrGLFunction<GrGLDeleteSamplersFn> fDeleteSamplers; + GrGLFunction<GrGLDeleteShaderFn> fDeleteShader; + GrGLFunction<GrGLDeleteTexturesFn> fDeleteTextures; + GrGLFunction<GrGLDeleteVertexArraysFn> fDeleteVertexArrays; + GrGLFunction<GrGLDepthMaskFn> fDepthMask; + GrGLFunction<GrGLDisableFn> fDisable; + GrGLFunction<GrGLDisableVertexAttribArrayFn> fDisableVertexAttribArray; + GrGLFunction<GrGLDrawArraysFn> fDrawArrays; + GrGLFunction<GrGLDrawArraysIndirectFn> fDrawArraysIndirect; + GrGLFunction<GrGLDrawArraysInstancedFn> fDrawArraysInstanced; + GrGLFunction<GrGLDrawBufferFn> fDrawBuffer; + GrGLFunction<GrGLDrawBuffersFn> fDrawBuffers; + GrGLFunction<GrGLDrawElementsFn> fDrawElements; + GrGLFunction<GrGLDrawElementsIndirectFn> fDrawElementsIndirect; + GrGLFunction<GrGLDrawElementsInstancedFn> fDrawElementsInstanced; + GrGLFunction<GrGLDrawRangeElementsFn> fDrawRangeElements; + GrGLFunction<GrGLEnableFn> fEnable; + GrGLFunction<GrGLEnableVertexAttribArrayFn> fEnableVertexAttribArray; + GrGLFunction<GrGLEndQueryFn> fEndQuery; + GrGLFunction<GrGLFinishFn> fFinish; + GrGLFunction<GrGLFinishFenceFn> fFinishFence; + GrGLFunction<GrGLFlushFn> fFlush; + GrGLFunction<GrGLFlushMappedBufferRangeFn> fFlushMappedBufferRange; + GrGLFunction<GrGLFramebufferRenderbufferFn> fFramebufferRenderbuffer; + GrGLFunction<GrGLFramebufferTexture2DFn> fFramebufferTexture2D; + GrGLFunction<GrGLFramebufferTexture2DMultisampleFn> fFramebufferTexture2DMultisample; + GrGLFunction<GrGLFrontFaceFn> fFrontFace; + GrGLFunction<GrGLGenBuffersFn> fGenBuffers; + GrGLFunction<GrGLGenFencesFn> fGenFences; + GrGLFunction<GrGLGenFramebuffersFn> fGenFramebuffers; + GrGLFunction<GrGLGenerateMipmapFn> fGenerateMipmap; + GrGLFunction<GrGLGenQueriesFn> fGenQueries; + GrGLFunction<GrGLGenRenderbuffersFn> fGenRenderbuffers; + GrGLFunction<GrGLGenSamplersFn> fGenSamplers; + GrGLFunction<GrGLGenTexturesFn> fGenTextures; + GrGLFunction<GrGLGenVertexArraysFn> fGenVertexArrays; + GrGLFunction<GrGLGetBufferParameterivFn> fGetBufferParameteriv; + GrGLFunction<GrGLGetErrorFn> fGetError; + GrGLFunction<GrGLGetFramebufferAttachmentParameterivFn> fGetFramebufferAttachmentParameteriv; + GrGLFunction<GrGLGetIntegervFn> fGetIntegerv; + GrGLFunction<GrGLGetMultisamplefvFn> fGetMultisamplefv; + GrGLFunction<GrGLGetProgramBinaryFn> fGetProgramBinary; + GrGLFunction<GrGLGetProgramInfoLogFn> fGetProgramInfoLog; + GrGLFunction<GrGLGetProgramivFn> fGetProgramiv; + GrGLFunction<GrGLGetQueryObjecti64vFn> fGetQueryObjecti64v; + GrGLFunction<GrGLGetQueryObjectivFn> fGetQueryObjectiv; + GrGLFunction<GrGLGetQueryObjectui64vFn> fGetQueryObjectui64v; + GrGLFunction<GrGLGetQueryObjectuivFn> fGetQueryObjectuiv; + GrGLFunction<GrGLGetQueryivFn> fGetQueryiv; + GrGLFunction<GrGLGetRenderbufferParameterivFn> fGetRenderbufferParameteriv; + GrGLFunction<GrGLGetShaderInfoLogFn> fGetShaderInfoLog; + GrGLFunction<GrGLGetShaderivFn> fGetShaderiv; + GrGLFunction<GrGLGetShaderPrecisionFormatFn> fGetShaderPrecisionFormat; + GrGLFunction<GrGLGetStringFn> fGetString; + GrGLFunction<GrGLGetStringiFn> fGetStringi; + GrGLFunction<GrGLGetTexLevelParameterivFn> fGetTexLevelParameteriv; + GrGLFunction<GrGLGetUniformLocationFn> fGetUniformLocation; + GrGLFunction<GrGLInsertEventMarkerFn> fInsertEventMarker; + GrGLFunction<GrGLInvalidateBufferDataFn> fInvalidateBufferData; + GrGLFunction<GrGLInvalidateBufferSubDataFn> fInvalidateBufferSubData; + GrGLFunction<GrGLInvalidateFramebufferFn> fInvalidateFramebuffer; + GrGLFunction<GrGLInvalidateSubFramebufferFn> fInvalidateSubFramebuffer; + GrGLFunction<GrGLInvalidateTexImageFn> fInvalidateTexImage; + GrGLFunction<GrGLInvalidateTexSubImageFn> fInvalidateTexSubImage; + GrGLFunction<GrGLIsTextureFn> fIsTexture; + GrGLFunction<GrGLLineWidthFn> fLineWidth; + GrGLFunction<GrGLLinkProgramFn> fLinkProgram; + GrGLFunction<GrGLProgramBinaryFn> fProgramBinary; + GrGLFunction<GrGLProgramParameteriFn> fProgramParameteri; + GrGLFunction<GrGLMapBufferFn> fMapBuffer; + GrGLFunction<GrGLMapBufferRangeFn> fMapBufferRange; + GrGLFunction<GrGLMapBufferSubDataFn> fMapBufferSubData; + GrGLFunction<GrGLMapTexSubImage2DFn> fMapTexSubImage2D; + GrGLFunction<GrGLMemoryBarrierFn> fMemoryBarrier; + GrGLFunction<GrGLDrawArraysInstancedBaseInstanceFn> fDrawArraysInstancedBaseInstance; + GrGLFunction<GrGLDrawElementsInstancedBaseVertexBaseInstanceFn> fDrawElementsInstancedBaseVertexBaseInstance; + GrGLFunction<GrGLMultiDrawArraysIndirectFn> fMultiDrawArraysIndirect; + GrGLFunction<GrGLMultiDrawElementsIndirectFn> fMultiDrawElementsIndirect; + GrGLFunction<GrGLMultiDrawArraysInstancedBaseInstanceFn> fMultiDrawArraysInstancedBaseInstance; + GrGLFunction<GrGLMultiDrawElementsInstancedBaseVertexBaseInstanceFn> fMultiDrawElementsInstancedBaseVertexBaseInstance; + GrGLFunction<GrGLPatchParameteriFn> fPatchParameteri; + GrGLFunction<GrGLPixelStoreiFn> fPixelStorei; + GrGLFunction<GrGLPolygonModeFn> fPolygonMode; + GrGLFunction<GrGLPopGroupMarkerFn> fPopGroupMarker; + GrGLFunction<GrGLPushGroupMarkerFn> fPushGroupMarker; + GrGLFunction<GrGLQueryCounterFn> fQueryCounter; + GrGLFunction<GrGLReadBufferFn> fReadBuffer; + GrGLFunction<GrGLReadPixelsFn> fReadPixels; + GrGLFunction<GrGLRenderbufferStorageFn> fRenderbufferStorage; + + // On OpenGL ES there are multiple incompatible extensions that add support for MSAA + // and ES3 adds MSAA support to the standard. On an ES3 driver we may still use the + // older extensions for performance reasons or due to ES3 driver bugs. We want the function + // that creates the GrGLInterface to provide all available functions and internally + // we will select among them. They all have a method called glRenderbufferStorageMultisample*. + // So we have separate function pointers for GL_IMG/EXT_multisampled_to_texture, + // GL_CHROMIUM/ANGLE_framebuffer_multisample/ES3, and GL_APPLE_framebuffer_multisample + // variations. + // + // If a driver supports multiple GL_ARB_framebuffer_multisample-style extensions then we will + // assume the function pointers for the standard (or equivalent GL_ARB) version have + // been preferred over GL_EXT, GL_CHROMIUM, or GL_ANGLE variations that have reduced + // functionality. + + // GL_EXT_multisampled_render_to_texture (preferred) or GL_IMG_multisampled_render_to_texture + GrGLFunction<GrGLRenderbufferStorageMultisampleFn> fRenderbufferStorageMultisampleES2EXT; + // GL_APPLE_framebuffer_multisample + GrGLFunction<GrGLRenderbufferStorageMultisampleFn> fRenderbufferStorageMultisampleES2APPLE; + + // This is used to store the pointer for GL_ARB/EXT/ANGLE/CHROMIUM_framebuffer_multisample or + // the standard function in ES3+ or GL 3.0+. + GrGLFunction<GrGLRenderbufferStorageMultisampleFn> fRenderbufferStorageMultisample; + + // Pointer to BindUniformLocationCHROMIUM from the GL_CHROMIUM_bind_uniform_location extension. + GrGLFunction<GrGLBindUniformLocationFn> fBindUniformLocation; + + GrGLFunction<GrGLResolveMultisampleFramebufferFn> fResolveMultisampleFramebuffer; + GrGLFunction<GrGLSamplerParameteriFn> fSamplerParameteri; + GrGLFunction<GrGLSamplerParameterivFn> fSamplerParameteriv; + GrGLFunction<GrGLScissorFn> fScissor; + GrGLFunction<GrGLSetFenceFn> fSetFence; + GrGLFunction<GrGLShaderSourceFn> fShaderSource; + GrGLFunction<GrGLStencilFuncFn> fStencilFunc; + GrGLFunction<GrGLStencilFuncSeparateFn> fStencilFuncSeparate; + GrGLFunction<GrGLStencilMaskFn> fStencilMask; + GrGLFunction<GrGLStencilMaskSeparateFn> fStencilMaskSeparate; + GrGLFunction<GrGLStencilOpFn> fStencilOp; + GrGLFunction<GrGLStencilOpSeparateFn> fStencilOpSeparate; + GrGLFunction<GrGLTestFenceFn> fTestFence; + GrGLFunction<GrGLTexBufferFn> fTexBuffer; + GrGLFunction<GrGLTexBufferRangeFn> fTexBufferRange; + GrGLFunction<GrGLTexImage2DFn> fTexImage2D; + GrGLFunction<GrGLTexParameterfFn> fTexParameterf; + GrGLFunction<GrGLTexParameterfvFn> fTexParameterfv; + GrGLFunction<GrGLTexParameteriFn> fTexParameteri; + GrGLFunction<GrGLTexParameterivFn> fTexParameteriv; + GrGLFunction<GrGLTexSubImage2DFn> fTexSubImage2D; + GrGLFunction<GrGLTexStorage2DFn> fTexStorage2D; + GrGLFunction<GrGLTextureBarrierFn> fTextureBarrier; + GrGLFunction<GrGLDiscardFramebufferFn> fDiscardFramebuffer; + GrGLFunction<GrGLUniform1fFn> fUniform1f; + GrGLFunction<GrGLUniform1iFn> fUniform1i; + GrGLFunction<GrGLUniform1fvFn> fUniform1fv; + GrGLFunction<GrGLUniform1ivFn> fUniform1iv; + GrGLFunction<GrGLUniform2fFn> fUniform2f; + GrGLFunction<GrGLUniform2iFn> fUniform2i; + GrGLFunction<GrGLUniform2fvFn> fUniform2fv; + GrGLFunction<GrGLUniform2ivFn> fUniform2iv; + GrGLFunction<GrGLUniform3fFn> fUniform3f; + GrGLFunction<GrGLUniform3iFn> fUniform3i; + GrGLFunction<GrGLUniform3fvFn> fUniform3fv; + GrGLFunction<GrGLUniform3ivFn> fUniform3iv; + GrGLFunction<GrGLUniform4fFn> fUniform4f; + GrGLFunction<GrGLUniform4iFn> fUniform4i; + GrGLFunction<GrGLUniform4fvFn> fUniform4fv; + GrGLFunction<GrGLUniform4ivFn> fUniform4iv; + GrGLFunction<GrGLUniformMatrix2fvFn> fUniformMatrix2fv; + GrGLFunction<GrGLUniformMatrix3fvFn> fUniformMatrix3fv; + GrGLFunction<GrGLUniformMatrix4fvFn> fUniformMatrix4fv; + GrGLFunction<GrGLUnmapBufferFn> fUnmapBuffer; + GrGLFunction<GrGLUnmapBufferSubDataFn> fUnmapBufferSubData; + GrGLFunction<GrGLUnmapTexSubImage2DFn> fUnmapTexSubImage2D; + GrGLFunction<GrGLUseProgramFn> fUseProgram; + GrGLFunction<GrGLVertexAttrib1fFn> fVertexAttrib1f; + GrGLFunction<GrGLVertexAttrib2fvFn> fVertexAttrib2fv; + GrGLFunction<GrGLVertexAttrib3fvFn> fVertexAttrib3fv; + GrGLFunction<GrGLVertexAttrib4fvFn> fVertexAttrib4fv; + GrGLFunction<GrGLVertexAttribDivisorFn> fVertexAttribDivisor; + GrGLFunction<GrGLVertexAttribIPointerFn> fVertexAttribIPointer; + GrGLFunction<GrGLVertexAttribPointerFn> fVertexAttribPointer; + GrGLFunction<GrGLViewportFn> fViewport; + + /* NV_framebuffer_mixed_samples */ + GrGLFunction<GrGLCoverageModulationFn> fCoverageModulation; + + /* ARB_sync */ + GrGLFunction<GrGLFenceSyncFn> fFenceSync; + GrGLFunction<GrGLIsSyncFn> fIsSync; + GrGLFunction<GrGLClientWaitSyncFn> fClientWaitSync; + GrGLFunction<GrGLWaitSyncFn> fWaitSync; + GrGLFunction<GrGLDeleteSyncFn> fDeleteSync; + + /* ARB_internalforamt_query */ + GrGLFunction<GrGLGetInternalformativFn> fGetInternalformativ; + + /* KHR_debug */ + GrGLFunction<GrGLDebugMessageControlFn> fDebugMessageControl; + GrGLFunction<GrGLDebugMessageInsertFn> fDebugMessageInsert; + GrGLFunction<GrGLDebugMessageCallbackFn> fDebugMessageCallback; + GrGLFunction<GrGLGetDebugMessageLogFn> fGetDebugMessageLog; + GrGLFunction<GrGLPushDebugGroupFn> fPushDebugGroup; + GrGLFunction<GrGLPopDebugGroupFn> fPopDebugGroup; + GrGLFunction<GrGLObjectLabelFn> fObjectLabel; + + /* EXT_window_rectangles */ + GrGLFunction<GrGLWindowRectanglesFn> fWindowRectangles; + + /* GL_QCOM_tiled_rendering */ + GrGLFunction<GrGLStartTilingFn> fStartTiling; + GrGLFunction<GrGLEndTilingFn> fEndTiling; + } fFunctions; + +#if GR_TEST_UTILS + // This exists for internal testing. + virtual void abandon() const; +#endif +}; + +#endif diff --git a/src/deps/skia/include/gpu/gl/GrGLTypes.h b/src/deps/skia/include/gpu/gl/GrGLTypes.h new file mode 100644 index 000000000..d5167787c --- /dev/null +++ b/src/deps/skia/include/gpu/gl/GrGLTypes.h @@ -0,0 +1,207 @@ + +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGLTypes_DEFINED +#define GrGLTypes_DEFINED + +#include "include/core/SkRefCnt.h" +#include "include/gpu/gl/GrGLConfig.h" + +/** + * Classifies GL contexts by which standard they implement (currently as OpenGL vs. OpenGL ES). + */ +enum GrGLStandard { + kNone_GrGLStandard, + kGL_GrGLStandard, + kGLES_GrGLStandard, + kWebGL_GrGLStandard, +}; +static const int kGrGLStandardCnt = 4; + +// The following allow certain interfaces to be turned off at compile time +// (for example, to lower code size). +#if SK_ASSUME_GL_ES + #define GR_IS_GR_GL(standard) false + #define GR_IS_GR_GL_ES(standard) true + #define GR_IS_GR_WEBGL(standard) false + #define SK_DISABLE_GL_INTERFACE 1 + #define SK_DISABLE_WEBGL_INTERFACE 1 +#elif SK_ASSUME_GL + #define GR_IS_GR_GL(standard) true + #define GR_IS_GR_GL_ES(standard) false + #define GR_IS_GR_WEBGL(standard) false + #define SK_DISABLE_GL_ES_INTERFACE 1 + #define SK_DISABLE_WEBGL_INTERFACE 1 +#elif SK_ASSUME_WEBGL + #define GR_IS_GR_GL(standard) false + #define GR_IS_GR_GL_ES(standard) false + #define GR_IS_GR_WEBGL(standard) true + #define SK_DISABLE_GL_ES_INTERFACE 1 + #define SK_DISABLE_GL_INTERFACE 1 +#else + #define GR_IS_GR_GL(standard) (kGL_GrGLStandard == standard) + #define GR_IS_GR_GL_ES(standard) (kGLES_GrGLStandard == standard) + #define GR_IS_GR_WEBGL(standard) (kWebGL_GrGLStandard == standard) +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/** + * The supported GL formats represented as an enum. Actual support by GrContext depends on GL + * context version and extensions. + */ +enum class GrGLFormat { + kUnknown, + + kRGBA8, + kR8, + kALPHA8, + kLUMINANCE8, + kLUMINANCE8_ALPHA8, + kBGRA8, + kRGB565, + kRGBA16F, + kR16F, + kRGB8, + kRGBX8, + kRG8, + kRGB10_A2, + kRGBA4, + kSRGB8_ALPHA8, + kCOMPRESSED_ETC1_RGB8, + kCOMPRESSED_RGB8_ETC2, + kCOMPRESSED_RGB8_BC1, + kCOMPRESSED_RGBA8_BC1, + kR16, + kRG16, + kRGBA16, + kRG16F, + kLUMINANCE16F, + + kLastColorFormat = kLUMINANCE16F, + + // Depth/Stencil formats + kSTENCIL_INDEX8, + kSTENCIL_INDEX16, + kDEPTH24_STENCIL8, + + kLast = kDEPTH24_STENCIL8 +}; + +/////////////////////////////////////////////////////////////////////////////// +/** + * Declares typedefs for all the GL functions used in GrGLInterface + */ + +typedef unsigned int GrGLenum; +typedef unsigned char GrGLboolean; +typedef unsigned int GrGLbitfield; +typedef signed char GrGLbyte; +typedef char GrGLchar; +typedef short GrGLshort; +typedef int GrGLint; +typedef int GrGLsizei; +typedef int64_t GrGLint64; +typedef unsigned char GrGLubyte; +typedef unsigned short GrGLushort; +typedef unsigned int GrGLuint; +typedef uint64_t GrGLuint64; +typedef unsigned short int GrGLhalf; +typedef float GrGLfloat; +typedef float GrGLclampf; +typedef double GrGLdouble; +typedef double GrGLclampd; +typedef void GrGLvoid; +#ifdef _WIN64 +typedef signed long long int GrGLintptr; +typedef signed long long int GrGLsizeiptr; +#else +typedef signed long int GrGLintptr; +typedef signed long int GrGLsizeiptr; +#endif +typedef void* GrGLeglImage; +typedef struct __GLsync* GrGLsync; + +struct GrGLDrawArraysIndirectCommand { + GrGLuint fCount; + GrGLuint fInstanceCount; + GrGLuint fFirst; + GrGLuint fBaseInstance; // Requires EXT_base_instance on ES. +}; + +// static_asserts must have messages in this file because its included in C++14 client code. +static_assert(16 == sizeof(GrGLDrawArraysIndirectCommand), ""); + +struct GrGLDrawElementsIndirectCommand { + GrGLuint fCount; + GrGLuint fInstanceCount; + GrGLuint fFirstIndex; + GrGLuint fBaseVertex; + GrGLuint fBaseInstance; // Requires EXT_base_instance on ES. +}; + +static_assert(20 == sizeof(GrGLDrawElementsIndirectCommand), ""); + +/** + * KHR_debug + */ +typedef void (GR_GL_FUNCTION_TYPE* GRGLDEBUGPROC)(GrGLenum source, + GrGLenum type, + GrGLuint id, + GrGLenum severity, + GrGLsizei length, + const GrGLchar* message, + const void* userParam); + +/** + * EGL types. + */ +typedef void* GrEGLImage; +typedef void* GrEGLDisplay; +typedef void* GrEGLContext; +typedef void* GrEGLClientBuffer; +typedef unsigned int GrEGLenum; +typedef int32_t GrEGLint; +typedef unsigned int GrEGLBoolean; + +/////////////////////////////////////////////////////////////////////////////// +/** + * Types for interacting with GL resources created externally to Skia. GrBackendObjects for GL + * textures are really const GrGLTexture*. The fFormat here should be a sized, internal format + * for the texture. We will try to use the sized format if the GL Context supports it, otherwise + * we will internally fall back to using the base internal formats. + */ +struct GrGLTextureInfo { + GrGLenum fTarget; + GrGLuint fID; + GrGLenum fFormat = 0; + + bool operator==(const GrGLTextureInfo& that) const { + return fTarget == that.fTarget && fID == that.fID && fFormat == that.fFormat; + } +}; + +struct GrGLFramebufferInfo { + GrGLuint fFBOID; + GrGLenum fFormat = 0; + + bool operator==(const GrGLFramebufferInfo& that) const { + return fFBOID == that.fFBOID && fFormat == that.fFormat; + } +}; + +struct GrGLSurfaceInfo { + uint32_t fSampleCount = 1; + uint32_t fLevelCount = 0; + GrProtected fProtected = GrProtected::kNo; + + GrGLenum fTarget = 0; + GrGLenum fFormat = 0; +}; + +#endif diff --git a/src/deps/skia/include/gpu/gl/egl/BUILD.bazel b/src/deps/skia/include/gpu/gl/egl/BUILD.bazel new file mode 100644 index 000000000..4e824371a --- /dev/null +++ b/src/deps/skia/include/gpu/gl/egl/BUILD.bazel @@ -0,0 +1,11 @@ +load("//bazel:macros.bzl", "generated_cc_atom") + +generated_cc_atom( + name = "GrGLMakeEGLInterface_hdr", + hdrs = ["GrGLMakeEGLInterface.h"], + visibility = ["//:__subpackages__"], + deps = [ + "//include/core:SkRefCnt_hdr", + "//include/gpu:GrTypes_hdr", + ], +) diff --git a/src/deps/skia/include/gpu/gl/egl/GrGLMakeEGLInterface.h b/src/deps/skia/include/gpu/gl/egl/GrGLMakeEGLInterface.h new file mode 100644 index 000000000..a3eb420b0 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/egl/GrGLMakeEGLInterface.h @@ -0,0 +1,14 @@ +/* + * Copyright 2021 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/gpu/GrTypes.h" + +#include "include/core/SkRefCnt.h" + +struct GrGLInterface; + +sk_sp<const GrGLInterface> GrGLMakeEGLInterface(); diff --git a/src/deps/skia/include/gpu/gl/glx/BUILD.bazel b/src/deps/skia/include/gpu/gl/glx/BUILD.bazel new file mode 100644 index 000000000..c336d4974 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/glx/BUILD.bazel @@ -0,0 +1,11 @@ +load("//bazel:macros.bzl", "generated_cc_atom") + +generated_cc_atom( + name = "GrGLMakeGLXInterface_hdr", + hdrs = ["GrGLMakeGLXInterface.h"], + visibility = ["//:__subpackages__"], + deps = [ + "//include/core:SkRefCnt_hdr", + "//include/gpu:GrTypes_hdr", + ], +) diff --git a/src/deps/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h b/src/deps/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h new file mode 100644 index 000000000..b49cde458 --- /dev/null +++ b/src/deps/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h @@ -0,0 +1,14 @@ +/* + * Copyright 2021 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/gpu/GrTypes.h" + +#include "include/core/SkRefCnt.h" + +struct GrGLInterface; + +sk_sp<const GrGLInterface> GrGLMakeGLXInterface(); |