Chromium Code Reviews| Index: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h |
| diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h |
| index b8b87a52a3eed2acce651642937d42664e2d7cf9..a35ae005ad3b200d0d00cc577b3101971ebe7ae6 100644 |
| --- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h |
| +++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h |
| @@ -242,10 +242,15 @@ class PLATFORM_EXPORT ImageDecoder { |
| bool failed() const { return m_failed; } |
| - // Clears decoded pixel data from all frames except the provided frame. |
| + // Clears decoded pixel data from all frames except the provided frame. If |
| + // subsequent frames depend on this frame's required previous frame, then that |
| + // frame is also kept in cache to prevent re-decoding from the beginning. |
| // Callers may pass WTF::kNotFound to clear all frames. |
| // Note: If |m_frameBufferCache| contains only one frame, it won't be cleared. |
| // Returns the number of bytes of frame data actually cleared. |
| + // |
| + // This is a virtual method because MockImageDecoder needs to override it in |
| + // order to run the test ImageFrameGenerator::clearMultiFrameDecode. |
|
scroggo_chromium
2016/12/01 14:44:07
Instead of making this virtual, how about making M
joostouwerling
2016/12/01 15:05:06
Sgtm but I propose to do that in a different CL. I
scroggo_chromium
2016/12/01 15:08:00
Okay by me, but can you add a TODO? The danger in
joostouwerling
2016/12/01 15:25:21
Done.
|
| virtual size_t clearCacheExceptFrame(size_t); |
| // If the image has a cursor hot-spot, stores it in the argument |
| @@ -351,6 +356,26 @@ class PLATFORM_EXPORT ImageDecoder { |
| // future decodes to purge old frames as it goes. |
| void updateAggressivePurging(size_t index); |
| + // The method is only relevant for multi-frame images. |
| + // |
| + // This method indicates whether the provided frame has enough data to decode |
| + // successive frames that depend on it. It is used by clearCacheExceptFrame |
| + // to determine which frame to keep in cache when the indicated frame is not |
| + // yet sufficiently decoded. |
| + // |
| + // The default condition is that the frame status needs to be FramePartial or |
| + // FrameComplete, since the data of previous frames is copied in |
| + // initFrameBuffer() before setting the status to FramePartial. For WebP, |
| + // however, the status needs to be FrameComplete since the complete buffer is |
| + // used to do alpha blending in WEBPImageDecoder::applyPostProcessing(). |
| + // |
| + // Before calling this, verify that frame |index| exists by checking that |
| + // |index| is smaller than |m_frameBufferCache|.size(). |
| + virtual bool frameStatusSufficientForSuccessors(size_t index) { |
| + DCHECK(index < m_frameBufferCache.size()); |
| + return m_frameBufferCache[index].getStatus() != ImageFrame::FrameEmpty; |
| + } |
| + |
| private: |
| enum class SniffResult { JPEG, PNG, GIF, WEBP, ICO, BMP, Invalid }; |