| Index: src/images/SkImageDecoder_libgif.cpp
|
| diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp
|
| index 3e4cda8a0bac26611ca1760c3da18aeaaf0f973c..1553af27c1d95bf7f5de7378c537d3671756d32d 100644
|
| --- a/src/images/SkImageDecoder_libgif.cpp
|
| +++ b/src/images/SkImageDecoder_libgif.cpp
|
| @@ -22,6 +22,8 @@ public:
|
| return kGIF_Format;
|
| }
|
|
|
| + virtual Format onGetFormat(SkStream*) const SK_OVERRIDE;
|
| +
|
| protected:
|
| virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE;
|
|
|
| @@ -91,9 +93,6 @@ private:
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -//#define GIF_STAMP "GIF" /* First chars in file - GIF stamp. */
|
| -//#define GIF_STAMP_LEN (sizeof(GIF_STAMP) - 1)
|
| -
|
| static int DecodeCallBackProc(GifFileType* fileType, GifByteType* out,
|
| int size) {
|
| SkStream* stream = (SkStream*) fileType->UserData;
|
| @@ -361,6 +360,25 @@ DONE:
|
| return true;
|
| }
|
|
|
| +static bool is_gif(SkStream* stream) {
|
| + char buf[GIF_STAMP_LEN];
|
| + if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
|
| + if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
|
| + memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
|
| + memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +SkImageDecoder::Format SkGIFImageDecoder::onGetFormat(SkStream* stream) const {
|
| + if (is_gif(stream)) {
|
| + return kGIF_Format;
|
| + }
|
| + return kUnknown_Format;
|
| +}
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
| DEFINE_DECODER_CREATOR(GIFImageDecoder);
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -368,13 +386,8 @@ DEFINE_DECODER_CREATOR(GIFImageDecoder);
|
| #include "SkTRegistry.h"
|
|
|
| static SkImageDecoder* sk_libgif_dfactory(SkStream* stream) {
|
| - char buf[GIF_STAMP_LEN];
|
| - if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
|
| - if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
|
| - memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
|
| - memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
|
| - return SkNEW(SkGIFImageDecoder);
|
| - }
|
| + if (is_gif(stream)) {
|
| + return SkNEW(SkGIFImageDecoder);
|
| }
|
| return NULL;
|
| }
|
|
|