diff options
author | Cary Clark <cary@android.com> | 2010-05-13 12:55:51 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-05-13 12:55:51 -0700 |
commit | 86644d6de5fbc08f13d386210ff951d53cdefa5b (patch) | |
tree | b7f3ae54b5409bdf70aca84e0e3badfd07f66dba /WebCore | |
parent | b94a30def72cdfa7401b9b0b960385e3a92afa94 (diff) | |
parent | 2e483c130bc3db530caa4b7c4f25b9232464d592 (diff) | |
download | external_webkit-86644d6de5fbc08f13d386210ff951d53cdefa5b.zip external_webkit-86644d6de5fbc08f13d386210ff951d53cdefa5b.tar.gz external_webkit-86644d6de5fbc08f13d386210ff951d53cdefa5b.tar.bz2 |
Merge "don't use animated gifs if gifs only have one frame"
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/graphics/android/ImageSourceAndroid.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/WebCore/platform/graphics/android/ImageSourceAndroid.cpp b/WebCore/platform/graphics/android/ImageSourceAndroid.cpp index 06455d2..914a9d6 100644 --- a/WebCore/platform/graphics/android/ImageSourceAndroid.cpp +++ b/WebCore/platform/graphics/android/ImageSourceAndroid.cpp @@ -228,10 +228,15 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived) { #ifdef ANDROID_ANIMATED_GIF // This is only necessary if we allow ourselves to partially decode GIF + bool disabledAnimatedGif = false; if (m_decoder.m_gifDecoder && !m_decoder.m_gifDecoder->failed()) { m_decoder.m_gifDecoder->setData(data, allDataReceived); - return; + if (!allDataReceived || m_decoder.m_gifDecoder->frameCount() != 1) + return; + disabledAnimatedGif = true; + delete m_decoder.m_gifDecoder; + m_decoder.m_gifDecoder = 0; } #endif if (NULL == m_decoder.m_image @@ -258,17 +263,26 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived) // First, check to see if this is an animated GIF const Vector<char>& buffer = data->buffer(); const char* contents = buffer.data(); - if (buffer.size() > 3 && strncmp(contents, "GIF8", 4) == 0 && - should_use_animated_gif(origW, origH)) { + if (buffer.size() > 3 && strncmp(contents, "GIF8", 4) == 0 + && should_use_animated_gif(origW, origH) + && !disabledAnimatedGif) { // This means we are looking at a GIF, so create special // GIF Decoder // Need to wait for all data received if we are assigning an // allocator (which we are not at the moment). if (!m_decoder.m_gifDecoder /*&& allDataReceived*/) m_decoder.m_gifDecoder = new GIFImageDecoder(); - if (!m_decoder.m_gifDecoder->failed()) + int frameCount = 0; + if (!m_decoder.m_gifDecoder->failed()) { m_decoder.m_gifDecoder->setData(data, allDataReceived); - return; + if (!allDataReceived) + return; + frameCount = m_decoder.m_gifDecoder->frameCount(); + } + if (frameCount != 1) + return; + delete m_decoder.m_gifDecoder; + m_decoder.m_gifDecoder = 0; } #endif |