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