Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1250)

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h

Issue 1460523002: GIF decoding to Index8, unit tests and misusing unit test as benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup. tableChanged was wrong - do proper check. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e37f7a37561d1e61d608720f64a57ef9040747c5..6905a9eb32a050b1adc4f51c9bb1ce1775d770bb 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h
@@ -58,12 +58,26 @@ 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);
+ // 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;
@@ -71,6 +85,8 @@ private:
size_t decodeFrameCount() override;
void initializeNewFrame(size_t) override;
void decode(size_t) override;
+ void decodeTo(size_t index, ImageFrame::ColorType outputColor) override;
+
// Parses as much as is needed to answer the query, ignoring bitmap
// data. If parsing fails, sets the "decode failure" flag.
@@ -80,10 +96,18 @@ private:
// 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 initFrameBufferIndex8(size_t frameIndex);
bool m_currentBufferSawAlpha;
mutable int m_repetitionCount;
OwnPtr<GIFImageReader> m_reader;
+
+ // Holds information about which decoding output was in client request.
+ ImageFrame::ColorType m_colorMode;
+
+ // 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

Powered by Google App Engine
This is Rietveld 408576698