Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkTimeKeeper Class Reference

Public Member Functions

void setStopAtEnd (bool s)
 
float currentTime ()
 
void setDuration (float d)
 
bool paused () const
 
float duration () const
 
void seek (float seconds)
 
void togglePaused ()
 

Detailed Description

Definition at line 69 of file SkottieViewController.mm.

Member Function Documentation

◆ currentTime()

float SkTimeKeeper::currentTime ( )
inline

Definition at line 80 of file SkottieViewController.mm.

80 {
81 if (0 == fDuration) {
82 return 0;
83 }
84 if (fPaused) {
85 return fAnimationMoment;
86 }
87 double time = 1e-9 * (SkTime::GetNSecs() - fStartTime);
88 if (fStopAtEnd && time >= fDuration) {
89 fPaused = true;
90 fAnimationMoment = fDuration;
91 return fAnimationMoment;
92 }
93 return std::fmod(time, fDuration);
94 }
double GetNSecs()
Definition: SkTime.cpp:17
static double time(int loops, Benchmark *bench, Target *target)
Definition: nanobench.cpp:394

◆ duration()

float SkTimeKeeper::duration ( ) const
inline

Definition at line 104 of file SkottieViewController.mm.

104{ return fDuration; }

◆ paused()

bool SkTimeKeeper::paused ( ) const
inline

Definition at line 102 of file SkottieViewController.mm.

102{ return fPaused; }

◆ seek()

void SkTimeKeeper::seek ( float  seconds)
inline

Definition at line 106 of file SkottieViewController.mm.

106 {
107 if (fPaused) {
108 fAnimationMoment = std::fmod(seconds, fDuration);
109 } else {
110 fStartTime = SkTime::GetNSecs() - 1e9 * seconds;
111 }
112 }

◆ setDuration()

void SkTimeKeeper::setDuration ( float  d)
inline

Definition at line 96 of file SkottieViewController.mm.

96 {
97 fDuration = d;
98 fStartTime = SkTime::GetNSecs();
99 fAnimationMoment = 0;
100 }
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

◆ setStopAtEnd()

void SkTimeKeeper::setStopAtEnd ( bool  s)
inline

Definition at line 78 of file SkottieViewController.mm.

78{ fStopAtEnd = s; }
struct MyStruct s

◆ togglePaused()

void SkTimeKeeper::togglePaused ( )
inline

Definition at line 114 of file SkottieViewController.mm.

114 {
115 if (fPaused) {
116 double offset = (fAnimationMoment >= fDuration) ? 0 : -1e9 * fAnimationMoment;
117 fStartTime = SkTime::GetNSecs() + offset;
118 fPaused = false;
119 } else {
120 fAnimationMoment = this->currentTime();
121 fPaused = true;
122 }
123 }
SeparatedVector2 offset

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