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

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 456843002: short circuit high quality scales that are actually the identity (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move erroneous assert into parent if() condition Created 6 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 | « no previous file | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | 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 d48679e8c993b0ddbb4e7a989b6edad8855307cc..6a6cc75b6e14ef688e8adaf967de3ce68e165a3a 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -167,6 +167,22 @@ bool SkBitmapProcState::possiblyScaleImage() {
SkScalar invScaleX = fInvMatrix.getScaleX();
SkScalar invScaleY = fInvMatrix.getScaleY();
+ if (SkScalarNearlyEqual(invScaleX,1.0f) &&
+ SkScalarNearlyEqual(invScaleY,1.0f)) {
+ // short-circuit identity scaling; the output is supposed to
+ // be the same as the input, so we might as well go fast.
+
+ // Note(humper): We could also probably do this if the scales
+ // are close to -1 as well, since the flip doesn't require
+ // any fancy re-sampling...
+
+ // Set our filter level to low -- the only post-filtering this
+ // image might require is some interpolation if the translation
+ // is fractional.
+ fFilterLevel = SkPaint::kLow_FilterLevel;
+ return false;
+ }
+
fScaledCacheID = SkScaledImageCache::FindAndLock(fOrigBitmap,
invScaleX, invScaleY,
&fScaledBitmap);
@@ -218,8 +234,10 @@ bool SkBitmapProcState::possiblyScaleImage() {
fInvMatrix.setTranslate(fInvMatrix.getTranslateX() / fInvMatrix.getScaleX(),
fInvMatrix.getTranslateY() / fInvMatrix.getScaleY());
- // no need for any further filtering; we just did it!
- fFilterLevel = SkPaint::kNone_FilterLevel;
+ // Set our filter level to low -- the only post-filtering this
+ // image might require is some interpolation if the translation
+ // is fractional.
+ fFilterLevel = SkPaint::kLow_FilterLevel;
unlocker.release();
return true;
}
« no previous file with comments | « no previous file | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698