diff options
Diffstat (limited to 'src/codec/SkWebpCodec.h')
-rw-r--r-- | src/codec/SkWebpCodec.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/codec/SkWebpCodec.h b/src/codec/SkWebpCodec.h index 93b60f646e..f4c7910ee6 100644 --- a/src/codec/SkWebpCodec.h +++ b/src/codec/SkWebpCodec.h @@ -11,9 +11,12 @@ #include "SkCodec.h" #include "SkColorSpace.h" #include "SkEncodedImageFormat.h" +#include "SkFrameHolder.h" #include "SkImageInfo.h" #include "SkTypes.h" +#include <vector> + class SkStream; extern "C" { struct WebPDemuxer; @@ -37,6 +40,11 @@ protected: bool onDimensionsSupported(const SkISize&) override; bool onGetValidSubset(SkIRect* /* desiredSubset */) const override; + + int onGetFrameCount() override; + bool onGetFrameInfo(int, FrameInfo*) const override; + int onGetRepetitionCount() override; + private: SkWebpCodec(int width, int height, const SkEncodedInfo&, sk_sp<SkColorSpace>, SkStream*, WebPDemuxer*, sk_sp<SkData>); @@ -47,6 +55,57 @@ private: // This should not be freed until the decode is completed. sk_sp<SkData> fData; + class Frame : public SkFrame { + public: + Frame(int i, bool alpha) + : INHERITED(i) + , fReportsAlpha(alpha) + {} + Frame(Frame&& other) + : INHERITED(other.frameId()) + , fReportsAlpha(other.fReportsAlpha) + {} + + protected: + bool onReportsAlpha() const override { + return fReportsAlpha; + } + + private: + const bool fReportsAlpha; + + typedef SkFrame INHERITED; + }; + + class FrameHolder : public SkFrameHolder { + public: + ~FrameHolder() override {} + void setScreenSize(int w, int h) { + fScreenWidth = w; + fScreenHeight = h; + } + Frame* appendNewFrame(bool hasAlpha); + const Frame* frame(int i) const; + int size() const { + return static_cast<int>(fFrames.size()); + } + void reserve(int size) { + fFrames.reserve(size); + } + + protected: + const SkFrame* onGetFrame(int i) const override; + + private: + std::vector<Frame> fFrames; + }; + + FrameHolder fFrameHolder; + // Set to true if WebPDemuxGetFrame fails. This only means + // that we will cap the frame count to the frames that + // succeed. + bool fFailed; + typedef SkCodec INHERITED; }; #endif // SkWebpCodec_DEFINED |