Debian Codegraph @

src/gpu/ganesh/mtl/GrMtlAttachment.h

raw
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 GrMtlAttachment_DEFINED
9 #define GrMtlAttachment_DEFINED
10
11 #include "include/gpu/ganesh/mtl/GrMtlTypes.h"
12 #include "src/gpu/ganesh/GrAttachment.h"
13
14 #import <Metal/Metal.h>
15
16 class GrBackendFormat;
17 class GrMtlGpu;
18
19 class GrMtlAttachment : public GrAttachment {
20 public:
21 static sk_sp<GrMtlAttachment> MakeStencil(GrMtlGpu* gpu,
22 SkISize dimensions,
23 int sampleCnt,
24 MTLPixelFormat format);
25
26 static sk_sp<GrMtlAttachment> MakeMSAA(GrMtlGpu* gpu,
27 SkISize dimensions,
28 int sampleCnt,
29 MTLPixelFormat format);
30
31 static sk_sp<GrMtlAttachment> MakeTexture(GrMtlGpu* gpu,
32 SkISize dimensions,
33 MTLPixelFormat format,
34 uint32_t mipLevels,
35 GrRenderable renderable,
36 int numSamples,
37 skgpu::Budgeted budgeted);
38
39 static sk_sp<GrMtlAttachment> MakeWrapped(GrMtlGpu* gpu,
40 SkISize dimensions,
41 id<MTLTexture>,
42 UsageFlags attachmentUsages,
43 GrWrapCacheable,
44 std::string_view label);
45
46 ~GrMtlAttachment() override;
47
48 GrBackendFormat backendFormat() const override;
49
50 MTLPixelFormat mtlFormat() const { return fTexture.pixelFormat; }
51
52 id<MTLTexture> mtlTexture() const { return fTexture; }
53
54 unsigned int sampleCount() const { return SkToU32(fTexture.sampleCount); }
55
56 bool framebufferOnly() const { return fTexture.framebufferOnly; }
57
58 protected:
59 void onRelease() override;
60 void onAbandon() override;
61
62 private:
63 static sk_sp<GrMtlAttachment> Make(GrMtlGpu* gpu,
64 SkISize dimensions,
65 UsageFlags attachmentUsages,
66 int sampleCnt,
67 MTLPixelFormat format,
68 uint32_t mipLevels,
69 int mtlTextureUsage,
70 int mtlStorageMode,
71 skgpu::Budgeted);
72
73 GrMtlAttachment(GrMtlGpu* gpu,
74 SkISize dimensions,
75 UsageFlags supportedUsages,
76 id<MTLTexture> texture,
77 skgpu::Budgeted,
78 std::string_view label);
79
80 GrMtlAttachment(GrMtlGpu* gpu,
81 SkISize dimensions,
82 UsageFlags supportedUsages,
83 id<MTLTexture> texture,
84 GrWrapCacheable,
85 std::string_view label);
86
87 GrMtlGpu* getMtlGpu() const;
88
89 void onSetLabel() override;
90
91 id<MTLTexture> fTexture;
92 };
93
94 #endif