Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkAnimCodecPlayer.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkAnimCodecPlayer_DEFINED
9#define SkAnimCodecPlayer_DEFINED
10
14#include "include/core/SkSize.h"
15
16#include <cstdint>
17#include <memory>
18#include <vector>
19
20class SkImage;
21
23public:
24 SkAnimCodecPlayer(std::unique_ptr<SkCodec> codec);
26
27 /**
28 * Returns the current frame of the animation. This defaults to the first frame for
29 * animated codecs (i.e. msec = 0). Calling this multiple times (without calling seek())
30 * will always return the same image object (or null if there was an error).
31 */
33
34 /**
35 * Return the size of the image(s) that will be returned by getFrame().
36 */
37 SkISize dimensions() const;
38
39 /**
40 * Returns the total duration of the animation in milliseconds. Returns 0 for a single-frame
41 * image.
42 */
43 uint32_t duration() const { return fTotalDuration; }
44
45 /**
46 * Finds the closest frame associated with the time code (in milliseconds) and sets that
47 * to be the current frame (call getFrame() to retrieve that image).
48 * Returns true iff this call to seek() changed the "current frame" for the animation.
49 * Thus if seek() returns false, then getFrame() will return the same image as it did
50 * before this call to seek().
51 */
52 bool seek(uint32_t msec);
53
54
55private:
56 std::unique_ptr<SkCodec> fCodec;
57 SkImageInfo fImageInfo;
58 std::vector<SkCodec::FrameInfo> fFrameInfos;
59 std::vector<sk_sp<SkImage> > fImages;
60 int fCurrIndex = 0;
61 uint32_t fTotalDuration;
62
63 sk_sp<SkImage> getFrameAt(int index);
64};
65
66#endif
67
sk_sp< SkImage > getFrame()
uint32_t duration() const
SkISize dimensions() const
bool seek(uint32_t msec)