| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false, false); | 381 check(r, "mandrill_64.png", SkISize::Make(64, 64), true, false, false); |
| 382 check(r, "plane.png", SkISize::Make(250, 126), true, false, false); | 382 check(r, "plane.png", SkISize::Make(250, 126), true, false, false); |
| 383 // FIXME: We are not ready to test incomplete interlaced pngs | 383 // FIXME: We are not ready to test incomplete interlaced pngs |
| 384 check(r, "plane_interlaced.png", SkISize::Make(250, 126), true, false, false
); | 384 check(r, "plane_interlaced.png", SkISize::Make(250, 126), true, false, false
); |
| 385 check(r, "randPixels.png", SkISize::Make(8, 8), true, false, false); | 385 check(r, "randPixels.png", SkISize::Make(8, 8), true, false, false); |
| 386 check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false, false); | 386 check(r, "yellow_rose.png", SkISize::Make(400, 301), true, false, false); |
| 387 | 387 |
| 388 // RAW | 388 // RAW |
| 389 #if defined(SK_CODEC_DECODES_RAW) | 389 #if defined(SK_CODEC_DECODES_RAW) |
| 390 check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); | 390 check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); |
| 391 check(r, "sample_1mp_rotated.dng", SkISize::Make(600, 338), false, false, fa
lse); |
| 391 check(r, "dng_with_preview.dng", SkISize::Make(600, 338), true, false, false
); | 392 check(r, "dng_with_preview.dng", SkISize::Make(600, 338), true, false, false
); |
| 392 #endif | 393 #endif |
| 393 } | 394 } |
| 394 | 395 |
| 395 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode | 396 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode |
| 396 DEF_TEST(Codec_stripes, r) { | 397 DEF_TEST(Codec_stripes, r) { |
| 397 const char * path = "plane_interlaced.png"; | 398 const char * path = "plane_interlaced.png"; |
| 398 SkAutoTDelete<SkStream> stream(resource(path)); | 399 SkAutoTDelete<SkStream> stream(resource(path)); |
| 399 if (!stream) { | 400 if (!stream) { |
| 400 SkDebugf("Missing resource '%s'\n", path); | 401 SkDebugf("Missing resource '%s'\n", path); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 test_dimensions(r, "3x3.png"); | 580 test_dimensions(r, "3x3.png"); |
| 580 test_dimensions(r, "3x1.png"); | 581 test_dimensions(r, "3x1.png"); |
| 581 test_dimensions(r, "1x1.png"); | 582 test_dimensions(r, "1x1.png"); |
| 582 test_dimensions(r, "16x1.png"); | 583 test_dimensions(r, "16x1.png"); |
| 583 test_dimensions(r, "1x16.png"); | 584 test_dimensions(r, "1x16.png"); |
| 584 test_dimensions(r, "mandrill_16.png"); | 585 test_dimensions(r, "mandrill_16.png"); |
| 585 | 586 |
| 586 // RAW | 587 // RAW |
| 587 #if defined(SK_CODEC_DECODES_RAW) | 588 #if defined(SK_CODEC_DECODES_RAW) |
| 588 test_dimensions(r, "sample_1mp.dng"); | 589 test_dimensions(r, "sample_1mp.dng"); |
| 590 test_dimensions(r, "sample_1mp_rotated.dng"); |
| 589 test_dimensions(r, "dng_with_preview.dng"); | 591 test_dimensions(r, "dng_with_preview.dng"); |
| 590 #endif | 592 #endif |
| 591 } | 593 } |
| 592 | 594 |
| 593 static void test_invalid(skiatest::Reporter* r, const char path[]) { | 595 static void test_invalid(skiatest::Reporter* r, const char path[]) { |
| 594 SkAutoTDelete<SkStream> stream(resource(path)); | 596 SkAutoTDelete<SkStream> stream(resource(path)); |
| 595 if (!stream) { | 597 if (!stream) { |
| 596 SkDebugf("Missing resource '%s'\n", path); | 598 SkDebugf("Missing resource '%s'\n", path); |
| 597 return; | 599 return; |
| 598 } | 600 } |
| (...skipping 354 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. | 955 // 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. | 956 // has bigger width/height) is also too big. |
| 955 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header | 957 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header |
| 956 0x84, 0x80, 0x00, // W: 65536 | 958 0x84, 0x80, 0x00, // W: 65536 |
| 957 0x84, 0x80, 0x00 }; // H: 65536 | 959 0x84, 0x80, 0x00 }; // H: 65536 |
| 958 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); | 960 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); |
| 959 codec.reset(SkCodec::NewFromStream(stream.detach())); | 961 codec.reset(SkCodec::NewFromStream(stream.detach())); |
| 960 | 962 |
| 961 REPORTER_ASSERT(r, !codec); | 963 REPORTER_ASSERT(r, !codec); |
| 962 } | 964 } |
| OLD | NEW |