Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
GrGLAttachment Class Reference

#include <GrGLAttachment.h>

Inheritance diagram for GrGLAttachment:
GrAttachment GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable

Public Member Functions

GrBackendFormat backendFormat () const override
 
GrGLuint renderbufferID () const
 
GrGLFormat format () const
 
- Public Member Functions inherited from GrAttachment
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (UsageFlags)
 
 ~GrAttachment () override
 
UsageFlags supportedUsages () const
 
int numSamples () const
 
skgpu::Mipmapped mipmapped () const
 
bool hasPerformedInitialClear () const
 
void markHasPerformedInitialClear ()
 
- Public Member Functions inherited from GrSurface
SkISize dimensions () const
 
int width () const
 
int height () const
 
SkRect getBoundsRect () const
 
virtual GrBackendFormat backendFormat () const =0
 
void setRelease (sk_sp< skgpu::RefCntedCallback > releaseHelper)
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
virtual GrTextureasTexture ()
 
virtual const GrTextureasTexture () const
 
virtual GrRenderTargetasRenderTarget ()
 
virtual const GrRenderTargetasRenderTarget () const
 
GrInternalSurfaceFlags flags () const
 
bool readOnly () const
 
bool framebufferOnly () const
 
bool isProtected () const
 
void setFramebufferOnly ()
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 
const GrDirectContextgetContext () const
 
GrDirectContextgetContext ()
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
const skgpu::UniqueKeygetUniqueKey () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ProxyAccess proxyAccess ()
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual const char * getResourceType () const =0
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
bool unique () const
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

static sk_sp< GrGLAttachmentMakeStencil (GrGLGpu *gpu, SkISize dimensions, int sampleCnt, GrGLFormat format)
 
static sk_sp< GrGLAttachmentMakeMSAA (GrGLGpu *gpu, SkISize dimensions, int sampleCnt, GrGLFormat format)
 
static sk_sp< GrGLAttachmentMakeWrappedRenderBuffer (GrGpu *gpu, GrGLuint renderbufferID, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, GrGLFormat format)
 
- Static Public Member Functions inherited from GrAttachment
static void ComputeSharedAttachmentUniqueKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, GrMemoryless memoryless, skgpu::UniqueKey *key)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected, GrMemoryless, skgpu::ScratchKey *key)
 
- Static Public Member Functions inherited from GrSurface
static size_t ComputeSize (const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
 
- Static Public Member Functions inherited from GrGpuResource
static uint32_t CreateUniqueID ()
 

Protected Member Functions

void onRelease () override
 
void onAbandon () override
 
void setMemoryBacking (SkTraceMemoryDump *traceMemoryDump, const SkString &dumpName) const override
 
- Protected Member Functions inherited from GrAttachment
 GrAttachment (GrGpu *gpu, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, std::string_view label, GrMemoryless memoryless=GrMemoryless::kNo)
 
- Protected Member Functions inherited from GrSurface
void setGLRTFBOIDIs0 ()
 
bool glRTFBOIDis0 () const
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
void setReadOnly ()
 
void setVkRTSupportsInputAttachment ()
 
 GrSurface (GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
 
 ~GrSurface () override
 
void onRelease () override
 
void onAbandon () override
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (skgpu::Budgeted)
 
void registerWithCacheWrapped (GrWrapCacheable)
 
 GrGpuResource (GrGpu *, std::string_view label)
 
virtual ~GrGpuResource ()
 
GrGpugetGpu () const
 
virtual void onRelease ()
 
virtual void onAbandon ()
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 
SkString getResourceName () const
 
void dumpMemoryStatisticsPriv (SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
 GrIORef ()
 
bool internalHasRef () const
 
bool internalHasNoCommandBufferUsages () const
 
void addInitialRef () const
 

Additional Inherited Members

- Public Types inherited from GrAttachment
enum class  UsageFlags : uint8_t { kStencilAttachment = 0x1 , kColorAttachment = 0x2 , kTexture = 0x4 }
 
- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Detailed Description

Definition at line 16 of file GrGLAttachment.h.

Member Function Documentation

◆ backendFormat()

GrBackendFormat GrGLAttachment::backendFormat ( ) const
overridevirtual

Implements GrSurface.

Definition at line 138 of file GrGLAttachment.cpp.

138 {
140}
#define GR_GL_TEXTURE_NONE
Definition: GrGLDefines.h:151
static constexpr GrGLenum GrGLFormatToEnum(GrGLFormat format)
Definition: GrGLUtil.h:445
SK_API GrBackendFormat MakeGL(GrGLenum format, GrGLenum target)

◆ format()

GrGLFormat GrGLAttachment::format ( ) const
inline

Definition at line 43 of file GrGLAttachment.h.

43{ return fFormat; }

◆ MakeMSAA()

sk_sp< GrGLAttachment > GrGLAttachment::MakeMSAA ( GrGLGpu gpu,
SkISize  dimensions,
int  sampleCnt,
GrGLFormat  format 
)
static

Definition at line 93 of file GrGLAttachment.cpp.

96 {
97 GrGLuint rbID = 0;
98
99 GL_CALL(GenRenderbuffers(1, &rbID));
100 if (!rbID) {
101 return nullptr;
102 }
103 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, rbID));
106 gpu, sampleCnt, glFmt, dimensions.width(), dimensions.height())) {
107 GL_CALL(DeleteRenderbuffers(1, &rbID));
108 return nullptr;
109 }
110
112 rbID,
115 sampleCnt,
116 format,
117 /*label=*/"GLAttachmentMakeMSAA"));
118}
static bool renderbuffer_storage_msaa(GrGLGpu *gpu, int sampleCount, GrGLenum format, int width, int height)
#define GL_CALL(X)
#define GR_GL_RENDERBUFFER
Definition: GrGLDefines.h:903
unsigned int GrGLuint
Definition: GrGLTypes.h:113
unsigned int GrGLenum
Definition: GrGLTypes.h:102
GrGLFormat format() const
GrGLenum getRenderbufferInternalFormat(GrGLFormat format) const
Definition: GrGLCaps.h:247
const GrGLCaps & glCaps() const
Definition: GrGLGpu.h:108
SkISize dimensions() const
Definition: GrSurface.h:27
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ MakeStencil()

sk_sp< GrGLAttachment > GrGLAttachment::MakeStencil ( GrGLGpu gpu,
SkISize  dimensions,
int  sampleCnt,
GrGLFormat  format 
)
static

Definition at line 55 of file GrGLAttachment.cpp.

58 {
59 GrGLuint rbID = 0;
60
61 GL_CALL(GenRenderbuffers(1, &rbID));
62 if (!rbID) {
63 return nullptr;
64 }
65 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, rbID));
67 // we do this "if" so that we don't call the multisample
68 // version on a GL that doesn't have an MSAA extension.
69 if (sampleCnt > 1) {
70 if (!renderbuffer_storage_msaa(gpu, sampleCnt, glFmt, dimensions.width(),
71 dimensions.height())) {
72 GL_CALL(DeleteRenderbuffers(1, &rbID));
73 return nullptr;
74 }
75 } else {
76 GrGLenum error = GL_ALLOC_CALL(RenderbufferStorage(
78 if (error != GR_GL_NO_ERROR) {
79 GL_CALL(DeleteRenderbuffers(1, &rbID));
80 return nullptr;
81 }
82 }
83
85 rbID,
88 sampleCnt,
89 format,
90 /*label=*/"GLAttachmentMakeStencil"));
91}
#define GL_ALLOC_CALL(call)
#define GR_GL_NO_ERROR
Definition: GrGLDefines.h:175
const uint8_t uint32_t uint32_t GError ** error

◆ MakeWrappedRenderBuffer()

static sk_sp< GrGLAttachment > GrGLAttachment::MakeWrappedRenderBuffer ( GrGpu gpu,
GrGLuint  renderbufferID,
SkISize  dimensions,
UsageFlags  supportedUsages,
int  sampleCnt,
GrGLFormat  format 
)
inlinestatic

Definition at line 28 of file GrGLAttachment.h.

33 {
36 /*label=*/"MakeWrappedRenderBuffer"));
37 }
UsageFlags supportedUsages() const
Definition: GrAttachment.h:36
GrGLuint renderbufferID() const

◆ onAbandon()

void GrGLAttachment::onAbandon ( )
overrideprotectedvirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources. This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrGpuResource.

Definition at line 132 of file GrGLAttachment.cpp.

132 {
133 fRenderbufferID = 0;
134
136}
void onAbandon() override
Definition: GrSurface.cpp:86

◆ onRelease()

void GrGLAttachment::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Definition at line 121 of file GrGLAttachment.cpp.

121 {
122 if (0 != fRenderbufferID) {
123 GrGLGpu* gpuGL = (GrGLGpu*)this->getGpu();
124 const GrGLInterface* gl = gpuGL->glInterface();
125 GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
126 fRenderbufferID = 0;
127 }
128
130}
#define GR_GL_CALL(IFACE, X)
Definition: GrGLUtil.h:381
const GrGLInterface * glInterface() const
Definition: GrGLGpu.h:103
GrGpu * getGpu() const
void onRelease() override
Definition: GrSurface.cpp:81
gl
Definition: malisc.py:41

◆ renderbufferID()

GrGLuint GrGLAttachment::renderbufferID ( ) const
inline

Definition at line 41 of file GrGLAttachment.h.

41{ return fRenderbufferID; }

◆ setMemoryBacking()

void GrGLAttachment::setMemoryBacking ( SkTraceMemoryDump ,
const SkString  
) const
overrideprotectedvirtual

Allows subclasses to add additional backing information to the SkTraceMemoryDump.

Reimplemented from GrGpuResource.

Definition at line 142 of file GrGLAttachment.cpp.

143 {
144 SkString renderbuffer_id;
145 renderbuffer_id.appendU32(this->renderbufferID());
146 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_renderbuffer", renderbuffer_id.c_str());
147}
void appendU32(uint32_t value)
Definition: SkString.h:210
const char * c_str() const
Definition: SkString.h:133

The documentation for this class was generated from the following files: