Index: cc/animation/animation.cc |
diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc |
index 263c34743dcf8d19ee4a9b958beb88e6323abb08..fb5efb083419193613eb4228540bd55ab9d3f30b 100644 |
--- a/cc/animation/animation.cc |
+++ b/cc/animation/animation.cc |
@@ -64,9 +64,9 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve, |
target_property_(target_property), |
run_state_(WaitingForTargetAvailability), |
iterations_(1), |
- start_time_(0), |
+ start_time_(base::TimeTicks()), |
alternates_direction_(false), |
- time_offset_(0), |
+ time_offset_(base::TimeTicks()), |
needs_synchronized_start_time_(false), |
received_finished_event_(false), |
suspended_(false), |
@@ -77,10 +77,10 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve, |
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 time) { |
if (suspended_) |
return; |
@@ -94,7 +94,6 @@ void Animation::SetRunState(RunState run_state, double monotonic_time) { |
bool is_waiting_to_start = run_state_ == WaitingForTargetAvailability || |
run_state_ == Starting; |
- |
if (is_waiting_to_start && run_state == Running) { |
TRACE_EVENT_ASYNC_BEGIN1( |
"cc", "Animation", this, "Name", TRACE_STR_COPY(name_buffer)); |
@@ -103,6 +102,7 @@ void Animation::SetRunState(RunState run_state, double monotonic_time) { |
bool was_finished = is_finished(); |
const char* old_run_state_name = s_runStateNames[run_state_]; |
+ double monotonic_time = (time - base::TimeTicks()).InSecondsF(); |
ajuma
2014/04/08 15:44:16
Instead of converting to double here, how about us
|
if (run_state == Running && run_state_ == Paused) |
total_paused_time_ += monotonic_time - pause_time_; |
@@ -131,33 +131,32 @@ 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 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_); |
+ double monotonic_time = (time - base::TimeTicks()).InSecondsF(); |
ajuma
2014/04/08 15:44:16
Can we avoid the conversion here by making sure th
|
+ return run_state_ == Running && iterations_ >= 0 && |
+ iterations_ * curve_->Duration() <= |
+ (monotonic_time - start_time() - total_paused_time_ + |
+ time_offset()); |
} |
-double Animation::TrimTimeToCurrentIteration(double monotonic_time) const { |
- double trimmed = monotonic_time + time_offset_; |
+double Animation::TrimTimeToCurrentIteration(base::TimeTicks time) const { |
+ double monotonic_time = (time - base::TimeTicks()).InSecondsF(); |
+ double trimmed = monotonic_time + time_offset(); |
// If we're paused, time is 'stuck' at the pause time. |
if (run_state_ == Paused) |
@@ -165,13 +164,13 @@ double Animation::TrimTimeToCurrentIteration(double monotonic_time) const { |
// Returned time should always be relative to the start time and should |
// subtract all time spent paused. |
- trimmed -= start_time_ + total_paused_time_; |
+ trimmed -= start_time() + 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(); |
// Zero is always the start of the animation. |
if (trimmed <= 0) |
@@ -214,8 +213,9 @@ scoped_ptr<Animation> Animation::Clone() const { |
return CloneAndInitialize(run_state_, start_time_); |
} |
-scoped_ptr<Animation> Animation::CloneAndInitialize(RunState initial_run_state, |
- double start_time) const { |
+scoped_ptr<Animation> Animation::CloneAndInitialize( |
+ RunState initial_run_state, |
+ base::TimeTicks start_time) const { |
scoped_ptr<Animation> to_return( |
new Animation(curve_->Clone(), id_, group_, target_property_)); |
to_return->run_state_ = initial_run_state; |