| Index: third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.h
|
| diff --git a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.h b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.h
|
| index 4144201a9b66088d12704bdf2d64feb9eac6c822..eea2106852f09406221ebef1fba3e8ef3c37070c 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.h
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.h
|
| @@ -52,14 +52,52 @@ class PLATFORM_EXPORT PNGImageReader final {
|
| PNGImageReader(PNGImageDecoder*, size_t offset);
|
| ~PNGImageReader();
|
|
|
| - bool decode(const SegmentReader&, bool sizeOnly);
|
| + struct FrameInfo {
|
| + size_t start;
|
| + size_t finish;
|
| + png_uint_32 width;
|
| + png_uint_32 height;
|
| + png_uint_32 xOffset;
|
| + png_uint_32 yOffset;
|
| + unsigned duration;
|
| + unsigned dispose;
|
| + unsigned blend;
|
| + };
|
| +
|
| + inline void processData(const SegmentReader& data,
|
| + size_t index,
|
| + size_t offset,
|
| + size_t endOffset) {
|
| + const char* segment;
|
| + while (size_t segmentLength = data.getSomeData(segment, offset)) {
|
| + if (endOffset && offset + segmentLength > endOffset)
|
| + segmentLength = endOffset - offset;
|
| +
|
| + offset += segmentLength;
|
| + png_process_data(m_png, m_info,
|
| + reinterpret_cast<png_bytep>(const_cast<char*>(segment)),
|
| + segmentLength);
|
| +
|
| + if (offset == endOffset)
|
| + break;
|
| + }
|
| + if (!index)
|
| + m_decodeOffset = offset;
|
| + }
|
| +
|
| + bool parse(SegmentReader&);
|
| + bool decode(SegmentReader&, size_t index);
|
| png_structp pngPtr() const { return m_png; }
|
| png_infop infoPtr() const { return m_info; }
|
|
|
| - size_t getReadOffset() const { return m_readOffset; }
|
| - void setReadOffset(size_t offset) { m_readOffset = offset; }
|
| - size_t currentBufferSize() const { return m_currentBufferSize; }
|
| - bool decodingSizeOnly() const { return m_decodingSizeOnly; }
|
| + int repetitionCount() const { return m_repetitionCount; }
|
| + size_t imagesCount() const {
|
| + return m_frames.isEmpty() ? 1 : m_frames.size() - m_posterFrame;
|
| + }
|
| + const FrameInfo* frameInfo(size_t index) const {
|
| + return m_frames.isEmpty() ? &m_currentFrame
|
| + : &m_frames[index + m_posterFrame];
|
| + }
|
| void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
|
| bool hasAlpha() const { return m_hasAlpha; }
|
|
|
| @@ -73,8 +111,18 @@ class PLATFORM_EXPORT PNGImageReader final {
|
| png_infop m_info;
|
| PNGImageDecoder* m_decoder;
|
| size_t m_readOffset;
|
| - size_t m_currentBufferSize;
|
| - bool m_decodingSizeOnly;
|
| + size_t m_parseOffset;
|
| + size_t m_decodeOffset;
|
| + size_t m_infoSize;
|
| + bool m_isAnimated;
|
| + bool m_isParsed;
|
| + png_uint_32 m_width;
|
| + png_uint_32 m_height;
|
| + int m_repetitionCount;
|
| + size_t m_posterFrame;
|
| + size_t m_visibleFrames;
|
| + FrameInfo m_currentFrame;
|
| + Vector<FrameInfo> m_frames;
|
| bool m_hasAlpha;
|
| std::unique_ptr<png_byte[]> m_interlaceBuffer;
|
| };
|
|
|