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

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

Issue 2565323003: Move gif image decoder to SkCodec (Closed)
Patch Set: Support SkCodec::NewFromStream finding an error in the input Created 3 years, 5 months 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 dec862c04dd80bc31c93bb790634b522496d3a4c..17582d5002559b4681f461094bd5e2e7b0788fab 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h
@@ -28,72 +28,52 @@
#include <memory>
#include "platform/image-decoders/ImageDecoder.h"
+#include "platform/image-decoders/SegmentStream.h"
#include "platform/wtf/Noncopyable.h"
+#include "platform/wtf/RefPtr.h"
+#include "third_party/skia/include/codec/SkCodec.h"
namespace blink {
-class GIFImageReader;
-
-using GIFRow = Vector<unsigned char>;
-
// This class decodes the GIF image format.
-class PLATFORM_EXPORT GIFImageDecoder final : public ImageDecoder {
+class PLATFORM_EXPORT GIFImageDecoder final : public blink::ImageDecoder {
WTF_MAKE_NONCOPYABLE(GIFImageDecoder);
public:
GIFImageDecoder(AlphaOption, const ColorBehavior&, size_t max_decoded_bytes);
~GIFImageDecoder() override;
- enum GIFParseQuery { kGIFSizeQuery, kGIFFrameCountQuery };
-
// ImageDecoder:
String FilenameExtension() const override { return "gif"; }
void OnSetData(SegmentReader* data) override;
int RepetitionCount() const override;
bool FrameIsCompleteAtIndex(size_t) const override;
float FrameDurationAtIndex(size_t) const override;
- // CAUTION: SetFailed() deletes |reader_|. Be careful to avoid
- // accessing deleted memory, especially when calling this from inside
- // GIFImageReader!
+ // CAUTION: SetFailed() deletes |codec_|. Be careful to avoid
+ // accessing deleted memory.
bool SetFailed() override;
- // Callbacks from the GIF reader.
- bool HaveDecodedRow(size_t frame_index,
- GIFRow::const_iterator row_begin,
- size_t width,
- size_t row_number,
- unsigned repeat_count,
- bool write_transparent_pixels);
- bool FrameComplete(size_t frame_index);
-
- // For testing.
- bool ParseCompleted() const;
+ size_t ClearCacheExceptFrame(size_t) override;
private:
// ImageDecoder:
- void ClearFrameBuffer(size_t frame_index) override;
- virtual void DecodeSize() { Parse(kGIFSizeQuery); }
+ void DecodeSize() override {}
size_t DecodeFrameCount() override;
- 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);
-
- // Reset the alpha tracker for this frame. Before calling this method, the
- // caller must verify that the frame exists.
- void OnInitFrameBuffer(size_t) override;
-
+ void InitializeNewFrame(size_t index) override;
+ void Decode(size_t index) override;
// When the disposal method of the frame is DisposeOverWritePrevious, the
- // next frame will use the previous frame's buffer as its starting state, so
+ // next frame will use a 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) const override;
- bool current_buffer_saw_alpha_;
- mutable int repetition_count_;
- std::unique_ptr<GIFImageReader> reader_;
+ size_t GetPreviousReferenceFrame(size_t index) const;
scroggo_chromium 2017/07/17 20:07:56 Add a comment, describing what this does? The par
vmpstr 2017/07/17 21:28:41 I think a comment is definitely the way to go here
cblume 2017/07/18 10:23:49 Done. The comment (and new name) I think better d
+
+ std::unique_ptr<SkCodec> codec_;
+ // segment_stream_ is a raw pointer because it passes ownership to
vmpstr 2017/07/17 21:28:41 Maybe just: |codec_| owns the SegmentStream, but w
cblume 2017/07/18 10:23:49 Done.
scroggo_chromium 2017/07/18 17:52:42 I think Chris originally used the word "reference"
cblume 2017/07/19 23:27:04 Done. I changed vmpstr@'s suggested comment to say
+ // codec_ when codec_ is created. However, we still need the
+ // pointer so we can append more data as it arrives.
+ SegmentStream* segment_stream_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698