aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SwizzlerTest.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2015-04-15 07:32:19 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-15 07:32:20 -0700
commite16b04aa6041efb6507546547737e9603fa1606e (patch)
tree3bd78e41a9ff3df445c64d3c0429d83bb698570d /tests/SwizzlerTest.cpp
parentf91e676f941c7e9ec91ac298eaa32e4bf8f52762 (diff)
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
Diffstat (limited to 'tests/SwizzlerTest.cpp')
-rw-r--r--tests/SwizzlerTest.cpp25
1 files changed, 21 insertions, 4 deletions
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);
}
}
}