| Index: src/codec/SkBmpMaskCodec.cpp
|
| diff --git a/src/codec/SkBmpMaskCodec.cpp b/src/codec/SkBmpMaskCodec.cpp
|
| index 1c89ba1c84de158d80efa8725aebeef6d6b6c68c..f58fe5acd31a8040d6f2dbc5f62ccc64246d483b 100644
|
| --- a/src/codec/SkBmpMaskCodec.cpp
|
| +++ b/src/codec/SkBmpMaskCodec.cpp
|
| @@ -46,10 +46,9 @@ SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| return kInvalidConversion;
|
| }
|
|
|
| - // Initialize a the mask swizzler
|
| - if (!this->initializeSwizzler(dstInfo)) {
|
| - SkCodecPrintf("Error: cannot initialize swizzler.\n");
|
| - return kInvalidConversion;
|
| + Result result = this->prepareToDecode(dstInfo, opts, inputColorPtr, inputColorCount);
|
| + if (kSuccess != result) {
|
| + return result;
|
| }
|
|
|
| return this->decode(dstInfo, dst, dstRowBytes, opts);
|
| @@ -57,12 +56,13 @@ SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo,
|
|
|
| bool SkBmpMaskCodec::initializeSwizzler(const SkImageInfo& dstInfo) {
|
| // Allocate space for a row buffer
|
| - const size_t rowBytes = SkAlign4(compute_row_bytes(dstInfo.width(), this->bitsPerPixel()));
|
| + const size_t rowBytes = SkAlign4(compute_row_bytes(this->getInfo().width(),
|
| + this->bitsPerPixel()));
|
| fSrcBuffer.reset(SkNEW_ARRAY(uint8_t, rowBytes));
|
|
|
| // Create the swizzler
|
| fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(
|
| - dstInfo, fMasks, this->bitsPerPixel()));
|
| + dstInfo, this->getInfo(), fMasks, this->bitsPerPixel()));
|
|
|
| if (NULL == fMaskSwizzler.get()) {
|
| return false;
|
| @@ -78,7 +78,7 @@ SkCodec::Result SkBmpMaskCodec::decode(const SkImageInfo& dstInfo,
|
| void* dst, size_t dstRowBytes,
|
| const Options& opts) {
|
| // Set constant values
|
| - const int width = dstInfo.width();
|
| + const int width = this->getInfo().width();
|
| const int height = dstInfo.height();
|
| const size_t rowBytes = SkAlign4(compute_row_bytes(width, this->bitsPerPixel()));
|
|
|
| @@ -100,7 +100,7 @@ SkCodec::Result SkBmpMaskCodec::decode(const SkImageInfo& dstInfo,
|
| }
|
|
|
| // Decode the row in destination format
|
| - int row = SkBmpCodec::kBottomUp_RowOrder == this->rowOrder() ? height - 1 - y : y;
|
| + uint32_t row = this->getDstRow(y, dstInfo.height());
|
| void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes);
|
| fMaskSwizzler->swizzle(dstRow, srcRow);
|
| }
|
| @@ -108,3 +108,14 @@ SkCodec::Result SkBmpMaskCodec::decode(const SkImageInfo& dstInfo,
|
| // Finished decoding the entire image
|
| return kSuccess;
|
| }
|
| +
|
| +SkCodec::Result SkBmpMaskCodec::prepareToDecode(const SkImageInfo& dstInfo,
|
| + const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
|
| + // Initialize a the mask swizzler
|
| + if (!this->initializeSwizzler(dstInfo)) {
|
| + SkCodecPrintf("Error: cannot initialize swizzler.\n");
|
| + return SkCodec::kInvalidConversion;
|
| + }
|
| +
|
| + return SkCodec::kSuccess;
|
| +}
|
|
|