Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1484)

Unified Diff: Source/core/platform/image-decoders/ImageDecoder.h

Issue 15350006: Decode GIF image frames on demand. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/image-decoders/ImageDecoder.h
diff --git a/Source/core/platform/image-decoders/ImageDecoder.h b/Source/core/platform/image-decoders/ImageDecoder.h
index 83dbdc070a653ec942c629b7e635ae8c4f37560e..25349167fc33d29da2e722a61faa9447f540afb3 100644
--- a/Source/core/platform/image-decoders/ImageDecoder.h
+++ b/Source/core/platform/image-decoders/ImageDecoder.h
@@ -117,6 +117,7 @@ namespace WebCore {
FrameDisposalMethod disposalMethod() const { return m_disposalMethod; }
bool premultiplyAlpha() const { return m_premultiplyAlpha; }
void reportMemoryUsage(MemoryObjectInfo*) const;
+ size_t requiredPreviousFrameIndex() const { return m_requiredPreviousFrameIndex; }
void setHasAlpha(bool alpha);
void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; }
@@ -124,6 +125,7 @@ namespace WebCore {
void setDuration(unsigned duration) { m_duration = duration; }
void setDisposalMethod(FrameDisposalMethod method) { m_disposalMethod = method; }
void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premultiplyAlpha; }
+ void setRequiredPreviousFrameIndex(size_t previousFrameIndex) { m_requiredPreviousFrameIndex = previousFrameIndex; }
inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a)
{
@@ -202,6 +204,10 @@ namespace WebCore {
unsigned m_duration;
FrameDisposalMethod m_disposalMethod;
bool m_premultiplyAlpha;
+
+ // The frame that must be decoded before this frame can be decoded.
+ // |notFound| if this frame doesn't require any previous frame.
+ size_t m_requiredPreviousFrameIndex;
};
// ImageDecoder is a base for all format-specific decoders
@@ -371,10 +377,11 @@ namespace WebCore {
bool failed() const { return m_failed; }
- // Clears decoded pixel data from before the provided frame unless that
+ // Clears decoded pixel data except the provided frame unless that
// data may be needed to decode future frames (e.g. due to GIF frame
- // compositing).
- virtual void clearFrameBufferCache(size_t) { }
+ // compositing). Pass a value greater than the frame count to clear
+ // decoded pixel data of all frames.
+ void clearFrameBufferCache(size_t clearExceptFrame);
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
void setMaxNumPixels(int m) { m_maxNumPixels = m; }
@@ -395,12 +402,20 @@ namespace WebCore {
}
protected:
+ // Finds the previous required frame for decoding the given frame based
+ // on the parsed meta data. Returns notFound if this frame doesn't
+ // require any previous frame. Subclasses should call this function and
+ // cache the result by calling ImageFrame::setRequiredPreviousFrame()
+ // when a new frame is created.
+ size_t findRequiredPreviousFrame(size_t frameIndex);
+
void prepareScaleDataIfNecessary();
int upperBoundScaledX(int origX, int searchStart = 0);
int lowerBoundScaledX(int origX, int searchStart = 0);
int upperBoundScaledY(int origY, int searchStart = 0);
int lowerBoundScaledY(int origY, int searchStart = 0);
int scaledY(int origY, int searchStart = 0);
+ virtual void clearFrameBuffer(size_t frameIndex);
RefPtr<SharedBuffer> m_data; // The encoded data.
Vector<ImageFrame, 1> m_frameBufferCache;

Powered by Google App Engine
This is Rietveld 408576698