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 GrMtlStencil_DEFINED 9 #define GrMtlStencil_DEFINED 10 11 #include "src/gpu/GrStencilAttachment.h" 12 13 #import <Metal/Metal.h> 14 15 class GrMtlImageView; 16 class GrMtlGpu; 17 18 class GrMtlStencilAttachment : public GrStencilAttachment { 19 public: 20 struct Format { 21 MTLPixelFormat fInternalFormat; 22 int fStencilBits; 23 int fTotalBits; 24 bool fPacked; 25 }; 26 27 static GrMtlStencilAttachment* Create(GrMtlGpu* gpu, int width, int height, 28 int sampleCnt, const Format& format); 29 30 ~GrMtlStencilAttachment() override; 31 mtlFormat()32 MTLPixelFormat mtlFormat() const { return fFormat.fInternalFormat; } 33 stencilView()34 id<MTLTexture> stencilView() const { return fStencilView; } 35 36 protected: 37 void onRelease() override; 38 void onAbandon() override; 39 40 private: 41 size_t onGpuMemorySize() const override; 42 43 GrMtlStencilAttachment(GrMtlGpu* gpu, 44 const Format& format, 45 const id<MTLTexture> stencilView); 46 47 GrMtlGpu* getMtlGpu() const; 48 49 Format fFormat; 50 51 id<MTLTexture> fStencilView; 52 }; 53 54 #endif 55