Index: src/images/SkImageDecoder.cpp |
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp |
index f9b04e39a7b3de3b247221a13426ef663c42c647..c5e973903d61a3fe25e6b4a7aaa99f1043b04335 100644 |
--- a/src/images/SkImageDecoder.cpp |
+++ b/src/images/SkImageDecoder.cpp |
@@ -156,7 +156,8 @@ SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha |
return ct; |
} |
-bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm, SkColorType pref, Mode mode) { |
+SkImageDecoder::Result SkImageDecoder::decode(SkStream* stream, SkBitmap* bm, SkColorType pref, |
+ Mode mode) { |
// we reset this to false before calling onDecode |
fShouldCancelDecode = false; |
// assign this, for use by getPrefColorType(), in case fUsePrefTable is false |
@@ -164,12 +165,12 @@ bool SkImageDecoder::decode(SkStream* stream, SkBitmap* bm, SkColorType pref, Mo |
// pass a temporary bitmap, so that if we return false, we are assured of |
// leaving the caller's bitmap untouched. |
- SkBitmap tmp; |
- if (!this->onDecode(stream, &tmp, mode)) { |
- return false; |
+ SkBitmap tmp; |
+ const Result result = this->onDecode(stream, &tmp, mode); |
+ if (kFailure != result) { |
+ bm->swap(tmp); |
} |
- bm->swap(tmp); |
- return true; |
+ return result; |
} |
bool SkImageDecoder::decodeSubset(SkBitmap* bm, const SkIRect& rect, SkColorType pref) { |
@@ -272,7 +273,7 @@ bool SkImageDecoder::DecodeStream(SkStreamRewindable* stream, SkBitmap* bm, SkCo |
SkImageDecoder* codec = SkImageDecoder::Factory(stream); |
if (codec) { |
- success = codec->decode(stream, bm, pref, mode); |
+ success = codec->decode(stream, bm, pref, mode) != kFailure; |
if (success && format) { |
*format = codec->getFormat(); |
if (kUnknown_Format == *format) { |