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

Unified Diff: cc/animation/scroll_offset_animation_curve.cc

Issue 231133002: CC::Animations should use TimeTicks & TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for build errors in ui/compositor unittests. Created 6 years, 7 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/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 ecba43f5cc9678c6060e5878c2c532af20ca3d25..a7283b8b5c601aca4a6f3dfac4e269b167c17966 100644
--- a/cc/animation/scroll_offset_animation_curve.cc
+++ b/cc/animation/scroll_offset_animation_curve.cc
@@ -25,9 +25,8 @@ scoped_ptr<ScrollOffsetAnimationCurve> ScrollOffsetAnimationCurve::Create(
ScrollOffsetAnimationCurve::ScrollOffsetAnimationCurve(
const gfx::Vector2dF& target_value,
scoped_ptr<TimingFunction> timing_function)
- : target_value_(target_value),
- duration_(0.0),
- timing_function_(timing_function.Pass()) {}
+ : target_value_(target_value), timing_function_(timing_function.Pass()) {
+}
ScrollOffsetAnimationCurve::~ScrollOffsetAnimationCurve() {}
@@ -43,17 +42,21 @@ void ScrollOffsetAnimationCurve::SetInitialValue(
float delta_x = std::abs(target_value_.x() - initial_value_.x());
float delta_y = std::abs(target_value_.y() - initial_value_.y());
float max_delta = std::max(delta_x, delta_y);
- duration_ = std::sqrt(max_delta)/kDurationDivisor;
+ duration_ = base::TimeDelta::FromMicroseconds(
+ (std::sqrt(max_delta) / kDurationDivisor) *
+ base::Time::kMicrosecondsPerSecond);
}
gfx::Vector2dF ScrollOffsetAnimationCurve::GetValue(double t) const {
+ double duration = duration_.InSecondsF();
+
if (t <= 0)
return initial_value_;
- if (t >= duration_)
+ if (t >= duration)
return target_value_;
- double progress = timing_function_->GetValue(t / duration_);
+ double progress = (timing_function_->GetValue(t / duration));
return gfx::Vector2dF(gfx::Tween::FloatValueBetween(
progress, initial_value_.x(), target_value_.x()),
gfx::Tween::FloatValueBetween(
@@ -61,7 +64,7 @@ gfx::Vector2dF ScrollOffsetAnimationCurve::GetValue(double t) const {
}
double ScrollOffsetAnimationCurve::Duration() const {
- return duration_;
+ return duration_.InSecondsF();
}
AnimationCurve::CurveType ScrollOffsetAnimationCurve::Type() const {

Powered by Google App Engine
This is Rietveld 408576698