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

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 916103008: use geometric ave for choosing mip level (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 30a64ed5a84e7f3b3bef80b5e429cc5d1d83457c..81c14a2ffdcd071f63196fb3a5bde63c9fa6412e 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -98,16 +98,14 @@ static bool valid_for_filtering(unsigned dimension) {
return (dimension & ~0x3FFF) == 0;
}
-static SkScalar effective_matrix_scale_sqrd(const SkMatrix& mat) {
- SkPoint v1, v2;
-
- v1.fX = mat.getScaleX();
- v1.fY = mat.getSkewY();
-
- v2.fX = mat.getSkewX();
- v2.fY = mat.getScaleY();
-
- return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd());
+static SkScalar effective_matrix_scale(const SkMatrix& mat) {
+ SkScalar dx = SkVector::Length(mat.getScaleX(), mat.getSkewY());
+ SkScalar dy = SkVector::Length(mat.getSkewX(), mat.getScaleY());
+#ifdef SK_SUPPORT_LEGACY_MIPMAP_EFFECTIVE_SCALE
+ return SkMaxScalar(dx, dy);
+#else
+ return SkScalarSqrt(dx * dy);
+#endif
}
// Check to see that the size of the bitmap that would be produced by
@@ -210,9 +208,9 @@ void SkBitmapProcState::processMediumRequest() {
// to a valid bitmap.
fFilterLevel = SkPaint::kLow_FilterLevel;
- SkScalar invScaleSqd = effective_matrix_scale_sqrd(fInvMatrix);
+ SkScalar invScale = effective_matrix_scale(fInvMatrix);
- if (invScaleSqd > SK_Scalar1) {
+ if (invScale > SK_Scalar1) {
fCurrMip.reset(SkMipMapCache::FindAndRef(fOrigBitmap));
if (NULL == fCurrMip.get()) {
fCurrMip.reset(SkMipMapCache::AddAndRef(fOrigBitmap));
@@ -225,7 +223,7 @@ void SkBitmapProcState::processMediumRequest() {
sk_throw();
}
- SkScalar levelScale = SkScalarInvert(SkScalarSqrt(invScaleSqd));
+ SkScalar levelScale = SkScalarInvert(invScale);
SkMipMap::Level level;
if (fCurrMip->extractLevel(levelScale, &level)) {
SkScalar invScaleFixup = level.fScale;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698