Debian Codegraph @

include/gpu/graphite/mtl/MtlGraphiteTypes.h

raw
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_MtlGraphiteTypes_DEFINED
9 #define skgpu_graphite_MtlGraphiteTypes_DEFINED
10
11 #if __OBJC__ // <Metal/Metal.h> only works when compiled for Objective C
12
13 #include "include/core/SkTypes.h"
14
15 #include "include/gpu/graphite/GraphiteTypes.h"
16 #include "include/gpu/graphite/TextureInfo.h"
17 #include "include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h"
18 #include "include/private/base/SkAPI.h"
19
20 #import <CoreFoundation/CoreFoundation.h>
21 #import <Metal/Metal.h>
22 #import <TargetConditionals.h>
23
24 class SkStream;
25 class SkWStream;
26
27 namespace skgpu::graphite {
28
29 class SK_API MtlTextureInfo final : public TextureInfo::Data {
30 public:
31 MTLPixelFormat fFormat = MTLPixelFormatInvalid;
32 MTLTextureUsage fUsage = MTLTextureUsageUnknown;
33 MTLStorageMode fStorageMode = MTLStorageModeShared;
34 bool fFramebufferOnly = false;
35
36 MtlTextureInfo() = default;
37 explicit MtlTextureInfo(CFTypeRef mtlTexture);
38 MtlTextureInfo(SampleCount sampleCount,
39 skgpu::Mipmapped mipmapped,
40 MTLPixelFormat format,
41 MTLTextureUsage usage,
42 MTLStorageMode storageMode,
43 bool framebufferOnly)
44 : Data(sampleCount, mipmapped)
45 , fFormat(format)
46 , fUsage(usage)
47 , fStorageMode(storageMode)
48 , fFramebufferOnly(framebufferOnly) {}
49
50 private:
51 friend class TextureInfo;
52 friend class TextureInfoPriv;
53
54 // Non-virtual template API for TextureInfo::Data accessed directly when backend type is known.
55 static constexpr skgpu::BackendApi kBackend = skgpu::BackendApi::kMetal;
56
57 Protected isProtected() const { return Protected::kNo; }
58 TextureFormat viewFormat() const;
59
60 // Virtual API when the specific backend type is not available.
61 SkString toBackendString() const override;
62
63 void copyTo(TextureInfo::AnyTextureInfoData& dstData) const override {
64 dstData.emplace<MtlTextureInfo>(*this);
65 }
66 bool isCompatible(const TextureInfo& that, bool requireExact) const override;
67 };
68
69 } // namespace skgpu::graphite
70
71 #endif // __OBJC__
72
73 #endif // skgpu_graphite_MtlGraphiteTypes_DEFINED