Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8058)

Unified Diff: cc/input/page_scale_animation.cc

Issue 226543005: CC should use TimeTicks and TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests related changes Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/input/page_scale_animation.cc
diff --git a/cc/input/page_scale_animation.cc b/cc/input/page_scale_animation.cc
index 7df0244ec0907a1466bc2ab9625c147fe075d754..a216cfd2c60f4568938b58fdd3cd19e2a6cbbb3a 100644
--- a/cc/input/page_scale_animation.cc
+++ b/cc/input/page_scale_animation.cc
@@ -166,33 +166,34 @@ bool PageScaleAnimation::IsAnimationStarted() const {
return start_time_ >= 0;
}
-void PageScaleAnimation::StartAnimation(double time) {
+void PageScaleAnimation::StartAnimation(base::TimeTicks time) {
DCHECK_GT(0, start_time_);
- start_time_ = time;
+ start_time_ = (time - base::TimeTicks()).InSecondsF();
}
-gfx::Vector2dF PageScaleAnimation::ScrollOffsetAtTime(double time) const {
+gfx::Vector2dF PageScaleAnimation::ScrollOffsetAtTime(
+ base::TimeTicks time) const {
DCHECK_GE(start_time_, 0);
return ScrollOffsetAt(InterpAtTime(time));
}
-float PageScaleAnimation::PageScaleFactorAtTime(double time) const {
+float PageScaleAnimation::PageScaleFactorAtTime(base::TimeTicks time) const {
DCHECK_GE(start_time_, 0);
return PageScaleFactorAt(InterpAtTime(time));
}
-bool PageScaleAnimation::IsAnimationCompleteAtTime(double time) const {
+bool PageScaleAnimation::IsAnimationCompleteAtTime(base::TimeTicks time) const {
DCHECK_GE(start_time_, 0);
- return time >= end_time();
+ return (time - base::TimeTicks()).InSecondsF() >= end_time();
}
-float PageScaleAnimation::InterpAtTime(double time) const {
+float PageScaleAnimation::InterpAtTime(base::TimeTicks time) const {
DCHECK_GE(start_time_, 0);
- DCHECK_GE(time, start_time_);
+ DCHECK_GE((time - base::TimeTicks()).InSecondsF(), start_time_);
if (IsAnimationCompleteAtTime(time))
return 1.f;
-
- const double normalized_time = (time - start_time_) / duration_;
+ double monotonic_time = (time - base::TimeTicks()).InSecondsF();
+ const double normalized_time = (monotonic_time - start_time_) / duration_;
return timing_function_->GetValue(normalized_time);
}

Powered by Google App Engine
This is Rietveld 408576698