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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 test_invalid(r, "invalid_images/mask-bmp-ico.ico"); | 630 test_invalid(r, "invalid_images/mask-bmp-ico.ico"); |
631 } | 631 } |
632 | 632 |
633 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { | 633 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { |
634 SkAutoTDelete<SkStream> stream(resource(path)); | 634 SkAutoTDelete<SkStream> stream(resource(path)); |
635 if (!stream) { | 635 if (!stream) { |
636 SkDebugf("Missing resource '%s'\n", path); | 636 SkDebugf("Missing resource '%s'\n", path); |
637 return; | 637 return; |
638 } | 638 } |
639 SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release())); | 639 SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release())); |
640 | 640 |
641 // This should return kSuccess because kIndex8 is supported. | 641 // This should return kSuccess because kIndex8 is supported. |
642 SkPMColor colorStorage[256]; | 642 SkPMColor colorStorage[256]; |
643 int colorCount; | 643 int colorCount; |
644 SkCodec::Result result = decoder->startScanlineDecode( | 644 SkCodec::Result result = decoder->startScanlineDecode( |
645 decoder->getInfo().makeColorType(kIndex_8_SkColorType), nullptr, colorSt
orage, &colorCount); | 645 decoder->getInfo().makeColorType(kIndex_8_SkColorType), nullptr, colorSt
orage, &colorCount); |
646 REPORTER_ASSERT(r, SkCodec::kSuccess == result); | 646 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
647 // The rest of the test is uninteresting if kIndex8 is not supported | 647 // The rest of the test is uninteresting if kIndex8 is not supported |
648 if (SkCodec::kSuccess != result) { | 648 if (SkCodec::kSuccess != result) { |
649 return; | 649 return; |
650 } | 650 } |
(...skipping 314 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. | 965 // 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. | 966 // has bigger width/height) is also too big. |
967 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header | 967 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header |
968 0x84, 0x80, 0x00, // W: 65536 | 968 0x84, 0x80, 0x00, // W: 65536 |
969 0x84, 0x80, 0x00 }; // H: 65536 | 969 0x84, 0x80, 0x00 }; // H: 65536 |
970 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); | 970 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); |
971 codec.reset(SkCodec::NewFromStream(stream.release())); | 971 codec.reset(SkCodec::NewFromStream(stream.release())); |
972 | 972 |
973 REPORTER_ASSERT(r, !codec); | 973 REPORTER_ASSERT(r, !codec); |
974 } | 974 } |
OLD | NEW |