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

Unified Diff: cc/animation/scroll_offset_animation_curve.cc

Issue 719453007: Make Keyframe use TimeTicks/TimeDelta to represent time instead of double. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/animation/scroll_offset_animation_curve.cc
diff --git a/cc/animation/scroll_offset_animation_curve.cc b/cc/animation/scroll_offset_animation_curve.cc
index e0b1a3b5e5c2f2da58642865d1c0854662efdd75..956726301c403904e46201079a8687ad7af78a46 100644
--- a/cc/animation/scroll_offset_animation_curve.cc
+++ b/cc/animation/scroll_offset_animation_curve.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "cc/animation/timing_function.h"
+#include "cc/base/time_util.h"
#include "ui/gfx/animation/tween.h"
const double kDurationDivisor = 60.0;
@@ -65,17 +66,18 @@ void ScrollOffsetAnimationCurve::SetInitialValue(
target_value_.DeltaFrom(initial_value_));
}
-gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue(double t) const {
- double duration = (total_animation_duration_ - last_retarget_).InSecondsF();
- t -= last_retarget_.InSecondsF();
+gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue(
+ base::TimeDelta t) const {
+ base::TimeDelta duration = total_animation_duration_ - last_retarget_;
+ t -= last_retarget_;
- if (t <= 0)
+ if (t <= base::TimeDelta())
return initial_value_;
if (t >= duration)
return target_value_;
- double progress = (timing_function_->GetValue(t / duration));
+ double progress = timing_function_->GetValue(TimeUtil::Divide(t, duration));
return gfx::ScrollOffset(
gfx::Tween::FloatValueBetween(
progress, initial_value_.x(), target_value_.x()),
@@ -105,7 +107,8 @@ scoped_ptr<AnimationCurve> ScrollOffsetAnimationCurve::Clone() const {
void ScrollOffsetAnimationCurve::UpdateTarget(
double t,
const gfx::ScrollOffset& new_target) {
- gfx::ScrollOffset current_position = GetValue(t);
+ gfx::ScrollOffset current_position =
+ GetValue(base::TimeDelta::FromSecondsD(t));
gfx::Vector2dF old_delta = target_value_.DeltaFrom(initial_value_);
gfx::Vector2dF new_delta = new_target.DeltaFrom(current_position);
« no previous file with comments | « cc/animation/scroll_offset_animation_curve.h ('k') | cc/animation/scroll_offset_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698