skia2/experimental/graphite/include/TextureInfo.h
Jim Van Verth ab4d4ae9e2 Revert "[graphite] Move Graphite into Skia base directories."
This reverts commit ae5e846047.

Reason for revert: Breaking Google3

Original change's description:
> [graphite] Move Graphite into Skia base directories.
>
> Change-Id: Ie0fb74f3766a8b33387c145bd1151344c25808cb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528708
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

Change-Id: Ia57992a22c42b17216b40fd29452865f957fb802
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528653
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-04-09 01:02:26 +00:00

91 lines
2.2 KiB
C++

/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef skgpu_graphite_TextureInfo_DEFINED
#define skgpu_graphite_TextureInfo_DEFINED
#include "experimental/graphite/include/GraphiteTypes.h"
#ifdef SK_METAL
#include "experimental/graphite/include/private/MtlTypesPriv.h"
#endif
namespace skgpu::graphite {
// Forward declares so we can friend classes in other namespaces
#ifdef SK_METAL
namespace graphite {
class MtlCaps;
class MtlTexture;
}
#endif
class TextureInfo {
public:
TextureInfo() {}
#ifdef SK_METAL
TextureInfo(const MtlTextureInfo& mtlInfo)
: fBackend(BackendApi::kMetal)
, fValid(true)
, fSampleCount(mtlInfo.fSampleCount)
, fLevelCount(mtlInfo.fLevelCount)
, fProtected(Protected::kNo)
, fMtlSpec(mtlInfo) {}
#endif
~TextureInfo() {}
TextureInfo(const TextureInfo&) = default;
TextureInfo& operator=(const TextureInfo&);
bool operator==(const TextureInfo&) const;
bool operator!=(const TextureInfo& that) const { return !(*this == that); }
bool isValid() const { return fValid; }
BackendApi backend() const { return fBackend; }
uint32_t numSamples() const { return fSampleCount; }
uint32_t numMipLevels() const { return fLevelCount; }
Protected isProtected() const { return fProtected; }
#ifdef SK_METAL
bool getMtlTextureInfo(MtlTextureInfo* info) const {
if (!this->isValid() || fBackend != BackendApi::kMetal) {
return false;
}
*info = MtlTextureSpecToTextureInfo(fMtlSpec, fSampleCount, fLevelCount);
return true;
}
#endif
private:
#ifdef SK_METAL
friend class MtlCaps;
friend class MtlTexture;
const MtlTextureSpec& mtlTextureSpec() const {
SkASSERT(fValid && fBackend == BackendApi::kMetal);
return fMtlSpec;
}
#endif
BackendApi fBackend = BackendApi::kMock;
bool fValid = false;
uint32_t fSampleCount = 1;
uint32_t fLevelCount = 0;
Protected fProtected = Protected::kNo;
union {
#ifdef SK_METAL
MtlTextureSpec fMtlSpec;
#endif
};
};
} // namespace skgpu::graphite
#endif //skgpu_graphite_TextureInfo_DEFINED