Index: src/codec/SkBmpStandardCodec.cpp |
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp |
index 51fd4e1bed8f31fe28a06c97e0cc4dd9f0a38eb7..bfb444fd9295aabc6918da780f91ace50a0d0c4a 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; |
@@ -165,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; |
} |