Chromium Code Reviews| Index: cc/animation/animation.cc |
| diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc |
| index 81659cbc269ba83469cc3c475f9d11b2572be772..e8a2815d1bf8407870d8673e203d14e806d61ac9 100644 |
| --- a/cc/animation/animation.cc |
| +++ b/cc/animation/animation.cc |
| @@ -64,23 +64,25 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve, |
| target_property_(target_property), |
| run_state_(WaitingForTargetAvailability), |
| iterations_(1), |
| - start_time_(0), |
| + start_time_(base::TimeTicks()), |
|
ajuma
2014/04/24 20:41:36
This line can be removed (the default constructor
Sikugu_
2014/05/05 07:09:19
Done.
|
| alternates_direction_(false), |
| - time_offset_(0), |
| + time_offset_(base::TimeDelta()), |
|
ajuma
2014/04/24 20:41:36
Can be removed.
Sikugu_
2014/05/05 07:09:19
Done.
|
| needs_synchronized_start_time_(false), |
| received_finished_event_(false), |
| suspended_(false), |
| - pause_time_(0), |
| - total_paused_time_(0), |
| + pause_time_(base::TimeTicks()), |
|
ajuma
2014/04/24 20:41:36
Remove.
Sikugu_
2014/05/05 07:09:19
Done.
|
| + total_paused_time_(base::TimeTicks()), |
|
ajuma
2014/04/24 20:41:36
Remove.
Sikugu_
2014/05/05 07:09:19
Done.
|
| is_controlling_instance_(false), |
| - is_impl_only_(false) {} |
| + is_impl_only_(false) { |
| +} |
| Animation::~Animation() { |
| if (run_state_ == Running || run_state_ == Paused) |
| - SetRunState(Aborted, 0); |
| + SetRunState(Aborted, base::TimeTicks()); |
| } |
| -void Animation::SetRunState(RunState run_state, double monotonic_time) { |
| +void Animation::SetRunState(RunState run_state, |
| + base::TimeTicks monotonic_time) { |
| if (suspended_) |
| return; |
| @@ -131,47 +133,47 @@ void Animation::SetRunState(RunState run_state, double monotonic_time) { |
| TRACE_STR_COPY(state_buffer)); |
| } |
| -void Animation::Suspend(double monotonic_time) { |
| +void Animation::Suspend(base::TimeTicks monotonic_time) { |
| SetRunState(Paused, monotonic_time); |
| suspended_ = true; |
| } |
| -void Animation::Resume(double monotonic_time) { |
| +void Animation::Resume(base::TimeTicks monotonic_time) { |
| suspended_ = false; |
| SetRunState(Running, monotonic_time); |
| } |
| -bool Animation::IsFinishedAt(double monotonic_time) const { |
| +bool Animation::IsFinishedAt(base::TimeTicks monotonic_time) const { |
| if (is_finished()) |
| return true; |
| if (needs_synchronized_start_time_) |
| return false; |
| - return run_state_ == Running && |
| - iterations_ >= 0 && |
| - iterations_ * curve_->Duration() <= (monotonic_time - |
| - start_time() - |
| - total_paused_time_ + |
| - time_offset_); |
| + return run_state_ == Running && iterations_ >= 0 && |
| + iterations_ * curve_->Duration() <= |
| + base::TimeTicks::InSecondsF((monotonic_time + time_offset_) - |
|
ajuma
2014/04/24 20:41:36
Duration should be compared to an amount of time,
Sikugu_
2014/05/05 07:09:19
When we start adding the Timedelta to Timeticks we
Sikugu_
2014/05/05 07:09:19
When we start adding the Timedelta to Timeticks we
ajuma
2014/05/05 15:13:32
Adding TimeDelta to TimeTicks should not lose prec
Sikugu_
2014/05/07 14:49:07
Its a misinterpretation by me, it works fine with
|
| + (start_time_ - total_paused_time_)); |
| } |
| -double Animation::TrimTimeToCurrentIteration(double monotonic_time) const { |
| - double trimmed = monotonic_time + time_offset_; |
| +double Animation::TrimTimeToCurrentIteration( |
| + base::TimeTicks monotonic_time) const { |
| + double trimmed = base::TimeTicks::InSecondsF(monotonic_time + time_offset_); |
|
ajuma
2014/04/24 20:41:36
Instead of converting to seconds here, wait until
Sikugu_
2014/05/05 07:09:19
Same here.
ajuma
2014/05/05 15:13:32
And same response :) Please give a specific examp
Sikugu_
2014/05/07 14:49:07
Its a misinterpretation by me, it works fine with
|
| // If we're paused, time is 'stuck' at the pause time. |
| if (run_state_ == Paused) |
| - trimmed = pause_time_; |
| + trimmed = base::TimeTicks::InSecondsF(pause_time_); |
| // Returned time should always be relative to the start time and should |
| // subtract all time spent paused. |
| - trimmed -= start_time_ + total_paused_time_; |
| + trimmed -= base::TimeTicks::InSecondsF(start_time_) + |
| + base::TimeTicks::InSecondsF(total_paused_time_); |
| // If we're just starting or we're waiting on receiving a start time, |
| // time is 'stuck' at the initial state. |
| if ((run_state_ == Starting && !has_set_start_time()) || |
| needs_synchronized_start_time()) |
| - trimmed = time_offset_; |
| + trimmed = time_offset_.InSecondsF(); |
| // Zero is always the start of the animation. |
| if (trimmed <= 0) |