Index: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h |
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h |
index 3ce2da9d3bbc71324c81ccc2e0559ece8a61b519..fbdc93a6414b4966edee0488e4c6e7c9d52878b8 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h |
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h |
@@ -31,6 +31,7 @@ |
#include "wtf/OwnPtr.h" |
class GIFImageReader; |
+struct GIFFrameContext; |
typedef Vector<unsigned char> GIFRow; |
@@ -40,7 +41,7 @@ namespace blink { |
class PLATFORM_EXPORT GIFImageDecoder final : public ImageDecoder { |
WTF_MAKE_NONCOPYABLE(GIFImageDecoder); |
public: |
- GIFImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBytes); |
+ GIFImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBytes, ImageFrame::ColorType decodeTo = ImageFrame::Index8); |
~GIFImageDecoder() override; |
enum GIFParseQuery { GIFSizeQuery, GIFFrameCountQuery }; |
@@ -58,12 +59,31 @@ public: |
bool setFailed() override; |
// Callbacks from the GIF reader. |
- bool haveDecodedRow(size_t frameIndex, GIFRow::const_iterator rowBegin, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels); |
+ bool (GIFImageDecoder::*phaveDecodedRow)(size_t frameIndex, GIFRow::const_iterator rowBegin, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels); |
+ inline bool haveDecodedRow(size_t frameIndex, GIFRow::const_iterator rowBegin, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels) |
+ { |
+ return (this->*phaveDecodedRow)(frameIndex, rowBegin, width, rowNumber, repeatCount, writeTransparentPixels); |
+ } |
bool frameComplete(size_t frameIndex); |
+ // Called to initialize the frame buffer with the given index, based on |
+ // the previous frame's disposal method. Returns true on success. On |
+ // failure, this will mark the image as failed. |
+ bool initFrameBuffer(size_t frameIndex); |
+ |
+ // Callback implementations for different output. |
+ bool haveDecodedRowN32(size_t frameIndex, GIFRow::const_iterator rowBegin, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels); |
+ bool haveDecodedRowIndex8(size_t frameIndex, GIFRow::const_iterator rowBegin, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels); |
+ |
+ // Callback when reader detects state requiring RGBA decoding. |
+ void setForceN32Decoding(bool); |
+ |
// For testing. |
bool parseCompleted() const; |
+ // For supporting both N32 and Index8 output. |
+ bool canDecodeTo(size_t index, ImageFrame::ColorType outputType) override; |
+ |
private: |
// ImageDecoder: |
void clearFrameBuffer(size_t frameIndex) override; |
@@ -72,18 +92,26 @@ private: |
void initializeNewFrame(size_t) override; |
void decode(size_t) override; |
+ |
// Parses as much as is needed to answer the query, ignoring bitmap |
// data. If parsing fails, sets the "decode failure" flag. |
void parse(GIFParseQuery); |
- // Called to initialize the frame buffer with the given index, based on |
- // the previous frame's disposal method. Returns true on success. On |
- // failure, this will mark the image as failed. |
- bool initFrameBuffer(size_t frameIndex); |
+ bool initFrameBufferN32(size_t frameIndex); |
+ |
+ void updateRequiredPreviousFrame(ImageFrame*, const GIFFrameContext&); |
bool m_currentBufferSawAlpha; |
mutable int m_repetitionCount; |
OwnPtr<GIFImageReader> m_reader; |
+ |
+ // Holds information about which decoding output was requested in constructor. |
+ // N32 color mode is used for testing only. |
+ ImageFrame::ColorType m_colorMode; |
+ |
+ // Used in Index8 decoding mode, some of the frames need to get decoded to N32. |
+ // This flag is reset when situation allows going back to Index8 decoding in initFrameBuffer. |
+ bool m_forceN32Decoding; |
}; |
} // namespace blink |