From e16b04aa6041efb6507546547737e9603fa1606e Mon Sep 17 00:00:00 2001 From: msarett Date: Wed, 15 Apr 2015 07:32:19 -0700 Subject: SkJpegCodec Enables basic decoding for jpegs Includes rewinding 565, YUV, and Jpeg encoding are not yet implemented BUG=skia:3257 Review URL: https://codereview.chromium.org/1076923002 --- tests/SwizzlerTest.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tests/SwizzlerTest.cpp') diff --git a/tests/SwizzlerTest.cpp b/tests/SwizzlerTest.cpp index 147dfaa83d..7ed1c390fb 100644 --- a/tests/SwizzlerTest.cpp +++ b/tests/SwizzlerTest.cpp @@ -42,13 +42,24 @@ static void check_fill(skiatest::Reporter* r, // Ensure that the pixels are filled properly // The bots should catch any memory corruption uint8_t* indexPtr = imageData + startRow * rowBytes; + uint8_t* grayPtr = indexPtr; uint32_t* colorPtr = (uint32_t*) indexPtr; for (uint32_t y = startRow; y <= endRow; y++) { for (int32_t x = 0; x < imageInfo.width(); x++) { - if (kIndex_8_SkColorType == imageInfo.colorType()) { - REPORTER_ASSERT(r, kFillIndex == indexPtr[x]); - } else { - REPORTER_ASSERT(r, kFillColor == colorPtr[x]); + switch (imageInfo.colorType()) { + case kIndex_8_SkColorType: + REPORTER_ASSERT(r, kFillIndex == indexPtr[x]); + break; + case kN32_SkColorType: + REPORTER_ASSERT(r, kFillColor == colorPtr[x]); + break; + case kGray_8_SkColorType: + // We always fill kGray with black + REPORTER_ASSERT(r, (uint8_t) kFillColor == grayPtr[x]); + break; + default: + REPORTER_ASSERT(r, false); + break; } } indexPtr += rowBytes; @@ -82,6 +93,7 @@ DEF_TEST(SwizzlerFill, r) { const SkImageInfo colorInfo = SkImageInfo::MakeN32(width, height, kUnknown_SkAlphaType); const SkImageInfo indexInfo = colorInfo.makeColorType(kIndex_8_SkColorType); + const SkImageInfo grayInfo = colorInfo.makeColorType(kGray_8_SkColorType); for (uint32_t padding : paddings) { @@ -89,6 +101,7 @@ DEF_TEST(SwizzlerFill, r) { size_t colorRowBytes = SkColorTypeBytesPerPixel(kN32_SkColorType) * width + padding; size_t indexRowBytes = width + padding; + size_t grayRowBytes = indexRowBytes; // If there is padding, we can invent an offset to change the memory alignment for (uint32_t offset = 0; offset <= padding; offset++) { @@ -108,6 +121,10 @@ DEF_TEST(SwizzlerFill, r) { // Fill with an index check_fill(r, indexInfo, startRow, endRow, indexRowBytes, offset, kFillIndex, NULL); + + // Fill a grayscale image + check_fill(r, grayInfo, startRow, endRow, grayRowBytes, offset, + kFillColor, NULL); } } } -- cgit v1.2.3