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

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: 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
Index: cc/animation/animation.cc
diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc
index 47ebaa3a358f5c7581c3151485e80823b9b800e9..a317d03ff9878517ee91eafce301829c33eb2df2 100644
--- a/cc/animation/animation.cc
+++ b/cc/animation/animation.cc
@@ -66,6 +66,7 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve,
iterations_(1),
direction_(Normal),
playback_rate_(1),
+ fill_mode_(FillModeNone),
needs_synchronized_start_time_(false),
received_finished_event_(false),
suspended_(false),
@@ -158,12 +159,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::NoEffectBeforeAnimation(base::TimeTicks monotonic_time) const {
dstockwell 2014/09/18 00:14:29 This method name is a little strange, perhaps just
samli 2014/09/18 00:59:55 Done.
+ return ConvertToActiveTime(monotonic_time) < 0 &&
+ (fill_mode_ == FillModeNone || fill_mode_ == FillModeForwards);
+}
- // Zero playback rate not supported
- DCHECK(playback_rate_);
+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)
@@ -179,7 +181,15 @@ 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 {
+ // Zero playback rate not supported
+ DCHECK(playback_rate_);
+
+ double active_time = ConvertToActiveTime(monotonic_time);
// Return 0 if we are before the start of the animation
if (active_time < 0)
@@ -256,6 +266,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();

Powered by Google App Engine
This is Rietveld 408576698