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

Unified Diff: cc/animation/animation.cc

Issue 423373003: CC: Support fractional iteration count on compositor animations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and review changes Created 6 years, 4 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
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation.cc
diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc
index 4adb88a12e5ea3a500e7a1774f1445eaf1e47d99..138664161c049a7f8234261693952e38dd2b277e 100644
--- a/cc/animation/animation.cc
+++ b/cc/animation/animation.cc
@@ -194,10 +194,12 @@ double Animation::TrimTimeToCurrentIteration(
// We need to know the current iteration if we're alternating.
int iteration = 0;
- // If we are past the active interval, return iteration duration.
+ // If we are past the active interval, return iteration duration of last
+ // iteration
if (is_past_total_duration) {
iteration = iterations_ - 1;
- trimmed_in_seconds = curve_->Duration();
+ double frac = fmod(curve_->Duration() * iterations_, curve_->Duration());
+ trimmed_in_seconds = frac == 0 ? curve_->Duration() : frac;
} else {
iteration = static_cast<int>(trimmed_in_seconds / curve_->Duration());
// Calculate x where trimmed = x + n * curve_->Duration() for some positive
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698