diff options
Diffstat (limited to 'src/images/SkImageDecoder_ktx.cpp')
-rw-r--r-- | src/images/SkImageDecoder_ktx.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/images/SkImageDecoder_ktx.cpp b/src/images/SkImageDecoder_ktx.cpp index 20c8bbc00b..8566375f0c 100644 --- a/src/images/SkImageDecoder_ktx.cpp +++ b/src/images/SkImageDecoder_ktx.cpp @@ -41,22 +41,22 @@ 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; }; -bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { +SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { // TODO: Implement SkStream::copyToData() that's cheap for memory and file streams SkAutoDataUnref data(SkCopyStreamToData(stream)); if (NULL == data) { - return false; + return kFailure; } SkKTXFile ktxFile(data); if (!ktxFile.valid()) { - return false; + return kFailure; } const unsigned short width = ktxFile.width(); @@ -65,7 +65,7 @@ bool SkKTXImageDecoder::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 @@ -84,7 +84,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { // If the client wants unpremul colors and we only have // premul, then we cannot honor their wish. if (bSrcIsPremul) { - return false; + return kFailure; } } else { alphaType = kPremul_SkAlphaType; @@ -121,12 +121,12 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { } if (SkImageDecoder::kDecodeBounds_Mode == mode) { - return true; + return kSuccess; } // If we've made it this far, then we know how to grok the data. if (!this->allocPixelRef(bm, NULL)) { - return false; + return kFailure; } // Lock the pixels, since we're about to write to them... @@ -134,7 +134,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { if (isCompressedAlpha) { if (!sampler.begin(bm, SkScaledBitmapSampler::kGray, *this)) { - return false; + return kFailure; } // Alpha data is only a single byte per pixel. @@ -146,7 +146,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { const uint8_t *buf = reinterpret_cast<const uint8_t *>(ktxFile.pixelData()); if (!SkTextureCompressor::DecompressBufferFromFormat( outRGBDataPtr, width, buf, width, height, ktxCompressedFormat)) { - return false; + return kFailure; } // Set each of the pixels... @@ -159,11 +159,11 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { srcRow += sampler.srcDY() * srcRowBytes; } - return true; + return kSuccess; } else if (ktxFile.isCompressedFormat(SkTextureCompressor::kETC1_Format)) { if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) { - return false; + return kFailure; } // ETC1 Data is encoded as RGB pixels, so we should extract it as such @@ -175,7 +175,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { const uint8_t *buf = reinterpret_cast<const uint8_t *>(ktxFile.pixelData()); if (!SkTextureCompressor::DecompressBufferFromFormat( outRGBDataPtr, width*3, buf, width, height, SkTextureCompressor::kETC1_Format)) { - return false; + return kFailure; } // Set each of the pixels... @@ -188,13 +188,13 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { srcRow += sampler.srcDY() * srcRowBytes; } - return true; + return kSuccess; } else if (ktxFile.isRGB8()) { // Uncompressed RGB data (without alpha) if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) { - return false; + return kFailure; } // Just need to read RGB pixels @@ -207,7 +207,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { srcRow += sampler.srcDY() * srcRowBytes; } - return true; + return kSuccess; } else if (ktxFile.isRGBA8()) { @@ -224,7 +224,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { } if (!sampler.begin(bm, SkScaledBitmapSampler::kRGBA, opts)) { - return false; + return kFailure; } // Just need to read RGBA pixels @@ -237,10 +237,10 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { srcRow += sampler.srcDY() * srcRowBytes; } - return true; + return kSuccess; } - return false; + return kFailure; } /////////////////////////////////////////////////////////////////////////////// |