diff options
author | Greg Daniel <egdaniel@google.com> | 2018-07-19 15:56:55 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-19 21:02:55 +0000 |
commit | 5191fd7555d34225ef771ad4cac65bcbbb50a89c (patch) | |
tree | 9923a48f455e48f839c3c855ba0982a80c5af9b7 /src/gpu/GrTextureProducer.cpp | |
parent | e530e5153f8dcd6a08125993c46b9db57c95e838 (diff) |
Don't require mips in GrTextureProducer if texture is 1x1.
Bug: chromium:862921
Change-Id: I5f3584ad36e160a5a09d0a37e31e147155076b4d
Reviewed-on: https://skia-review.googlesource.com/142586
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrTextureProducer.cpp')
-rw-r--r-- | src/gpu/GrTextureProducer.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index 59962c55b1..cdf2a476e3 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -11,6 +11,7 @@ #include "GrRenderTargetContext.h" #include "GrTextureProxy.h" #include "SkGr.h" +#include "SkMipMap.h" #include "SkRectPriv.h" #include "effects/GrBicubicEffect.h" #include "effects/GrSimpleTextureEffect.h" @@ -226,8 +227,18 @@ sk_sp<GrTextureProxy> GrTextureProducer::refTextureProxyForParams( SkDEBUGCODE(bool expectNoScale = (sampler.filter() != GrSamplerState::Filter::kMipMap && !sampler.isRepeated())); SkASSERT(scaleAdjust || expectNoScale); + + int mipCount = SkMipMap::ComputeLevelCount(this->width(), this->height()); + bool willBeMipped = GrSamplerState::Filter::kMipMap == sampler.filter() && mipCount && + fContext->contextPriv().caps()->mipMapSupport(); + auto result = - this->onRefTextureProxyForParams(sampler, dstColorSpace, proxyColorSpace, scaleAdjust); + this->onRefTextureProxyForParams(sampler, dstColorSpace, proxyColorSpace, willBeMipped, + scaleAdjust); + + // Check to make sure that if we say the texture willBeMipped that the returned texture has mip + // maps. + SkASSERT(!result || !willBeMipped || result->mipMapped() == GrMipMapped::kYes); // Check that the "no scaling expected" case always returns a proxy of the same size as the // producer. @@ -243,8 +254,18 @@ sk_sp<GrTextureProxy> GrTextureProducer::refTextureProxy(GrMipMapped willNeedMip GrMipMapped::kNo == willNeedMips ? GrSamplerState::Filter::kNearest : GrSamplerState::Filter::kMipMap; GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, filter); + + int mipCount = SkMipMap::ComputeLevelCount(this->width(), this->height()); + bool willBeMipped = GrSamplerState::Filter::kMipMap == sampler.filter() && mipCount && + fContext->contextPriv().caps()->mipMapSupport(); + auto result = - this->onRefTextureProxyForParams(sampler, dstColorSpace, proxyColorSpace, nullptr); + this->onRefTextureProxyForParams(sampler, dstColorSpace, proxyColorSpace, + willBeMipped, nullptr); + + // Check to make sure that if we say the texture willBeMipped that the returned texture has mip + // maps. + SkASSERT(!result || !willBeMipped || result->mipMapped() == GrMipMapped::kYes); // Check that no scaling occured and we returned a proxy of the same size as the producer. SkASSERT(!result || (result->width() == this->width() && result->height() == this->height())); |