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