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

Unified Diff: src/codec/SkSwizzler.cpp

Issue 1076923002: SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@gif-real
Patch Set: Added comment Created 5 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/SkSwizzler.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkSwizzler.cpp
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index 791363381f52a243ac39a2266d99154c0a1a7db5..294229c37c6e914be706ee89cf605af06edafc25 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,15 @@ 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.
+ // We will not assert that the high bits of colorOrIndex must be zeroed.
+ // This allows us to take advantage of the fact that the low 8 bits of an
+ // SKPMColor may be a valid a grayscale color. For example, the low 8
+ // bits of SK_ColorBLACK are identical to the grayscale representation
+ // for black.
+ memset(dstStartRow, (uint8_t) colorOrIndex, bytesToFill);
+ break;
default:
SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n");
SkASSERT(false);
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698