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

Unified Diff: src/images/SkImageDecoder_pkm.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/SkImageDecoder_libwebp.cpp ('k') | src/images/SkImageDecoder_wbmp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_pkm.cpp
diff --git a/src/images/SkImageDecoder_pkm.cpp b/src/images/SkImageDecoder_pkm.cpp
index f5fd4b3fbcad54f7c2327b1c072159a97b0b1a73..746ae40c4c287a44839ad6d22d4fa84acd402742 100644
--- a/src/images/SkImageDecoder_pkm.cpp
+++ b/src/images/SkImageDecoder_pkm.cpp
@@ -24,7 +24,7 @@ public:
}
protected:
- virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
+ virtual Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
private:
typedef SkImageDecoder INHERITED;
@@ -32,11 +32,11 @@ private:
/////////////////////////////////////////////////////////////////////////////////////////
-bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
+SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
SkAutoMalloc autoMal;
const size_t length = SkCopyStreamToStorage(&autoMal, stream);
if (0 == length) {
- return false;
+ return kFailure;
}
unsigned char* buf = (unsigned char*)autoMal.get();
@@ -50,7 +50,7 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
// should we allow the Chooser (if present) to pick a config for us???
if (!this->chooseFromOneChoice(kN32_SkColorType, width, height)) {
- return false;
+ return kFailure;
}
#endif
@@ -61,18 +61,18 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight(),
kOpaque_SkAlphaType));
if (SkImageDecoder::kDecodeBounds_Mode == mode) {
- return true;
+ return kSuccess;
}
if (!this->allocPixelRef(bm, NULL)) {
- return false;
+ return kFailure;
}
// Lock the pixels, since we're about to write to them...
SkAutoLockPixels alp(*bm);
if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) {
- return false;
+ return kFailure;
}
// Advance buffer past the header
@@ -86,7 +86,7 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
// Decode ETC1
if (!SkTextureCompressor::DecompressBufferFromFormat(
outRGBDataPtr, width*3, buf, width, height, SkTextureCompressor::kETC1_Format)) {
- return false;
+ return kFailure;
}
// Set each of the pixels...
@@ -99,7 +99,7 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
srcRow += sampler.srcDY() * srcRowBytes;
}
- return true;
+ return kSuccess;
}
/////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/images/SkImageDecoder_libwebp.cpp ('k') | src/images/SkImageDecoder_wbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698