diff options
author | Brian Osman <brianosman@google.com> | 2018-02-15 10:09:48 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-16 13:39:35 +0000 |
commit | db78cba957889285604aeacb75e47af4600880c4 (patch) | |
tree | bd44a73a8de38497aed8319bc5b880c12d3b2a7a /src/gpu/SkGr.cpp | |
parent | f6f7b67ac230b14a725fbdabe951c70ea5b4428f (diff) |
Avoid creating MIPs until necessary when MIP bias is active
With sharpened mips, the scale at which we begin to sample level 1 is
(obviously) less than 1. This change avoids creation of mips for images
that are only slightly downscaled (and for which we wouldn't have sampled
those MIPs anyway).
Change-Id: If8ffc79c2ce2ff1f3aae7f5732d8a50aca0e26be
Reviewed-on: https://skia-review.googlesource.com/107801
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu/SkGr.cpp')
-rw-r--r-- | src/gpu/SkGr.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 12e7670029..c4bbf487f8 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -562,6 +562,7 @@ bool SkPaintToGrPaintWithTexture(GrContext* context, GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality, const SkMatrix& viewM, const SkMatrix& localM, + bool sharpenMipmappedTextures, bool* doBicubic) { *doBicubic = false; GrSamplerState::Filter textureFilterMode; @@ -575,7 +576,16 @@ GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilt case kMedium_SkFilterQuality: { SkMatrix matrix; matrix.setConcat(viewM, localM); - if (matrix.getMinScale() < SK_Scalar1) { + // With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until the + // computed LOD is >= 0.5. At what scale factor does a texture get an LOD of 0.5? + // + // Want: 0 = log2(1/s) - 0.5 + // 0.5 = log2(1/s) + // 2^0.5 = 1/s + // 1/2^0.5 = s + // 2^0.5/2 = s + SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1; + if (matrix.getMinScale() < mipScale) { textureFilterMode = GrSamplerState::Filter::kMipMap; } else { // Don't trigger MIP level generation unnecessarily. |