Use geometric mean when selecting a mipmap scale
authorfmalita <fmalita@chromium.org>
Wed, 17 Feb 2016 14:17:12 +0000 (06:17 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 17 Feb 2016 14:17:12 +0000 (06:17 -0800)
Workaround for anisotropic mipmap quality issues.

R=reed@google.com,robertphillips@google.com
BUG=skia:4863,chromium:586894
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1697423002

Review URL: https://codereview.chromium.org/1697423002

src/core/SkMipMap.cpp

index 7266dc6b21192c16019c0277ea4387244033d209..1f69c2411ba30e6df45bef94b2d04a96111a3b7a 100644 (file)
@@ -326,8 +326,16 @@ bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const {
     }
 
     SkASSERT(scaleSize.width() >= 0 && scaleSize.height() >= 0);
+
+#ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
     // Use the smallest scale to match the GPU impl.
     const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height());
+#else
+    // Ideally we'd pick the smaller scale, to match Ganesh.  But ignoring one of the
+    // scales can produce some atrocious results, so for now we use the geometric mean.
+    // (https://bugs.chromium.org/p/skia/issues/detail?id=4863)
+    const SkScalar scale = SkScalarSqrt(scaleSize.width() * scaleSize.height());
+#endif
 
     if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) {
         return false;