Chromium Code Reviews| Index: src/gpu/GrTextureParamsAdjuster.cpp |
| diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp |
| index 0547d95053d870bd856a34b2aafe82853cc5451c..08c5f1030a15036c4caf3bb82f1b954f780102ff 100644 |
| --- a/src/gpu/GrTextureParamsAdjuster.cpp |
| +++ b/src/gpu/GrTextureParamsAdjuster.cpp |
| @@ -213,7 +213,7 @@ static DomainMode determine_domain_mode( |
| return kNoDomain_DomainMode; |
| } |
| - bool restrictFilterToRect = (filterConstraint == GrTextureAdjuster::kYes_FilterConstraint); |
| + bool restrictFilterToRect = (filterConstraint == GrTextureProducer::kYes_FilterConstraint); |
| // If we can filter outside the constraint rect, and there is no non-content area of the |
| // texture, and we aren't going to generate sample coords outside the constraint rect then we |
| @@ -237,8 +237,11 @@ static DomainMode determine_domain_mode( |
| filterHalfWidth = .5f; |
| break; |
| case GrTextureParams::kMipMap_FilterMode: |
| - // No domain can save use here. |
| - return kTightCopy_DomainMode; |
| + if (restrictFilterToRect || textureContentArea) { |
|
bsalomon
2015/11/17 23:15:57
this check should have been here all along.
robertphillips
2015/11/18 13:58:35
use -> us ?
bsalomon
2015/11/18 18:05:37
Done
|
| + // No domain can save use here. |
| + return kTightCopy_DomainMode; |
| + } |
| + return kNoDomain_DomainMode; |
| } |
| } else { |
| // bicubic does nearest filtering internally. |
| @@ -322,6 +325,33 @@ static DomainMode determine_domain_mode( |
| domainRect->fRight /= texW; |
| domainRect->fBottom /= texH; |
| return kDomain_DomainMode; |
|
robertphillips
2015/11/18 13:58:35
rm ';' ?
bsalomon
2015/11/18 18:05:38
Done.
|
| +}; |
| + |
|
robertphillips
2015/11/18 13:58:35
static ?
bsalomon
2015/11/18 18:05:38
Done.
|
| +const GrFragmentProcessor* create_fp_for_domain_and_filter( |
| + GrTexture* texture, |
| + const SkMatrix& textureMatrix, |
| + DomainMode domainMode, |
| + const SkRect& domain, |
| + const GrTextureParams::FilterMode* filterOrNullForBicubic) { |
| + SkASSERT(kTightCopy_DomainMode != domainMode); |
| + if (filterOrNullForBicubic) { |
| + if (kDomain_DomainMode == domainMode) { |
| + return GrTextureDomainEffect::Create(texture, textureMatrix, domain, |
| + GrTextureDomain::kClamp_Mode, |
| + *filterOrNullForBicubic); |
| + } else { |
| + GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic); |
| + return GrSimpleTextureEffect::Create(texture, textureMatrix, params); |
| + } |
| + } else { |
| + if (kDomain_DomainMode == domainMode) { |
| + return GrBicubicEffect::Create(texture, textureMatrix, domain); |
| + } else { |
| + static const SkShader::TileMode kClampClamp[] = |
| + { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode }; |
| + return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp); |
| + } |
| + } |
| } |
| const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor( |
| @@ -368,57 +398,81 @@ const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor( |
| SkASSERT(kNoDomain_DomainMode == domainMode || |
| (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); |
| textureMatrix.postIDiv(texture->width(), texture->height()); |
| - if (filterOrNullForBicubic) { |
| - if (kDomain_DomainMode == domainMode) { |
| - return GrTextureDomainEffect::Create(texture, textureMatrix, domain, |
| - GrTextureDomain::kClamp_Mode, |
| - *filterOrNullForBicubic); |
| - } else { |
| - GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic); |
| - return GrSimpleTextureEffect::Create(texture, textureMatrix, params); |
| - } |
| - } else { |
| - if (kDomain_DomainMode == domainMode) { |
| - return GrBicubicEffect::Create(texture, textureMatrix, domain); |
| - } else { |
| - static const SkShader::TileMode kClampClamp[] = |
| - { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode }; |
| - return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp); |
| - } |
| - } |
| + return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, domain, |
| + filterOrNullForBicubic); |
| } |
| ////////////////////////////////////////////////////////////////////////////// |
| -GrTexture* GrTextureMaker::refTextureForParams(GrContext* ctx, const GrTextureParams& params) { |
| +GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) { |
| CopyParams copyParams; |
| - if (!ctx->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params, |
| - ©Params)) { |
| - return this->refOriginalTexture(ctx); |
| + if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params, |
| + ©Params)) { |
| + return this->refOriginalTexture(); |
| } |
| GrUniqueKey copyKey; |
| this->makeCopyKey(copyParams, ©Key); |
| if (copyKey.isValid()) { |
| - GrTexture* result = ctx->textureProvider()->findAndRefTextureByUniqueKey(copyKey); |
| + GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniqueKey(copyKey); |
| if (result) { |
| return result; |
| } |
| } |
| - GrTexture* result = this->generateTextureForParams(ctx, copyParams); |
| + GrTexture* result = this->generateTextureForParams(copyParams); |
| if (!result) { |
| return nullptr; |
| } |
| if (copyKey.isValid()) { |
|
robertphillips
2015/11/18 13:58:35
Why not fContext ?
bsalomon
2015/11/18 18:05:37
Done.
|
| - ctx->textureProvider()->assignUniqueKeyToTexture(copyKey, result); |
| + this->context()->textureProvider()->assignUniqueKeyToTexture(copyKey, result); |
| this->didCacheCopy(copyKey); |
| } |
| return result; |
| } |
| -GrTexture* GrTextureMaker::generateTextureForParams(GrContext* ctx, const CopyParams& copyParams) { |
| - SkAutoTUnref<GrTexture> original(this->refOriginalTexture(ctx)); |
| +const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor( |
| + const SkMatrix& textureMatrix, |
| + const SkRect& constraintRect, |
| + FilterConstraint filterConstraint, |
| + bool coordsLimitedToConstraintRect, |
| + const GrTextureParams::FilterMode* filterOrNullForBicubic) { |
| + |
|
robertphillips
2015/11/18 13:58:35
// The filter mode used to determine the domain di
bsalomon
2015/11/18 18:05:38
The explanation is two lines below
|
| + const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBicubic; |
| + if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic && |
| + kYes_FilterConstraint == filterConstraint) { |
| + // TOOD: Here we should force a copy restricted to the constraintRect since MIP maps will |
| + // read outside the constraint rect. However, as in the adjuster case, we aren't currently |
| + // doing that. |
| + static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBilerp_FilterMode; |
| + fmForDetermineDomain = &kBilerp; |
| + } |
| + |
| + GrTextureParams params; |
| + if (filterOrNullForBicubic) { |
| + params.reset(SkShader::kClamp_TileMode, *filterOrNullForBicubic); |
| + } else { |
| + // Bicubic doesn't use filtering for it's texture accesses. |
| + params.reset(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode); |
| + } |
| + SkAutoTUnref<GrTexture> texture(this->refTextureForParams(params)); |
| + if (!texture) { |
| + return nullptr; |
| + } |
| + SkRect domain; |
| + DomainMode domainMode = |
| + determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToConstraintRect, |
| + texture->width(), texture->height(), nullptr, fmForDetermineDomain, |
| + &domain); |
| + SkASSERT(kTightCopy_DomainMode != domainMode); |
| + SkMatrix normalizedTextureMatrix = textureMatrix; |
| + normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); |
| + return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, domainMode, domain, |
| + filterOrNullForBicubic); |
| +} |
| + |
| +GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams) { |
| + SkAutoTUnref<GrTexture> original(this->refOriginalTexture()); |
| if (!original) { |
| return nullptr; |
| } |