| Index: src/images/SkImageDecoder_libwebp.cpp
|
| diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
|
| index f32587ddcc2427c1e3630cd5285f1049aaf71224..8bf15c92e6235b52751a444aac5ecf6a898f14e2 100644
|
| --- a/src/images/SkImageDecoder_libwebp.cpp
|
| +++ b/src/images/SkImageDecoder_libwebp.cpp
|
| @@ -111,7 +111,7 @@ public:
|
| protected:
|
| virtual bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) SK_OVERRIDE;
|
| virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRIDE;
|
| - virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
|
| + virtual Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
|
|
|
| private:
|
| /**
|
| @@ -162,11 +162,22 @@ private:
|
|
|
| // This guy exists just to aid in debugging, as it allows debuggers to just
|
| // set a break-point in one place to see all error exists.
|
| -static bool return_false(const SkBitmap& bm, const char msg[]) {
|
| +static void print_webp_error(const SkBitmap& bm, const char msg[]) {
|
| SkDEBUGF(("libwebp error %s [%d %d]", msg, bm.width(), bm.height()));
|
| +}
|
| +
|
| +static bool return_false(const SkBitmap& bm, const char msg[]) {
|
| + print_webp_error(bm, msg);
|
| return false; // must always return false
|
| }
|
|
|
| +static SkImageDecoder::Result return_failure(const SkBitmap& bm, const char msg[]) {
|
| + print_webp_error(bm, msg);
|
| + return SkImageDecoder::kFailure; // must always return kFailure
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +
|
| static WEBP_CSP_MODE webp_decode_mode(const SkBitmap* decodedBitmap, bool premultiply) {
|
| WEBP_CSP_MODE mode = MODE_LAST;
|
| const SkColorType ct = decodedBitmap->colorType();
|
| @@ -409,15 +420,15 @@ bool SkWEBPImageDecoder::onDecodeSubset(SkBitmap* decodedBitmap,
|
| return true;
|
| }
|
|
|
| -bool SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
|
| - Mode mode) {
|
| +SkImageDecoder::Result SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
|
| + Mode mode) {
|
| #ifdef TIME_DECODE
|
| AutoTimeMillis atm("WEBP Decode");
|
| #endif
|
|
|
| int origWidth, origHeight, hasAlpha;
|
| if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) {
|
| - return false;
|
| + return kFailure;
|
| }
|
| this->fHasAlpha = hasAlpha;
|
|
|
| @@ -425,16 +436,16 @@ bool SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
|
| SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize);
|
| if (!setDecodeConfig(decodedBitmap, sampler.scaledWidth(),
|
| sampler.scaledHeight())) {
|
| - return false;
|
| + return kFailure;
|
| }
|
|
|
| // If only bounds are requested, done
|
| if (SkImageDecoder::kDecodeBounds_Mode == mode) {
|
| - return true;
|
| + return kSuccess;
|
| }
|
|
|
| if (!this->allocPixelRef(decodedBitmap, NULL)) {
|
| - return return_false(*decodedBitmap, "allocPixelRef");
|
| + return return_failure(*decodedBitmap, "allocPixelRef");
|
| }
|
|
|
| SkAutoLockPixels alp(*decodedBitmap);
|
| @@ -442,11 +453,11 @@ bool SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
|
| WebPDecoderConfig config;
|
| if (!webp_get_config_resize(&config, decodedBitmap, origWidth, origHeight,
|
| this->shouldPremultiply())) {
|
| - return false;
|
| + return kFailure;
|
| }
|
|
|
| // Decode the WebP image data stream using WebP incremental decoding.
|
| - return webp_idecode(stream, &config);
|
| + return webp_idecode(stream, &config) ? kSuccess : kFailure;
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|