From a87508008dfa1604baf2d4e39bf44704c00f261c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 3 Apr 2022 16:34:10 -0700 Subject: skia WIP --- src/deps/skia/include/utils/SkAnimCodecPlayer.h | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/deps/skia/include/utils/SkAnimCodecPlayer.h (limited to 'src/deps/skia/include/utils/SkAnimCodecPlayer.h') diff --git a/src/deps/skia/include/utils/SkAnimCodecPlayer.h b/src/deps/skia/include/utils/SkAnimCodecPlayer.h new file mode 100644 index 000000000..c8c98a483 --- /dev/null +++ b/src/deps/skia/include/utils/SkAnimCodecPlayer.h @@ -0,0 +1,60 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkAnimCodecPlayer_DEFINED +#define SkAnimCodecPlayer_DEFINED + +#include "include/codec/SkCodec.h" + +class SkImage; + +class SkAnimCodecPlayer { +public: + SkAnimCodecPlayer(std::unique_ptr codec); + ~SkAnimCodecPlayer(); + + /** + * Returns the current frame of the animation. This defaults to the first frame for + * animated codecs (i.e. msec = 0). Calling this multiple times (without calling seek()) + * will always return the same image object (or null if there was an error). + */ + sk_sp getFrame(); + + /** + * Return the size of the image(s) that will be returned by getFrame(). + */ + SkISize dimensions() const; + + /** + * Returns the total duration of the animation in milliseconds. Returns 0 for a single-frame + * image. + */ + uint32_t duration() const { return fTotalDuration; } + + /** + * Finds the closest frame associated with the time code (in milliseconds) and sets that + * to be the current frame (call getFrame() to retrieve that image). + * Returns true iff this call to seek() changed the "current frame" for the animation. + * Thus if seek() returns false, then getFrame() will return the same image as it did + * before this call to seek(). + */ + bool seek(uint32_t msec); + + +private: + std::unique_ptr fCodec; + SkImageInfo fImageInfo; + std::vector fFrameInfos; + std::vector > fImages; + int fCurrIndex = 0; + uint32_t fTotalDuration; + + sk_sp getFrameAt(int index); +}; + +#endif + -- cgit v1.2.3