diff options
author | Brian Salomon <bsalomon@google.com> | 2017-09-07 12:36:34 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-07 16:58:31 +0000 |
commit | 2bbdcc44c63974f29f3743bb58d929601a3f65c6 (patch) | |
tree | d420f298f606b061054e56866d1930ab84f00ed5 /src/gpu/GrTextureProducer.cpp | |
parent | 4df0092eac6e9bb5afc516773a0c618630193dc6 (diff) |
Rework GrSamplerParams to be more compact and use its own wrap mode enum.
The main change is to make GrSamplerParams smaller by making its enums have byte-sized underlying types. The rest is cosmetic.
Change-Id: Ib71ea50612d24619a85e463826c6b8dfb9b445e3
Reviewed-on: https://skia-review.googlesource.com/43200
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrTextureProducer.cpp')
-rw-r--r-- | src/gpu/GrTextureProducer.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index 92732238e6..91e196da12 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -41,7 +41,7 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context, } bool needsDomain = false; - if (copyParams.fFilter != GrSamplerParams::kNone_FilterMode) { + if (copyParams.fFilter != GrSamplerState::Filter::kNearest) { bool resizing = localRect.width() != dstRect.width() || localRect.height() != dstRect.height(); @@ -56,13 +56,13 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context, const SkRect domain = localRect.makeInset(0.5f, 0.5f); // This would cause us to read values from outside the subset. Surely, the caller knows // better! - SkASSERT(copyParams.fFilter != GrSamplerParams::kMipMap_FilterMode); + SkASSERT(copyParams.fFilter != GrSamplerState::Filter::kMipMap); paint.addColorFragmentProcessor( GrTextureDomainEffect::Make(std::move(inputProxy), nullptr, SkMatrix::I(), domain, GrTextureDomain::kClamp_Mode, copyParams.fFilter)); } else { - GrSamplerParams params(SkShader::kClamp_TileMode, copyParams.fFilter); - paint.addColorTextureProcessor(std::move(inputProxy), nullptr, SkMatrix::I(), params); + GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, copyParams.fFilter); + paint.addColorTextureProcessor(std::move(inputProxy), nullptr, SkMatrix::I(), samplerState); } paint.setPorterDuffXPFactory(SkBlendMode::kSrc); @@ -84,13 +84,13 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context, * latter is true we only need to consider whether the filter would extend beyond the rects. */ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode( - const SkRect& constraintRect, - FilterConstraint filterConstraint, - bool coordsLimitedToConstraintRect, - GrTextureProxy* proxy, - const SkIRect* contentRect, - const GrSamplerParams::FilterMode* filterModeOrNullForBicubic, - SkRect* domainRect) { + const SkRect& constraintRect, + FilterConstraint filterConstraint, + bool coordsLimitedToConstraintRect, + GrTextureProxy* proxy, + const SkIRect* contentRect, + const GrSamplerState::Filter* filterModeOrNullForBicubic, + SkRect* domainRect) { const SkIRect proxyBounds = SkIRect::MakeWH(proxy->width(), proxy->height()); SkASSERT(proxyBounds.contains(constraintRect)); @@ -124,17 +124,17 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode( SkScalar filterHalfWidth = 0.f; if (filterModeOrNullForBicubic) { switch (*filterModeOrNullForBicubic) { - case GrSamplerParams::kNone_FilterMode: + case GrSamplerState::Filter::kNearest: if (coordsLimitedToConstraintRect) { return kNoDomain_DomainMode; } else { filterHalfWidth = 0.f; } break; - case GrSamplerParams::kBilerp_FilterMode: + case GrSamplerState::Filter::kBilerp: filterHalfWidth = .5f; break; - case GrSamplerParams::kMipMap_FilterMode: + case GrSamplerState::Filter::kMipMap: if (restrictFilterToRect || contentRect) { // No domain can save us here. return kTightCopy_DomainMode; @@ -224,7 +224,7 @@ std::unique_ptr<GrFragmentProcessor> GrTextureProducer::CreateFragmentProcessorF const SkMatrix& textureMatrix, DomainMode domainMode, const SkRect& domain, - const GrSamplerParams::FilterMode* filterOrNullForBicubic) { + const GrSamplerState::Filter* filterOrNullForBicubic) { SkASSERT(kTightCopy_DomainMode != domainMode); if (filterOrNullForBicubic) { if (kDomain_DomainMode == domainMode) { @@ -233,18 +233,17 @@ std::unique_ptr<GrFragmentProcessor> GrTextureProducer::CreateFragmentProcessorF domain, GrTextureDomain::kClamp_Mode, *filterOrNullForBicubic); } else { - GrSamplerParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic); - return GrSimpleTextureEffect::Make(std::move(proxy), - std::move(colorSpaceXform), textureMatrix, - params); + GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, *filterOrNullForBicubic); + return GrSimpleTextureEffect::Make(std::move(proxy), std::move(colorSpaceXform), + textureMatrix, samplerState); } } else { if (kDomain_DomainMode == domainMode) { return GrBicubicEffect::Make(std::move(proxy), std::move(colorSpaceXform), textureMatrix, domain); } else { - static const SkShader::TileMode kClampClamp[] = - { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode }; + static const GrSamplerState::WrapMode kClampClamp[] = { + GrSamplerState::WrapMode::kClamp, GrSamplerState::WrapMode::kClamp}; return GrBicubicEffect::Make(std::move(proxy), std::move(colorSpaceXform), textureMatrix, kClampClamp); } |