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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 SkDebugf("Missing resource '%s'\n", path); | 574 SkDebugf("Missing resource '%s'\n", path); |
575 return; | 575 return; |
576 } | 576 } |
577 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.det
ach())); | 577 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.det
ach())); |
578 if (!codec) { | 578 if (!codec) { |
579 ERRORF(r, "Unable to create codec '%s'", path); | 579 ERRORF(r, "Unable to create codec '%s'", path); |
580 return; | 580 return; |
581 } | 581 } |
582 | 582 |
583 // Check that the decode is successful for a variety of scales | 583 // Check that the decode is successful for a variety of scales |
584 for (int sampleSize = 1; sampleSize < 10; sampleSize++) { | 584 for (int sampleSize = 1; sampleSize < 32; sampleSize++) { |
585 // Scale the output dimensions | 585 // Scale the output dimensions |
586 SkISize scaledDims = codec->getSampledDimensions(sampleSize); | 586 SkISize scaledDims = codec->getSampledDimensions(sampleSize); |
587 SkImageInfo scaledInfo = codec->getInfo() | 587 SkImageInfo scaledInfo = codec->getInfo() |
588 .makeWH(scaledDims.width(), scaledDims.height()) | 588 .makeWH(scaledDims.width(), scaledDims.height()) |
589 .makeColorType(kN32_SkColorType); | 589 .makeColorType(kN32_SkColorType); |
590 | 590 |
591 // Set up for the decode | 591 // Set up for the decode |
592 size_t rowBytes = scaledDims.width() * sizeof(SkPMColor); | 592 size_t rowBytes = scaledDims.width() * sizeof(SkPMColor); |
593 size_t totalBytes = scaledInfo.getSafeSize(rowBytes); | 593 size_t totalBytes = scaledInfo.getSafeSize(rowBytes); |
594 SkAutoTMalloc<SkPMColor> pixels(totalBytes); | 594 SkAutoTMalloc<SkPMColor> pixels(totalBytes); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 678 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
679 result = decoder->startScanlineDecode( | 679 result = decoder->startScanlineDecode( |
680 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); | 680 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); |
681 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 681 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
682 } | 682 } |
683 | 683 |
684 DEF_TEST(Codec_Params, r) { | 684 DEF_TEST(Codec_Params, r) { |
685 test_invalid_parameters(r, "index8.png"); | 685 test_invalid_parameters(r, "index8.png"); |
686 test_invalid_parameters(r, "mandrill.wbmp"); | 686 test_invalid_parameters(r, "mandrill.wbmp"); |
687 } | 687 } |
OLD | NEW |