16#if !__has_feature(objc_arc)
17#error This file must be compiled with Arc. Use -fobjc-arc flag
22GrMtlAttachment::GrMtlAttachment(
GrMtlGpu* gpu,
24 UsageFlags supportedUsages,
27 std::string_view label)
37 this->registerWithCache(budgeted);
40GrMtlAttachment::GrMtlAttachment(
GrMtlGpu* gpu,
42 UsageFlags supportedUsages,
45 std::string_view label)
55 this->registerWithCacheWrapped(cacheable);
64 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
65 textureUsage = MTLTextureUsageRenderTarget;
66 storageMode = MTLStorageModePrivate;
78 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
79 textureUsage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
80 storageMode = MTLStorageModePrivate;
95 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
96 textureUsage = MTLTextureUsageShaderRead;
97 storageMode = MTLStorageModePrivate;
102 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
103 textureUsage |= MTLTextureUsageRenderTarget;
108 textureUsage, storageMode, budgeted);
113 UsageFlags attachmentUsages,
120 auto desc = [[MTLTextureDescriptor alloc]
init];
121 desc.textureType = (sampleCnt > 1) ? MTLTextureType2DMultisample : MTLTextureType2D;
126 desc.mipmapLevelCount = mipLevels;
127 desc.sampleCount = sampleCnt;
128 desc.arrayLength = 1;
129 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
130 desc.usage = mtlTextureUsage;
131 desc.storageMode = (MTLStorageMode)mtlStorageMode;
134#ifdef SK_ENABLE_MTL_DEBUG_INFO
140 texture.label =
@"MSAA TextureRenderTarget";
142 texture.label =
@"MSAA RenderTarget";
146 texture.label =
@"TextureRenderTarget";
148 texture.label =
@"RenderTarget";
159 "MakeMtlAttachment"));
168 std::string_view label) {
193GrMtlGpu* GrMtlAttachment::getMtlGpu()
const {
198void GrMtlAttachment::onSetLabel() {
201 NSString* labelStr = @(this->
getLabel().c_str());
202 fTexture.label = [
@"_Skia_" stringByAppendingString:labelStr];
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
static constexpr bool SkToBool(const T &x)
constexpr uint32_t SkToU32(S x)
std::string getLabel() const
bool wasDestroyed() const
GrBackendFormat backendFormat() const override
~GrMtlAttachment() override
void onAbandon() override
static sk_sp< GrMtlAttachment > MakeTexture(GrMtlGpu *gpu, SkISize dimensions, MTLPixelFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted)
static sk_sp< GrMtlAttachment > MakeWrapped(GrMtlGpu *gpu, SkISize dimensions, id< MTLTexture >, UsageFlags attachmentUsages, GrWrapCacheable, std::string_view label)
void onRelease() override
static sk_sp< GrMtlAttachment > MakeStencil(GrMtlGpu *gpu, SkISize dimensions, int sampleCnt, MTLPixelFormat format)
static sk_sp< GrMtlAttachment > MakeMSAA(GrMtlGpu *gpu, SkISize dimensions, int sampleCnt, MTLPixelFormat format)
id< MTLDevice > device() const
SkISize dimensions() const
void onAbandon() override
void onRelease() override
EMSCRIPTEN_KEEPALIVE void empty()
uint32_t uint32_t * format
constexpr int32_t width() const
constexpr int32_t height() const