Index: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h |
diff --git a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h |
index 7ce6aa0faf83c7c6d2ece1ce6cc94ea5d07f7427..8ebdca5537dcb8992141b6e063e1a7314d91e144 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h |
+++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h |
@@ -43,26 +43,52 @@ class PLATFORM_EXPORT PNGImageDecoder final : public ImageDecoder { |
size_t offset = 0); |
~PNGImageDecoder() override; |
+ enum class PNGParseQuery { PNGSizeQuery, PNGMetaDataQuery }; |
+ |
// ImageDecoder: |
String filenameExtension() const override { return "png"; } |
+ int repetitionCount() const override; |
+ bool frameIsCompleteAtIndex(size_t) const override; |
+ float frameDurationAtIndex(size_t) const override; |
+ size_t clearCacheExceptFrame(size_t) override; |
// Callbacks from libpng |
void headerAvailable(); |
void rowAvailable(unsigned char* row, unsigned rowIndex, int); |
void complete(); |
+ // Additional methods used for APNG |
+ void setRepetitionCount(size_t); |
+ |
private: |
// ImageDecoder: |
- void decodeSize() override { decode(true); } |
- void decode(size_t) override { decode(false); } |
+ void decodeSize() override { parse(PNGParseQuery::PNGSizeQuery); } |
+ void decode(size_t) override; |
+ size_t decodeFrameCount() override; |
+ void initializeNewFrame(size_t) override; |
+ void clearFrameBuffer(size_t) override; |
- // Decodes the image. If |onlySize| is true, stops decoding after |
- // calculating the image size. If decoding fails but there is no more |
- // data coming, sets the "decode failure" flag. |
- void decode(bool onlySize); |
+ bool initFrameBuffer(size_t); |
+ void parse(PNGParseQuery); |
+ // Used by clearCacheExceptFrame if two frames need to be kept in cache. |
+ size_t clearCacheExceptTwoFrames(size_t, size_t); |
+ // Non-first frames that depend on previous frames should not be decoded row |
scroggo_chromium
2016/11/09 13:42:50
I don't think "Non-first" is necessary here. The f
joostouwerling
2016/11/11 20:22:19
Acknowledged.
|
+ // by row, to prevent partially overwriting the content of the previous frame. |
+ // The frame at |index| must exist before calling this method. |
+ bool frameShouldBeDecodedIncrementally(size_t index) { |
+ ASSERT(index < m_frameBufferCache.size()); |
+ return (index == 0 || |
+ m_frameBufferCache[index].requiredPreviousFrameIndex() == kNotFound); |
+ } |
std::unique_ptr<PNGImageReader> m_reader; |
const unsigned m_offset; |
+ size_t m_frameCount; |
+ size_t m_currentFrame; |
+ // m_repetitionCount is set to cAnimationLoopOnce by default, so the |
+ // DeferredImageDecoder takes into account that this may be an animated |
+ // image, but we don't know for sure yet. |
+ int m_repetitionCount; |
}; |
} // namespace blink |