55#include " impeller/scene/animation/animation_clip.h"
66
77#include < algorithm>
8- #include < chrono>
98#include < cmath>
109#include < memory>
1110#include < valarray>
@@ -44,7 +43,7 @@ void AnimationClip::Pause() {
4443
4544void AnimationClip::Stop () {
4645 SetPlaying (false );
47- Seek (std::chrono::duration<Scalar> ::zero ());
46+ Seek (SecondsF ::zero ());
4847}
4948
5049bool AnimationClip::GetLoop () const {
@@ -71,17 +70,16 @@ void AnimationClip::SetWeight(Scalar weight) {
7170 weight_ = weight;
7271}
7372
74- std::chrono::duration<Scalar> AnimationClip::GetPlaybackTime () const {
73+ SecondsF AnimationClip::GetPlaybackTime () const {
7574 return playback_time_;
7675}
7776
78- void AnimationClip::Seek (std::chrono::duration<Scalar> time) {
79- playback_time_ = std::clamp (time, std::chrono::duration<Scalar>::zero (),
80- animation_->GetEndTime ());
77+ void AnimationClip::Seek (SecondsF time) {
78+ playback_time_ = std::clamp (time, SecondsF::zero (), animation_->GetEndTime ());
8179}
8280
83- void AnimationClip::Advance (std::chrono::duration<Scalar> delta_time) {
84- if (!playing_ || delta_time <= std::chrono::duration<Scalar> ::zero ()) {
81+ void AnimationClip::Advance (SecondsF delta_time) {
82+ if (!playing_ || delta_time <= SecondsF ::zero ()) {
8583 return ;
8684 }
8785 delta_time *= playback_time_scale_;
@@ -90,27 +88,25 @@ void AnimationClip::Advance(std::chrono::duration<Scalar> delta_time) {
9088 // / Handle looping behavior.
9189
9290 auto end_time = animation_->GetEndTime ();
93- if (end_time == std::chrono::duration<Scalar> ::zero ()) {
94- playback_time_ = std::chrono::duration<Scalar> ::zero ();
91+ if (end_time == SecondsF ::zero ()) {
92+ playback_time_ = SecondsF ::zero ();
9593 return ;
9694 }
97- if (!loop_ && (playback_time_ < std::chrono::duration<Scalar>:: zero () ||
98- playback_time_ > end_time)) {
95+ if (!loop_ &&
96+ (playback_time_ < SecondsF::zero () || playback_time_ > end_time)) {
9997 // If looping is disabled, clamp to the end (or beginning, if playing in
10098 // reverse) and pause.
10199 Pause ();
102- playback_time_ = std::clamp (
103- playback_time_, std::chrono::duration<Scalar>::zero (), end_time);
100+ playback_time_ = std::clamp (playback_time_, SecondsF::zero (), end_time);
104101 } else if (/* loop && */ playback_time_ > end_time) {
105102 // If looping is enabled and we ran off the end, loop to the beginning.
106- playback_time_ = std::chrono::duration<Scalar>(
107- std::fmod (std::abs (playback_time_.count ()), end_time.count ()));
108- } else if (/* loop && */ playback_time_ <
109- std::chrono::duration<Scalar>::zero ()) {
103+ playback_time_ =
104+ SecondsF (std::fmod (std::abs (playback_time_.count ()), end_time.count ()));
105+ } else if (/* loop && */ playback_time_ < SecondsF::zero ()) {
110106 // If looping is enabled and we ran off the beginning, loop to the end.
111107 playback_time_ =
112- end_time - std::chrono::duration<Scalar>( std::fmod (
113- std::abs (playback_time_.count ()), end_time.count ()));
108+ end_time -
109+ SecondsF ( std::fmod ( std::abs (playback_time_.count ()), end_time.count ()));
114110 }
115111}
116112
0 commit comments