diff options
author | humper <humper@google.com> | 2014-08-28 09:54:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-28 09:54:41 -0700 |
commit | 60cc7d353b2adc8fcc1712e1f7a965e70121ebcc (patch) | |
tree | b73b8ab5d07473cc1107f29b966dace328b481de /src/core | |
parent | 744998e666073166307d2522847b2536000a7619 (diff) |
manual revert of bitmap scale change while I investigate failures
on chromeos
TBR=reed
NOTREECHECKS=True
Author: humper@google.com
Review URL: https://codereview.chromium.org/516923003
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 46 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.h | 1 |
2 files changed, 13 insertions, 34 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 2583cb5011..7640573596 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -149,34 +149,21 @@ static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) { bool SkBitmapProcState::possiblyScaleImage() { SkASSERT(NULL == fBitmap); - fAdjustedMatrix = false; - if (fFilterLevel <= SkPaint::kLow_FilterLevel) { return false; } // Check to see if the transformation matrix is simple, and if we're // doing high quality scaling. If so, do the bitmap scale here and - // remove the (non-fractional) scaling component from the matrix. - - SkScalar invScaleX = fInvMatrix.getScaleX(); - SkScalar invScaleY = fInvMatrix.getScaleY(); - - float trueDestWidth = fOrigBitmap.width() / invScaleX; - float trueDestHeight = fOrigBitmap.height() / invScaleY; - -#ifndef SK_IGNORE_PROPER_FRACTIONAL_SCALING - float roundedDestWidth = SkScalarRoundToScalar(trueDestWidth); - float roundedDestHeight = SkScalarRoundToScalar(trueDestHeight); -#else - float roundedDestWidth = trueDestWidth; - float roundedDestHeight = trueDestHeight; -#endif + // remove the scaling component from the matrix. if (SkPaint::kHigh_FilterLevel == fFilterLevel && fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) && kN32_SkColorType == fOrigBitmap.colorType() && cache_size_okay(fOrigBitmap, fInvMatrix)) { + 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 @@ -193,14 +180,17 @@ bool SkBitmapProcState::possiblyScaleImage() { return false; } - if (!SkBitmapCache::Find(fOrigBitmap, roundedDestWidth, roundedDestHeight, &fScaledBitmap)) { + if (!SkBitmapCache::Find(fOrigBitmap, invScaleX, invScaleY, &fScaledBitmap)) { + float dest_width = fOrigBitmap.width() / invScaleX; + float dest_height = fOrigBitmap.height() / invScaleY; + // All the criteria are met; let's make a new bitmap. if (!SkBitmapScaler::Resize(&fScaledBitmap, fOrigBitmap, SkBitmapScaler::RESIZE_BEST, - roundedDestWidth, - roundedDestHeight, + dest_width, + dest_height, SkScaledImageCache::GetAllocator())) { // we failed to create fScaledBitmap, so just return and let // the scanline proc handle it. @@ -209,7 +199,7 @@ bool SkBitmapProcState::possiblyScaleImage() { } SkASSERT(NULL != fScaledBitmap.getPixels()); - SkBitmapCache::Add(fOrigBitmap, roundedDestWidth, roundedDestHeight, fScaledBitmap); + SkBitmapCache::Add(fOrigBitmap, invScaleX, invScaleY, fScaledBitmap); } SkASSERT(NULL != fScaledBitmap.getPixels()); @@ -219,19 +209,9 @@ bool SkBitmapProcState::possiblyScaleImage() { fInvMatrix.setTranslate(fInvMatrix.getTranslateX() / fInvMatrix.getScaleX(), fInvMatrix.getTranslateY() / fInvMatrix.getScaleY()); -#ifndef SK_IGNORE_PROPER_FRACTIONAL_SCALING - // reintroduce any fractional scaling missed by our integral scale done above. - - float fractionalScaleX = trueDestWidth/roundedDestWidth; - float fractionalScaleY = trueDestHeight/roundedDestHeight; - - fInvMatrix.postScale(fractionalScaleX, fractionalScaleY); -#endif - fAdjustedMatrix = true; - // Set our filter level to low -- the only post-filtering this // image might require is some interpolation if the translation - // is fractional or if there's any remaining scaling to be done. + // is fractional. fFilterLevel = SkPaint::kLow_FilterLevel; return true; } @@ -387,7 +367,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && SkShader::kClamp_TileMode == fTileModeY; - if (!(fAdjustedMatrix || clampClamp || trivialMatrix)) { + if (!(clampClamp || trivialMatrix)) { fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); } diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index 4e4eded202..64dda2ecb3 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -144,7 +144,6 @@ private: SkBitmap fScaledBitmap; // chooseProcs SkAutoTUnref<const SkMipMap> fCurrMip; - bool fAdjustedMatrix; // set by possiblyScaleImage MatrixProc chooseMatrixProc(bool trivial_matrix); bool chooseProcs(const SkMatrix& inv, const SkPaint&); |