diff options
author | reed <reed@google.com> | 2015-02-19 18:39:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-19 18:39:49 -0800 |
commit | 0c2da0c99f3553d406e937fc9026f31cfc77507f (patch) | |
tree | 197f3d69e892ae0f86ba776452fc6e0950ebfea5 /src | |
parent | 176cd92a61a35432d8cba10d61c3e579654835df (diff) |
use geometric ave for choosing mip level
requires https://codereview.chromium.org/937233002/
BUG=skia:
Review URL: https://codereview.chromium.org/916103008
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 30a64ed5a8..81c14a2ffd 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; |