Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / include / gpu / graphite / TextureInfo.h
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_TextureInfo_DEFINED
9 #define skgpu_graphite_TextureInfo_DEFINED
10
11 #include "include/gpu/graphite/GraphiteTypes.h"
12
13 #ifdef SK_METAL
14 #include "include/private/gpu/graphite/MtlTypesPriv.h"
15 #endif
16
17 namespace skgpu::graphite {
18
19 // Forward declares so we can friend classes in other namespaces
20 #ifdef SK_METAL
21 namespace graphite {
22     class MtlCaps;
23     class MtlTexture;
24 }
25 #endif
26
27 class TextureInfo {
28 public:
29     TextureInfo() {}
30 #ifdef SK_METAL
31     TextureInfo(const MtlTextureInfo& mtlInfo)
32             : fBackend(BackendApi::kMetal)
33             , fValid(true)
34             , fSampleCount(mtlInfo.fSampleCount)
35             , fLevelCount(mtlInfo.fLevelCount)
36             , fProtected(Protected::kNo)
37             , fMtlSpec(mtlInfo) {}
38 #endif
39
40     ~TextureInfo() {}
41     TextureInfo(const TextureInfo&) = default;
42     TextureInfo& operator=(const TextureInfo&);
43
44     bool operator==(const TextureInfo&) const;
45     bool operator!=(const TextureInfo& that) const { return !(*this == that); }
46
47     bool isValid() const { return fValid; }
48     BackendApi backend() const { return fBackend; }
49
50     uint32_t numSamples() const { return fSampleCount; }
51     uint32_t numMipLevels() const { return fLevelCount; }
52     Protected isProtected() const { return fProtected; }
53
54 #ifdef SK_METAL
55     bool getMtlTextureInfo(MtlTextureInfo* info) const {
56         if (!this->isValid() || fBackend != BackendApi::kMetal) {
57             return false;
58         }
59         *info = MtlTextureSpecToTextureInfo(fMtlSpec, fSampleCount, fLevelCount);
60         return true;
61     }
62 #endif
63
64 private:
65 #ifdef SK_METAL
66     friend class MtlCaps;
67     friend class MtlGraphicsPipeline;
68     friend class MtlTexture;
69     const MtlTextureSpec& mtlTextureSpec() const {
70         SkASSERT(fValid && fBackend == BackendApi::kMetal);
71         return fMtlSpec;
72     }
73 #endif
74
75     BackendApi fBackend = BackendApi::kMock;
76     bool fValid = false;
77
78     uint32_t fSampleCount = 1;
79     uint32_t fLevelCount = 0;
80     Protected fProtected = Protected::kNo;
81
82     union {
83 #ifdef SK_METAL
84         MtlTextureSpec fMtlSpec;
85 #endif
86     };
87 };
88
89 }  // namespace skgpu::graphite
90
91 #endif  //skgpu_graphite_TextureInfo_DEFINED