OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 REPORTER_ASSERT(r, SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTo
p)); | 145 REPORTER_ASSERT(r, SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTo
p)); |
146 } else { | 146 } else { |
147 // No subsets will work. | 147 // No subsets will work. |
148 REPORTER_ASSERT(r, result == SkCodec::kUnimplemented); | 148 REPORTER_ASSERT(r, result == SkCodec::kUnimplemented); |
149 } | 149 } |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 DEF_TEST(Codec, r) { | 153 DEF_TEST(Codec, r) { |
154 // WBMP | 154 // WBMP |
155 check(r, "mandrill.wbmp", SkISize::Make(512, 512), false, false); | 155 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); |
156 | 156 |
157 // WEBP | 157 // WEBP |
158 check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); | 158 check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); |
159 check(r, "color_wheel.webp", SkISize::Make(128, 128), 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); | 160 check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); |
161 | 161 |
162 // BMP | 162 // BMP |
163 check(r, "randPixels.bmp", SkISize::Make(8, 8), false, false); | 163 check(r, "randPixels.bmp", SkISize::Make(8, 8), false, false); |
164 | 164 |
165 // ICO | 165 // ICO |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 test_empty(r, "empty_images/zero-embedded.ico"); | 282 test_empty(r, "empty_images/zero-embedded.ico"); |
283 test_empty(r, "empty_images/zero-width.bmp"); | 283 test_empty(r, "empty_images/zero-width.bmp"); |
284 test_empty(r, "empty_images/zero-height.bmp"); | 284 test_empty(r, "empty_images/zero-height.bmp"); |
285 test_empty(r, "empty_images/zero-width.jpg"); | 285 test_empty(r, "empty_images/zero-width.jpg"); |
286 test_empty(r, "empty_images/zero-height.jpg"); | 286 test_empty(r, "empty_images/zero-height.jpg"); |
287 test_empty(r, "empty_images/zero-width.png"); | 287 test_empty(r, "empty_images/zero-width.png"); |
288 test_empty(r, "empty_images/zero-height.png"); | 288 test_empty(r, "empty_images/zero-height.png"); |
289 test_empty(r, "empty_images/zero-width.wbmp"); | 289 test_empty(r, "empty_images/zero-width.wbmp"); |
290 test_empty(r, "empty_images/zero-height.wbmp"); | 290 test_empty(r, "empty_images/zero-height.wbmp"); |
291 } | 291 } |
| 292 |
| 293 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { |
| 294 SkAutoTDelete<SkStream> stream(resource(path)); |
| 295 if (!stream) { |
| 296 SkDebugf("Missing resource '%s'\n", path); |
| 297 return; |
| 298 } |
| 299 SkAutoTDelete<SkScanlineDecoder> decoder(SkScanlineDecoder::NewFromStream( |
| 300 stream.detach())); |
| 301 |
| 302 // This should return kSuccess because kIndex8 is supported. |
| 303 SkPMColor colorStorage[256]; |
| 304 int colorCount; |
| 305 SkCodec::Result result = decoder->start( |
| 306 decoder->getInfo().makeColorType(kIndex_8_SkColorType), NULL, colorStora
ge, &colorCount); |
| 307 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 308 // The rest of the test is uninteresting if kIndex8 is not supported |
| 309 if (SkCodec::kSuccess != result) { |
| 310 return; |
| 311 } |
| 312 |
| 313 // This should return kInvalidParameters because, in kIndex_8 mode, we must
pass in a valid |
| 314 // colorPtr and a valid colorCountPtr. |
| 315 result = decoder->start( |
| 316 decoder->getInfo().makeColorType(kIndex_8_SkColorType), NULL, NULL, NULL
); |
| 317 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 318 result = decoder->start( |
| 319 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); |
| 320 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 321 } |
| 322 |
| 323 DEF_TEST(Codec_Params, r) { |
| 324 test_invalid_parameters(r, "index8.png"); |
| 325 test_invalid_parameters(r, "mandrill.wbmp"); |
| 326 } |
OLD | NEW |