Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private 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
 
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
 
- 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
 
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
 

Private Member Functions

void onSetLabel () override
 

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
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 GR_GL_RENDERBUFFER
#define GL_CALL(X)
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
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
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}
virtual void onAbandon()

◆ 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
virtual void onRelease()

◆ onSetLabel()

void GrGLAttachment::onSetLabel ( )
overrideprivatevirtual

Reimplemented from GrAttachment.

Definition at line 149 of file GrGLAttachment.cpp.

149 {
150 SkASSERT(fRenderbufferID);
151 if (!this->getLabel().empty()) {
152 const std::string label = "_Skia_" + this->getLabel();
153 GrGLGpu* glGpu = static_cast<GrGLGpu*>(this->getGpu());
154 if (glGpu->glCaps().debugSupport()) {
155 GR_GL_CALL(glGpu->glInterface(),
156 ObjectLabel(GR_GL_TEXTURE, fRenderbufferID, -1, label.c_str()));
157 }
158 }
159}
#define GR_GL_TEXTURE
#define SkASSERT(cond)
Definition SkAssert.h:116
bool debugSupport() const
Is there support for GL_KHR_debug?
Definition GrGLCaps.h:359
std::string getLabel() const
EMSCRIPTEN_KEEPALIVE void empty()

◆ 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: