1/*
2 * Copyright 2020 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 SkottieVectorKeyframeAnimator_DEFINED
9#define SkottieVectorKeyframeAnimator_DEFINED
10
11#include "modules/skottie/src/animator/KeyframeAnimator.h"
12
13#include <vector>
14
15namespace skottie::internal {
16
17class VectorKeyframeAnimatorBuilder final : public KeyframeAnimatorBuilder {
18public:
19 using VectorLenParser = bool(*)(const skjson::Value&, size_t*);
20 using VectorDataParser = bool(*)(const skjson::Value&, size_t, float*);
21
22 VectorKeyframeAnimatorBuilder(VectorLenParser, VectorDataParser);
23
24 sk_sp<KeyframeAnimator> make(const AnimationBuilder&,
25 const skjson::ArrayValue&,
26 void*) override;
27
28private:
29 bool parseValue(const AnimationBuilder&,
30 const skjson::Value&,
31 void*) const override;
32
33 bool parseKFValue(const AnimationBuilder&,
34 const skjson::ObjectValue&,
35 const skjson::Value&,
36 Keyframe::Value*) override;
37
38 const VectorLenParser fParseLen;
39 const VectorDataParser fParseData;
40
41 std::vector<float> fStorage;
42 size_t fVecLen, // size of individual vector values we store
43 fCurrentVec = 0; // vector value index being parsed (corresponding
44 // storage offset is fCurrentVec * fVecLen)
45};
46
47} // namespace skottie::internal
48
49#endif // SkottieVectorKeyframeAnimator_DEFINED
50