Chromium Code Reviews| Index: src/codec/SkSwizzler.cpp |
| diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp |
| index 754b08883544928f7066456b409420d52a596e84..d8a8f9e6cc360713c34df5da0341237fbb9732b2 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 * bytesPerPixel); |
|
scroggo
2015/04/10 17:19:07
bytesPerPixel will always be 1 here, right?
msarett
2015/04/13 20:54:05
Yes. There is no need for this multiplication.
|
| + 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()) { |