halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "Resources.h" |
| 9 | #include "SkBitmap.h" |
| 10 | #include "SkCodec.h" |
| 11 | #include "SkMD5.h" |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 12 | #include "SkRandom.h" |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 13 | #include "SkScanlineDecoder.h" |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 14 | #include "Test.h" |
| 15 | |
| 16 | static SkStreamAsset* resource(const char path[]) { |
| 17 | SkString fullPath = GetResourcePath(path); |
| 18 | return SkStream::NewFromFile(fullPath.c_str()); |
| 19 | } |
| 20 | |
| 21 | static void md5(const SkBitmap& bm, SkMD5::Digest* digest) { |
| 22 | SkAutoLockPixels autoLockPixels(bm); |
| 23 | SkASSERT(bm.getPixels()); |
| 24 | SkMD5 md5; |
| 25 | size_t rowLen = bm.info().bytesPerPixel() * bm.width(); |
| 26 | for (int y = 0; y < bm.height(); ++y) { |
| 27 | md5.update(static_cast<uint8_t*>(bm.getAddr(0, y)), rowLen); |
| 28 | } |
| 29 | md5.finish(*digest); |
| 30 | } |
| 31 | |
scroggo | 9b2cdbf4 | 2015-07-10 12:07:02 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Compute the digest for bm and compare it to a known good digest. |
| 34 | * @param r Reporter to assert that bm's digest matches goodDigest. |
| 35 | * @param goodDigest The known good digest to compare to. |
| 36 | * @param bm The bitmap to test. |
| 37 | */ |
| 38 | static void compare_to_good_digest(skiatest::Reporter* r, const SkMD5::Digest& goodDigest, |
| 39 | const SkBitmap& bm) { |
| 40 | SkMD5::Digest digest; |
| 41 | md5(bm, &digest); |
| 42 | REPORTER_ASSERT(r, digest == goodDigest); |
| 43 | } |
| 44 | |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 45 | SkIRect generate_random_subset(SkRandom* rand, int w, int h) { |
| 46 | SkIRect rect; |
| 47 | do { |
| 48 | rect.fLeft = rand->nextRangeU(0, w); |
| 49 | rect.fTop = rand->nextRangeU(0, h); |
| 50 | rect.fRight = rand->nextRangeU(0, w); |
| 51 | rect.fBottom = rand->nextRangeU(0, h); |
| 52 | rect.sort(); |
| 53 | } while (rect.isEmpty()); |
| 54 | return rect; |
| 55 | } |
| 56 | |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 57 | static void check(skiatest::Reporter* r, |
| 58 | const char path[], |
| 59 | SkISize size, |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 60 | bool supportsScanlineDecoding, |
| 61 | bool supportsSubsetDecoding) { |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 62 | SkAutoTDelete<SkStream> stream(resource(path)); |
| 63 | if (!stream) { |
| 64 | SkDebugf("Missing resource '%s'\n", path); |
| 65 | return; |
| 66 | } |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 67 | SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
| 68 | if (!codec) { |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 69 | ERRORF(r, "Unable to decode '%s'", path); |
| 70 | return; |
| 71 | } |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 72 | |
| 73 | // This test is used primarily to verify rewinding works properly. Using kN32 allows |
| 74 | // us to test this without the added overhead of creating different bitmaps depending |
| 75 | // on the color type (ex: building a color table for kIndex8). DM is where we test |
| 76 | // decodes to all possible destination color types. |
| 77 | SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 78 | REPORTER_ASSERT(r, info.dimensions() == size); |
| 79 | SkBitmap bm; |
| 80 | bm.allocPixels(info); |
| 81 | SkAutoLockPixels autoLockPixels(bm); |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 82 | SkCodec::Result result = |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 83 | codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL); |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 84 | REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 85 | |
scroggo | 9b2cdbf4 | 2015-07-10 12:07:02 -0700 | [diff] [blame] | 86 | SkMD5::Digest digest; |
| 87 | md5(bm, &digest); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 88 | |
| 89 | bm.eraseColor(SK_ColorYELLOW); |
| 90 | |
| 91 | result = |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 92 | codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 93 | |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 94 | REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 95 | // verify that re-decoding gives the same result. |
scroggo | 9b2cdbf4 | 2015-07-10 12:07:02 -0700 | [diff] [blame] | 96 | compare_to_good_digest(r, digest, bm); |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 97 | |
scroggo | 1c005e4 | 2015-08-04 09:24:45 -0700 | [diff] [blame] | 98 | stream.reset(resource(path)); |
| 99 | SkAutoTDelete<SkScanlineDecoder> scanlineDecoder( |
| 100 | SkScanlineDecoder::NewFromStream(stream.detach())); |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 101 | if (supportsScanlineDecoding) { |
| 102 | bm.eraseColor(SK_ColorYELLOW); |
| 103 | REPORTER_ASSERT(r, scanlineDecoder); |
msarett | c0e80c1 | 2015-07-01 06:50:35 -0700 | [diff] [blame] | 104 | |
scroggo | 1c005e4 | 2015-08-04 09:24:45 -0700 | [diff] [blame] | 105 | REPORTER_ASSERT(r, scanlineDecoder->start(info) == SkCodec::kSuccess); |
scroggo | 9b2cdbf4 | 2015-07-10 12:07:02 -0700 | [diff] [blame] | 106 | |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 107 | for (int y = 0; y < info.height(); y++) { |
| 108 | result = scanlineDecoder->getScanlines(bm.getAddr(0, y), 1, 0); |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 109 | REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 110 | } |
| 111 | // verify that scanline decoding gives the same result. |
scroggo | 9b2cdbf4 | 2015-07-10 12:07:02 -0700 | [diff] [blame] | 112 | compare_to_good_digest(r, digest, bm); |
scroggo | 5842154 | 2015-04-01 11:25:20 -0700 | [diff] [blame] | 113 | } else { |
| 114 | REPORTER_ASSERT(r, !scanlineDecoder); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 115 | } |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 116 | |
| 117 | // The rest of this function tests decoding subsets, and will decode an arbitrary number of |
| 118 | // random subsets. |
| 119 | // Do not attempt to decode subsets of an image of only once pixel, since there is no |
| 120 | // meaningful subset. |
| 121 | if (size.width() * size.height() == 1) { |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | SkRandom rand; |
| 126 | SkIRect subset; |
| 127 | SkCodec::Options opts; |
| 128 | opts.fSubset = ⊂ |
| 129 | for (int i = 0; i < 5; i++) { |
| 130 | subset = generate_random_subset(&rand, size.width(), size.height()); |
| 131 | SkASSERT(!subset.isEmpty()); |
| 132 | const bool supported = codec->getValidSubset(&subset); |
| 133 | REPORTER_ASSERT(r, supported == supportsSubsetDecoding); |
| 134 | |
| 135 | SkImageInfo subsetInfo = info.makeWH(subset.width(), subset.height()); |
| 136 | SkBitmap bm; |
| 137 | bm.allocPixels(subsetInfo); |
| 138 | const SkCodec::Result result = codec->getPixels(bm.info(), bm.getPixels(), bm.rowBytes(), |
| 139 | &opts, NULL, NULL); |
| 140 | |
| 141 | if (supportsSubsetDecoding) { |
| 142 | REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
| 143 | // Webp is the only codec that supports subsets, and it will have modified the subset |
| 144 | // to have even left/top. |
| 145 | REPORTER_ASSERT(r, SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop)); |
| 146 | } else { |
| 147 | // No subsets will work. |
| 148 | REPORTER_ASSERT(r, result == SkCodec::kUnimplemented); |
| 149 | } |
| 150 | } |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | DEF_TEST(Codec, r) { |
| 154 | // WBMP |
msarett | 99f567e | 2015-08-05 12:58:26 -0700 | [diff] [blame] | 155 | check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 156 | |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 157 | // WEBP |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 158 | check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); |
| 159 | check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); |
| 160 | check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 161 | |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 162 | // BMP |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 163 | check(r, "randPixels.bmp", SkISize::Make(8, 8), false, false); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 164 | |
| 165 | // ICO |
msarett | 68b204e | 2015-04-01 12:09:21 -0700 | [diff] [blame] | 166 | // These two tests examine interestingly different behavior: |
| 167 | // Decodes an embedded BMP image |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 168 | check(r, "color_wheel.ico", SkISize::Make(128, 128), false, false); |
msarett | 68b204e | 2015-04-01 12:09:21 -0700 | [diff] [blame] | 169 | // Decodes an embedded PNG image |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 170 | check(r, "google_chrome.ico", SkISize::Make(256, 256), false, false); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 171 | |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 172 | // GIF |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 173 | check(r, "box.gif", SkISize::Make(200, 55), false, false); |
| 174 | check(r, "color_wheel.gif", SkISize::Make(128, 128), false, false); |
| 175 | check(r, "randPixels.gif", SkISize::Make(8, 8), false, false); |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 176 | |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 177 | // JPG |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 178 | check(r, "CMYK.jpg", SkISize::Make(642, 516), true, false); |
| 179 | check(r, "color_wheel.jpg", SkISize::Make(128, 128), true, false); |
| 180 | check(r, "grayscale.jpg", SkISize::Make(128, 128), true, false); |
| 181 | check(r, "mandrill_512_q075.jpg", SkISize::Make(512, 512), true, false); |
| 182 | check(r, "randPixels.jpg", SkISize::Make(8, 8), true, false); |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 183 | |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 184 | // PNG |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 185 | check(r, "arrow.png", SkISize::Make(187, 312), true, false); |
| 186 | check(r, "baby_tux.png", SkISize::Make(240, 246), true, false); |
| 187 | check(r, "color_wheel.png", SkISize::Make(128, 128), true, false); |
| 188 | check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), true, false); |
| 189 | check(r, "mandrill_128.png", SkISize::Make(128, 128), true, false); |
| 190 | check(r, "mandrill_16.png", SkISize::Make(16, 16), true, false); |
| 191 | check(r, "mandrill_256.png", SkISize::Make(256, 256), true, false); |
| 192 | check(r, "mandrill_32.png", SkISize::Make(32, 32), true, false); |
| 193 | check(r, "mandrill_512.png", SkISize::Make(512, 512), true, false); |
| 194 | check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false); |
| 195 | check(r, "plane.png", SkISize::Make(250, 126), true, false); |
| 196 | check(r, "randPixels.png", SkISize::Make(8, 8), true, false); |
| 197 | check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false); |
halcanary | a096d7a | 2015-03-27 12:16:53 -0700 | [diff] [blame] | 198 | } |
scroggo | 0a7e69c | 2015-04-03 07:22:22 -0700 | [diff] [blame] | 199 | |
| 200 | static void test_invalid_stream(skiatest::Reporter* r, const void* stream, size_t len) { |
| 201 | SkCodec* codec = SkCodec::NewFromStream(new SkMemoryStream(stream, len, false)); |
| 202 | // We should not have gotten a codec. Bots should catch us if we leaked anything. |
| 203 | REPORTER_ASSERT(r, !codec); |
| 204 | } |
| 205 | |
| 206 | // Ensure that SkCodec::NewFromStream handles freeing the passed in SkStream, |
| 207 | // even on failure. Test some bad streams. |
| 208 | DEF_TEST(Codec_leaks, r) { |
| 209 | // No codec should claim this as their format, so this tests SkCodec::NewFromStream. |
| 210 | const char nonSupportedStream[] = "hello world"; |
| 211 | // The other strings should look like the beginning of a file type, so we'll call some |
| 212 | // internal version of NewFromStream, which must also delete the stream on failure. |
| 213 | const unsigned char emptyPng[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a }; |
| 214 | const unsigned char emptyJpeg[] = { 0xFF, 0xD8, 0xFF }; |
| 215 | const char emptyWebp[] = "RIFF1234WEBPVP"; |
| 216 | const char emptyBmp[] = { 'B', 'M' }; |
| 217 | const char emptyIco[] = { '\x00', '\x00', '\x01', '\x00' }; |
| 218 | const char emptyGif[] = "GIFVER"; |
| 219 | |
| 220 | test_invalid_stream(r, nonSupportedStream, sizeof(nonSupportedStream)); |
| 221 | test_invalid_stream(r, emptyPng, sizeof(emptyPng)); |
| 222 | test_invalid_stream(r, emptyJpeg, sizeof(emptyJpeg)); |
| 223 | test_invalid_stream(r, emptyWebp, sizeof(emptyWebp)); |
| 224 | test_invalid_stream(r, emptyBmp, sizeof(emptyBmp)); |
| 225 | test_invalid_stream(r, emptyIco, sizeof(emptyIco)); |
| 226 | test_invalid_stream(r, emptyGif, sizeof(emptyGif)); |
| 227 | } |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 228 | |
| 229 | static void test_dimensions(skiatest::Reporter* r, const char path[]) { |
| 230 | // Create the codec from the resource file |
| 231 | SkAutoTDelete<SkStream> stream(resource(path)); |
| 232 | if (!stream) { |
| 233 | SkDebugf("Missing resource '%s'\n", path); |
| 234 | return; |
| 235 | } |
| 236 | SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
| 237 | if (!codec) { |
| 238 | ERRORF(r, "Unable to create codec '%s'", path); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | // Check that the decode is successful for a variety of scales |
| 243 | for (float scale = -0.05f; scale < 2.0f; scale += 0.05f) { |
| 244 | // Scale the output dimensions |
| 245 | SkISize scaledDims = codec->getScaledDimensions(scale); |
| 246 | SkImageInfo scaledInfo = codec->getInfo().makeWH(scaledDims.width(), scaledDims.height()); |
| 247 | |
| 248 | // Set up for the decode |
| 249 | size_t rowBytes = scaledDims.width() * sizeof(SkPMColor); |
| 250 | size_t totalBytes = scaledInfo.getSafeSize(rowBytes); |
| 251 | SkAutoTMalloc<SkPMColor> pixels(totalBytes); |
| 252 | |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 253 | SkCodec::Result result = |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 254 | codec->getPixels(scaledInfo, pixels.get(), rowBytes, NULL, NULL, NULL); |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 255 | REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
| 259 | // Ensure that onGetScaledDimensions returns valid image dimensions to use for decodes |
| 260 | DEF_TEST(Codec_Dimensions, r) { |
| 261 | // JPG |
| 262 | test_dimensions(r, "CMYK.jpg"); |
| 263 | test_dimensions(r, "color_wheel.jpg"); |
| 264 | test_dimensions(r, "grayscale.jpg"); |
| 265 | test_dimensions(r, "mandrill_512_q075.jpg"); |
| 266 | test_dimensions(r, "randPixels.jpg"); |
| 267 | } |
| 268 | |
msarett | d0375bc | 2015-08-12 08:08:56 -0700 | [diff] [blame^] | 269 | static void test_invalid(skiatest::Reporter* r, const char path[]) { |
msarett | 4b17fa3 | 2015-04-23 08:53:39 -0700 | [diff] [blame] | 270 | SkAutoTDelete<SkStream> stream(resource(path)); |
| 271 | if (!stream) { |
| 272 | SkDebugf("Missing resource '%s'\n", path); |
| 273 | return; |
| 274 | } |
| 275 | SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
| 276 | REPORTER_ASSERT(r, NULL == codec); |
| 277 | } |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 278 | |
msarett | 4b17fa3 | 2015-04-23 08:53:39 -0700 | [diff] [blame] | 279 | DEF_TEST(Codec_Empty, r) { |
| 280 | // Test images that should not be able to create a codec |
msarett | d0375bc | 2015-08-12 08:08:56 -0700 | [diff] [blame^] | 281 | test_invalid(r, "empty_images/zero-dims.gif"); |
| 282 | test_invalid(r, "empty_images/zero-embedded.ico"); |
| 283 | test_invalid(r, "empty_images/zero-width.bmp"); |
| 284 | test_invalid(r, "empty_images/zero-height.bmp"); |
| 285 | test_invalid(r, "empty_images/zero-width.jpg"); |
| 286 | test_invalid(r, "empty_images/zero-height.jpg"); |
| 287 | test_invalid(r, "empty_images/zero-width.png"); |
| 288 | test_invalid(r, "empty_images/zero-height.png"); |
| 289 | test_invalid(r, "empty_images/zero-width.wbmp"); |
| 290 | test_invalid(r, "empty_images/zero-height.wbmp"); |
| 291 | // This image is an ico with an embedded mask-bmp. This is illegal. |
| 292 | test_invalid(r, "invalid_images/mask-bmp-ico.ico"); |
msarett | 4b17fa3 | 2015-04-23 08:53:39 -0700 | [diff] [blame] | 293 | } |
msarett | 99f567e | 2015-08-05 12:58:26 -0700 | [diff] [blame] | 294 | |
| 295 | static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { |
| 296 | SkAutoTDelete<SkStream> stream(resource(path)); |
| 297 | if (!stream) { |
| 298 | SkDebugf("Missing resource '%s'\n", path); |
| 299 | return; |
| 300 | } |
| 301 | SkAutoTDelete<SkScanlineDecoder> decoder(SkScanlineDecoder::NewFromStream( |
| 302 | stream.detach())); |
| 303 | |
| 304 | // This should return kSuccess because kIndex8 is supported. |
| 305 | SkPMColor colorStorage[256]; |
| 306 | int colorCount; |
| 307 | SkCodec::Result result = decoder->start( |
| 308 | decoder->getInfo().makeColorType(kIndex_8_SkColorType), NULL, colorStorage, &colorCount); |
| 309 | REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 310 | // The rest of the test is uninteresting if kIndex8 is not supported |
| 311 | if (SkCodec::kSuccess != result) { |
| 312 | return; |
| 313 | } |
| 314 | |
| 315 | // This should return kInvalidParameters because, in kIndex_8 mode, we must pass in a valid |
| 316 | // colorPtr and a valid colorCountPtr. |
| 317 | result = decoder->start( |
| 318 | decoder->getInfo().makeColorType(kIndex_8_SkColorType), NULL, NULL, NULL); |
| 319 | REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 320 | result = decoder->start( |
| 321 | decoder->getInfo().makeColorType(kIndex_8_SkColorType)); |
| 322 | REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 323 | } |
| 324 | |
| 325 | DEF_TEST(Codec_Params, r) { |
| 326 | test_invalid_parameters(r, "index8.png"); |
| 327 | test_invalid_parameters(r, "mandrill.wbmp"); |
| 328 | } |