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

Unified Diff: src/core/SkBitmapController.cpp

Issue 1320513005: simplify bitmap scaler and cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « src/core/SkBitmapCache.cpp ('k') | src/core/SkBitmapScaler.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 e4b4199c6955941655db0dd4f67c503a7757396a..3c3e69413ab2e12f3dbbc66ca28fd56aa996a446 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;
}
« no previous file with comments | « src/core/SkBitmapCache.cpp ('k') | src/core/SkBitmapScaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698