Anisotropic mipmap fixes
1) when selecting a level scale, use max(scaleX, scaleY) instead of
current sqrt(scaleX * scaleY)
2) track and apply non-uniform fixup scales
R=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1617183004
Review URL: https://codereview.chromium.org/1617183004
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index 61c14dc..5430575 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -160,8 +160,15 @@
if (!fInvMatrix.decomposeScale(&invScaleSize, nullptr)) {
return false;
}
+
+#ifdef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAPS
SkScalar invScale = SkScalarSqrt(invScaleSize.width() * invScaleSize.height());
-
+#else
+ // Use the largest (non-inverse) scale, to ensure anisotropic consistency.
+ SkASSERT(invScaleSize.width() >= 0 && invScaleSize.height() >= 0);
+ const SkScalar invScale = SkTMin(invScaleSize.width(), invScaleSize.height());
+#endif
+
if (invScale > SK_Scalar1) {
fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc()));
if (nullptr == fCurrMip.get()) {
@@ -182,9 +189,9 @@
SkScalar levelScale = SkScalarInvert(invScale);
SkMipMap::Level level;
if (fCurrMip->extractLevel(levelScale, &level)) {
- SkScalar invScaleFixup = level.fScale;
- fInvMatrix.postScale(invScaleFixup, invScaleFixup);
-
+ const SkSize& invScaleFixup = level.fScale;
+ fInvMatrix.postScale(invScaleFixup.width(), invScaleFixup.height());
+
// todo: if we could wrap the fCurrMip in a pixelref, then we could just install
// that here, and not need to explicitly track it ourselves.
return fResultBitmap.installPixels(level.fPixmap);