Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
GrRenderTarget Class Referenceabstract

#include <GrRenderTarget.h>

Inheritance diagram for GrRenderTarget:
GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrD3DRenderTarget GrGLRenderTarget GrMockRenderTarget GrMtlRenderTarget GrVkRenderTarget GrD3DTextureRenderTarget GrGLTextureRenderTarget GrMockTextureRenderTarget GrMtlTextureRenderTarget GrVkTextureRenderTarget

Public Member Functions

virtual bool alwaysClearStencil () const
 
GrRenderTargetasRenderTarget () override
 
const GrRenderTargetasRenderTarget () const override
 
int numSamples () const
 
virtual GrBackendRenderTarget getBackendRenderTarget () const =0
 
GrAttachmentgetStencilAttachment (bool useMSAASurface) const
 
GrAttachmentgetStencilAttachment () const
 
virtual bool canAttemptStencilAttachment (bool useMSAASurface) const =0
 
void attachStencilAttachment (sk_sp< GrAttachment > stencil, bool useMSAASurface)
 
int numStencilBits (bool useMSAASurface) const
 
int getSamplePatternKey ()
 
const skia_private::TArray< SkPoint > & getSampleLocations ()
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
- 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
 

Protected Member Functions

 GrRenderTarget (GrGpu *, const SkISize &, int sampleCount, GrProtected, std::string_view label, sk_sp< GrAttachment > stenicl=nullptr)
 
 ~GrRenderTarget () override
 
void onAbandon () override
 
void onRelease () override
 
- 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
 

Private Member Functions

virtual bool completeStencilAttachment (GrAttachment *stencil, bool useMSAASurface)=0
 

Additional Inherited Members

- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 
- 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 ()
 

Detailed Description

GrRenderTarget represents a 2D buffer of pixels that can be rendered to. A context's render target is set by setRenderTarget(). Render targets are created by a createTexture with the kRenderTarget_SurfaceFlag flag. Additionally, GrContext provides methods for creating GrRenderTargets that wrap externally created render targets.

Definition at line 26 of file GrRenderTarget.h.

Constructor & Destructor Documentation

◆ GrRenderTarget()

GrRenderTarget::GrRenderTarget ( GrGpu gpu,
const SkISize dimensions,
int  sampleCount,
GrProtected  isProtected,
std::string_view  label,
sk_sp< GrAttachment stenicl = nullptr 
)
protected

Definition at line 17 of file GrRenderTarget.cpp.

23 : INHERITED(gpu, dimensions, isProtected, label)
24 , fSampleCnt(sampleCount) {
25 if (this->numSamples() > 1) {
26 fMSAAStencilAttachment = std::move(stencil);
27 } else {
28 fStencilAttachment = std::move(stencil);
29 }
30}
int numSamples() const
SkISize dimensions() const
Definition: GrSurface.h:27
bool isProtected() const
Definition: GrSurface.h:87

◆ ~GrRenderTarget()

GrRenderTarget::~GrRenderTarget ( )
overrideprotecteddefault

Member Function Documentation

◆ alwaysClearStencil()

virtual bool GrRenderTarget::alwaysClearStencil ( ) const
inlinevirtual

Reimplemented in GrGLRenderTarget.

Definition at line 32 of file GrRenderTarget.h.

32{ return false; }

◆ asRenderTarget() [1/2]

const GrRenderTarget * GrRenderTarget::asRenderTarget ( ) const
inlineoverridevirtual

Reimplemented from GrSurface.

Reimplemented in GrMockTextureRenderTarget.

Definition at line 36 of file GrRenderTarget.h.

36{ return this; }

◆ asRenderTarget() [2/2]

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

Reimplemented from GrSurface.

Reimplemented in GrMockTextureRenderTarget.

Definition at line 35 of file GrRenderTarget.h.

35{ return this; }

◆ attachStencilAttachment()

void GrRenderTarget::attachStencilAttachment ( sk_sp< GrAttachment stencil,
bool  useMSAASurface 
)

Definition at line 48 of file GrRenderTarget.cpp.

48 {
49 auto stencilAttachment = (useMSAASurface) ? &GrRenderTarget::fMSAAStencilAttachment
50 : &GrRenderTarget::fStencilAttachment;
51 if (!stencil && !(this->*stencilAttachment)) {
52 // No need to do any work since we currently don't have a stencil attachment and
53 // we're not actually adding one.
54 return;
55 }
56
57 if (!this->completeStencilAttachment(stencil.get(), useMSAASurface)) {
58 return;
59 }
60
61 this->*stencilAttachment = std::move(stencil);
62}
virtual bool completeStencilAttachment(GrAttachment *stencil, bool useMSAASurface)=0
T * get() const
Definition: SkRefCnt.h:303

◆ canAttemptStencilAttachment()

virtual bool GrRenderTarget::canAttemptStencilAttachment ( bool  useMSAASurface) const
pure virtual

◆ completeStencilAttachment()

virtual bool GrRenderTarget::completeStencilAttachment ( GrAttachment stencil,
bool  useMSAASurface 
)
privatepure virtual

Implemented in GrMockRenderTarget.

◆ getBackendRenderTarget()

virtual GrBackendRenderTarget GrRenderTarget::getBackendRenderTarget ( ) const
pure virtual

◆ getSampleLocations()

const skia_private::TArray< SkPoint > & GrRenderTarget::getSampleLocations ( )

Retrieves the per-pixel HW sample locations for this render target, and, as a by-product, the actual number of samples in use. (This may differ from fSampleCnt.) Sample locations are returned as 0..1 offsets relative to the top-left corner of the pixel.

◆ getSamplePatternKey()

int GrRenderTarget::getSamplePatternKey ( )

Returns a unique key that identifies this render target's sample pattern. (Must be multisampled.)

◆ getStencilAttachment() [1/2]

GrAttachment * GrRenderTarget::getStencilAttachment ( ) const
inline

Definition at line 49 of file GrRenderTarget.h.

49 {
50 return getStencilAttachment(this->numSamples() > 1);
51 }
GrAttachment * getStencilAttachment() const

◆ getStencilAttachment() [2/2]

GrAttachment * GrRenderTarget::getStencilAttachment ( bool  useMSAASurface) const
inline

Definition at line 45 of file GrRenderTarget.h.

45 {
46 return (useMSAASurface) ? fMSAAStencilAttachment.get() : fStencilAttachment.get();
47 }

◆ numSamples()

int GrRenderTarget::numSamples ( ) const
inline

Returns the number of samples/pixel in the color buffer (One if non-MSAA).

Definition at line 41 of file GrRenderTarget.h.

41{ return fSampleCnt; }

◆ numStencilBits()

int GrRenderTarget::numStencilBits ( bool  useMSAASurface) const

Definition at line 64 of file GrRenderTarget.cpp.

64 {
65 return GrBackendFormatStencilBits(this->getStencilAttachment(useMSAASurface)->backendFormat());
66}
int GrBackendFormatStencilBits(const GrBackendFormat &format)
virtual GrBackendFormat backendFormat() const =0

◆ onAbandon()

void GrRenderTarget::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 GrMtlRenderTarget, GrMtlTextureRenderTarget, GrVkRenderTarget, and GrVkTextureRenderTarget.

Definition at line 41 of file GrRenderTarget.cpp.

41 {
42 fStencilAttachment = nullptr;
43 fMSAAStencilAttachment = nullptr;
44
46}
void onAbandon() override
Definition: GrSurface.cpp:86

◆ onRelease()

void GrRenderTarget::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Reimplemented in GrMtlRenderTarget, GrMtlTextureRenderTarget, GrVkRenderTarget, and GrVkTextureRenderTarget.

Definition at line 34 of file GrRenderTarget.cpp.

34 {
35 fStencilAttachment = nullptr;
36 fMSAAStencilAttachment = nullptr;
37
39}
void onRelease() override
Definition: GrSurface.cpp:81

◆ requiresManualMSAAResolve()

bool GrSurface::requiresManualMSAAResolve ( ) const
inline

Definition at line 126 of file GrSurface.h.

126 {
128 }

◆ setRequiresManualMSAAResolve()

void GrSurface::setRequiresManualMSAAResolve ( )
inline

Definition at line 121 of file GrSurface.h.

121 {
122 SkASSERT(!this->glRTFBOIDis0());
123 SkASSERT(this->asRenderTarget());
125 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
GrRenderTarget * asRenderTarget() override
bool glRTFBOIDis0() const
Definition: GrSurface.h:117

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