Index: src/codec/SkSwizzler.cpp |
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp |
index b2b7f927ac262913d86fcfd6c89af7cf430723cb..ed36d469f53126922a1e32440f675886cc8bbe6e 100644 |
--- a/src/codec/SkSwizzler.cpp |
+++ b/src/codec/SkSwizzler.cpp |
@@ -137,6 +137,28 @@ static SkSwizzler::ResultAlpha swizzle_small_index_to_index( |
return COMPUTE_RESULT_ALPHA; |
} |
+static SkSwizzler::ResultAlpha swizzle_small_index_to_565( |
+ void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
+ int bitsPerPixel, const SkPMColor ctable[]) { |
+ |
+ uint16_t* SK_RESTRICT dst = (uint16_t*) dstRow; |
+ const uint32_t pixelsPerByte = 8 / bitsPerPixel; |
+ const size_t rowBytes = compute_row_bytes_ppb(width, pixelsPerByte); |
+ const uint8_t mask = (1 << bitsPerPixel) - 1; |
+ int x = 0; |
+ for (uint32_t byte = 0; byte < rowBytes; byte++) { |
+ uint8_t pixelData = src[byte]; |
+ for (uint32_t p = 0; p < pixelsPerByte && x < width; p++) { |
+ uint8_t index = (pixelData >> (8 - bitsPerPixel)) & mask; |
+ uint16_t c = SkPixel32ToPixel16(ctable[index]); |
+ dst[x] = c; |
+ pixelData <<= bitsPerPixel; |
+ x++; |
+ } |
+ } |
+ return SkSwizzler::kOpaque_ResultAlpha; |
+} |
+ |
static SkSwizzler::ResultAlpha swizzle_small_index_to_n32( |
void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
int bitsPerPixel, const SkPMColor ctable[]) { |
@@ -271,6 +293,19 @@ static SkSwizzler::ResultAlpha swizzle_bgrx_to_n32( |
return SkSwizzler::kOpaque_ResultAlpha; |
} |
+static SkSwizzler::ResultAlpha swizzle_bgrx_to_565( |
+ void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
+ int bytesPerPixel, const SkPMColor ctable[]) { |
+ // FIXME: Support dithering? |
+ uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow; |
+ for (int x = 0; x < width; x++) { |
+ // FIXME: I believe this is correct - still need to test. |
scroggo_chromium
2015/08/10 17:26:16
Oops. Will remove this in a followup
msarett
2015/08/10 17:44:24
Acknowledged.
|
+ dst[x] = SkPack888ToRGB16(src[2], src[1], src[0]); |
+ src += bytesPerPixel; |
+ } |
+ return SkSwizzler::kOpaque_ResultAlpha; |
+} |
+ |
// kBGRA |
static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_unpremul( |
@@ -489,6 +524,9 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, |
case kN32_SkColorType: |
proc = &swizzle_bgrx_to_n32; |
break; |
+ case kRGB_565_SkColorType: |
+ proc = &swizzle_bgrx_to_565; |
+ break; |
default: |
break; |
} |