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

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 20005003: add scaledimagecache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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/SkBitmapProcState.h ('k') | src/core/SkScaledImageCache.h » ('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 991521a95df115a626ecd353e9ca259480c17c9c..f880a86196e4c0a267751320f3b21836c0124341 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -12,6 +12,7 @@
#include "SkShader.h" // for tilemodes
#include "SkUtilsArm.h"
#include "SkBitmapScaler.h"
+#include "SkScaledImageCache.h"
#if !SK_ARM_NEON_IS_NONE
// These are defined in src/opts/SkBitmapProcState_arm_neon.cpp
@@ -142,14 +143,29 @@ void SkBitmapProcState::possiblyScaleImage() {
fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) &&
fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) {
- int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / fInvMatrix.getScaleX());
- int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / fInvMatrix.getScaleY());
-
- // All the criteria are met; let's make a new bitmap.
-
- fScaledBitmap = SkBitmapScaler::Resize( fOrigBitmap, SkBitmapScaler::RESIZE_BEST,
- dest_width, dest_height, fConvolutionProcs );
-
+ SkScalar invScaleX = fInvMatrix.getScaleX();
+ SkScalar invScaleY = fInvMatrix.getScaleY();
+
+ SkASSERT(NULL == fScaledCacheID);
+ fScaledCacheID = SkScaledImageCache::FindAndLock(fOrigBitmap,
+ invScaleX, invScaleY,
+ &fScaledBitmap);
+ if (NULL == fScaledCacheID) {
+ int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / invScaleX);
+ int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / invScaleY);
+
+ // All the criteria are met; let's make a new bitmap.
+
+ fScaledBitmap = SkBitmapScaler::Resize(fOrigBitmap,
+ SkBitmapScaler::RESIZE_BEST,
+ dest_width,
+ dest_height,
+ fConvolutionProcs);
+ fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap,
+ invScaleX,
+ invScaleY,
+ fScaledBitmap);
+ }
fScaledBitmap.lockPixels();
fBitmap = &fScaledBitmap;
@@ -234,6 +250,11 @@ void SkBitmapProcState::endContext() {
SkDELETE(fBitmapFilter);
fBitmapFilter = NULL;
fScaledBitmap.reset();
+
+ if (fScaledCacheID) {
+ SkScaledImageCache::Unlock(fScaledCacheID);
+ fScaledCacheID = NULL;
+ }
}
bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkScaledImageCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698