Index: src/codec/SkBmpMaskCodec.cpp |
diff --git a/src/codec/SkBmpMaskCodec.cpp b/src/codec/SkBmpMaskCodec.cpp |
index 03c16c058896649ae5e9117736e432d6b85208a9..b173317c10a53ef9bee10721978e2b403080ad11 100644 |
--- a/src/codec/SkBmpMaskCodec.cpp |
+++ b/src/codec/SkBmpMaskCodec.cpp |
@@ -58,12 +58,25 @@ |
return kSuccess; |
} |
+bool SkBmpMaskCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& options) { |
+ // Create the swizzler |
+ fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(dstInfo, this->getInfo(), fMasks, |
+ this->bitsPerPixel(), options)); |
+ |
+ if (nullptr == fMaskSwizzler.get()) { |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
SkCodec::Result SkBmpMaskCodec::prepareToDecode(const SkImageInfo& dstInfo, |
const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) { |
- // Initialize the mask swizzler |
- fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(dstInfo, this->getInfo(), fMasks, |
- this->bitsPerPixel(), options)); |
- SkASSERT(fMaskSwizzler); |
+ // Initialize a the mask swizzler |
+ if (!this->initializeSwizzler(dstInfo, options)) { |
+ SkCodecPrintf("Error: cannot initialize swizzler.\n"); |
+ return SkCodec::kInvalidConversion; |
+ } |
return SkCodec::kSuccess; |
} |