Return kNearest from GrSkFilterQualityToGrFilterMode for 1x1 images

Bug: skia:
Change-Id: I358e5c74d918b880bea05a6129dbffcae0e8046d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234181
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Chris Dalton 2019-08-13 10:32:47 -06:00 committed by Skia Commit-Bot
parent fd91d20a46
commit 309c6c0929
5 changed files with 19 additions and 22 deletions

View File

@ -769,7 +769,7 @@ bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr
GrSamplerState samplerState;
bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
quality, viewMatrix, srcToDstRect,
image->width(), image->height(), quality, viewMatrix, srcToDstRect,
fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
int tileFilterPad;
@ -1171,8 +1171,8 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
GrSamplerState sampleState;
bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
paint.getFilterQuality(), this->ctm(), srcToDstMatrix,
fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
bitmap.width(), bitmap.height(), paint.getFilterQuality(), this->ctm(),
srcToDstMatrix, fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
int tileFilterPad;

View File

@ -266,7 +266,7 @@ static void draw_texture_producer(GrContext* context, GrRenderTargetContext* rtc
}
bool doBicubic;
GrSamplerState::Filter fm = GrSkFilterQualityToGrFilterMode(
paint.getFilterQuality(), ctm, srcToDst,
producer->width(), producer->height(), paint.getFilterQuality(), ctm, srcToDst,
context->priv().options().fSharpenMipmappedTextures, &doBicubic);
const GrSamplerState::Filter* filterMode = doBicubic ? nullptr : &fm;

View File

@ -542,20 +542,21 @@ bool SkPaintToGrPaintWithTexture(GrRecordingContext* context,
////////////////////////////////////////////////////////////////////////////////////////////////
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,
SkFilterQuality paintFilterQuality,
const SkMatrix& viewM,
const SkMatrix& localM,
bool sharpenMipmappedTextures,
bool* doBicubic) {
*doBicubic = false;
GrSamplerState::Filter textureFilterMode;
if (imageWidth <= 1 && imageHeight <= 1) {
return GrSamplerState::Filter::kNearest;
}
switch (paintFilterQuality) {
case kNone_SkFilterQuality:
textureFilterMode = GrSamplerState::Filter::kNearest;
break;
return GrSamplerState::Filter::kNearest;
case kLow_SkFilterQuality:
textureFilterMode = GrSamplerState::Filter::kBilerp;
break;
return GrSamplerState::Filter::kBilerp;
case kMedium_SkFilterQuality: {
SkMatrix matrix;
matrix.setConcat(viewM, localM);
@ -569,24 +570,19 @@ GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilt
// 2^0.5/2 = s
SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1;
if (matrix.getMinScale() < mipScale) {
textureFilterMode = GrSamplerState::Filter::kMipMap;
return GrSamplerState::Filter::kMipMap;
} else {
// Don't trigger MIP level generation unnecessarily.
textureFilterMode = GrSamplerState::Filter::kBilerp;
return GrSamplerState::Filter::kBilerp;
}
break;
}
case kHigh_SkFilterQuality: {
SkMatrix matrix;
matrix.setConcat(viewM, localM);
GrSamplerState::Filter textureFilterMode;
*doBicubic = GrBicubicEffect::ShouldUseBicubic(matrix, &textureFilterMode);
break;
}
default:
// Should be unreachable. If not, fall back to mipmaps.
textureFilterMode = GrSamplerState::Filter::kMipMap;
break;
}
return textureFilterMode;
}
}
SkUNREACHABLE;
}

View File

@ -140,7 +140,8 @@ GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info);
bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*);
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,
SkFilterQuality paintFilterQuality,
const SkMatrix& viewM,
const SkMatrix& localM,
bool sharpenMipmappedTextures,

View File

@ -218,7 +218,7 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
// are provided by the caller.
bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
args.fFilterQuality, *args.fViewMatrix, *lm,
fImage->width(), fImage->height(), args.fFilterQuality, *args.fViewMatrix, *lm,
args.fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
GrSamplerState samplerState(wrapModes, textureFilterMode);
SkScalar scaleAdjust[2] = { 1.0f, 1.0f };