diff options
author | reed <reed@google.com> | 2015-08-31 15:16:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-31 15:16:17 -0700 |
commit | 99138876a699a41637fe8c46ccdb0292dcabd7ce (patch) | |
tree | 111029462b64e08de0899e6ff08c92ef02dce4a3 /src/core/SkBitmapController.cpp | |
parent | aba1dc8c6aa5cbc4f38ddfce757832359f200b54 (diff) |
simplify bitmap scaler and cache
BUG=skia:
Review URL: https://codereview.chromium.org/1320513005
Diffstat (limited to 'src/core/SkBitmapController.cpp')
-rw-r--r-- | src/core/SkBitmapController.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp index e4b4199c69..3c3e69413a 100644 --- a/src/core/SkBitmapController.cpp +++ b/src/core/SkBitmapController.cpp @@ -10,6 +10,9 @@ #include "SkMatrix.h" #include "SkTemplates.h" +// RESIZE_LANCZOS3 is another good option, but chrome prefers mitchell at the moment +#define kHQ_RESIZE_METHOD SkBitmapScaler::RESIZE_MITCHELL + /////////////////////////////////////////////////////////////////////////////////////////////////// static bool valid_for_drawing(const SkBitmap& bm) { @@ -117,31 +120,28 @@ bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmap& origBitmap return false; // no need for HQ } - SkScalar trueDestWidth = origBitmap.width() / invScaleX; - SkScalar trueDestHeight = origBitmap.height() / invScaleY; - SkScalar roundedDestWidth = SkScalarRoundToScalar(trueDestWidth); - SkScalar roundedDestHeight = SkScalarRoundToScalar(trueDestHeight); + const int dstW = SkScalarRoundToScalar(origBitmap.width() / invScaleX); + const int dstH = SkScalarRoundToScalar(origBitmap.height() / invScaleY); - if (!SkBitmapCache::Find(origBitmap, roundedDestWidth, roundedDestHeight, &fResultBitmap)) { + if (!SkBitmapCache::FindWH(origBitmap, dstW, dstH, &fResultBitmap)) { SkAutoPixmapUnlock src; if (!origBitmap.requestLock(&src)) { return false; } - if (!SkBitmapScaler::Resize(&fResultBitmap, src.pixmap(), SkBitmapScaler::RESIZE_BEST, - roundedDestWidth, roundedDestHeight, - SkResourceCache::GetAllocator())) { + if (!SkBitmapScaler::Resize(&fResultBitmap, src.pixmap(), kHQ_RESIZE_METHOD, + dstW, dstH, SkResourceCache::GetAllocator())) { return false; // we failed to create fScaledBitmap } SkASSERT(fResultBitmap.getPixels()); fResultBitmap.setImmutable(); - SkBitmapCache::Add(origBitmap, roundedDestWidth, roundedDestHeight, fResultBitmap); + SkBitmapCache::AddWH(origBitmap, dstW, dstH, fResultBitmap); } SkASSERT(fResultBitmap.getPixels()); - fInvMatrix.postScale(roundedDestWidth / origBitmap.width(), - roundedDestHeight / origBitmap.height()); + fInvMatrix.postScale(SkIntToScalar(dstW) / origBitmap.width(), + SkIntToScalar(dstH) / origBitmap.height()); fQuality = kLow_SkFilterQuality; return true; } |