1 /* 2 * Copyright 2018 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrMtlAttachment_DEFINED 9 #define GrMtlAttachment_DEFINED 10 11 #include "src/gpu/GrAttachment.h" 12 13 #import <Metal/Metal.h> 14 15 class GrMtlImageView; 16 class GrMtlGpu; 17 18 class GrMtlAttachment : public GrAttachment { 19 public: 20 static sk_sp<GrMtlAttachment> MakeStencil(GrMtlGpu* gpu, 21 SkISize dimensions, 22 int sampleCnt, 23 MTLPixelFormat format); 24 25 ~GrMtlAttachment() override; 26 backendFormat()27 GrBackendFormat backendFormat() const override { 28 return GrBackendFormat::MakeMtl(fView.pixelFormat); 29 } 30 mtlFormat()31 MTLPixelFormat mtlFormat() const { return fView.pixelFormat; } 32 view()33 id<MTLTexture> view() const { return fView; } 34 35 protected: 36 void onRelease() override; 37 void onAbandon() override; 38 39 private: 40 GrMtlAttachment(GrMtlGpu* gpu, 41 SkISize dimensions, 42 UsageFlags supportedUsages, 43 const id<MTLTexture> View); 44 45 GrMtlGpu* getMtlGpu() const; 46 47 id<MTLTexture> fView; 48 }; 49 50 #endif 51