aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapController.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-08-31 15:16:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-31 15:16:17 -0700
commit99138876a699a41637fe8c46ccdb0292dcabd7ce (patch)
tree111029462b64e08de0899e6ff08c92ef02dce4a3 /src/core/SkBitmapController.cpp
parentaba1dc8c6aa5cbc4f38ddfce757832359f200b54 (diff)
simplify bitmap scaler and cache
Diffstat (limited to 'src/core/SkBitmapController.cpp')
-rw-r--r--src/core/SkBitmapController.cpp22
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;
}