2 * Copyright 2021 Google LLC
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef skgpu_graphite_TextureInfo_DEFINED
9 #define skgpu_graphite_TextureInfo_DEFINED
11 #include "include/gpu/graphite/GraphiteTypes.h"
14 #include "include/private/gpu/graphite/MtlTypesPriv.h"
17 namespace skgpu::graphite {
19 // Forward declares so we can friend classes in other namespaces
31 TextureInfo(const MtlTextureInfo& mtlInfo)
32 : fBackend(BackendApi::kMetal)
34 , fSampleCount(mtlInfo.fSampleCount)
35 , fLevelCount(mtlInfo.fLevelCount)
36 , fProtected(Protected::kNo)
37 , fMtlSpec(mtlInfo) {}
41 TextureInfo(const TextureInfo&) = default;
42 TextureInfo& operator=(const TextureInfo&);
44 bool operator==(const TextureInfo&) const;
45 bool operator!=(const TextureInfo& that) const { return !(*this == that); }
47 bool isValid() const { return fValid; }
48 BackendApi backend() const { return fBackend; }
50 uint32_t numSamples() const { return fSampleCount; }
51 uint32_t numMipLevels() const { return fLevelCount; }
52 Protected isProtected() const { return fProtected; }
55 bool getMtlTextureInfo(MtlTextureInfo* info) const {
56 if (!this->isValid() || fBackend != BackendApi::kMetal) {
59 *info = MtlTextureSpecToTextureInfo(fMtlSpec, fSampleCount, fLevelCount);
67 friend class MtlGraphicsPipeline;
68 friend class MtlTexture;
69 const MtlTextureSpec& mtlTextureSpec() const {
70 SkASSERT(fValid && fBackend == BackendApi::kMetal);
75 BackendApi fBackend = BackendApi::kMock;
78 uint32_t fSampleCount = 1;
79 uint32_t fLevelCount = 0;
80 Protected fProtected = Protected::kNo;
84 MtlTextureSpec fMtlSpec;
89 } // namespace skgpu::graphite
91 #endif //skgpu_graphite_TextureInfo_DEFINED