| 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 dacc93828c0ce9879cd776667be3e5fb0c33aed2..d4d3e70fd165f9bd5c231aff3011ce1173095de0 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h
|
| @@ -44,26 +44,69 @@ 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;
|
| + // Failures are handled differently, based on the image and state of the
|
| + // decoder:
|
| + //
|
| + // 1) When a non-animated PNG or the first frame of an animated PNG can't be
|
| + // decoded or parsed, set the decoder to the failed state, because there
|
| + // are no frames we can show to the client. Also set the state to failed if
|
| + // a parse error occurs before any frames were received.
|
| + // 2) When a decoding failure occurs for non-first frames, we still want to
|
| + // show earlier frames. This means the frame count needs to be adjusted.
|
| + // 3) When a parsing failure occurs, the frame count is adjusted to the number
|
| + // of successfully parsed frames, since we can still show those.
|
| + //
|
| + // In cases 2 and 3, we have to prevent parse() from adjusting the frame
|
| + // count to pre-failure values by setting |m_failedWithCorrectFrames| to true.
|
| + bool setFailed() 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;
|
| +
|
| + // Create an interlacing buffer when the frame is encoded with interlacing.
|
| + void onInitFrameBuffer(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);
|
| + // When the disposal method of the frame is DisposeOverwritePrevious, the
|
| + // next frame will use the previous frame's buffer as its starting state, so
|
| + // we can't take over the data in that case. Before calling this method, the
|
| + // caller must verify that the frame exists.
|
| + bool canReusePreviousFrameBuffer(size_t index) const override;
|
| +
|
| + void parse(PNGParseQuery);
|
|
|
| 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;
|
| + bool m_hasAlphaChannel;
|
| + bool m_currentBufferSawAlpha;
|
| +
|
| + // This flag is set to true while PNGImageReader is parsing. This is used by
|
| + // setFailed() to determine how to handle a failure.
|
| + bool m_isParsing;
|
| };
|
|
|
| } // namespace blink
|
|
|