diff options
-rw-r--r-- | webkit/port/platform/graphics/ImageSkia.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/webkit/port/platform/graphics/ImageSkia.cpp b/webkit/port/platform/graphics/ImageSkia.cpp index 5ffd3e3..e84ec8f5 100644 --- a/webkit/port/platform/graphics/ImageSkia.cpp +++ b/webkit/port/platform/graphics/ImageSkia.cpp @@ -328,8 +328,9 @@ void FrameData::clear() { // The frame data is released in ImageSource::clear. m_frame = 0; - m_duration = 0.0f; - m_hasAlpha = true; + // NOTE: We purposefully don't reset metadata here, so that even if we + // throw away previously-decoded data, animation loops can still access + // properties like frame durations without re-decoding. } static inline PassRefPtr<Image> loadImageWithResourceId(int resourceId) @@ -471,6 +472,11 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, if (!m_source.initialized()) return; + // Spin the animation to the correct frame before we try to draw it, so we + // don't draw an old frame and then immediately need to draw a newer one, + // causing flicker and wasting CPU. + startAnimation(); + const NativeImageSkia* bm = nativeImageForCurrentFrame(); if (!bm) return; // It's too early and we don't have an image yet. @@ -483,8 +489,6 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, enclosingIntRect(srcRect), enclosingIntRect(dstRect), WebCoreCompositeToSkiaComposite(compositeOp)); - - startAnimation(); } void BitmapImageSingleFrameSkia::draw(GraphicsContext* ctxt, |