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

#include <GrMtlTexture.h>

Inheritance diagram for GrMtlTexture:
GrTexture GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrMtlTextureRenderTarget

Public Member Functions

 ~GrMtlTexture () override
 
GrMtlAttachmentattachment () const
 
id< MTLTexture > mtlTexture () const
 
GrBackendTexture getBackendTexture () const override
 
GrBackendFormat backendFormat () const override
 
void textureParamsModified () override
 
bool reallocForMipmap (GrMtlGpu *gpu, uint32_t mipLevels)
 
- Public Member Functions inherited from GrTexture
GrTextureasTexture () override
 
const GrTextureasTexture () const override
 
virtual GrBackendTexture getBackendTexture () const =0
 
virtual void textureParamsModified ()=0
 
GrTextureType textureType () const
 
bool hasRestrictedSampling () const
 
void markMipmapsDirty ()
 
void markMipmapsClean ()
 
skgpu::Mipmapped mipmapped () const
 
bool mipmapsAreDirty () const
 
GrMipmapStatus mipmapStatus () const
 
int maxMipmapLevel () 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
 

Static Public Member Functions

static sk_sp< GrMtlTextureMakeNewTexture (GrMtlGpu *, skgpu::Budgeted budgeted, SkISize dimensions, MTLPixelFormat format, uint32_t mipLevels, GrMipmapStatus, std::string_view label)
 
static sk_sp< GrMtlTextureMakeWrappedTexture (GrMtlGpu *, SkISize, id< MTLTexture >, GrWrapCacheable, GrIOType)
 
- Static Public Member Functions inherited from GrTexture
static bool StealBackendTexture (sk_sp< GrTexture >, GrBackendTexture *, SkImages::BackendTextureReleaseProc *)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, 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

 GrMtlTexture (GrMtlGpu *, SkISize, sk_sp< GrMtlAttachment >, GrMipmapStatus, std::string_view label)
 
GrMtlGpugetMtlGpu () const
 
void onAbandon () override
 
void onRelease () override
 
bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
 
void onSetLabel () override
 
- Protected Member Functions inherited from GrTexture
 GrTexture (GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
 
virtual bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *)=0
 
void computeScratchKey (skgpu::ScratchKey *) const 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
 

Additional Inherited Members

- 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 18 of file GrMtlTexture.h.

Constructor & Destructor Documentation

◆ ~GrMtlTexture()

GrMtlTexture::~GrMtlTexture ( )
override

Definition at line 122 of file GrMtlTexture.mm.

122 {
123 SkASSERT(nil == fTexture);
124}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ GrMtlTexture()

GrMtlTexture::GrMtlTexture ( GrMtlGpu gpu,
SkISize  dimensions,
sk_sp< GrMtlAttachment texture,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
protected

Definition at line 65 of file GrMtlTexture.mm.

72 , fTexture(std::move(texture)) {
73 SkDEBUGCODE(id<MTLTexture> mtlTexture = fTexture->mtlTexture();)
74 SkASSERT((GrMipmapStatus::kNotAllocated == mipmapStatus) == (1 == mtlTexture.mipmapLevelCount));
75 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
76 SkASSERT(SkToBool(mtlTexture.usage & MTLTextureUsageShaderRead));
77 }
78 SkASSERT(!mtlTexture.framebufferOnly);
79}
GrMipmapStatus
Definition: GrTypesPriv.h:523
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
id< MTLTexture > mtlTexture() const
id< MTLTexture > mtlTexture() const
Definition: GrMtlTexture.h:37
SkISize dimensions() const
Definition: GrSurface.h:27
GrSurface(GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
Definition: GrSurface.h:140
GrMipmapStatus mipmapStatus() const
Definition: GrTexture.h:66
if(end==-1)
FlTexture * texture

Member Function Documentation

◆ attachment()

GrMtlAttachment * GrMtlTexture::attachment ( ) const
inline

Definition at line 36 of file GrMtlTexture.h.

36{ return fTexture.get(); }
T * get() const
Definition: SkRefCnt.h:303

◆ backendFormat()

GrBackendFormat GrMtlTexture::backendFormat ( ) const
overridevirtual

Implements GrSurface.

Reimplemented in GrMtlTextureRenderTarget.

Definition at line 140 of file GrMtlTexture.mm.

140 {
141 return GrBackendFormats::MakeMtl(fTexture->mtlFormat());
142}
MTLPixelFormat mtlFormat() const
SK_API GrBackendFormat MakeMtl(GrMTLPixelFormat format)

◆ getBackendTexture()

GrBackendTexture GrMtlTexture::getBackendTexture ( ) const
overridevirtual

Implements GrTexture.

Definition at line 131 of file GrMtlTexture.mm.

131 {
132 skgpu::Mipmapped mipmapped = fTexture->mtlTexture().mipmapLevelCount > 1
135 GrMtlTextureInfo info;
136 info.fTexture.reset(GrRetainPtrFromId(fTexture->mtlTexture()));
137 return GrBackendTextures::MakeMtl(this->width(), this->height(), mipmapped, info);
138}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SK_ALWAYS_INLINE CF_RETURNS_RETAINED const void * GrRetainPtrFromId(id idObject)
Definition: GrMtlUtil.h:59
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32
skgpu::Mipmapped mipmapped() const
Definition: GrTexture.h:62
SK_API GrBackendTexture MakeMtl(int width, int height, skgpu::Mipmapped, const GrMtlTextureInfo &mtlInfo, std::string_view label={})
Mipmapped
Definition: GpuTypes.h:53

◆ getMtlGpu()

GrMtlGpu * GrMtlTexture::getMtlGpu ( ) const
protected

Definition at line 126 of file GrMtlTexture.mm.

126 {
127 SkASSERT(!this->wasDestroyed());
128 return static_cast<GrMtlGpu*>(this->getGpu());
129}
GrGpu * getGpu() const
bool wasDestroyed() const

◆ MakeNewTexture()

sk_sp< GrMtlTexture > GrMtlTexture::MakeNewTexture ( GrMtlGpu gpu,
skgpu::Budgeted  budgeted,
SkISize  dimensions,
MTLPixelFormat  format,
uint32_t  mipLevels,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
static

Definition at line 81 of file GrMtlTexture.mm.

87 {
89 gpu, dimensions, format, mipLevels, GrRenderable::kNo, /*numSamples=*/1, budgeted);
90
91 if (!texture) {
92 return nullptr;
93 }
94 return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, budgeted, dimensions, std::move(texture),
95 mipmapStatus, label));
96}
static sk_sp< GrMtlAttachment > MakeTexture(GrMtlGpu *gpu, SkISize dimensions, MTLPixelFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted)
GrMtlTexture(GrMtlGpu *, SkISize, sk_sp< GrMtlAttachment >, GrMipmapStatus, std::string_view label)
Definition: GrMtlTexture.mm:65
uint32_t uint32_t * format

◆ MakeWrappedTexture()

sk_sp< GrMtlTexture > GrMtlTexture::MakeWrappedTexture ( GrMtlGpu gpu,
SkISize  dimensions,
id< MTLTexture >  texture,
GrWrapCacheable  cacheable,
GrIOType  ioType 
)
static

Definition at line 98 of file GrMtlTexture.mm.

102 {
103 SkASSERT(nil != texture);
104 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
105 SkASSERT(SkToBool(texture.usage & MTLTextureUsageShaderRead));
106 }
110 /*label=*/"MtlAttachment_MakeWrapped");
111 if (!attachment) {
112 return nullptr;
113 }
114
117 return sk_sp<GrMtlTexture>(
118 new GrMtlTexture(gpu, kWrapped, dimensions, std::move(attachment), mipmapStatus,
119 cacheable, ioType, /*label=*/"MtlTextureWrappedTexture"));
120}
static sk_sp< GrMtlAttachment > MakeWrapped(GrMtlGpu *gpu, SkISize dimensions, id< MTLTexture >, UsageFlags attachmentUsages, GrWrapCacheable, std::string_view label)
GrMtlAttachment * attachment() const
Definition: GrMtlTexture.h:36

◆ mtlTexture()

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

Definition at line 37 of file GrMtlTexture.h.

37{ return fTexture->mtlTexture(); }

◆ onAbandon()

void GrMtlTexture::onAbandon ( )
inlineoverrideprotectedvirtual

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

Reimplemented in GrMtlTextureRenderTarget.

Definition at line 56 of file GrMtlTexture.h.

56 {
57 fTexture = nil;
59 }
void onAbandon() override
Definition: GrSurface.cpp:86

◆ onRelease()

void GrMtlTexture::onRelease ( )
inlineoverrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrSurface.

Reimplemented in GrMtlTextureRenderTarget.

Definition at line 60 of file GrMtlTexture.h.

60 {
61 fTexture = nil;
63 }
void onRelease() override
Definition: GrSurface.cpp:81

◆ onSetLabel()

void GrMtlTexture::onSetLabel ( )
overrideprotectedvirtual

Implements GrGpuResource.

Definition at line 144 of file GrMtlTexture.mm.

144 {
145 SkASSERT(fTexture);
146 if (!this->getLabel().empty()) {
147 NSString* labelStr = @(this->getLabel().c_str());
148 fTexture->mtlTexture().label = [@"_Skia_" stringByAppendingString:labelStr];
149 }
150}
std::string getLabel() const
EMSCRIPTEN_KEEPALIVE void empty()

◆ onStealBackendTexture()

bool GrMtlTexture::onStealBackendTexture ( GrBackendTexture ,
SkImages::BackendTextureReleaseProc  
)
inlineoverrideprotectedvirtual

Implements GrTexture.

Definition at line 65 of file GrMtlTexture.h.

65 {
66 return false;
67 }

◆ reallocForMipmap()

bool GrMtlTexture::reallocForMipmap ( GrMtlGpu gpu,
uint32_t  mipLevels 
)

◆ textureParamsModified()

void GrMtlTexture::textureParamsModified ( )
inlineoverridevirtual

This function indicates that the texture parameters (wrap mode, filtering, ...) have been changed externally to Skia.

Implements GrTexture.

Definition at line 43 of file GrMtlTexture.h.

43{}

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