Chromium Code Reviews| 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 724e27c918dc3e3c7a5dcd00f2ef98bfa3cd2aeb..d57464e311533caafaf0d8cfd05eb1bf2f688287 100644 | 
| --- a/Source/core/platform/image-decoders/ImageDecoder.h | 
| +++ b/Source/core/platform/image-decoders/ImageDecoder.h | 
| @@ -115,6 +115,11 @@ namespace WebCore { | 
| FrameDisposalMethod disposalMethod() const { return m_disposalMethod; } | 
| bool premultiplyAlpha() const { return m_premultiplyAlpha; } | 
| void reportMemoryUsage(MemoryObjectInfo*) const; | 
| + size_t requiredPreviousFrameIndex() const | 
| + { | 
| + ASSERT(m_requiredPreviousFrameIndexValid); | 
| + return m_requiredPreviousFrameIndex; | 
| + } | 
| void setHasAlpha(bool alpha); | 
| void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } | 
| @@ -122,6 +127,13 @@ 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; | 
| +#ifndef NDEBUG | 
| + m_requiredPreviousFrameIndexValid = true; | 
| +#endif | 
| + } | 
| inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a) | 
| { | 
| @@ -200,6 +212,13 @@ 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. | 
| 
 
Peter Kasting
2013/05/29 02:02:18
Nit: Add this at end:
This is used by ImageDecode
 
Xianzhu
2013/05/29 18:37:01
Done.
 
 | 
| + size_t m_requiredPreviousFrameIndex; | 
| +#ifndef NDEBUG | 
| + bool m_requiredPreviousFrameIndexValid; | 
| +#endif | 
| }; | 
| // ImageDecoder is a base for all format-specific decoders | 
| @@ -358,10 +377,12 @@ 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. | 
| + // Returns number of bytes of the cleared frames. | 
| 
 
Peter Kasting
2013/05/29 02:02:18
Nit: How about this comment:
Clears decoded pixel
 
Xianzhu
2013/05/29 18:37:01
Done.
 
 | 
| + size_t clearCacheExceptFrame(size_t); | 
| // If the image has a cursor hot-spot, stores it in the argument | 
| // and returns true. Otherwise returns false. | 
| @@ -378,6 +399,18 @@ 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, | 
| + // and must ensure all previous frame's required previous frame has been | 
| + // cached before calling this method. | 
| 
 
Peter Kasting
2013/05/29 02:02:18
Nit: How about this comment:
Calculates the most
 
Xianzhu
2013/05/29 18:37:01
Done.
 
 | 
| + size_t findRequiredPreviousFrame(size_t frameIndex); | 
| + | 
| + virtual void clearFrameBuffer(size_t frameIndex); | 
| + | 
| RefPtr<SharedBuffer> m_data; // The encoded data. | 
| Vector<ImageFrame, 1> m_frameBufferCache; | 
| bool m_premultiplyAlpha; |