Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
skottie::internal::VectorAnimatorBuilder Class Referencefinal

#include <VectorKeyframeAnimator.h>

Inheritance diagram for skottie::internal::VectorAnimatorBuilder:
skottie::internal::AnimatorBuilder SkNoncopyable

Public Types

using VectorLenParser = bool(*)(const skjson::Value &, size_t *)
 
using VectorDataParser = bool(*)(const skjson::Value &, size_t, float *)
 

Public Member Functions

 VectorAnimatorBuilder (std::vector< float > *, VectorLenParser, VectorDataParser)
 
sk_sp< KeyframeAnimatormakeFromKeyframes (const AnimationBuilder &, const skjson::ArrayValue &) override
 
sk_sp< AnimatormakeFromExpression (ExpressionManager &, const char *) override
 
- Public Member Functions inherited from skottie::internal::AnimatorBuilder
virtual ~AnimatorBuilder ()
 
virtual sk_sp< KeyframeAnimatormakeFromKeyframes (const AnimationBuilder &, const skjson::ArrayValue &)=0
 
virtual sk_sp< AnimatormakeFromExpression (ExpressionManager &, const char *)=0
 
virtual bool parseValue (const AnimationBuilder &, const skjson::Value &) const =0
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Additional Inherited Members

- Protected Member Functions inherited from skottie::internal::AnimatorBuilder
 AnimatorBuilder (Keyframe::Value::Type ty)
 
virtual bool parseKFValue (const AnimationBuilder &, const skjson::ObjectValue &, const skjson::Value &, Keyframe::Value *)=0
 
bool parseKeyframes (const AnimationBuilder &, const skjson::ArrayValue &)
 
- Protected Attributes inherited from skottie::internal::AnimatorBuilder
std::vector< KeyframefKFs
 
std::vector< SkCubicMapfCMs
 

Detailed Description

Definition at line 31 of file VectorKeyframeAnimator.h.

Member Typedef Documentation

◆ VectorDataParser

Definition at line 34 of file VectorKeyframeAnimator.h.

◆ VectorLenParser

Definition at line 33 of file VectorKeyframeAnimator.h.

Constructor & Destructor Documentation

◆ VectorAnimatorBuilder()

skottie::internal::VectorAnimatorBuilder::VectorAnimatorBuilder ( std::vector< float > *  target,
VectorLenParser  parse_len,
VectorDataParser  parse_data 
)

Definition at line 189 of file VectorKeyframeAnimator.cpp.

193 , fParseLen(parse_len)
194 , fParseData(parse_data)
195 , fTarget(target) {}
uint32_t * target

Member Function Documentation

◆ makeFromExpression()

sk_sp< Animator > skottie::internal::VectorAnimatorBuilder::makeFromExpression ( ExpressionManager em,
const char *  expr 
)
overridevirtual

Implements skottie::internal::AnimatorBuilder.

Definition at line 234 of file VectorKeyframeAnimator.cpp.

234 {
236 em.createArrayExpressionEvaluator(expr);
237 return sk_make_sp<VectorExpressionAnimator>(expression_evaluator, fTarget);
238}

◆ makeFromKeyframes()

sk_sp< KeyframeAnimator > skottie::internal::VectorAnimatorBuilder::makeFromKeyframes ( const AnimationBuilder abuilder,
const skjson::ArrayValue jkfs 
)
overridevirtual

Implements skottie::internal::AnimatorBuilder.

Definition at line 197 of file VectorKeyframeAnimator.cpp.

198 {
199 SkASSERT(jkfs.size() > 0);
200
201 // peek at the first keyframe value to find our vector length
202 const skjson::ObjectValue* jkf0 = jkfs[0];
203 if (!jkf0 || !fParseLen((*jkf0)["s"], &fVecLen)) {
204 return nullptr;
205 }
206
207 SkSafeMath safe;
208 // total elements: vector length x number vectors
209 const auto total_size = safe.mul(fVecLen, jkfs.size());
210
211 // we must be able to store all offsets in Keyframe::Value::idx (uint32_t)
212 if (!safe || !SkTFitsIn<uint32_t>(total_size)) {
213 return nullptr;
214 }
215 fStorage.resize(total_size);
216
217 if (!this->parseKeyframes(abuilder, jkfs)) {
218 return nullptr;
219 }
220
221 // parseKFValue() might have stored fewer vectors thanks to tail-deduping.
222 SkASSERT(fCurrentVec <= jkfs.size());
223 fStorage.resize(fCurrentVec * fVecLen);
224 fStorage.shrink_to_fit();
225
227 new VectorKeyframeAnimator(std::move(fKFs),
228 std::move(fCMs),
229 std::move(fStorage),
230 fVecLen,
231 fTarget));
232}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static size_t total_size(SkSBlockAllocator< N > &pool)
size_t mul(size_t x, size_t y)
Definition: SkSafeMath.h:29
size_t size() const
Definition: SkJSON.h:262
std::vector< SkCubicMap > fCMs
bool parseKeyframes(const AnimationBuilder &, const skjson::ArrayValue &)

The documentation for this class was generated from the following files: