Index: src/codec/SkSwizzler.cpp |
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp |
index 791363381f52a243ac39a2266d99154c0a1a7db5..80e51d2c462ea8c128d8654d4c29d84db5a0e6c6 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: |
+ // Always fill kGray with black |
+ memset(dstStartRow, 0xFF, bytesToFill); |
msarett
2015/04/13 20:54:06
I'm not exactly sure what the best decision is her
scroggo
2015/04/14 13:10:33
I am not familiar with kGray, but is 0xFF black? I
msarett
2015/04/14 19:30:36
Wow yes you are right. This is a nice reminder to
|
+ break; |
default: |
SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n"); |
SkASSERT(false); |