Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
GrSurface Class Referenceabstract

#include <GrSurface.h>

Inheritance diagram for GrSurface:
GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrAttachment GrRenderTarget GrTexture GrD3DAttachment GrGLAttachment GrMockAttachment GrMtlAttachment GrVkImage GrD3DRenderTarget GrGLRenderTarget GrMockRenderTarget GrMtlRenderTarget GrVkRenderTarget GrD3DTexture GrGLTexture GrMockTexture GrMtlTexture GrVkTexture

Classes

class  RefCntedReleaseProc
 

Public Types

typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Public Member Functions

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

Private Member Functions

virtual void onSetRelease (sk_sp< RefCntedReleaseProc >)
 

Detailed Description

Definition at line 22 of file GrSurface.h.

Member Typedef Documentation

◆ ReleaseCtx

typedef void* GrSurface::ReleaseCtx

Definition at line 50 of file GrSurface.h.

◆ ReleaseProc

typedef void(* GrSurface::ReleaseProc) (ReleaseCtx)

Definition at line 51 of file GrSurface.h.

Constructor & Destructor Documentation

◆ GrSurface()

GrSurface::GrSurface ( GrGpu gpu,
const SkISize dimensions,
skgpu::Protected  isProtected,
std::string_view  label 
)
inlineprotected

Definition at line 140 of file GrSurface.h.

144 : INHERITED(gpu, label)
145 , fDimensions(dimensions)
146 , fSurfaceFlags(GrInternalSurfaceFlags::kNone)
147 , fIsProtected(isProtected) {}
SkISize dimensions() const
Definition: GrSurface.h:27
bool isProtected() const
Definition: GrSurface.h:87

◆ ~GrSurface()

GrSurface::~GrSurface ( )
inlineoverrideprotected

Definition at line 149 of file GrSurface.h.

149 {
150 // check that invokeReleaseProc has been called (if needed)
151 SkASSERT(!fReleaseHelper);
152 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

Member Function Documentation

◆ asRenderTarget() [1/2]

virtual GrRenderTarget * GrSurface::asRenderTarget ( )
inlinevirtual
Returns
the render target underlying this surface, may be null.

Reimplemented in GrRenderTarget, and GrMockTextureRenderTarget.

Definition at line 65 of file GrSurface.h.

65{ return nullptr; }

◆ asRenderTarget() [2/2]

virtual const GrRenderTarget * GrSurface::asRenderTarget ( ) const
inlinevirtual

Reimplemented in GrRenderTarget, and GrMockTextureRenderTarget.

Definition at line 66 of file GrSurface.h.

66{ return nullptr; }

◆ asTexture() [1/2]

virtual GrTexture * GrSurface::asTexture ( )
inlinevirtual
Returns
the texture associated with the surface, may be null.

Reimplemented in GrTexture, and GrMockTextureRenderTarget.

Definition at line 59 of file GrSurface.h.

59{ return nullptr; }

◆ asTexture() [2/2]

virtual const GrTexture * GrSurface::asTexture ( ) const
inlinevirtual

Reimplemented in GrTexture, and GrMockTextureRenderTarget.

Definition at line 60 of file GrSurface.h.

60{ return nullptr; }

◆ backendFormat()

virtual GrBackendFormat GrSurface::backendFormat ( ) const
pure virtual

◆ ComputeSize()

size_t GrSurface::ComputeSize ( const GrBackendFormat format,
SkISize  dimensions,
int  colorSamplesPerPixel,
skgpu::Mipmapped  mipmapped,
bool  binSize = false 
)
static

Definition at line 21 of file GrSurface.cpp.

25 {
26 // For external formats we do not actually know the real size of the resource so we just return
27 // 0 here to indicate this.
28 if (format.textureType() == GrTextureType::kExternal) {
29 return 0;
30 }
31
32 size_t colorSize;
33
34 if (binSize) {
36 }
37
39 if (compressionType != SkTextureCompressionType::kNone) {
41 compressionType, dimensions, mipmapped == skgpu::Mipmapped::kYes);
42 } else {
43 colorSize = (size_t)dimensions.width() * dimensions.height() *
45 }
46 SkASSERT(colorSize > 0);
47
48 size_t finalSize = colorSamplesPerPixel * colorSize;
49
50 if (skgpu::Mipmapped::kYes == mipmapped) {
51 // We don't have to worry about the mipmaps being a different dimensions than
52 // we'd expect because we never change fDesc.fWidth/fHeight.
53 finalSize += colorSize/3;
54 }
55 return finalSize;
56}
size_t GrBackendFormatBytesPerPixel(const GrBackendFormat &format)
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
size_t SkCompressedFormatDataSize(SkTextureCompressionType compressionType, SkISize dimensions, bool mipmapped)
SkTextureCompressionType
uint32_t uint32_t * format
SkISize GetApproxSize(SkISize size)
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ dimensions()

SkISize GrSurface::dimensions ( ) const
inline

Retrieves the dimensions of the surface.

Definition at line 27 of file GrSurface.h.

27{ return fDimensions; }

◆ flags()

GrInternalSurfaceFlags GrSurface::flags ( ) const
inline

Definition at line 68 of file GrSurface.h.

68{ return fSurfaceFlags; }

◆ framebufferOnly()

bool GrSurface::framebufferOnly ( ) const
inline

Definition at line 82 of file GrSurface.h.

82 {
83 return fSurfaceFlags & GrInternalSurfaceFlags::kFramebufferOnly;
84 }

◆ getBoundsRect()

SkRect GrSurface::getBoundsRect ( ) const
inline

Helper that gets the width and height of the surface as a bounding rectangle.

Definition at line 42 of file GrSurface.h.

42{ return SkRect::Make(this->dimensions()); }
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ glRTFBOIDis0()

bool GrSurface::glRTFBOIDis0 ( ) const
inlineprotected

Definition at line 117 of file GrSurface.h.

117 {
118 return fSurfaceFlags & GrInternalSurfaceFlags::kGLRTFBOIDIs0;
119 }

◆ height()

int GrSurface::height ( ) const
inline

Retrieves the height of the surface.

Definition at line 37 of file GrSurface.h.

37{ return fDimensions.height(); }

◆ isProtected()

bool GrSurface::isProtected ( ) const
inline

Definition at line 87 of file GrSurface.h.

87{ return fIsProtected == skgpu::Protected::kYes; }

◆ onAbandon()

void GrSurface::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.

Reimplemented in GrMockTexture, GrMtlAttachment, GrMtlRenderTarget, GrMtlTexture, GrMtlTextureRenderTarget, GrVkRenderTarget, GrVkTexture, and GrVkTextureRenderTarget.

Definition at line 86 of file GrSurface.cpp.

86 {
87 this->invokeReleaseProc();
89}
virtual void onAbandon()

◆ onRelease()

void GrSurface::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Reimplemented in GrMockTexture, GrMtlAttachment, GrMtlRenderTarget, GrMtlTexture, GrMtlTextureRenderTarget, GrVkRenderTarget, GrVkTexture, and GrVkTextureRenderTarget.

Definition at line 81 of file GrSurface.cpp.

81 {
82 this->invokeReleaseProc();
84}
virtual void onRelease()

◆ onSetRelease()

virtual void GrSurface::onSetRelease ( sk_sp< RefCntedReleaseProc )
inlineprivatevirtual

Reimplemented in GrVkTexture.

Definition at line 164 of file GrSurface.h.

164{}

◆ readOnly()

bool GrSurface::readOnly ( ) const
inline

The pixel values of this surface cannot be modified (e.g. doesn't support write pixels or MIP map level regen).

Definition at line 80 of file GrSurface.h.

80{ return fSurfaceFlags & GrInternalSurfaceFlags::kReadOnly; }

◆ requiresManualMSAAResolve()

bool GrSurface::requiresManualMSAAResolve ( ) const
inlineprotected

Definition at line 126 of file GrSurface.h.

126 {
128 }

◆ setFramebufferOnly()

void GrSurface::setFramebufferOnly ( )
inline

Definition at line 89 of file GrSurface.h.

89 {
90 SkASSERT(this->asRenderTarget());
92 }
virtual GrRenderTarget * asRenderTarget()
Definition: GrSurface.h:65

◆ setGLRTFBOIDIs0()

void GrSurface::setGLRTFBOIDIs0 ( )
inlineprotected

Definition at line 111 of file GrSurface.h.

111 {
113 SkASSERT(!this->asTexture());
114 SkASSERT(this->asRenderTarget());
116 }
virtual GrTexture * asTexture()
Definition: GrSurface.h:59
bool requiresManualMSAAResolve() const
Definition: GrSurface.h:126

◆ setReadOnly()

void GrSurface::setReadOnly ( )
inlineprotected

Definition at line 130 of file GrSurface.h.

130 {
131 SkASSERT(!this->asRenderTarget());
132 fSurfaceFlags |= GrInternalSurfaceFlags::kReadOnly;
133 }

◆ setRelease() [1/2]

void GrSurface::setRelease ( ReleaseProc  proc,
ReleaseCtx  ctx 
)
inline

Definition at line 52 of file GrSurface.h.

52 {
54 }
void setRelease(sk_sp< skgpu::RefCntedCallback > releaseHelper)
Definition: GrSurface.cpp:60
static sk_sp< RefCntedCallback > Make(Callback proc, Context ctx)

◆ setRelease() [2/2]

void GrSurface::setRelease ( sk_sp< skgpu::RefCntedCallback releaseHelper)

Definition at line 60 of file GrSurface.cpp.

60 {
61 SkASSERT(this->getContext());
62 fReleaseHelper.reset(new RefCntedReleaseProc(std::move(releaseHelper),
63 sk_ref_sp(this->getContext())));
64 this->onSetRelease(fReleaseHelper);
65}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
const GrDirectContext * getContext() const
virtual void onSetRelease(sk_sp< RefCntedReleaseProc >)
Definition: GrSurface.h:164

◆ setRequiresManualMSAAResolve()

void GrSurface::setRequiresManualMSAAResolve ( )
inlineprotected

Definition at line 121 of file GrSurface.h.

121 {
122 SkASSERT(!this->glRTFBOIDis0());
123 SkASSERT(this->asRenderTarget());
125 }
bool glRTFBOIDis0() const
Definition: GrSurface.h:117

◆ setVkRTSupportsInputAttachment()

void GrSurface::setVkRTSupportsInputAttachment ( )
inlineprotected

Definition at line 135 of file GrSurface.h.

◆ width()

int GrSurface::width ( ) const
inline

Retrieves the width of the surface.

Definition at line 32 of file GrSurface.h.

32{ return fDimensions.width(); }

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