1 /* 2 * Copyright 2021 Google LLC 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 skgpu_MtlTexture_DEFINED 9 #define skgpu_MtlTexture_DEFINED 10 11 #include "experimental/graphite/src/Texture.h" 12 #include "include/core/SkRefCnt.h" 13 14 #import <Metal/Metal.h> 15 16 namespace skgpu::mtl { 17 18 class Gpu; 19 20 class Texture : public skgpu::Texture { 21 public: 22 static sk_cfp<id<MTLTexture>> MakeMtlTexture(const Gpu*, 23 SkISize dimensions, 24 const skgpu::TextureInfo&); 25 26 static sk_sp<Texture> Make(const Gpu*, 27 SkISize dimensions, 28 const skgpu::TextureInfo&); 29 30 static sk_sp<Texture> MakeWrapped(const Gpu*, 31 SkISize dimensions, 32 const skgpu::TextureInfo&, 33 sk_cfp<id<MTLTexture>>); 34 ~Texture()35 ~Texture() override {} 36 mtlTexture()37 id<MTLTexture> mtlTexture() const { return fTexture.get(); } 38 39 private: 40 Texture(const Gpu* gpu, 41 SkISize dimensions, 42 const skgpu::TextureInfo& info, 43 sk_cfp<id<MTLTexture>>, 44 Ownership); 45 46 void onFreeGpuData() override; 47 48 sk_cfp<id<MTLTexture>> fTexture; 49 }; 50 51 } // namepsace skgpu::mtl 52 53 #endif // skgpu_MtlTexture_DEFINED 54