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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h

Issue 2775063002: Move WEBPImageDecoder to SkCodec
Patch Set: Pull in changes from the gif decoder Created 3 years, 4 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/webp/WEBPImageDecoder.h
diff --git a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h
index 68d6bc52df2dc657c2a495d2ddba74a4475b82fc..ef8bf47d9a41ef8e73b2d7186186140b90a476c3 100644
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h
@@ -29,19 +29,23 @@
#ifndef WEBPImageDecoder_h
#define WEBPImageDecoder_h
+#include <memory>
#include "platform/image-decoders/ImageDecoder.h"
-#include "webp/decode.h"
-#include "webp/demux.h"
-
-class SkData;
+#include "platform/wtf/Noncopyable.h"
+#include "platform/wtf/RefPtr.h"
+#include "third_party/skia/include/codec/SkCodec.h"
namespace blink {
+class SegmentStream;
+
class PLATFORM_EXPORT WEBPImageDecoder final : public ImageDecoder {
WTF_MAKE_NONCOPYABLE(WEBPImageDecoder);
public:
WEBPImageDecoder(AlphaOption, const ColorBehavior&, size_t max_decoded_bytes);
+ WEBPImageDecoder(WEBPImageDecoder&&) = default;
+ WEBPImageDecoder& operator=(WEBPImageDecoder&&) = default;
~WEBPImageDecoder() override;
// ImageDecoder:
@@ -50,21 +54,22 @@ class PLATFORM_EXPORT WEBPImageDecoder final : public ImageDecoder {
int RepetitionCount() const override;
bool FrameIsReceivedAtIndex(size_t) const override;
float FrameDurationAtIndex(size_t) const override;
+ // CAUTION: SetFailed() deletes |codec_|. Be careful to avoid
+ // accessing deleted memory.
+ bool SetFailed() override;
+
+ size_t ClearCacheExceptFrame(size_t) override;
private:
// ImageDecoder:
- virtual void DecodeSize() { UpdateDemuxer(); }
+ void DecodeSize() override {}
size_t DecodeFrameCount() override;
void InitializeNewFrame(size_t) override;
void Decode(size_t) override;
- bool DecodeSingleFrame(const uint8_t* data_bytes,
- size_t data_size,
- size_t frame_index);
-
// For WebP images, the frame status needs to be FrameComplete to decode
// subsequent frames that depend on frame |index|. The reason for this is that
- // WebP uses the previous frame for alpha blending, in ApplyPostProcessing().
+ // WebP uses the previous frame for alpha blending.
//
// Before calling this, verify that frame |index| exists by checking that
// |index| is smaller than |frame_buffer_cache_|.size().
@@ -73,42 +78,16 @@ class PLATFORM_EXPORT WEBPImageDecoder final : public ImageDecoder {
return frame_buffer_cache_[index].GetStatus() == ImageFrame::kFrameComplete;
}
- WebPIDecoder* decoder_;
- WebPDecBuffer decoder_buffer_;
- int format_flags_;
- bool frame_background_has_alpha_;
-
- void ReadColorProfile();
- bool UpdateDemuxer();
-
- // Set |frame_background_has_alpha_| based on this frame's characteristics.
- // Before calling this method, the caller must verify that the frame exists.
- void OnInitFrameBuffer(size_t frame_index) override;
-
- // When the blending method of this frame is BlendAtopPreviousFrame, the
- // previous frame's buffer is necessary to decode this frame in
- // ApplyPostProcessing, so we can't take over the data. Before calling this
- // method, the caller must verify that the frame exists.
- bool CanReusePreviousFrameBuffer(size_t frame_index) const override;
-
- void ApplyPostProcessing(size_t frame_index);
- void ClearFrameBuffer(size_t frame_index) override;
-
- WebPDemuxer* demux_;
- WebPDemuxState demux_state_;
- bool have_already_parsed_this_data_;
- int repetition_count_;
- int decoded_height_;
-
- typedef void (*AlphaBlendFunction)(ImageFrame&, ImageFrame&, int, int, int);
- AlphaBlendFunction blend_function_;
-
- void Clear();
- void ClearDecoder();
+ // When a frame depends on a previous frame's content, there is a list of
+ // candidate reference frames. This function will find a previous frame from
+ // that list which satisfies the requirements of being a reference frame.
+ size_t GetViableReferenceFrameIndex(size_t) const;
- // FIXME: Update libwebp's API so it does not require copying the data on each
- // update.
- sk_sp<SkData> consolidated_data_;
+ std::unique_ptr<SkCodec> codec_;
+ // |codec_| owns the SegmentStream, but we need access to it to append more
+ // data as it arrives.
+ SegmentStream* segment_stream_;
+ mutable int repetition_count_ = kAnimationLoopOnce;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698