Chromium Code Reviews| 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 "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 } | 326 } |
| 327 | 327 |
| 328 // If we've just tested incomplete decodes, let's run the same test again on full decodes. | 328 // If we've just tested incomplete decodes, let's run the same test again on full decodes. |
| 329 if (isIncomplete) { | 329 if (isIncomplete) { |
| 330 check(r, path, size, supportsScanlineDecoding, supportsSubsetDecoding, f alse); | 330 check(r, path, size, supportsScanlineDecoding, supportsSubsetDecoding, f alse); |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 DEF_TEST(Codec, r) { | 334 DEF_TEST(Codec, r) { |
| 335 // WBMP | 335 // WBMP |
| 336 #if defined(SK_CODEC_DECODES_WBMP) | |
|
msarett
2016/02/16 22:52:26
Thinking about this a little further...
Maybe we
mtklein
2016/02/16 23:16:01
Agree.
| |
| 336 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); | 337 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); |
| 338 #endif | |
| 337 | 339 |
| 338 // WEBP | 340 // WEBP |
| 341 #if defined(SK_CODEC_DECODES_WEBP) | |
| 339 check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); | 342 check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); |
| 340 check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); | 343 check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); |
| 341 check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); | 344 check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); |
| 345 #endif | |
| 342 | 346 |
| 343 // BMP | 347 // BMP |
| 348 #if defined(SK_CODEC_DECODES_BMP) | |
| 344 check(r, "randPixels.bmp", SkISize::Make(8, 8), true, false); | 349 check(r, "randPixels.bmp", SkISize::Make(8, 8), true, false); |
| 345 check(r, "rle.bmp", SkISize::Make(320, 240), true, false); | 350 check(r, "rle.bmp", SkISize::Make(320, 240), true, false); |
| 351 #endif | |
| 346 | 352 |
| 347 // ICO | 353 // ICO |
| 354 #if defined(SK_CODEC_DECODES_ICO) | |
| 348 // FIXME: We are not ready to test incomplete ICOs | 355 // FIXME: We are not ready to test incomplete ICOs |
| 349 // These two tests examine interestingly different behavior: | 356 // These two tests examine interestingly different behavior: |
| 350 // Decodes an embedded BMP image | 357 // Decodes an embedded BMP image |
| 351 check(r, "color_wheel.ico", SkISize::Make(128, 128), true, false, false); | 358 check(r, "color_wheel.ico", SkISize::Make(128, 128), true, false, false); |
| 352 // Decodes an embedded PNG image | 359 // Decodes an embedded PNG image |
| 353 check(r, "google_chrome.ico", SkISize::Make(256, 256), true, false, false); | 360 check(r, "google_chrome.ico", SkISize::Make(256, 256), true, false, false); |
| 361 #endif | |
| 354 | 362 |
| 355 // GIF | 363 // GIF |
| 364 #if defined(SK_CODEC_DECODES_GIF) | |
| 356 // FIXME: We are not ready to test incomplete GIFs | 365 // FIXME: We are not ready to test incomplete GIFs |
| 357 check(r, "box.gif", SkISize::Make(200, 55), true, false, false); | 366 check(r, "box.gif", SkISize::Make(200, 55), true, false, false); |
| 358 check(r, "color_wheel.gif", SkISize::Make(128, 128), true, false, false); | 367 check(r, "color_wheel.gif", SkISize::Make(128, 128), true, false, false); |
| 359 // randPixels.gif is too small to test incomplete | 368 // randPixels.gif is too small to test incomplete |
| 360 check(r, "randPixels.gif", SkISize::Make(8, 8), true, false, false); | 369 check(r, "randPixels.gif", SkISize::Make(8, 8), true, false, false); |
| 370 #endif | |
| 361 | 371 |
| 362 // JPG | 372 // JPG |
| 373 #if defined(SK_CODEC_DECODES_JPEG) | |
| 363 check(r, "CMYK.jpg", SkISize::Make(642, 516), true, false); | 374 check(r, "CMYK.jpg", SkISize::Make(642, 516), true, false); |
| 364 check(r, "color_wheel.jpg", SkISize::Make(128, 128), true, false); | 375 check(r, "color_wheel.jpg", SkISize::Make(128, 128), true, false); |
| 365 // grayscale.jpg is too small to test incomplete | 376 // grayscale.jpg is too small to test incomplete |
| 366 check(r, "grayscale.jpg", SkISize::Make(128, 128), true, false, false); | 377 check(r, "grayscale.jpg", SkISize::Make(128, 128), true, false, false); |
| 367 check(r, "mandrill_512_q075.jpg", SkISize::Make(512, 512), true, false); | 378 check(r, "mandrill_512_q075.jpg", SkISize::Make(512, 512), true, false); |
| 368 // randPixels.jpg is too small to test incomplete | 379 // randPixels.jpg is too small to test incomplete |
| 369 check(r, "randPixels.jpg", SkISize::Make(8, 8), true, false, false); | 380 check(r, "randPixels.jpg", SkISize::Make(8, 8), true, false, false); |
| 381 #endif | |
| 370 | 382 |
| 371 // PNG | 383 // PNG |
| 384 #if defined(SK_CODEC_DECODES_PNG) | |
| 372 check(r, "arrow.png", SkISize::Make(187, 312), true, false, false); | 385 check(r, "arrow.png", SkISize::Make(187, 312), true, false, false); |
| 373 check(r, "baby_tux.png", SkISize::Make(240, 246), true, false, false); | 386 check(r, "baby_tux.png", SkISize::Make(240, 246), true, false, false); |
| 374 check(r, "color_wheel.png", SkISize::Make(128, 128), true, false, false); | 387 check(r, "color_wheel.png", SkISize::Make(128, 128), true, false, false); |
| 375 check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), true, fals e, false); | 388 check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), true, fals e, false); |
| 376 check(r, "mandrill_128.png", SkISize::Make(128, 128), true, false, false); | 389 check(r, "mandrill_128.png", SkISize::Make(128, 128), true, false, false); |
| 377 check(r, "mandrill_16.png", SkISize::Make(16, 16), true, false, false); | 390 check(r, "mandrill_16.png", SkISize::Make(16, 16), true, false, false); |
| 378 check(r, "mandrill_256.png", SkISize::Make(256, 256), true, false, false); | 391 check(r, "mandrill_256.png", SkISize::Make(256, 256), true, false, false); |
| 379 check(r, "mandrill_32.png", SkISize::Make(32, 32), true, false, false); | 392 check(r, "mandrill_32.png", SkISize::Make(32, 32), true, false, false); |
| 380 check(r, "mandrill_512.png", SkISize::Make(512, 512), true, false, false); | 393 check(r, "mandrill_512.png", SkISize::Make(512, 512), true, false, false); |
| 381 check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false, false); | 394 check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false, false); |
| 382 check(r, "plane.png", SkISize::Make(250, 126), true, false, false); | 395 check(r, "plane.png", SkISize::Make(250, 126), true, false, false); |
| 383 // FIXME: We are not ready to test incomplete interlaced pngs | 396 // FIXME: We are not ready to test incomplete interlaced pngs |
| 384 check(r, "plane_interlaced.png", SkISize::Make(250, 126), true, false, false ); | 397 check(r, "plane_interlaced.png", SkISize::Make(250, 126), true, false, false ); |
| 385 check(r, "randPixels.png", SkISize::Make(8, 8), true, false, false); | 398 check(r, "randPixels.png", SkISize::Make(8, 8), true, false, false); |
| 386 check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false, false); | 399 check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false, false); |
| 400 #endif | |
| 387 | 401 |
| 388 // RAW | 402 // RAW |
| 389 #if defined(SK_CODEC_DECODES_RAW) | 403 #if defined(SK_CODEC_DECODES_RAW) |
| 390 check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); | 404 check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); |
| 391 check(r, "dng_with_preview.dng", SkISize::Make(600, 338), true, false, false ); | 405 check(r, "dng_with_preview.dng", SkISize::Make(600, 338), true, false, false ); |
| 392 #endif | 406 #endif |
| 393 } | 407 } |
| 394 | 408 |
| 395 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode | 409 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode |
| 396 DEF_TEST(Codec_stripes, r) { | 410 DEF_TEST(Codec_stripes, r) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 options.fSampleSize = sampleSize; | 570 options.fSampleSize = sampleSize; |
| 557 SkCodec::Result result = | 571 SkCodec::Result result = |
| 558 codec->getAndroidPixels(scaledInfo, pixels.get(), rowBytes, &opt ions); | 572 codec->getAndroidPixels(scaledInfo, pixels.get(), rowBytes, &opt ions); |
| 559 REPORTER_ASSERT(r, SkCodec::kSuccess == result); | 573 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 560 } | 574 } |
| 561 } | 575 } |
| 562 | 576 |
| 563 // Ensure that onGetScaledDimensions returns valid image dimensions to use for d ecodes | 577 // Ensure that onGetScaledDimensions returns valid image dimensions to use for d ecodes |
| 564 DEF_TEST(Codec_Dimensions, r) { | 578 DEF_TEST(Codec_Dimensions, r) { |
| 565 // JPG | 579 // JPG |
| 580 #if defined(SK_CODEC_DECODES_JPEG) | |
| 566 test_dimensions(r, "CMYK.jpg"); | 581 test_dimensions(r, "CMYK.jpg"); |
| 567 test_dimensions(r, "color_wheel.jpg"); | 582 test_dimensions(r, "color_wheel.jpg"); |
| 568 test_dimensions(r, "grayscale.jpg"); | 583 test_dimensions(r, "grayscale.jpg"); |
| 569 test_dimensions(r, "mandrill_512_q075.jpg"); | 584 test_dimensions(r, "mandrill_512_q075.jpg"); |
| 570 test_dimensions(r, "randPixels.jpg"); | 585 test_dimensions(r, "randPixels.jpg"); |
| 586 #endif | |
| 571 | 587 |
| 572 // Decoding small images with very large scaling factors is a potential | 588 // Decoding small images with very large scaling factors is a potential |
| 573 // source of bugs and crashes. We disable these tests in Gold because | 589 // source of bugs and crashes. We disable these tests in Gold because |
| 574 // tiny images are not very useful to look at. | 590 // tiny images are not very useful to look at. |
| 575 // Here we make sure that we do not crash or access illegal memory when | 591 // Here we make sure that we do not crash or access illegal memory when |
| 576 // performing scaled decodes on small images. | 592 // performing scaled decodes on small images. |
| 593 #if defined(SK_CODEC_DECODES_PNG) | |
| 577 test_dimensions(r, "1x1.png"); | 594 test_dimensions(r, "1x1.png"); |
| 578 test_dimensions(r, "2x2.png"); | 595 test_dimensions(r, "2x2.png"); |
| 579 test_dimensions(r, "3x3.png"); | 596 test_dimensions(r, "3x3.png"); |
| 580 test_dimensions(r, "3x1.png"); | 597 test_dimensions(r, "3x1.png"); |
| 581 test_dimensions(r, "1x1.png"); | 598 test_dimensions(r, "1x1.png"); |
| 582 test_dimensions(r, "16x1.png"); | 599 test_dimensions(r, "16x1.png"); |
| 583 test_dimensions(r, "1x16.png"); | 600 test_dimensions(r, "1x16.png"); |
| 584 test_dimensions(r, "mandrill_16.png"); | 601 test_dimensions(r, "mandrill_16.png"); |
| 602 #endif | |
| 585 | 603 |
| 586 // RAW | 604 // RAW |
| 587 #if defined(SK_CODEC_DECODES_RAW) | 605 #if defined(SK_CODEC_DECODES_RAW) |
| 588 test_dimensions(r, "sample_1mp.dng"); | 606 test_dimensions(r, "sample_1mp.dng"); |
| 589 test_dimensions(r, "dng_with_preview.dng"); | 607 test_dimensions(r, "dng_with_preview.dng"); |
| 590 #endif | 608 #endif |
| 591 } | 609 } |
| 592 | 610 |
| 593 static void test_invalid(skiatest::Reporter* r, const char path[]) { | 611 static void test_invalid(skiatest::Reporter* r, const char path[]) { |
| 594 SkAutoTDelete<SkStream> stream(resource(path)); | 612 SkAutoTDelete<SkStream> stream(resource(path)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 // colorPtr and a valid colorCountPtr. | 657 // colorPtr and a valid colorCountPtr. |
| 640 result = decoder->startScanlineDecode( | 658 result = decoder->startScanlineDecode( |
| 641 decoder->getInfo().makeColorType(kIndex_8_SkColorType), nullptr, nullptr , nullptr); | 659 decoder->getInfo().makeColorType(kIndex_8_SkColorType), nullptr, nullptr , nullptr); |
| 642 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 660 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 643 result = decoder->startScanlineDecode( | 661 result = decoder->startScanlineDecode( |
| 644 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); | 662 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); |
| 645 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 663 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 646 } | 664 } |
| 647 | 665 |
| 648 DEF_TEST(Codec_Params, r) { | 666 DEF_TEST(Codec_Params, r) { |
| 667 #if defined(SK_CODEC_DECODES_PNG) | |
| 649 test_invalid_parameters(r, "index8.png"); | 668 test_invalid_parameters(r, "index8.png"); |
| 669 #endif | |
| 670 #if defined(SK_CODEC_DECODES_WBMP) | |
| 650 test_invalid_parameters(r, "mandrill.wbmp"); | 671 test_invalid_parameters(r, "mandrill.wbmp"); |
| 672 #endif | |
| 651 } | 673 } |
| 652 | 674 |
| 653 static void codex_test_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) { | 675 static void codex_test_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) { |
| 654 SkWStream* sk_stream = (SkWStream*)png_get_io_ptr(png_ptr); | 676 SkWStream* sk_stream = (SkWStream*)png_get_io_ptr(png_ptr); |
| 655 if (!sk_stream->write(data, len)) { | 677 if (!sk_stream->write(data, len)) { |
| 656 png_error(png_ptr, "sk_write_fn Error!"); | 678 png_error(png_ptr, "sk_write_fn Error!"); |
| 657 } | 679 } |
| 658 } | 680 } |
| 659 | 681 |
| 660 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED | 682 #if defined(SK_CODEC_DECODES_PNG) && defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) |
| 661 DEF_TEST(Codec_pngChunkReader, r) { | 683 DEF_TEST(Codec_pngChunkReader, r) { |
| 662 // Create a dummy bitmap. Use unpremul RGBA for libpng. | 684 // Create a dummy bitmap. Use unpremul RGBA for libpng. |
| 663 SkBitmap bm; | 685 SkBitmap bm; |
| 664 const int w = 1; | 686 const int w = 1; |
| 665 const int h = 1; | 687 const int h = 1; |
| 666 const SkImageInfo bmInfo = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, | 688 const SkImageInfo bmInfo = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, |
| 667 kUnpremul_SkAlphaType); | 689 kUnpremul_SkAlphaType); |
| 668 bm.setInfo(bmInfo); | 690 bm.setInfo(bmInfo); |
| 669 bm.allocPixels(); | 691 bm.allocPixels(); |
| 670 bm.eraseColor(SK_ColorBLUE); | 692 bm.eraseColor(SK_ColorBLUE); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 compare_to_good_digest(r, goodDigest, decodedBm); | 819 compare_to_good_digest(r, goodDigest, decodedBm); |
| 798 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); | 820 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); |
| 799 | 821 |
| 800 // Decoding again will read the chunks again. | 822 // Decoding again will read the chunks again. |
| 801 chunkReader.reset(); | 823 chunkReader.reset(); |
| 802 REPORTER_ASSERT(r, !chunkReader.allHaveBeenSeen()); | 824 REPORTER_ASSERT(r, !chunkReader.allHaveBeenSeen()); |
| 803 result = codec->getPixels(codec->getInfo(), decodedBm.getPixels(), decodedBm .rowBytes()); | 825 result = codec->getPixels(codec->getInfo(), decodedBm.getPixels(), decodedBm .rowBytes()); |
| 804 REPORTER_ASSERT(r, SkCodec::kSuccess == result); | 826 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 805 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); | 827 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); |
| 806 } | 828 } |
| 807 #endif // PNG_READ_UNKNOWN_CHUNKS_SUPPORTED | 829 #endif // SK_CODEC_DECODES_PNG && PNG_READ_UNKNOWN_CHUNKS_SUPPORTED |
| 808 | 830 |
| 809 // Stream that can only peek up to a limit | 831 // Stream that can only peek up to a limit |
| 810 class LimitedPeekingMemStream : public SkStream { | 832 class LimitedPeekingMemStream : public SkStream { |
| 811 public: | 833 public: |
| 812 LimitedPeekingMemStream(SkData* data, size_t limit) | 834 LimitedPeekingMemStream(SkData* data, size_t limit) |
| 813 : fStream(data) | 835 : fStream(data) |
| 814 , fLimit(limit) {} | 836 , fLimit(limit) {} |
| 815 | 837 |
| 816 size_t peek(void* buf, size_t bytes) const override { | 838 size_t peek(void* buf, size_t bytes) const override { |
| 817 return fStream.peek(buf, SkTMin(bytes, fLimit)); | 839 return fStream.peek(buf, SkTMin(bytes, fLimit)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 return; | 893 return; |
| 872 } | 894 } |
| 873 | 895 |
| 874 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(new NotAssetMemStream(da ta))); | 896 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(new NotAssetMemStream(da ta))); |
| 875 REPORTER_ASSERT(r, codec); | 897 REPORTER_ASSERT(r, codec); |
| 876 | 898 |
| 877 test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); | 899 test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); |
| 878 } | 900 } |
| 879 #endif | 901 #endif |
| 880 | 902 |
| 903 #if defined(SK_CODEC_DECODES_WEBP) | |
| 881 // Test that even if webp_parse_header fails to peek enough, it will fall back t o read() | 904 // Test that even if webp_parse_header fails to peek enough, it will fall back t o read() |
| 882 // + rewind() and succeed. | 905 // + rewind() and succeed. |
| 883 DEF_TEST(Codec_webp_peek, r) { | 906 DEF_TEST(Codec_webp_peek, r) { |
| 884 const char* path = "baby_tux.webp"; | 907 const char* path = "baby_tux.webp"; |
| 885 SkString fullPath(GetResourcePath(path)); | 908 SkString fullPath(GetResourcePath(path)); |
| 886 SkAutoTUnref<SkData> data(SkData::NewFromFileName(fullPath.c_str())); | 909 SkAutoTUnref<SkData> data(SkData::NewFromFileName(fullPath.c_str())); |
| 887 if (!data) { | 910 if (!data) { |
| 888 SkDebugf("Missing resource '%s'\n", path); | 911 SkDebugf("Missing resource '%s'\n", path); |
| 889 return; | 912 return; |
| 890 } | 913 } |
| 891 | 914 |
| 892 // The limit is less than webp needs to peek or read. | 915 // The limit is less than webp needs to peek or read. |
| 893 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(new LimitedPeekingMemStr eam(data, 25))); | 916 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(new LimitedPeekingMemStr eam(data, 25))); |
| 894 REPORTER_ASSERT(r, codec); | 917 REPORTER_ASSERT(r, codec); |
| 895 | 918 |
| 896 test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); | 919 test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); |
| 897 | 920 |
| 898 // Similarly, a stream which does not peek should still succeed. | 921 // Similarly, a stream which does not peek should still succeed. |
| 899 codec.reset(SkCodec::NewFromStream(new LimitedPeekingMemStream(data, 0))); | 922 codec.reset(SkCodec::NewFromStream(new LimitedPeekingMemStream(data, 0))); |
| 900 REPORTER_ASSERT(r, codec); | 923 REPORTER_ASSERT(r, codec); |
| 901 | 924 |
| 902 test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); | 925 test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); |
| 903 } | 926 } |
| 927 #endif | |
| 904 | 928 |
| 929 #if defined(SK_CODEC_DECODES_WBMP) | |
| 905 // SkCodec's wbmp decoder was initially more restrictive than SkImageDecoder. | 930 // SkCodec's wbmp decoder was initially more restrictive than SkImageDecoder. |
| 906 // It required the second byte to be zero. But SkImageDecoder allowed a couple | 931 // It required the second byte to be zero. But SkImageDecoder allowed a couple |
| 907 // of bits to be 1 (so long as they do not overlap with 0x9F). Test that | 932 // of bits to be 1 (so long as they do not overlap with 0x9F). Test that |
| 908 // SkCodec now supports an image with these bits set. | 933 // SkCodec now supports an image with these bits set. |
| 909 DEF_TEST(Codec_wbmp, r) { | 934 DEF_TEST(Codec_wbmp, r) { |
| 910 const char* path = "mandrill.wbmp"; | 935 const char* path = "mandrill.wbmp"; |
| 911 SkAutoTDelete<SkStream> stream(resource(path)); | 936 SkAutoTDelete<SkStream> stream(resource(path)); |
| 912 if (!stream) { | 937 if (!stream) { |
| 913 SkDebugf("Missing resource '%s'\n", path); | 938 SkDebugf("Missing resource '%s'\n", path); |
| 914 return; | 939 return; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 953 // Now test an image which is too big. Any image with a larger header (i.e. | 978 // Now test an image which is too big. Any image with a larger header (i.e. |
| 954 // has bigger width/height) is also too big. | 979 // has bigger width/height) is also too big. |
| 955 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header | 980 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header |
| 956 0x84, 0x80, 0x00, // W: 65536 | 981 0x84, 0x80, 0x00, // W: 65536 |
| 957 0x84, 0x80, 0x00 }; // H: 65536 | 982 0x84, 0x80, 0x00 }; // H: 65536 |
| 958 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); | 983 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); |
| 959 codec.reset(SkCodec::NewFromStream(stream.detach())); | 984 codec.reset(SkCodec::NewFromStream(stream.detach())); |
| 960 | 985 |
| 961 REPORTER_ASSERT(r, !codec); | 986 REPORTER_ASSERT(r, !codec); |
| 962 } | 987 } |
| 988 #endif | |
| OLD | NEW |