| Index: src/codec/SkBmpStandardCodec.cpp
|
| diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
|
| index 0d91a9cb6683c48db3cbb3228055dd9e352b383f..660f32e22c245da7e8b943ef8ac9ce37ba9a035d 100644
|
| --- a/src/codec/SkBmpStandardCodec.cpp
|
| +++ b/src/codec/SkBmpStandardCodec.cpp
|
| @@ -68,7 +68,8 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| /*
|
| * Process the color table for the bmp input
|
| */
|
| - bool SkBmpStandardCodec::createColorTable(SkAlphaType dstAlphaType, int* numColors) {
|
| + bool SkBmpStandardCodec::createColorTable(SkColorType dstColorType, SkAlphaType dstAlphaType,
|
| + int* numColors) {
|
| // Allocate memory for color table
|
| uint32_t colorBytes = 0;
|
| SkPMColor colorTable[256];
|
| @@ -94,12 +95,8 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| }
|
|
|
| // Choose the proper packing function
|
| - SkPMColor (*packARGB) (uint32_t, uint32_t, uint32_t, uint32_t);
|
| - if (fIsOpaque || kUnpremul_SkAlphaType == dstAlphaType) {
|
| - packARGB = &SkPackARGB32NoCheck;
|
| - } else {
|
| - packARGB = &SkPremultiplyARGBInline;
|
| - }
|
| + bool isPremul = (kPremul_SkAlphaType == dstAlphaType) && !fIsOpaque;
|
| + PackColorProc packARGB = choose_pack_color_proc(isPremul, dstColorType);
|
|
|
| // Fill in the color table
|
| uint32_t i = 0;
|
| @@ -153,40 +150,11 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| }
|
|
|
| void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) {
|
| - // Get swizzler configuration
|
| - SkSwizzler::SrcConfig config = SkSwizzler::kUnknown;
|
| - switch (this->bitsPerPixel()) {
|
| - case 1:
|
| - config = SkSwizzler::kIndex1;
|
| - break;
|
| - case 2:
|
| - config = SkSwizzler::kIndex2;
|
| - break;
|
| - case 4:
|
| - config = SkSwizzler::kIndex4;
|
| - break;
|
| - case 8:
|
| - config = SkSwizzler::kIndex;
|
| - break;
|
| - case 24:
|
| - config = SkSwizzler::kBGR;
|
| - break;
|
| - case 32:
|
| - if (fIsOpaque) {
|
| - config = SkSwizzler::kBGRX;
|
| - } else {
|
| - config = SkSwizzler::kBGRA;
|
| - }
|
| - break;
|
| - default:
|
| - SkASSERT(false);
|
| - }
|
| -
|
| // Get a pointer to the color table if it exists
|
| const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
|
|
|
| // Create swizzler
|
| - fSwizzler.reset(SkSwizzler::CreateSwizzler(config, colorPtr, dstInfo, opts));
|
| + fSwizzler.reset(SkSwizzler::CreateSwizzler(this->getEncodedInfo(), colorPtr, dstInfo, opts));
|
| SkASSERT(fSwizzler);
|
| }
|
|
|
| @@ -194,7 +162,7 @@ SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo,
|
| const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
|
| // Create the color table if necessary and prepare the stream for decode
|
| // Note that if it is non-NULL, inputColorCount will be modified
|
| - if (!this->createColorTable(dstInfo.alphaType(), inputColorCount)) {
|
| + if (!this->createColorTable(dstInfo.colorType(), dstInfo.alphaType(), inputColorCount)) {
|
| SkCodecPrintf("Error: could not create color table.\n");
|
| return SkCodec::kInvalidInput;
|
| }
|
|
|