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