Test Codec::getFrameCount updates with more data
This mimics Chromium's TestResumePartialDecodeAfterClearFrameBufferCache, which expects the frame count to increase as more data comes in, even if the decoder is in the middle of an incremental decode: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/image-decoders/image_decoder_test_helpers.cc?l=365&rcl=23787ba147959ebf4ad168c595d5ec87919fdbd2 Bug: skia:8235 Change-Id: Icc19ebea6d77f6b6fb62e3b2ff0c2ffb1ef0950d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250476 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
parent
352f4f7800
commit
a1cc9f6b84
@ -170,6 +170,36 @@ DEF_TEST(Codec_partialWuffs, r) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SK_HAS_WUFFS_LIBRARY
|
||||
DEF_TEST(Codec_frameCountUpdatesInIncrementalDecode, r) {
|
||||
sk_sp<SkData> file = GetResourceAsData("images/colorTables.gif");
|
||||
size_t fileSize = file->size();
|
||||
REPORTER_ASSERT(r, fileSize == 2829);
|
||||
std::unique_ptr<SkCodec> fullCodec(SkCodec::MakeFromData(file));
|
||||
REPORTER_ASSERT(r, fullCodec->getFrameCount() == 2);
|
||||
const SkImageInfo info = standardize_info(fullCodec.get());
|
||||
|
||||
static const size_t n = 1000;
|
||||
HaltingStream* stream = new HaltingStream(file, n);
|
||||
// Note that we cheat and hold on to a pointer to stream, though it is owned by
|
||||
// partialCodec.
|
||||
auto partialCodec = SkCodec::MakeFromStream(std::unique_ptr<SkStream>(stream));
|
||||
REPORTER_ASSERT(r, partialCodec->getFrameCount() == 1);
|
||||
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocPixels(info);
|
||||
REPORTER_ASSERT(r, SkCodec::kSuccess ==
|
||||
partialCodec->startIncrementalDecode(
|
||||
info, bitmap.getPixels(), bitmap.rowBytes()));
|
||||
REPORTER_ASSERT(r, SkCodec::kIncompleteInput ==
|
||||
partialCodec->incrementalDecode());
|
||||
|
||||
REPORTER_ASSERT(r, partialCodec->getFrameCount() == 1);
|
||||
stream->addNewData(fileSize - n);
|
||||
REPORTER_ASSERT(r, partialCodec->getFrameCount() == 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Verify that when decoding an animated gif byte by byte we report the correct
|
||||
// fRequiredFrame as soon as getFrameInfo reports the frame.
|
||||
DEF_TEST(Codec_requiredFrame, r) {
|
||||
|
Loading…
Reference in New Issue
Block a user