Chromium Code Reviews| Index: src/codec/SkSwizzler.cpp |
| diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp |
| index 791363381f52a243ac39a2266d99154c0a1a7db5..97bc1041473f9d2f7c33da0662f3557c66ee1e99 100644 |
| --- a/src/codec/SkSwizzler.cpp |
| +++ b/src/codec/SkSwizzler.cpp |
| @@ -68,6 +68,8 @@ static SkSwizzler::ResultAlpha swizzle_small_index_to_n32( |
| return COMPUTE_RESULT_ALPHA; |
| } |
| +// kIndex |
| + |
| static SkSwizzler::ResultAlpha swizzle_index_to_index( |
| void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
| int bytesPerPixel, int y, const SkPMColor ctable[]) { |
| @@ -84,8 +86,6 @@ static SkSwizzler::ResultAlpha swizzle_index_to_index( |
| return COMPUTE_RESULT_ALPHA; |
| } |
| -// kIndex |
| - |
| static SkSwizzler::ResultAlpha swizzle_index_to_n32( |
| void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
| int bytesPerPixel, int y, const SkPMColor ctable[]) { |
| @@ -118,6 +118,28 @@ static SkSwizzler::ResultAlpha swizzle_index_to_n32_skipZ( |
| #undef A32_MASK_IN_PLACE |
| +// kGray |
| + |
| +static SkSwizzler::ResultAlpha swizzle_gray_to_n32( |
| + void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
| + int bytesPerPixel, int y, const SkPMColor ctable[]) { |
| + |
| + SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; |
| + for (int x = 0; x < width; x++) { |
| + dst[x] = SkPackARGB32NoCheck(0xFF, src[x], src[x], src[x]); |
| + } |
| + return SkSwizzler::kOpaque_ResultAlpha; |
| +} |
| + |
| +static SkSwizzler::ResultAlpha swizzle_gray_to_gray( |
| + void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
| + int bytesPerPixel, int y, const SkPMColor ctable[]) { |
| + memcpy(dstRow, src, width); |
| + return SkSwizzler::kOpaque_ResultAlpha; |
| +} |
| + |
| +// kBGRX |
| + |
| static SkSwizzler::ResultAlpha swizzle_bgrx_to_n32( |
| void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, |
| int bytesPerPixel, int y, const SkPMColor ctable[]) { |
| @@ -299,6 +321,17 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, |
| break; |
| } |
| break; |
| + case kGray: |
| + switch (info.colorType()) { |
| + case kN32_SkColorType: |
| + proc = &swizzle_gray_to_n32; |
| + break; |
| + case kGray_8_SkColorType: |
| + proc = &swizzle_gray_to_gray; |
| + default: |
| + break; |
| + } |
| + break; |
| case kBGR: |
| case kBGRX: |
| switch (info.colorType()) { |
| @@ -464,6 +497,10 @@ void SkSwizzler::Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstR |
| SkASSERT(colorOrIndex == (uint8_t) colorOrIndex); |
| memset(dstStartRow, colorOrIndex, bytesToFill); |
| break; |
| + case kGray_8_SkColorType: |
| + // If the destination is kGray, the caller passes in an 8-bit color |
| + memset(dstStartRow, (uint8_t) colorOrIndex, bytesToFill); |
|
scroggo
2015/04/15 14:00:18
Interestingly, we assert for index8 that the input
msarett
2015/04/15 14:20:15
Agreed.
|
| + break; |
| default: |
| SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n"); |
| SkASSERT(false); |