d4ca5e11a1
The caller to ResourceProvider should be passing in the TextureInfo they want. Thus we don't need all the specialized factores on mtl::Texture. Also removes UsageFlags from Texture which aren't needed. Bug: skia:12466 Change-Id: Iad51a7da6efe481382a3f5fbaefc6d2504d1c013 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456236 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
87 lines
2.0 KiB
C++
87 lines
2.0 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_TextureInfo_DEFINED
|
|
#define skgpu_TextureInfo_DEFINED
|
|
|
|
#include "experimental/graphite/include/GraphiteTypes.h"
|
|
|
|
#ifdef SK_METAL
|
|
#include "experimental/graphite/include/private/MtlTypesPriv.h"
|
|
#endif
|
|
|
|
namespace skgpu {
|
|
|
|
// Forward declares so we can friend classes in other namespaces
|
|
#ifdef SK_METAL
|
|
namespace mtl {
|
|
class Caps;
|
|
class Texture;
|
|
}
|
|
#endif
|
|
|
|
class TextureInfo {
|
|
public:
|
|
TextureInfo() {}
|
|
#ifdef SK_METAL
|
|
TextureInfo(const mtl::TextureInfo& mtlInfo)
|
|
: fBackend(BackendApi::kMetal)
|
|
, fValid(true)
|
|
, fSampleCount(mtlInfo.fSampleCount)
|
|
, fLevelCount(mtlInfo.fLevelCount)
|
|
, fProtected(Protected::kNo)
|
|
, fMtlSpec(mtlInfo) {}
|
|
#endif
|
|
|
|
~TextureInfo() {}
|
|
TextureInfo(const TextureInfo&) = default;
|
|
|
|
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(mtl::TextureInfo* info) const {
|
|
if (!this->isValid() || fBackend != BackendApi::kMetal) {
|
|
return false;
|
|
}
|
|
*info = mtl::TextureSpecToTextureInfo(fMtlSpec, fSampleCount, fLevelCount);
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
private:
|
|
#ifdef SK_METAL
|
|
friend class mtl::Caps;
|
|
friend class mtl::Texture;
|
|
const mtl::TextureSpec& 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
|
|
mtl::TextureSpec fMtlSpec;
|
|
#endif
|
|
};
|
|
};
|
|
|
|
} // namespace skgpu
|
|
|
|
#endif //skgpu_TextureInfo_DEFINED
|