diff options
author | msarett <msarett@google.com> | 2015-08-05 12:58:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-05 12:58:26 -0700 |
commit | 99f567e617b6c5a81e6b822c30ccb0d357db21fc (patch) | |
tree | c119d5f8abfd674533ef2ccb04d9bfa1ec188a0d /tests | |
parent | dfcba473b0462be3ed4babc07b1d50f4fafaeded (diff) |
Scanline decoding for wbmp
We are also changing the wbmp to use SkSwizzler. This
will allow us to take advantage of the sampling routines
that are being implemented in SkSwizzler.
The image in this upload came from:
https://commons.wikimedia.org/wiki/File:Android_robot.png
It is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
BUG=skia:
Review URL: https://codereview.chromium.org/1254483004
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CodexTest.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp index 1dd64d9a6d..b7f1584a16 100644 --- a/tests/CodexTest.cpp +++ b/tests/CodexTest.cpp @@ -152,7 +152,7 @@ static void check(skiatest::Reporter* r, DEF_TEST(Codec, r) { // WBMP - check(r, "mandrill.wbmp", SkISize::Make(512, 512), false, false); + check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); // WEBP check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); @@ -289,3 +289,38 @@ DEF_TEST(Codec_Empty, r) { test_empty(r, "empty_images/zero-width.wbmp"); test_empty(r, "empty_images/zero-height.wbmp"); } + +static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { + SkAutoTDelete<SkStream> stream(resource(path)); + if (!stream) { + SkDebugf("Missing resource '%s'\n", path); + return; + } + SkAutoTDelete<SkScanlineDecoder> decoder(SkScanlineDecoder::NewFromStream( + stream.detach())); + + // This should return kSuccess because kIndex8 is supported. + SkPMColor colorStorage[256]; + int colorCount; + SkCodec::Result result = decoder->start( + decoder->getInfo().makeColorType(kIndex_8_SkColorType), NULL, colorStorage, &colorCount); + REPORTER_ASSERT(r, SkCodec::kSuccess == result); + // The rest of the test is uninteresting if kIndex8 is not supported + if (SkCodec::kSuccess != result) { + return; + } + + // This should return kInvalidParameters because, in kIndex_8 mode, we must pass in a valid + // colorPtr and a valid colorCountPtr. + result = decoder->start( + decoder->getInfo().makeColorType(kIndex_8_SkColorType), NULL, NULL, NULL); + REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); + result = decoder->start( + decoder->getInfo().makeColorType(kIndex_8_SkColorType)); + REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); +} + +DEF_TEST(Codec_Params, r) { + test_invalid_parameters(r, "index8.png"); + test_invalid_parameters(r, "mandrill.wbmp"); +} |