Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Protected Member Functions | List of all members
skottie::internal::KeyframeAnimator Class Reference

#include <KeyframeAnimator.h>

Inheritance diagram for skottie::internal::KeyframeAnimator:
skottie::internal::Animator SkRefCnt SkRefCntBase

Classes

struct  LERPInfo
 

Public Member Functions

 ~KeyframeAnimator () override
 
bool isConstant () const
 
- Public Member Functions inherited from skottie::internal::Animator
StateChanged seek (float t)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

 KeyframeAnimator (std::vector< Keyframe > kfs, std::vector< SkCubicMap > cms)
 
LERPInfo getLERPInfo (float t) const
 
- Protected Member Functions inherited from skottie::internal::Animator
 Animator ()=default
 
virtual StateChanged onSeek (float t)=0
 

Additional Inherited Members

- Public Types inherited from skottie::internal::Animator
using StateChanged = bool
 

Detailed Description

Definition at line 69 of file KeyframeAnimator.h.

Constructor & Destructor Documentation

◆ ~KeyframeAnimator()

skottie::internal::KeyframeAnimator::~KeyframeAnimator ( )
overridedefault

◆ KeyframeAnimator()

skottie::internal::KeyframeAnimator::KeyframeAnimator ( std::vector< Keyframe kfs,
std::vector< SkCubicMap cms 
)
inlineprotected

Definition at line 81 of file KeyframeAnimator.h.

82 : fKFs(std::move(kfs))
83 , fCMs(std::move(cms)) {}

Member Function Documentation

◆ getLERPInfo()

KeyframeAnimator::LERPInfo skottie::internal::KeyframeAnimator::getLERPInfo ( float  t) const
protected

Definition at line 22 of file KeyframeAnimator.cpp.

22 {
23 SkASSERT(!fKFs.empty());
24
25 if (t <= fKFs.front().t) {
26 // Constant/clamped segment.
27 return { 0, fKFs.front().v, fKFs.front().v };
28 }
29 if (t >= fKFs.back().t) {
30 // Constant/clamped segment.
31 return { 0, fKFs.back().v, fKFs.back().v };
32 }
33
34 // Cache the current segment (most queries have good locality).
35 if (!fCurrentSegment.contains(t)) {
36 fCurrentSegment = this->find_segment(t);
37 }
38 SkASSERT(fCurrentSegment.contains(t));
39
40 if (fCurrentSegment.kf0->mapping == Keyframe::kConstantMapping) {
41 // Constant/hold segment.
42 return { 0, fCurrentSegment.kf0->v, fCurrentSegment.kf0->v };
43 }
44
45 return {
46 this->compute_weight(fCurrentSegment, t),
47 fCurrentSegment.kf0->v,
48 fCurrentSegment.kf1->v,
49 };
50}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static constexpr uint32_t kConstantMapping

◆ isConstant()

bool skottie::internal::KeyframeAnimator::isConstant ( ) const
inline

Definition at line 73 of file KeyframeAnimator.h.

73 {
74 SkASSERT(!fKFs.empty());
75
76 // parseKeyFrames() ensures we only keep a single frame for constant properties.
77 return fKFs.size() == 1;
78 }

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