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
GrMtlAttachment Class Reference

#include <GrMtlAttachment.h>

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

Public Member Functions

 ~GrMtlAttachment () override
 
GrBackendFormat backendFormat () const override
 
MTLPixelFormat mtlFormat () const
 
id< MTLTexture > mtlTexture () const
 
unsigned int sampleCount () const
 
bool framebufferOnly () 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< GrMtlAttachmentMakeStencil (GrMtlGpu *gpu, SkISize dimensions, int sampleCnt, MTLPixelFormat format)
 
static sk_sp< GrMtlAttachmentMakeMSAA (GrMtlGpu *gpu, SkISize dimensions, int sampleCnt, MTLPixelFormat format)
 
static sk_sp< GrMtlAttachmentMakeTexture (GrMtlGpu *gpu, SkISize dimensions, MTLPixelFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted)
 
static sk_sp< GrMtlAttachmentMakeWrapped (GrMtlGpu *gpu, SkISize dimensions, id< MTLTexture >, UsageFlags attachmentUsages, GrWrapCacheable, std::string_view label)
 
- 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
 
- 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 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

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 19 of file GrMtlAttachment.h.

Constructor & Destructor Documentation

◆ ~GrMtlAttachment()

GrMtlAttachment::~GrMtlAttachment ( )
override

Definition at line 174 of file GrMtlAttachment.mm.

174 {
175 // should have been released or abandoned first
176 SkASSERT(!fTexture);
177}
#define SkASSERT(cond)
Definition SkAssert.h:116

Member Function Documentation

◆ backendFormat()

GrBackendFormat GrMtlAttachment::backendFormat ( ) const
overridevirtual

Implements GrSurface.

Definition at line 179 of file GrMtlAttachment.mm.

179 {
180 return GrBackendFormats::MakeMtl(SkToU32(fTexture.pixelFormat));
181}
constexpr uint32_t SkToU32(S x)
Definition SkTo.h:26
SK_API GrBackendFormat MakeMtl(GrMTLPixelFormat format)

◆ framebufferOnly()

bool GrMtlAttachment::framebufferOnly ( ) const
inline

Definition at line 56 of file GrMtlAttachment.h.

56{ return fTexture.framebufferOnly; }

◆ MakeMSAA()

sk_sp< GrMtlAttachment > GrMtlAttachment::MakeMSAA ( GrMtlGpu gpu,
SkISize  dimensions,
int  sampleCnt,
MTLPixelFormat  format 
)
static

Definition at line 72 of file GrMtlAttachment.mm.

75 {
76 int textureUsage = 0;
77 int storageMode = 0;
78 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
79 textureUsage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
80 storageMode = MTLStorageModePrivate;
81 }
82 return GrMtlAttachment::Make(gpu, dimensions, UsageFlags::kColorAttachment, sampleCnt, format,
83 /*mipLevels=*/1, textureUsage, storageMode, skgpu::Budgeted::kYes);
84}
SkISize dimensions() const
Definition GrSurface.h:27
uint32_t uint32_t * format

◆ MakeStencil()

sk_sp< GrMtlAttachment > GrMtlAttachment::MakeStencil ( GrMtlGpu gpu,
SkISize  dimensions,
int  sampleCnt,
MTLPixelFormat  format 
)
static

Definition at line 58 of file GrMtlAttachment.mm.

61 {
62 int textureUsage = 0;
63 int storageMode = 0;
64 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
65 textureUsage = MTLTextureUsageRenderTarget;
66 storageMode = MTLStorageModePrivate;
67 }
68 return GrMtlAttachment::Make(gpu, dimensions, UsageFlags::kStencilAttachment, sampleCnt, format,
69 /*mipLevels=*/1, textureUsage, storageMode, skgpu::Budgeted::kYes);
70}

◆ MakeTexture()

sk_sp< GrMtlAttachment > GrMtlAttachment::MakeTexture ( GrMtlGpu gpu,
SkISize  dimensions,
MTLPixelFormat  format,
uint32_t  mipLevels,
GrRenderable  renderable,
int  numSamples,
skgpu::Budgeted  budgeted 
)
static

Definition at line 86 of file GrMtlAttachment.mm.

92 {
93 int textureUsage = 0;
94 int storageMode = 0;
95 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
96 textureUsage = MTLTextureUsageShaderRead;
97 storageMode = MTLStorageModePrivate;
98 }
100 if (renderable == GrRenderable::kYes) {
101 usageFlags |= UsageFlags::kColorAttachment;
102 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
103 textureUsage |= MTLTextureUsageRenderTarget;
104 }
105 }
106
107 return GrMtlAttachment::Make(gpu, dimensions, usageFlags, numSamples, format, mipLevels,
108 textureUsage, storageMode, budgeted);
109}
int numSamples() const

◆ MakeWrapped()

sk_sp< GrMtlAttachment > GrMtlAttachment::MakeWrapped ( GrMtlGpu gpu,
SkISize  dimensions,
id< MTLTexture >  texture,
UsageFlags  attachmentUsages,
GrWrapCacheable  cacheable,
std::string_view  label 
)
static

Definition at line 162 of file GrMtlAttachment.mm.

168 {
169
170 return sk_sp<GrMtlAttachment>(new GrMtlAttachment(gpu, dimensions, attachmentUsages, texture,
171 cacheable, label));
172}
FlTexture * texture

◆ mtlFormat()

MTLPixelFormat GrMtlAttachment::mtlFormat ( ) const
inline

Definition at line 50 of file GrMtlAttachment.h.

50{ return fTexture.pixelFormat; }

◆ mtlTexture()

id< MTLTexture > GrMtlAttachment::mtlTexture ( ) const
inline

Definition at line 52 of file GrMtlAttachment.h.

52{ return fTexture; }

◆ onAbandon()

void GrMtlAttachment::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 188 of file GrMtlAttachment.mm.

188 {
189 fTexture = nil;
191}
virtual void onAbandon()

◆ onRelease()

void GrMtlAttachment::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Definition at line 183 of file GrMtlAttachment.mm.

183 {
184 fTexture = nil;
186}
virtual void onRelease()

◆ onSetLabel()

void GrMtlAttachment::onSetLabel ( )
overrideprivatevirtual

Reimplemented from GrAttachment.

Definition at line 198 of file GrMtlAttachment.mm.

198 {
199 SkASSERT(fTexture);
200 if (!this->getLabel().empty()) {
201 NSString* labelStr = @(this->getLabel().c_str());
202 fTexture.label = [@"_Skia_" stringByAppendingString:labelStr];
203 }
204}
std::string getLabel() const
EMSCRIPTEN_KEEPALIVE void empty()

◆ sampleCount()

unsigned int GrMtlAttachment::sampleCount ( ) const
inline

Definition at line 54 of file GrMtlAttachment.h.

54{ return SkToU32(fTexture.sampleCount); }

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