}
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;
(static_cast<int>(buf[2]) << 16);
}
-bool SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
+SkImageDecoder::Result SkASTCImageDecoder::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();
if (1 != blockDimZ) {
// We don't support decoding 3D
- return false;
+ return kFailure;
}
// Choose the proper ASTC format
astcFormat = SkTextureCompressor::kASTC_12x12_Format;
} else {
// We don't support any other block dimensions..
- return false;
+ return kFailure;
}
// Advance buf past the block dimensions
if (1 != depth) {
// We don't support decoding 3D.
- return false;
+ return kFailure;
}
// Advance the buffer past the image dimensions
#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
bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight(), alphaType));
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::kRGBA, *this)) {
- return false;
+ return kFailure;
}
// ASTC Data is encoded as RGBA pixels, so we should extract it as such
// Decode ASTC
if (!SkTextureCompressor::DecompressBufferFromFormat(
outRGBADataPtr, width*4, buf, width, height, astcFormat)) {
+ return kFailure;
}
// Set each of the pixels...
srcRow += sampler.srcDY() * srcRowBytes;
}
- return true;
+ return kSuccess;
}
/////////////////////////////////////////////////////////////////////////////////////////