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

Unified Diff: src/images/SkImageDecoder.cpp

Issue 647023006: Qualify the return value of SkImageDecoder::decode (Closed) Base URL: https://skia.googlesource.com/skia.git/+/master
Patch Set: fix a sample Created 6 years, 2 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/images/SkDecodingImageGenerator.cpp ('k') | src/images/SkImageDecoder_astc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/images/SkDecodingImageGenerator.cpp ('k') | src/images/SkImageDecoder_astc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698