Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: src/codec/SkBmpStandardCodec.cpp

Issue 1907593004: Support the non-native (RGBA/BGRA) swizzle (Closed) Base URL: https://skia.googlesource.com/skia.git@tryagain
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698