From a16cb97c89fedcd521aeaadfa94feddbcb6729b1 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Thu, 18 Jun 2009 20:26:58 +0000 Subject: really fix gif movie registration git-svn-id: http://skia.googlecode.com/svn/trunk@223 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/images/SkImageDecoder_Factory.cpp | 4 ++++ src/images/SkMovie_gif.cpp | 2 ++ 2 files changed, 6 insertions(+) (limited to 'src/images') diff --git a/src/images/SkImageDecoder_Factory.cpp b/src/images/SkImageDecoder_Factory.cpp index 9dd9913bb5..bd81d1fc1d 100644 --- a/src/images/SkImageDecoder_Factory.cpp +++ b/src/images/SkImageDecoder_Factory.cpp @@ -28,6 +28,8 @@ SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) { const DecodeReg* curr = DecodeReg::Head(); while (curr) { SkImageDecoder* codec = curr->factory()(stream); + // we rewind here, because we promise later when we call "decode", that + // the stream will be at its beginning. stream->rewind(); if (codec) { return codec; @@ -48,6 +50,8 @@ SkMovie* SkMovie::DecodeStream(SkStream* stream) { if (movie) { return movie; } + // we must rewind only if we got NULL, since we gave the stream to the + // movie, who may have already started reading from it stream->rewind(); curr = curr->next(); } diff --git a/src/images/SkMovie_gif.cpp b/src/images/SkMovie_gif.cpp index 68af85a94b..113804462a 100644 --- a/src/images/SkMovie_gif.cpp +++ b/src/images/SkMovie_gif.cpp @@ -220,6 +220,8 @@ SkMovie* Factory(SkStream* stream) { 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) { + // must rewind here, since our construct wants to re-read the data + stream->rewind(); return SkNEW_ARGS(SkGIFMovie, (stream)); } } -- cgit v1.2.3