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