Index: src/core/SkBitmap.cpp |
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
index 563fc2875c41221e1cacec39d108febd1f084377..cb4f1c6057b230229bddbd202dac2f48b18acaf2 100644 |
--- a/src/core/SkBitmap.cpp |
+++ b/src/core/SkBitmap.cpp |
@@ -337,13 +337,24 @@ bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactor |
return true; |
} |
+static void invoke_release_proc(void (*proc)(void* pixels, void* ctx), void* pixels, void* ctx) { |
+ if (proc) { |
+ proc(pixels, ctx); |
+ } |
+} |
+ |
bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, size_t rb, |
SkColorTable* ct, void (*releaseProc)(void* addr, void* context), |
void* context) { |
if (!this->setInfo(requestedInfo, rb)) { |
+ invoke_release_proc(releaseProc, pixels, context); |
this->reset(); |
return false; |
} |
+ if (NULL == pixels) { |
+ invoke_release_proc(releaseProc, pixels, context); |
+ return true; // we behaved as if they called setInfo() |
+ } |
// setInfo may have corrected info (e.g. 565 is always opaque). |
const SkImageInfo& correctedInfo = this->info(); |