aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Leon Scroggins <scroggo@google.com>2017-07-11 17:35:31 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-11 18:00:31 +0000
commit571b30f6117eede6d64cd2b924dc1f6aaa59e70e (patch)
treea617b52ab7728fc7b2324fef75a0775438d94d71 /tests
parentf778eb2f51572d57a75e1a9cec25d5495f6662e1 (diff)
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/CodecAnimTest.cpp4
-rw-r--r--tests/CodecPartialTest.cpp2
-rw-r--r--tests/CodecPriv.h16
-rw-r--r--tests/CodecTest.cpp71
-rw-r--r--tests/GifTest.cpp54
5 files changed, 13 insertions, 134 deletions
diff --git a/tests/CodecAnimTest.cpp b/tests/CodecAnimTest.cpp
index 27fe0038b5..84dc9faa6b 100644
--- a/tests/CodecAnimTest.cpp
+++ b/tests/CodecAnimTest.cpp
@@ -60,7 +60,7 @@ DEF_TEST(Codec_565, r) {
options.fPriorFrame = SkCodec::kNone;
const auto result = codec->getPixels(info, bm.getPixels(), bm.rowBytes(),
- &options, nullptr, nullptr);
+ &options);
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
}
@@ -329,7 +329,7 @@ DEF_TEST(Codec_frames, r) {
opts.fFrameIndex = index;
opts.fPriorFrame = cachedIndex;
const auto result = codec->getPixels(decodeInfo, bm->getPixels(), bm->rowBytes(),
- &opts, nullptr, nullptr);
+ &opts);
if (cachedIndex != SkCodec::kNone && restore_previous(frameInfos[cachedIndex])) {
if (result == SkCodec::kInvalidParameters) {
return true;
diff --git a/tests/CodecPartialTest.cpp b/tests/CodecPartialTest.cpp
index 975ca63ee9..ee012711a6 100644
--- a/tests/CodecPartialTest.cpp
+++ b/tests/CodecPartialTest.cpp
@@ -209,7 +209,7 @@ DEF_TEST(Codec_partialAnim, r) {
SkCodec::Options opts;
opts.fFrameIndex = i;
const SkCodec::Result result = fullCodec->getPixels(info, frame.getPixels(),
- frame.rowBytes(), &opts, nullptr, nullptr);
+ frame.rowBytes(), &opts);
if (result == SkCodec::kIncompleteInput || result == SkCodec::kInvalidInput) {
// We need to distinguish between a partial frame and no more frames.
diff --git a/tests/CodecPriv.h b/tests/CodecPriv.h
index cfa794ed68..d80bb69672 100644
--- a/tests/CodecPriv.h
+++ b/tests/CodecPriv.h
@@ -17,21 +17,9 @@ inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
return false;
}
- // Construct a color table for the decode if necessary
- sk_sp<SkColorTable> colorTable(nullptr);
- SkPMColor* colorPtr = nullptr;
- int* colorCountPtr = nullptr;
- int maxColors = 256;
- if (kIndex_8_SkColorType == codec->getInfo().colorType()) {
- SkPMColor colors[256];
- colorTable.reset(new SkColorTable(colors, maxColors));
- colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
- colorCountPtr = &maxColors;
- }
-
- bm->allocPixels(codec->getInfo(), colorTable);
+ bm->allocPixels(codec->getInfo());
const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPixels(),
- bm->rowBytes(), nullptr, colorPtr, colorCountPtr);
+ bm->rowBytes());
return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput;
}
#endif // CodecPriv_DEFINED
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 7ec903728e..1d7d89aa34 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -348,8 +348,7 @@ static void check(skiatest::Reporter* r,
SkIRect subset = SkIRect::MakeXYWH(2 * (width / 3), 0, width / 3, height);
options.fSubset = &subset;
- 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 @@ static void check(skiatest::Reporter* r,
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 @@ DEF_TEST(Codec_Empty, r) {
#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 bool alpha_type_match(SkAlphaType origAlphaType, SkAlphaType codecAlphaTy
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 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk
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 @@ static void decode_frame(skiatest::Reporter* r, SkCodec* codec, size_t frame) {
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
diff --git a/tests/GifTest.cpp b/tests/GifTest.cpp
index 0168d89d83..7728d27dcb 100644
--- a/tests/GifTest.cpp
+++ b/tests/GifTest.cpp
@@ -238,25 +238,11 @@ DEF_TEST(Gif_Sampled, r) {
return;
}
- // Construct a color table for the decode if necessary
- sk_sp<SkColorTable> colorTable(nullptr);
- SkPMColor* colorPtr = nullptr;
- int* colorCountPtr = nullptr;
- int maxColors = 256;
- if (kIndex_8_SkColorType == codec->getInfo().colorType()) {
- SkPMColor colors[256];
- colorTable.reset(new SkColorTable(colors, maxColors));
- colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
- colorCountPtr = &maxColors;
- }
-
SkAndroidCodec::AndroidOptions options;
options.fSampleSize = 4;
- options.fColorPtr = colorPtr;
- options.fColorCount = colorCountPtr;
SkBitmap bm;
- bm.allocPixels(codec->getInfo(), colorTable);
+ bm.allocPixels(codec->getInfo());
const SkCodec::Result result = codec->getAndroidPixels(codec->getInfo(), bm.getPixels(),
bm.rowBytes(), &options);
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
@@ -273,41 +259,3 @@ DEF_TEST(Codec_GifTruncated, r) {
std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
REPORTER_ASSERT(r, !codec);
}
-
-// There was a bug where SkAndroidCodec::computeOutputColorType returned kIndex_8 for
-// GIFs that did not support kIndex_8. Verify that for such an image, the method computes
-// something that it can actually decode to.
-DEF_TEST(Codec_GifIndex8, r) {
- std::unique_ptr<SkStream> stream(GetResourceAsStream("randPixelsOffset.gif"));
- if (!stream) {
- return;
- }
-
- std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
- REPORTER_ASSERT(r, codec);
- if (!codec) {
- return;
- }
-
- REPORTER_ASSERT(r, codec->getInfo().colorType() == kN32_SkColorType);
- const SkColorType outputColorType = codec->computeOutputColorType(kN32_SkColorType);
- REPORTER_ASSERT(r, outputColorType == kN32_SkColorType);
-
- SkAndroidCodec::AndroidOptions options;
- sk_sp<SkColorTable> colorTable(nullptr);
- int maxColors = 256;
- if (kIndex_8_SkColorType == outputColorType) {
- SkPMColor colors[256];
- colorTable.reset(new SkColorTable(colors, maxColors));
- options.fColorPtr = const_cast<SkPMColor*>(colorTable->readColors());
- options.fColorCount = &maxColors;
- }
-
- auto info = codec->getInfo().makeColorType(outputColorType);
- SkBitmap bm;
- bm.setInfo(info);
- bm.allocPixels(colorTable.get());
-
- REPORTER_ASSERT(r, SkCodec::kSuccess == codec->getAndroidPixels(info, bm.getPixels(),
- bm.rowBytes(), &options));
-}