| Index: src/codec/SkCodec.cpp
|
| diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
|
| index a49586ffeb1ecf6ff337b1dc12fd0fe8120be113..ea318fbb86aa0bca9f8c41da5eefdcbe3ae01381 100644
|
| --- a/src/codec/SkCodec.cpp
|
| +++ b/src/codec/SkCodec.cpp
|
| @@ -18,15 +18,25 @@ struct DecoderProc {
|
| };
|
|
|
| static const DecoderProc gDecoderProcs[] = {
|
| - { SkPngCodec::IsPng, SkPngCodec::NewFromStream },
|
| { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream },
|
| { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }
|
| };
|
|
|
| -SkCodec* SkCodec::NewFromStream(SkStream* stream) {
|
| +SkCodec* SkCodec::NewFromStream(SkStream* stream, SkChunkReader* chunkReader) {
|
| if (!stream) {
|
| return NULL;
|
| }
|
| +
|
| + // PNG is special, since we want to be able to supply an SkChunkReader.
|
| + // But this code follows the same pattern as the loop.
|
| + const bool isPng = SkPngCodec::IsPng(stream);
|
| + if (!stream->rewind()) {
|
| + return NULL;
|
| + }
|
| + if (isPng) {
|
| + return SkPngCodec::NewFromStream(stream, chunkReader);
|
| + }
|
| +
|
| for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) {
|
| DecoderProc proc = gDecoderProcs[i];
|
| const bool correctFormat = proc.IsFormat(stream);
|
| @@ -40,11 +50,11 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) {
|
| return NULL;
|
| }
|
|
|
| -SkCodec* SkCodec::NewFromData(SkData* data) {
|
| +SkCodec* SkCodec::NewFromData(SkData* data, SkChunkReader* reader) {
|
| if (!data) {
|
| return NULL;
|
| }
|
| - return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
|
| + return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)), reader);
|
| }
|
|
|
| SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
|
|
|