8#ifndef GrSamplerState_DEFINED
9#define GrSamplerState_DEFINED
32 kLast = kClampToBorder
42 : fWrapModes{wrapXAndY, wrapXAndY}, fFilter(
filter), fMipmapMode(mm) {}
48 : fWrapModes{wrapX, wrapY}, fFilter(
filter), fMipmapMode(mm) {}
53 : fWrapModes{wrapModes[0], wrapModes[1]}, fFilter(
filter), fMipmapMode(mm) {}
65 sampler.fWrapModes[0] = wrapX;
66 sampler.fWrapModes[1] = wrapY;
103 bool isAniso()
const {
return fMaxAniso > 1; }
106 return fWrapModes[0] == that.fWrapModes[0] && fWrapModes[1] == that.fWrapModes[1] &&
107 fFilter == that.fFilter && fMipmapMode == that.fMipmapMode;
117 uint32_t
asKey(
bool anisoIsOrthogonal)
const {
123 constexpr int kWrapXShift = 0;
124 constexpr int kWrapYShift = kWrapXShift + kNumWrapBits;
125 constexpr int kMaxAnisoShift = kWrapYShift + kNumWrapBits;
126 constexpr int kFilterShift = kMaxAnisoShift + kNumMaxAnisoBits;
127 constexpr int kMipmapModeShift = kFilterShift + kNumFilterBits;
129 static_assert(kMipmapModeShift + kNumMipmapModeBits <= 32);
131 uint32_t
key = (
static_cast<uint32_t
>(fWrapModes[0]) << kWrapXShift)
132 | (
static_cast<uint32_t
>(fWrapModes[1]) << kWrapYShift)
133 | (
static_cast<uint32_t
>(fMaxAniso) << kMaxAnisoShift);
134 if (fMaxAniso == 1 || anisoIsOrthogonal) {
135 key |= (
static_cast<uint32_t
>(fFilter) << kFilterShift)
136 | (
static_cast<uint32_t
>(fMipmapMode) << kMipmapModeShift);
144 static constexpr int kMaxMaxAniso = 1024;
constexpr int SkNextLog2_portable(uint32_t value)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
constexpr GrSamplerState & operator=(const GrSamplerState &)=default
static constexpr GrSamplerState Aniso(WrapMode wrapX, WrapMode wrapY, int maxAniso, skgpu::Mipmapped viewIsMipped)
constexpr GrSamplerState(Filter filter)
constexpr GrSamplerState(Filter filter, MipmapMode mm)
constexpr GrSamplerState(WrapMode wrapXAndY, Filter filter, MipmapMode mm=MipmapMode::kNone)
static constexpr int kMipmapModeCount
static constexpr int kFilterCount
constexpr skgpu::Mipmapped mipmapped() const
constexpr WrapMode wrapModeX() const
constexpr bool operator==(GrSamplerState that) const
constexpr Filter filter() const
constexpr bool isRepeatedX() const
constexpr GrSamplerState(const WrapMode wrapModes[2], Filter filter, MipmapMode mm=MipmapMode::kNone)
uint32_t asKey(bool anisoIsOrthogonal) const
constexpr GrSamplerState(WrapMode wrapX, WrapMode wrapY, Filter filter, MipmapMode mm=MipmapMode::kNone)
constexpr GrSamplerState(const GrSamplerState &)=default
constexpr MipmapMode mipmapMode() const
constexpr bool operator!=(const GrSamplerState &that) const
constexpr bool isRepeated() const
static constexpr int kWrapModeCount
constexpr bool isRepeatedY() const
constexpr GrSamplerState()=default
constexpr WrapMode wrapModeY() const