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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 check(r, "mandrill_16.png", SkISize::Make(16, 16), true, false, false); | 443 check(r, "mandrill_16.png", SkISize::Make(16, 16), true, false, false); |
444 check(r, "mandrill_256.png", SkISize::Make(256, 256), true, false, false); | 444 check(r, "mandrill_256.png", SkISize::Make(256, 256), true, false, false); |
445 check(r, "mandrill_32.png", SkISize::Make(32, 32), true, false, false); | 445 check(r, "mandrill_32.png", SkISize::Make(32, 32), true, false, false); |
446 check(r, "mandrill_512.png", SkISize::Make(512, 512), true, false, false); | 446 check(r, "mandrill_512.png", SkISize::Make(512, 512), true, false, false); |
447 check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false, false); | 447 check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false, false); |
448 check(r, "plane.png", SkISize::Make(250, 126), true, false, false); | 448 check(r, "plane.png", SkISize::Make(250, 126), true, false, false); |
449 // FIXME: We are not ready to test incomplete interlaced pngs | 449 // FIXME: We are not ready to test incomplete interlaced pngs |
450 check(r, "plane_interlaced.png", SkISize::Make(250, 126), true, false, false
); | 450 check(r, "plane_interlaced.png", SkISize::Make(250, 126), true, false, false
); |
451 check(r, "randPixels.png", SkISize::Make(8, 8), true, false, false); | 451 check(r, "randPixels.png", SkISize::Make(8, 8), true, false, false); |
452 check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false, false); | 452 check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false, false); |
453 | |
454 // RAW | |
455 check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); | |
456 } | 453 } |
457 | 454 |
458 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode | 455 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode |
459 DEF_TEST(Codec_stripes, r) { | 456 DEF_TEST(Codec_stripes, r) { |
460 const char * path = "plane_interlaced.png"; | 457 const char * path = "plane_interlaced.png"; |
461 SkAutoTDelete<SkStream> stream(resource(path)); | 458 SkAutoTDelete<SkStream> stream(resource(path)); |
462 if (!stream) { | 459 if (!stream) { |
463 SkDebugf("Missing resource '%s'\n", path); | 460 SkDebugf("Missing resource '%s'\n", path); |
464 } | 461 } |
465 | 462 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 // performing scaled decodes on small images. | 636 // performing scaled decodes on small images. |
640 test_dimensions(r, "1x1.png"); | 637 test_dimensions(r, "1x1.png"); |
641 test_dimensions(r, "2x2.png"); | 638 test_dimensions(r, "2x2.png"); |
642 test_dimensions(r, "3x3.png"); | 639 test_dimensions(r, "3x3.png"); |
643 test_dimensions(r, "3x1.png"); | 640 test_dimensions(r, "3x1.png"); |
644 test_dimensions(r, "1x1.png"); | 641 test_dimensions(r, "1x1.png"); |
645 test_dimensions(r, "16x1.png"); | 642 test_dimensions(r, "16x1.png"); |
646 test_dimensions(r, "1x16.png"); | 643 test_dimensions(r, "1x16.png"); |
647 test_dimensions(r, "mandrill_16.png"); | 644 test_dimensions(r, "mandrill_16.png"); |
648 | 645 |
649 // RAW | |
650 test_dimensions(r, "sample_1mp.dng"); | |
651 } | 646 } |
652 | 647 |
653 static void test_invalid(skiatest::Reporter* r, const char path[]) { | 648 static void test_invalid(skiatest::Reporter* r, const char path[]) { |
654 SkAutoTDelete<SkStream> stream(resource(path)); | 649 SkAutoTDelete<SkStream> stream(resource(path)); |
655 if (!stream) { | 650 if (!stream) { |
656 SkDebugf("Missing resource '%s'\n", path); | 651 SkDebugf("Missing resource '%s'\n", path); |
657 return; | 652 return; |
658 } | 653 } |
659 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); | 654 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
660 REPORTER_ASSERT(r, nullptr == codec); | 655 REPORTER_ASSERT(r, nullptr == codec); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 // Now test an image which is too big. Any image with a larger header (i.e. | 960 // Now test an image which is too big. Any image with a larger header (i.e. |
966 // has bigger width/height) is also too big. | 961 // has bigger width/height) is also too big. |
967 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header | 962 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header |
968 0x84, 0x80, 0x00, // W: 65536 | 963 0x84, 0x80, 0x00, // W: 65536 |
969 0x84, 0x80, 0x00 }; // H: 65536 | 964 0x84, 0x80, 0x00 }; // H: 65536 |
970 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); | 965 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); |
971 codec.reset(SkCodec::NewFromStream(stream.detach())); | 966 codec.reset(SkCodec::NewFromStream(stream.detach())); |
972 | 967 |
973 REPORTER_ASSERT(r, !codec); | 968 REPORTER_ASSERT(r, !codec); |
974 } | 969 } |
OLD | NEW |