diff options
Diffstat (limited to 'chromium/third_party/skia/src/core/SkBitmapProcState.cpp')
-rw-r--r-- | chromium/third_party/skia/src/core/SkBitmapProcState.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/chromium/third_party/skia/src/core/SkBitmapProcState.cpp b/chromium/third_party/skia/src/core/SkBitmapProcState.cpp index cdc582bfeec..f6f9f3fa06c 100644 --- a/chromium/third_party/skia/src/core/SkBitmapProcState.cpp +++ b/chromium/third_party/skia/src/core/SkBitmapProcState.cpp @@ -15,6 +15,7 @@ #include "SkMipMap.h" #include "SkPixelRef.h" #include "SkScaledImageCache.h" +#include "SkImageEncoder.h" #if !SK_ARM_NEON_IS_NONE // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp @@ -146,7 +147,7 @@ bool SkBitmapProcState::possiblyScaleImage() { if (SkPaint::kHigh_FilterLevel == fFilterLevel && fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) && - fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { + kN32_SkColorType == fOrigBitmap.colorType()) { SkScalar invScaleX = fInvMatrix.getScaleX(); SkScalar invScaleY = fInvMatrix.getScaleY(); @@ -166,8 +167,8 @@ bool SkBitmapProcState::possiblyScaleImage() { } if (NULL == fScaledCacheID) { - int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / invScaleX); - int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / invScaleY); + float dest_width = fOrigBitmap.width() / invScaleX; + float dest_height = fOrigBitmap.height() / invScaleY; // All the criteria are met; let's make a new bitmap. @@ -187,6 +188,7 @@ bool SkBitmapProcState::possiblyScaleImage() { return false; } + SkASSERT(NULL != fScaledBitmap.getPixels()); fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap, invScaleX, @@ -263,6 +265,7 @@ bool SkBitmapProcState::possiblyScaleImage() { if (mip) { fScaledCacheID = SkScaledImageCache::AddAndLockMip(fOrigBitmap, mip); + SkASSERT(mip->getRefCnt() > 1); mip->unref(); // the cache took a ref SkASSERT(fScaledCacheID); } @@ -277,10 +280,10 @@ bool SkBitmapProcState::possiblyScaleImage() { SkScalar invScaleFixup = level.fScale; fInvMatrix.postScale(invScaleFixup, invScaleFixup); - fScaledBitmap.setConfig(fOrigBitmap.config(), - level.fWidth, level.fHeight, - level.fRowBytes); - fScaledBitmap.setPixels(level.fPixels); + SkImageInfo info = fOrigBitmap.info(); + info.fWidth = level.fWidth; + info.fHeight = level.fHeight; + fScaledBitmap.installPixels(info, level.fPixels, level.fRowBytes); fBitmap = &fScaledBitmap; fFilterLevel = SkPaint::kLow_FilterLevel; unlocker.release(); @@ -359,17 +362,6 @@ bool SkBitmapProcState::lockBaseBitmap() { return true; } -void SkBitmapProcState::endContext() { - SkDELETE(fBitmapFilter); - fBitmapFilter = NULL; - fScaledBitmap.reset(); - - if (fScaledCacheID) { - SkScaledImageCache::Unlock(fScaledCacheID); - fScaledCacheID = NULL; - } -} - SkBitmapProcState::~SkBitmapProcState() { if (fScaledCacheID) { SkScaledImageCache::Unlock(fScaledCacheID); @@ -398,10 +390,17 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { } // The above logic should have always assigned fBitmap, but in case it // didn't, we check for that now... + // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)? if (NULL == fBitmap) { return false; } + // If we are "still" kMedium_FilterLevel, then the request was not fulfilled by possiblyScale, + // so we downgrade to kLow (so the rest of the sniffing code can assume that) + if (SkPaint::kMedium_FilterLevel == fFilterLevel) { + fFilterLevel = SkPaint::kLow_FilterLevel; + } + bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && SkShader::kClamp_TileMode == fTileModeY; @@ -480,6 +479,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { // shader will perform. fMatrixProc = this->chooseMatrixProc(trivialMatrix); + // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never returns NULL. if (NULL == fMatrixProc) { return false; } @@ -503,24 +503,25 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { index |= 4; } // bits 3,4,5 encoding the source bitmap format - switch (fBitmap->config()) { - case SkBitmap::kARGB_8888_Config: + switch (fBitmap->colorType()) { + case kN32_SkColorType: index |= 0; break; - case SkBitmap::kRGB_565_Config: + case kRGB_565_SkColorType: index |= 8; break; - case SkBitmap::kIndex8_Config: + case kIndex_8_SkColorType: index |= 16; break; - case SkBitmap::kARGB_4444_Config: + case kARGB_4444_SkColorType: index |= 24; break; - case SkBitmap::kA8_Config: + case kAlpha_8_SkColorType: index |= 32; fPaintPMColor = SkPreMultiplyColor(paint.getColor()); break; default: + // TODO(dominikg): Should we ever get here? SkASSERT(false) instead? return false; } @@ -880,7 +881,7 @@ bool SkBitmapProcState::setupForTranslate() { SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { - if (SkBitmap::kARGB_8888_Config != fBitmap->config()) { + if (kN32_SkColorType != fBitmap->colorType()) { return NULL; } |