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 20102002: free cache in destructor, in case endContext was not called. change Resize to return bool indicatin… (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/SkBitmapScaler.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 3a059d3876da56f2baba557192074c95920e2006..6e52546938066ee1aa920179a7418c0dfa6d1f5b 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -157,11 +157,17 @@ void SkBitmapProcState::possiblyScaleImage() {
// All the criteria are met; let's make a new bitmap.
- fScaledBitmap = SkBitmapScaler::Resize(fOrigBitmap,
- SkBitmapScaler::RESIZE_BEST,
- dest_width,
- dest_height,
- fConvolutionProcs);
+ if (!SkBitmapScaler::Resize(&fScaledBitmap,
+ fOrigBitmap,
+ SkBitmapScaler::RESIZE_BEST,
+ dest_width,
+ dest_height,
+ fConvolutionProcs)) {
+ // we failed to create fScaledBitmap, so just return and let
+ // the scanline proc handle it.
+ return;
+
+ }
fScaledCacheID = SkScaledImageCache::AddAndLock(fOrigBitmap,
invScaleX,
invScaleY,
@@ -277,6 +283,13 @@ void SkBitmapProcState::endContext() {
}
}
+SkBitmapProcState::~SkBitmapProcState() {
+ if (fScaledCacheID) {
+ SkScaledImageCache::Unlock(fScaledCacheID);
+ }
+ SkDELETE(fBitmapFilter);
+}
+
bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) {
return false;
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapScaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698