Reland "Remove support for decoding to kIndex_8"
Original change's description:
> > Remove support for decoding to kIndex_8
> >
> > Fix up callsites, and remove tests that no longer make sense.
> >
> > Bug: skia:6828
> > Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295
> > Reviewed-on: https://skia-review.googlesource.com/21664
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Leon Scroggins <scroggo@google.com>
>
> TBR=djsollen@google.com,scroggo@google.com
>
> Change-Id: I1bc669441f250690884e75a9a61427fdf75c6907
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:6828
> Reviewed-on: https://skia-review.googlesource.com/22120
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>
TBR=djsollen@google.com,scroggo@google.com
Bug: skia:6828
Change-Id: I36ff5a11c529d29e8adc95f43b8edc6fd1dbf5b8
Reviewed-on: https://skia-review.googlesource.com/22320
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 7ec9037..1d7d89a 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -348,8 +348,7 @@
SkIRect subset = SkIRect::MakeXYWH(2 * (width / 3), 0, width / 3, height);
options.fSubset = ⊂
- const SkCodec::Result partialStartResult = codec->startScanlineDecode(info, &options,
- nullptr, nullptr);
+ const auto partialStartResult = codec->startScanlineDecode(info, &options);
REPORTER_ASSERT(r, partialStartResult == SkCodec::kSuccess);
for (int y = 0; y < height; y++) {
@@ -384,8 +383,7 @@
SkImageInfo subsetInfo = info.makeWH(subset.width(), subset.height());
SkBitmap bm;
bm.allocPixels(subsetInfo);
- const SkCodec::Result result = codec->getPixels(bm.info(), bm.getPixels(), bm.rowBytes(),
- &opts, nullptr, nullptr);
+ const auto result = codec->getPixels(bm.info(), bm.getPixels(), bm.rowBytes(), &opts);
if (supportsSubsetDecoding) {
if (expectedResult == SkCodec::kSuccess) {
@@ -668,53 +666,6 @@
#endif
}
-static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) {
- std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
- if (!stream) {
- return;
- }
- std::unique_ptr<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
- if (!decoder) {
- SkDebugf("Missing codec for %s\n", path);
- return;
- }
-
- const SkImageInfo info = decoder->getInfo().makeColorType(kIndex_8_SkColorType);
-
- // This should return kSuccess because kIndex8 is supported.
- SkPMColor colorStorage[256];
- int colorCount;
- SkCodec::Result result = decoder->startScanlineDecode(info, nullptr, colorStorage,
- &colorCount);
- if (SkCodec::kSuccess == result) {
- // This should return kInvalidParameters because, in kIndex_8 mode, we must pass in a valid
- // colorPtr and a valid colorCountPtr.
- result = decoder->startScanlineDecode(info, nullptr, nullptr, nullptr);
- REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
- result = decoder->startScanlineDecode(info);
- REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
- } else if (SkCodec::kUnimplemented == result) {
- // New method should be supported:
- SkBitmap bm;
- bm.allocPixels(info, SkColorTable::Make(colorStorage, 256));
- result = decoder->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes(), nullptr,
- colorStorage, &colorCount);
- REPORTER_ASSERT(r, SkCodec::kSuccess == result);
- result = decoder->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes());
- REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
- } else {
- // The test is uninteresting if kIndex8 is not supported
- ERRORF(r, "Should not call test_invalid_parameters for non-Index8 file: %s\n", path);
- return;
- }
-
-}
-
-DEF_TEST(Codec_Params, r) {
- test_invalid_parameters(r, "index8.png");
- test_invalid_parameters(r, "mandrill.wbmp");
-}
-
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#ifndef SK_PNG_DISABLE_TESTS // reading chunks does not work properly with older versions.
@@ -1102,14 +1053,8 @@
static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const SkImageInfo& info) {
SkBitmap bm1;
- SkPMColor colors[256];
- sk_sp<SkColorTable> colorTable1 = SkColorTable::Make(colors, 256);
- bm1.allocPixels(info, colorTable1);
- int numColors;
- SkCodec::Result result = origCodec->getPixels(info, bm1.getPixels(), bm1.rowBytes(), nullptr,
- const_cast<SkPMColor*>(colorTable1->readColors()),
- &numColors);
- // This will fail to update colorTable1->count() but is fine for the purpose of this test.
+ bm1.allocPixels(info);
+ SkCodec::Result result = origCodec->getPixels(info, bm1.getPixels(), bm1.rowBytes());
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
// Encode the image to png.
@@ -1121,10 +1066,8 @@
REPORTER_ASSERT(r, alpha_type_match(info.alphaType(), codec->getInfo().alphaType()));
SkBitmap bm2;
- sk_sp<SkColorTable> colorTable2 = SkColorTable::Make(colors, 256);
- bm2.allocPixels(info, colorTable2);
- result = codec->getPixels(info, bm2.getPixels(), bm2.rowBytes(), nullptr,
- const_cast<SkPMColor*>(colorTable2->readColors()), &numColors);
+ bm2.allocPixels(info);
+ result = codec->getPixels(info, bm2.getPixels(), bm2.rowBytes());
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
SkMD5::Digest d1, d2;
@@ -1251,7 +1194,7 @@
SkCodec::Options opts;
opts.fFrameIndex = frame;
REPORTER_ASSERT(r, SkCodec::kSuccess == codec->getPixels(info,
- bm.getPixels(), bm.rowBytes(), &opts, nullptr, nullptr));
+ bm.getPixels(), bm.rowBytes(), &opts));
}
// For an animated GIF, we should only read enough to decode frame 0 if the