Remove setters from GrSamplerState.

The motivation is that a future change will add a factory fn that
makes an aniso samplerstate. We don't want to support arbitrary
combinations of aniso with other knobs.

Bug: skia:13036

Change-Id: Id962f89019a37763961981990d0e49e298e16064
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/516816
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2022-03-07 08:12:59 -05:00 committed by SkCQ
parent 6a6dea778b
commit b4baebadd4
6 changed files with 20 additions and 17 deletions

View File

@ -140,13 +140,12 @@ protected:
const SkRect* subset = j > 0 ? &kColorRect : nullptr;
GrSamplerState samplerState;
samplerState.setFilterMode(kFilters[i]);
auto wm = GrSamplerState::WrapMode::kClamp;
if (j > 0) {
auto wm = static_cast<GrSamplerState::WrapMode>(j - 1);
samplerState.setWrapModeX(wm);
samplerState.setWrapModeY(wm);
wm = static_cast<GrSamplerState::WrapMode>(j - 1);
}
GrSamplerState samplerState(wm, kFilters[i]);
const auto& caps = *rContext->priv().caps();
std::unique_ptr<GrFragmentProcessor> fp =
GrYUVtoRGBEffect::Make(fProxies, samplerState, caps, SkMatrix::I(), subset);

View File

@ -61,7 +61,10 @@ void GrGeometryProcessor::TextureSampler::reset(GrSamplerState samplerState,
const GrBackendFormat& backendFormat,
const skgpu::Swizzle& swizzle) {
fSamplerState = samplerState;
fSamplerState.setFilterMode(clamp_filter(backendFormat.textureType(), samplerState.filter()));
fSamplerState = GrSamplerState(samplerState.wrapModeX(),
samplerState.wrapModeY(),
clamp_filter(backendFormat.textureType(), samplerState.filter()),
samplerState.mipmapMode());
fBackendFormat = backendFormat;
fSwizzle = swizzle;
fIsInitialized = true;

View File

@ -78,14 +78,6 @@ public:
return GrMipmapped(fMipmapMode != MipmapMode::kNone);
}
constexpr void setFilterMode(Filter filterMode) { fFilter = filterMode; }
constexpr void setMipmapMode(MipmapMode mm) { fMipmapMode = mm; }
constexpr void setWrapModeX(const WrapMode wrap) { fWrapModes[0] = wrap; }
constexpr void setWrapModeY(const WrapMode wrap) { fWrapModes[1] = wrap; }
constexpr bool operator==(GrSamplerState that) const {
return fWrapModes[0] == that.fWrapModes[0] && fWrapModes[1] == that.fWrapModes[1] &&
fFilter == that.fFilter && fMipmapMode == that.fMipmapMode;

View File

@ -177,7 +177,10 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(const GrYUVATextureP
} else {
GrSamplerState planeSampler = samplerState;
if (makeLinearWithSnap) {
planeSampler.setFilterMode(GrSamplerState::Filter::kLinear);
planeSampler = GrSamplerState(samplerState.wrapModeX(),
samplerState.wrapModeY(),
GrSamplerState::Filter::kLinear,
samplerState.mipmapMode());
}
planeFPs[i] = GrTextureEffect::Make(std::move(view),
kUnknown_SkAlphaType,

View File

@ -2664,7 +2664,10 @@ void GrGLGpu::bindTexture(int unitIdx, GrSamplerState samplerState, const skgpu:
if (samplerState.mipmapped() == GrMipmapped::kYes) {
if (!this->caps()->mipmapSupport() || texture->mipmapped() == GrMipmapped::kNo) {
samplerState.setMipmapMode(GrSamplerState::MipmapMode::kNone);
samplerState = GrSamplerState(samplerState.wrapModeX(),
samplerState.wrapModeY(),
samplerState.filter(),
GrSamplerState::MipmapMode::kNone);
} else {
SkASSERT(!texture->mipmapsAreDirty());
}

View File

@ -194,7 +194,10 @@ std::unique_ptr<GrFragmentProcessor> SkImage_GpuYUVA::onAsFragmentProcessor(
auto wmy = SkTileModeToWrapMode(tileModes[1]);
GrSamplerState sampler(wmx, wmy, sampling.filter, sampling.mipmap);
if (sampler.mipmapped() == GrMipmapped::kYes && !this->setupMipmapsForPlanes(context)) {
sampler.setMipmapMode(GrSamplerState::MipmapMode::kNone);
sampler = GrSamplerState(sampler.wrapModeX(),
sampler.wrapModeY(),
sampler.filter(),
GrSamplerState::MipmapMode::kNone);
}
const auto& yuvM = sampling.useCubic ? SkMatrix::I() : m;