Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp

Issue 2618633004: Add support for Animated PNG (Closed)
Patch Set: Respond to comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp
index 18c1406991de52f5afdf6e59480852329ed4339b..b41606a16c56c8dbd382944ccd5fc888ac35d440 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp
@@ -54,10 +54,10 @@ void createDecodingBaseline(DecoderCreator createDecoder,
}
}
-static void testByteByByteDecode(DecoderCreator createDecoder,
- SharedBuffer* data,
- size_t expectedFrameCount,
- int expectedRepetitionCount) {
+void testByteByByteDecode(DecoderCreator createDecoder,
+ SharedBuffer* data,
+ size_t expectedFrameCount,
+ int expectedRepetitionCount) {
ASSERT_TRUE(data->data());
Vector<unsigned> baselineHashes;
@@ -224,8 +224,10 @@ static void testByteByByteSizeAvailable(DecoderCreator createDecoder,
// Send data to the decoder byte-by-byte and use the provided frame offset in
// the data to check that isSizeAvailable() changes state only when that
// offset is reached. Also check other decoder state.
+ RefPtr<SharedBuffer> tempData = SharedBuffer::create();
+ const char* source = data->data();
for (size_t length = 1; length <= frameOffset; ++length) {
- RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), length);
+ tempData->append(source++, 1u);
decoder->setData(tempData.get(), false);
if (length < frameOffset) {
@@ -258,9 +260,11 @@ static void testProgressiveDecoding(DecoderCreator createDecoder,
Vector<unsigned> progressiveHashes;
// Compute hashes when the file is truncated.
+ RefPtr<SharedBuffer> data = SharedBuffer::create();
+ const char* source = fullData->data();
for (size_t i = 1; i <= fullLength; i += increment) {
decoder = createDecoder();
- RefPtr<SharedBuffer> data = SharedBuffer::create(fullData->data(), i);
+ data->append(source++, 1u);
decoder->setData(data.get(), i == fullLength);
ImageFrame* frame = decoder->frameBufferAtIndex(0);
if (!frame) {
@@ -272,8 +276,10 @@ static void testProgressiveDecoding(DecoderCreator createDecoder,
// Compute hashes when the file is progressively decoded.
decoder = createDecoder();
+ data = SharedBuffer::create();
+ source = fullData->data();
for (size_t i = 1; i <= fullLength; i += increment) {
- RefPtr<SharedBuffer> data = SharedBuffer::create(fullData->data(), i);
+ data->append(source++, 1u);
decoder->setData(data.get(), i == fullLength);
ImageFrame* frame = decoder->frameBufferAtIndex(0);
if (!frame) {
@@ -294,12 +300,11 @@ void testUpdateRequiredPreviousFrameAfterFirstDecode(
// Give it data that is enough to parse but not decode in order to check the
// status of requiredPreviousFrameIndex before decoding.
- size_t partialSize = 1;
+ RefPtr<SharedBuffer> data = SharedBuffer::create();
+ const char* source = fullData->data();
do {
- RefPtr<SharedBuffer> data =
- SharedBuffer::create(fullData->data(), partialSize);
+ data->append(source++, 1u);
decoder->setData(data.get(), false);
- ++partialSize;
} while (!decoder->frameCount() ||
decoder->frameBufferAtIndex(0)->getStatus() ==
ImageFrame::FrameEmpty);
@@ -329,12 +334,11 @@ void testResumePartialDecodeAfterClearFrameBufferCache(
std::unique_ptr<ImageDecoder> decoder = createDecoder();
// Let frame 0 be partially decoded.
- size_t partialSize = 1;
+ RefPtr<SharedBuffer> data = SharedBuffer::create();
+ const char* source = fullData->data();
do {
- RefPtr<SharedBuffer> data =
- SharedBuffer::create(fullData->data(), partialSize);
+ data->append(source++, 1u);
decoder->setData(data.get(), false);
- ++partialSize;
} while (!decoder->frameCount() ||
decoder->frameBufferAtIndex(0)->getStatus() ==
ImageFrame::FrameEmpty);

Powered by Google App Engine
This is Rietveld 408576698