Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1007)

Unified Diff: src/core/SkBitmapController.cpp

Issue 1617183004: Anisotropic mipmap fixes (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: SkIntToScalar Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkMipMap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapController.cpp
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index 61c14dc7b8c7250e248d596d792ca5d58cd340c2..5430575515d38bda1f849fcd049df57234c8a21d 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -160,8 +160,15 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
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 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
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);
« no previous file with comments | « no previous file | src/core/SkMipMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698