Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrGLInterface.h
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrGLInterface_DEFINED
9#define GrGLInterface_DEFINED
10
14
15////////////////////////////////////////////////////////////////////////////////
16
17typedef void(*GrGLFuncPtr)();
18struct GrGLInterface;
19
20
21#if !defined(SK_DISABLE_LEGACY_GL_MAKE_NATIVE_INTERFACE)
22/**
23 * Rather than depend on platform-specific GL headers and libraries, we require
24 * the client to provide a struct of GL function pointers. This struct can be
25 * specified per-GrContext as a parameter to GrContext::MakeGL. If no interface is
26 * passed to MakeGL then a default GL interface is created using GrGLMakeNativeInterface().
27 * If this returns nullptr then GrContext::MakeGL() will fail.
28 *
29 * The implementation of GrGLMakeNativeInterface is platform-specific. Several
30 * implementations have been provided (for GLX, WGL, EGL, etc), along with an
31 * implementation that simply returns nullptr. Clients should select the most
32 * appropriate one to build.
33 */
35#endif
36
37/**
38 * GrContext uses the following interface to make all calls into OpenGL. When a
39 * GrContext is created it is given a GrGLInterface. The interface's function
40 * pointers must be valid for the OpenGL context associated with the GrContext.
41 * On some platforms, such as Windows, function pointers for OpenGL extensions
42 * may vary between OpenGL contexts. So the caller must be careful to use a
43 * GrGLInterface initialized for the correct context. All functions that should
44 * be available based on the OpenGL's version and extension string must be
45 * non-NULL or GrContext creation will fail. This can be tested with the
46 * validate() method when the OpenGL context has been made current.
47 */
48struct SK_API GrGLInterface : public SkRefCnt {
49private:
50 using INHERITED = SkRefCnt;
51
52#if GR_GL_CHECK_ERROR
53 // This is here to avoid having our debug code that checks for a GL error after most GL calls
54 // accidentally swallow an OOM that should be reported.
55 mutable bool fOOMed = false;
56 bool fSuppressErrorLogging = false;
57#endif
58
59public:
61
62 // Validates that the GrGLInterface supports its advertised standard. This means the necessary
63 // function pointers have been initialized for both the GL version and any advertised
64 // extensions.
65 bool validate() const;
66
67#if GR_GL_CHECK_ERROR
68 GrGLenum checkError(const char* location, const char* call) const;
69 bool checkAndResetOOMed() const;
70 void suppressErrorLogging();
71#endif
72
73#if defined(GR_TEST_UTILS)
74 GrGLInterface(const GrGLInterface& that)
75 : fStandard(that.fStandard)
76 , fExtensions(that.fExtensions)
77 , fFunctions(that.fFunctions) {}
78#endif
79
80 // Indicates the type of GL implementation
83
84 bool hasExtension(const char ext[]) const { return fExtensions.has(ext); }
85
86 /**
87 * The function pointers are in a struct so that we can have a compiler generated assignment
88 * operator.
89 */
90 struct Functions {
221
222 // On OpenGL ES there are multiple incompatible extensions that add support for MSAA
223 // and ES3 adds MSAA support to the standard. On an ES3 driver we may still use the
224 // older extensions for performance reasons or due to ES3 driver bugs. We want the function
225 // that creates the GrGLInterface to provide all available functions and internally
226 // we will select among them. They all have a method called glRenderbufferStorageMultisample*.
227 // So we have separate function pointers for GL_IMG/EXT_multisampled_to_texture,
228 // GL_CHROMIUM/ANGLE_framebuffer_multisample/ES3, and GL_APPLE_framebuffer_multisample
229 // variations.
230 //
231 // If a driver supports multiple GL_ARB_framebuffer_multisample-style extensions then we will
232 // assume the function pointers for the standard (or equivalent GL_ARB) version have
233 // been preferred over GL_EXT, GL_CHROMIUM, or GL_ANGLE variations that have reduced
234 // functionality.
235
236 // GL_EXT_multisampled_render_to_texture (preferred) or GL_IMG_multisampled_render_to_texture
238 // GL_APPLE_framebuffer_multisample
240
241 // This is used to store the pointer for GL_ARB/EXT/ANGLE/CHROMIUM_framebuffer_multisample or
242 // the standard function in ES3+ or GL 3.0+.
244
245 // Pointer to BindUniformLocationCHROMIUM from the GL_CHROMIUM_bind_uniform_location extension.
247
304
305 /* ARB_sync */
311
312 /* ARB_internalforamt_query */
314
315 /* KHR_debug */
323
324 /* EXT_window_rectangles */
326
327 /* GL_QCOM_tiled_rendering */
330 } fFunctions;
331
332#if defined(GR_TEST_UTILS)
333 // This exists for internal testing.
334 virtual void abandon() const;
335#endif
336};
337
338#endif
SK_API sk_sp< const GrGLInterface > GrGLMakeNativeInterface()
void(* GrGLFuncPtr)()
GrGLStandard
Definition GrGLTypes.h:19
unsigned int GrGLenum
Definition GrGLTypes.h:102
#define SK_API
Definition SkAPI.h:35
bool has(const char[]) const
GrGLFunction< GrGLGetQueryObjectuivFn > fGetQueryObjectuiv
GrGLFunction< GrGLBufferSubDataFn > fBufferSubData
GrGLFunction< GrGLEnableVertexAttribArrayFn > fEnableVertexAttribArray
GrGLFunction< GrGLGenerateMipmapFn > fGenerateMipmap
GrGLFunction< GrGLBindSamplerFn > fBindSampler
GrGLFunction< GrGLDisableFn > fDisable
GrGLFunction< GrGLGetQueryObjectivFn > fGetQueryObjectiv
GrGLFunction< GrGLBlitFramebufferFn > fBlitFramebuffer
GrGLFunction< GrGLBlendBarrierFn > fBlendBarrier
GrGLFunction< GrGLEndTilingFn > fEndTiling
GrGLFunction< GrGLDrawElementsIndirectFn > fDrawElementsIndirect
GrGLFunction< GrGLDrawElementsFn > fDrawElements
GrGLFunction< GrGLMapBufferSubDataFn > fMapBufferSubData
GrGLFunction< GrGLBeginQueryFn > fBeginQuery
GrGLFunction< GrGLVertexAttrib2fvFn > fVertexAttrib2fv
GrGLFunction< GrGLSamplerParameterfFn > fSamplerParameterf
GrGLFunction< GrGLDiscardFramebufferFn > fDiscardFramebuffer
GrGLFunction< GrGLUniform3fvFn > fUniform3fv
GrGLFunction< GrGLClearTexImageFn > fClearTexImage
GrGLFunction< GrGLBlendColorFn > fBlendColor
GrGLFunction< GrGLDepthMaskFn > fDepthMask
GrGLFunction< GrGLClientWaitSyncFn > fClientWaitSync
GrGLFunction< GrGLGetBufferParameterivFn > fGetBufferParameteriv
GrGLFunction< GrGLUnmapBufferFn > fUnmapBuffer
GrGLFunction< GrGLIsSyncFn > fIsSync
GrGLFunction< GrGLClearTexSubImageFn > fClearTexSubImage
GrGLFunction< GrGLInvalidateTexSubImageFn > fInvalidateTexSubImage
GrGLFunction< GrGLInvalidateBufferDataFn > fInvalidateBufferData
GrGLFunction< GrGLFramebufferRenderbufferFn > fFramebufferRenderbuffer
GrGLFunction< GrGLGetShaderivFn > fGetShaderiv
GrGLFunction< GrGLQueryCounterFn > fQueryCounter
GrGLFunction< GrGLMultiDrawElementsInstancedBaseVertexBaseInstanceFn > fMultiDrawElementsInstancedBaseVertexBaseInstance
GrGLFunction< GrGLPixelStoreiFn > fPixelStorei
GrGLFunction< GrGLCreateProgramFn > fCreateProgram
GrGLFunction< GrGLUniform4fvFn > fUniform4fv
GrGLFunction< GrGLFinishFenceFn > fFinishFence
GrGLFunction< GrGLUniform3fFn > fUniform3f
GrGLFunction< GrGLGetUniformLocationFn > fGetUniformLocation
GrGLFunction< GrGLTexSubImage2DFn > fTexSubImage2D
GrGLFunction< GrGLMultiDrawElementsIndirectFn > fMultiDrawElementsIndirect
GrGLFunction< GrGLInvalidateSubFramebufferFn > fInvalidateSubFramebuffer
GrGLFunction< GrGLDrawRangeElementsFn > fDrawRangeElements
GrGLFunction< GrGLActiveTextureFn > fActiveTexture
GrGLFunction< GrGLReadPixelsFn > fReadPixels
GrGLFunction< GrGLVertexAttrib4fvFn > fVertexAttrib4fv
GrGLFunction< GrGLAttachShaderFn > fAttachShader
GrGLFunction< GrGLRenderbufferStorageMultisampleFn > fRenderbufferStorageMultisampleES2EXT
GrGLFunction< GrGLVertexAttribIPointerFn > fVertexAttribIPointer
GrGLFunction< GrGLMultiDrawArraysIndirectFn > fMultiDrawArraysIndirect
GrGLFunction< GrGLRenderbufferStorageMultisampleFn > fRenderbufferStorageMultisampleES2APPLE
GrGLFunction< GrGLBindFragDataLocationIndexedFn > fBindFragDataLocationIndexed
GrGLFunction< GrGLUniform2ivFn > fUniform2iv
GrGLFunction< GrGLShaderSourceFn > fShaderSource
GrGLFunction< GrGLPatchParameteriFn > fPatchParameteri
GrGLFunction< GrGLVertexAttrib3fvFn > fVertexAttrib3fv
GrGLFunction< GrGLCompileShaderFn > fCompileShader
GrGLFunction< GrGLRenderbufferStorageFn > fRenderbufferStorage
GrGLFunction< GrGLTexImage2DFn > fTexImage2D
GrGLFunction< GrGLPopDebugGroupFn > fPopDebugGroup
GrGLFunction< GrGLLinkProgramFn > fLinkProgram
GrGLFunction< GrGLGetErrorFn > fGetError
GrGLFunction< GrGLTexBufferFn > fTexBuffer
GrGLFunction< GrGLResolveMultisampleFramebufferFn > fResolveMultisampleFramebuffer
GrGLFunction< GrGLGetShaderInfoLogFn > fGetShaderInfoLog
GrGLFunction< GrGLDebugMessageCallbackFn > fDebugMessageCallback
GrGLFunction< GrGLInvalidateBufferSubDataFn > fInvalidateBufferSubData
GrGLFunction< GrGLUniformMatrix2fvFn > fUniformMatrix2fv
GrGLFunction< GrGLCullFaceFn > fCullFace
GrGLFunction< GrGLGenQueriesFn > fGenQueries
GrGLFunction< GrGLCopyBufferSubDataFn > fCopyBufferSubData
GrGLFunction< GrGLUniform2fFn > fUniform2f
GrGLFunction< GrGLUniform1fvFn > fUniform1fv
GrGLFunction< GrGLDrawElementsInstancedBaseVertexBaseInstanceFn > fDrawElementsInstancedBaseVertexBaseInstance
GrGLFunction< GrGLBindFragDataLocationFn > fBindFragDataLocation
GrGLFunction< GrGLUniform4ivFn > fUniform4iv
GrGLFunction< GrGLMapTexSubImage2DFn > fMapTexSubImage2D
GrGLFunction< GrGLDeleteVertexArraysFn > fDeleteVertexArrays
GrGLFunction< GrGLUseProgramFn > fUseProgram
GrGLFunction< GrGLDebugMessageInsertFn > fDebugMessageInsert
GrGLFunction< GrGLReadBufferFn > fReadBuffer
GrGLFunction< GrGLFrontFaceFn > fFrontFace
GrGLFunction< GrGLInvalidateFramebufferFn > fInvalidateFramebuffer
GrGLFunction< GrGLViewportFn > fViewport
GrGLFunction< GrGLTexParameterivFn > fTexParameteriv
GrGLFunction< GrGLStencilOpFn > fStencilOp
GrGLFunction< GrGLStencilOpSeparateFn > fStencilOpSeparate
GrGLFunction< GrGLTexBufferRangeFn > fTexBufferRange
GrGLFunction< GrGLGenFencesFn > fGenFences
GrGLFunction< GrGLDeleteTexturesFn > fDeleteTextures
GrGLFunction< GrGLEnableFn > fEnable
GrGLFunction< GrGLUniform2iFn > fUniform2i
GrGLFunction< GrGLGenSamplersFn > fGenSamplers
GrGLFunction< GrGLMapBufferFn > fMapBuffer
GrGLFunction< GrGLStencilFuncFn > fStencilFunc
GrGLFunction< GrGLDeleteFramebuffersFn > fDeleteFramebuffers
GrGLFunction< GrGLGenBuffersFn > fGenBuffers
GrGLFunction< GrGLDeleteSyncFn > fDeleteSync
GrGLFunction< GrGLMultiDrawArraysInstancedBaseInstanceFn > fMultiDrawArraysInstancedBaseInstance
GrGLFunction< GrGLDrawArraysInstancedFn > fDrawArraysInstanced
GrGLFunction< GrGLDrawElementsInstancedFn > fDrawElementsInstanced
GrGLFunction< GrGLUniform3iFn > fUniform3i
GrGLFunction< GrGLDeleteProgramFn > fDeleteProgram
GrGLFunction< GrGLIsTextureFn > fIsTexture
GrGLFunction< GrGLGetMultisamplefvFn > fGetMultisamplefv
GrGLFunction< GrGLDeleteShaderFn > fDeleteShader
GrGLFunction< GrGLStencilMaskSeparateFn > fStencilMaskSeparate
GrGLFunction< GrGLUniform1ivFn > fUniform1iv
GrGLFunction< GrGLDrawBufferFn > fDrawBuffer
GrGLFunction< GrGLPolygonModeFn > fPolygonMode
GrGLFunction< GrGLCopyTexSubImage2DFn > fCopyTexSubImage2D
GrGLFunction< GrGLStencilFuncSeparateFn > fStencilFuncSeparate
GrGLFunction< GrGLUnmapBufferSubDataFn > fUnmapBufferSubData
GrGLFunction< GrGLGetIntegervFn > fGetIntegerv
GrGLFunction< GrGLObjectLabelFn > fObjectLabel
GrGLFunction< GrGLFramebufferTexture2DFn > fFramebufferTexture2D
GrGLFunction< GrGLUniform2fvFn > fUniform2fv
GrGLFunction< GrGLTexParameteriFn > fTexParameteri
GrGLFunction< GrGLFlushMappedBufferRangeFn > fFlushMappedBufferRange
GrGLFunction< GrGLBufferDataFn > fBufferData
GrGLFunction< GrGLGetShaderPrecisionFormatFn > fGetShaderPrecisionFormat
GrGLFunction< GrGLVertexAttrib1fFn > fVertexAttrib1f
GrGLFunction< GrGLMapBufferRangeFn > fMapBufferRange
GrGLFunction< GrGLDeleteBuffersFn > fDeleteBuffers
GrGLFunction< GrGLScissorFn > fScissor
GrGLFunction< GrGLUniformMatrix3fvFn > fUniformMatrix3fv
GrGLFunction< GrGLBlendEquationFn > fBlendEquation
GrGLFunction< GrGLProgramBinaryFn > fProgramBinary
GrGLFunction< GrGLClearStencilFn > fClearStencil
GrGLFunction< GrGLGenVertexArraysFn > fGenVertexArrays
GrGLFunction< GrGLGetFramebufferAttachmentParameterivFn > fGetFramebufferAttachmentParameteriv
GrGLFunction< GrGLUniform4fFn > fUniform4f
GrGLFunction< GrGLGetProgramivFn > fGetProgramiv
GrGLFunction< GrGLGetFloatvFn > fGetFloatv
GrGLFunction< GrGLCompressedTexImage2DFn > fCompressedTexImage2D
GrGLFunction< GrGLGetDebugMessageLogFn > fGetDebugMessageLog
GrGLFunction< GrGLFenceSyncFn > fFenceSync
GrGLFunction< GrGLInsertEventMarkerFn > fInsertEventMarker
GrGLFunction< GrGLProgramParameteriFn > fProgramParameteri
GrGLFunction< GrGLBindVertexArrayFn > fBindVertexArray
GrGLFunction< GrGLBlendFuncFn > fBlendFunc
GrGLFunction< GrGLGetQueryObjectui64vFn > fGetQueryObjectui64v
GrGLFunction< GrGLGetProgramBinaryFn > fGetProgramBinary
GrGLFunction< GrGLBindTextureFn > fBindTexture
GrGLFunction< GrGLGetQueryivFn > fGetQueryiv
GrGLFunction< GrGLFramebufferTexture2DMultisampleFn > fFramebufferTexture2DMultisample
GrGLFunction< GrGLBindRenderbufferFn > fBindRenderbuffer
GrGLFunction< GrGLDrawBuffersFn > fDrawBuffers
GrGLFunction< GrGLColorMaskFn > fColorMask
GrGLFunction< GrGLTextureBarrierFn > fTextureBarrier
GrGLFunction< GrGLDeleteFencesFn > fDeleteFences
GrGLFunction< GrGLDeleteQueriesFn > fDeleteQueries
GrGLFunction< GrGLPopGroupMarkerFn > fPopGroupMarker
GrGLFunction< GrGLTexStorage2DFn > fTexStorage2D
GrGLFunction< GrGLBindFramebufferFn > fBindFramebuffer
GrGLFunction< GrGLDeleteRenderbuffersFn > fDeleteRenderbuffers
GrGLFunction< GrGLCheckFramebufferStatusFn > fCheckFramebufferStatus
GrGLFunction< GrGLInvalidateTexImageFn > fInvalidateTexImage
GrGLFunction< GrGLDrawArraysInstancedBaseInstanceFn > fDrawArraysInstancedBaseInstance
GrGLFunction< GrGLVertexAttribDivisorFn > fVertexAttribDivisor
GrGLFunction< GrGLClearColorFn > fClearColor
GrGLFunction< GrGLGenFramebuffersFn > fGenFramebuffers
GrGLFunction< GrGLCompressedTexSubImage2DFn > fCompressedTexSubImage2D
GrGLFunction< GrGLUniform4iFn > fUniform4i
GrGLFunction< GrGLGetProgramInfoLogFn > fGetProgramInfoLog
GrGLFunction< GrGLRenderbufferStorageMultisampleFn > fRenderbufferStorageMultisample
GrGLFunction< GrGLGetQueryObjecti64vFn > fGetQueryObjecti64v
GrGLFunction< GrGLGetStringFn > fGetString
GrGLFunction< GrGLBindAttribLocationFn > fBindAttribLocation
GrGLFunction< GrGLStencilMaskFn > fStencilMask
GrGLFunction< GrGLGetRenderbufferParameterivFn > fGetRenderbufferParameteriv
GrGLFunction< GrGLBindBufferFn > fBindBuffer
GrGLFunction< GrGLDrawArraysIndirectFn > fDrawArraysIndirect
GrGLFunction< GrGLGetStringiFn > fGetStringi
GrGLFunction< GrGLTexParameterfFn > fTexParameterf
GrGLFunction< GrGLGenRenderbuffersFn > fGenRenderbuffers
GrGLFunction< GrGLUniform1fFn > fUniform1f
GrGLFunction< GrGLWindowRectanglesFn > fWindowRectangles
GrGLFunction< GrGLDeleteSamplersFn > fDeleteSamplers
GrGLFunction< GrGLUniform3ivFn > fUniform3iv
GrGLFunction< GrGLSetFenceFn > fSetFence
GrGLFunction< GrGLGetTexLevelParameterivFn > fGetTexLevelParameteriv
GrGLFunction< GrGLBindUniformLocationFn > fBindUniformLocation
GrGLFunction< GrGLSamplerParameteriFn > fSamplerParameteri
GrGLFunction< GrGLFinishFn > fFinish
GrGLFunction< GrGLDrawArraysFn > fDrawArrays
GrGLFunction< GrGLDisableVertexAttribArrayFn > fDisableVertexAttribArray
GrGLFunction< GrGLTexParameterfvFn > fTexParameterfv
GrGLFunction< GrGLTestFenceFn > fTestFence
GrGLFunction< GrGLDebugMessageControlFn > fDebugMessageControl
GrGLFunction< GrGLUniform1iFn > fUniform1i
GrGLFunction< GrGLFlushFn > fFlush
GrGLFunction< GrGLCreateShaderFn > fCreateShader
GrGLFunction< GrGLLineWidthFn > fLineWidth
GrGLFunction< GrGLPushGroupMarkerFn > fPushGroupMarker
GrGLFunction< GrGLPushDebugGroupFn > fPushDebugGroup
GrGLFunction< GrGLUnmapTexSubImage2DFn > fUnmapTexSubImage2D
GrGLFunction< GrGLClearFn > fClear
GrGLFunction< GrGLSamplerParameterivFn > fSamplerParameteriv
GrGLFunction< GrGLWaitSyncFn > fWaitSync
GrGLFunction< GrGLGetInternalformativFn > fGetInternalformativ
GrGLFunction< GrGLGenTexturesFn > fGenTextures
GrGLFunction< GrGLUniformMatrix4fvFn > fUniformMatrix4fv
GrGLFunction< GrGLStartTilingFn > fStartTiling
GrGLFunction< GrGLMemoryBarrierFn > fMemoryBarrier
GrGLFunction< GrGLEndQueryFn > fEndQuery
GrGLFunction< GrGLVertexAttribPointerFn > fVertexAttribPointer
bool hasExtension(const char ext[]) const
struct GrGLInterface::Functions fFunctions
GrGLExtensions fExtensions
GrGLStandard fStandard