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

Unified Diff: cc/animation/animation.cc

Issue 579863004: CC: Add fill mode to compositor animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 6 years, 3 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 dc26a3e2a859b373f0ba11b2e7a78c83c5d4ec7e..d4364826674f519b75bc01d8be2bccb449b03c27 100644
--- a/cc/animation/animation.cc
+++ b/cc/animation/animation.cc
@@ -67,6 +67,7 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve,
iteration_start_(0),
direction_(Normal),
playback_rate_(1),
+ fill_mode_(FillModeNone),
needs_synchronized_start_time_(false),
received_finished_event_(false),
suspended_(false),
@@ -159,13 +160,13 @@ bool Animation::IsFinishedAt(base::TimeTicks monotonic_time) const {
.InSecondsF();
}
-double Animation::TrimTimeToCurrentIteration(
- base::TimeTicks monotonic_time) const {
- base::TimeTicks trimmed = monotonic_time + time_offset_;
+bool Animation::InEffect(base::TimeTicks monotonic_time) const {
+ return ConvertToActiveTime(monotonic_time) >= 0 ||
+ (fill_mode_ == FillModeBoth || fill_mode_ == FillModeBackwards);
+}
- // Check for valid parameters
- DCHECK(playback_rate_);
- DCHECK_GE(iteration_start_, 0);
+double Animation::ConvertToActiveTime(base::TimeTicks monotonic_time) const {
+ base::TimeTicks trimmed = monotonic_time + time_offset_;
// If we're paused, time is 'stuck' at the pause time.
if (run_state_ == Paused)
@@ -181,7 +182,16 @@ double Animation::TrimTimeToCurrentIteration(
needs_synchronized_start_time())
trimmed = base::TimeTicks() + time_offset_;
- double active_time = (trimmed - base::TimeTicks()).InSecondsF();
+ return (trimmed - base::TimeTicks()).InSecondsF();
+}
+
+double Animation::TrimTimeToCurrentIteration(
+ base::TimeTicks monotonic_time) const {
+ // Check for valid parameters
+ DCHECK(playback_rate_);
+ DCHECK_GE(iteration_start_, 0);
+
+ double active_time = ConvertToActiveTime(monotonic_time);
// Return 0 if we are before the start of the animation
if (active_time < 0)
@@ -254,6 +264,7 @@ scoped_ptr<Animation> Animation::CloneAndInitialize(
to_return->time_offset_ = time_offset_;
to_return->direction_ = direction_;
to_return->playback_rate_ = playback_rate_;
+ to_return->fill_mode_ = fill_mode_;
DCHECK(!to_return->is_controlling_instance_);
to_return->is_controlling_instance_ = true;
return to_return.Pass();
« 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