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

Unified Diff: src/codec/SkBmpRLECodec.cpp

Issue 1907593004: Support the non-native (RGBA/BGRA) swizzle (Closed) Base URL: https://skia.googlesource.com/skia.git@tryagain
Patch Set: Multiple bug fixes 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
« no previous file with comments | « src/codec/SkBmpRLECodec.h ('k') | src/codec/SkBmpStandardCodec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkBmpRLECodec.cpp
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index d80dd1a18ab63f5bf5f91920d11cf6e748afccbb..02b42f6d90ce086496c6a15dbba8d1bd4cd31c9d 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -70,7 +70,7 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo,
/*
* Process the color table for the bmp input
*/
- bool SkBmpRLECodec::createColorTable(int* numColors) {
+ bool SkBmpRLECodec::createColorTable(SkColorType dstColorType, int* numColors) {
// Allocate memory for color table
uint32_t colorBytes = 0;
SkPMColor colorTable[256];
@@ -96,12 +96,13 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo,
}
// Fill in the color table
+ PackColorProc packARGB = choose_pack_color_proc(false, dstColorType);
uint32_t i = 0;
for (; i < numColorsToRead; i++) {
uint8_t blue = get_byte(cBuffer.get(), i*fBytesPerColor);
uint8_t green = get_byte(cBuffer.get(), i*fBytesPerColor + 1);
uint8_t red = get_byte(cBuffer.get(), i*fBytesPerColor + 2);
- colorTable[i] = SkPackARGB32NoCheck(0xFF, red, green, blue);
+ colorTable[i] = packARGB(0xFF, red, green, blue);
}
// To avoid segmentation faults on bad pixel data, fill the end of the
@@ -208,7 +209,8 @@ void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes,
// Set the pixel based on destination color type
const int dstX = get_dst_coord(x, fSampleX);
switch (dstInfo.colorType()) {
- case kN32_SkColorType: {
+ case kRGBA_8888_SkColorType:
+ case kBGRA_8888_SkColorType: {
SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
dstRow[dstX] = fColorTable->operator[](index);
break;
@@ -241,9 +243,14 @@ void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes,
// Set the pixel based on destination color type
const int dstX = get_dst_coord(x, fSampleX);
switch (dstInfo.colorType()) {
- case kN32_SkColorType: {
+ case kRGBA_8888_SkColorType: {
SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
- dstRow[dstX] = SkPackARGB32NoCheck(0xFF, red, green, blue);
+ dstRow[dstX] = SkPackARGB_as_RGBA(0xFF, red, green, blue);
+ break;
+ }
+ case kBGRA_8888_SkColorType: {
+ SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
+ dstRow[dstX] = SkPackARGB_as_BGRA(0xFF, red, green, blue);
break;
}
case kRGB_565_SkColorType: {
@@ -275,7 +282,7 @@ SkCodec::Result SkBmpRLECodec::prepareToDecode(const SkImageInfo& dstInfo,
// 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(inputColorCount)) {
+ if (!this->createColorTable(dstInfo.colorType(), inputColorCount)) {
SkCodecPrintf("Error: could not create color table.\n");
return SkCodec::kInvalidInput;
}
@@ -315,7 +322,8 @@ int SkBmpRLECodec::decodeRows(const SkImageInfo& info, void* dst, size_t dstRowB
// the skipped pixels will be transparent.
// Because of the need for transparent pixels, kN32 is the only color
// type that makes sense for the destination format.
- SkASSERT(kN32_SkColorType == dstInfo.colorType());
+ SkASSERT(kRGBA_8888_SkColorType == dstInfo.colorType() ||
+ kBGRA_8888_SkColorType == dstInfo.colorType());
if (dst) {
SkSampler::Fill(dstInfo, dst, dstRowBytes, SK_ColorTRANSPARENT, opts.fZeroInitialized);
}
« no previous file with comments | « src/codec/SkBmpRLECodec.h ('k') | src/codec/SkBmpStandardCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698