diff options
author | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-04 20:33:40 +0000 |
---|---|---|
committer | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-04 20:33:40 +0000 |
commit | 57c0e87ac3474f48bbd4f6b6311054ad85899f4c (patch) | |
tree | da4c2d562d132d0190d175de8b2688766ea602a9 /cc/animation | |
parent | 6669c8926e57adefcc1458e53dab1780b6831efa (diff) | |
download | chromium_src-57c0e87ac3474f48bbd4f6b6311054ad85899f4c.zip chromium_src-57c0e87ac3474f48bbd4f6b6311054ad85899f4c.tar.gz chromium_src-57c0e87ac3474f48bbd4f6b6311054ad85899f4c.tar.bz2 |
Take time_offset into account when ticking animations that are Starting
LayerAnimationController::TickAnimations ignores the time_offset for
animations that are Starting and for animations waiting for a synchronized
start time. This CL makes Animation::TrimTimeToCurrentIteration handle
computing the trimmed time for such animations, removing the need for
TickAnimations to have special cases for computing trimmed time.
BUG=284590
Review URL: https://chromiumcodereview.appspot.com/23926003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation')
-rw-r--r-- | cc/animation/animation.cc | 6 | ||||
-rw-r--r-- | cc/animation/animation_unittest.cc | 35 | ||||
-rw-r--r-- | cc/animation/layer_animation_controller.cc | 10 |
3 files changed, 41 insertions, 10 deletions
diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc index 214b8bfc..b509cfd 100644 --- a/cc/animation/animation.cc +++ b/cc/animation/animation.cc @@ -167,6 +167,12 @@ double Animation::TrimTimeToCurrentIteration(double monotonic_time) const { // subtract all time spent paused. trimmed -= start_time_ + total_paused_time_; + // If we're just starting or we're waiting on receiving a start time, + // time is 'stuck' at the initial state. + if ((run_state_ == Starting && !has_set_start_time()) || + needs_synchronized_start_time()) + trimmed = time_offset_; + // Zero is always the start of the animation. if (trimmed <= 0) return 0; diff --git a/cc/animation/animation_unittest.cc b/cc/animation/animation_unittest.cc index 337d3ee..23d4169 100644 --- a/cc/animation/animation_unittest.cc +++ b/cc/animation/animation_unittest.cc @@ -110,6 +110,41 @@ TEST(AnimationTest, TrimTimeZeroDuration) { EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(1.0)); } +TEST(AnimationTest, TrimTimeStarting) { + scoped_ptr<Animation> anim(CreateAnimation(1, 5.0)); + anim->SetRunState(Animation::Starting, 0.0); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0)); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(0.0)); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0)); + anim->set_time_offset(2.0); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(-1.0)); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(0.0)); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); + anim->set_start_time(1.0); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0)); + EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0)); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); + EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(2.0)); +} + +TEST(AnimationTest, TrimTimeNeedsSynchronizedStartTime) { + scoped_ptr<Animation> anim(CreateAnimation(1, 5.0)); + anim->SetRunState(Animation::Running, 0.0); + anim->set_needs_synchronized_start_time(true); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0)); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(0.0)); + EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0)); + anim->set_time_offset(2.0); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(-1.0)); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(0.0)); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); + anim->set_start_time(1.0); + anim->set_needs_synchronized_start_time(false); + EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0)); + EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); + EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(2.0)); +} + TEST(AnimationTest, IsFinishedAtZeroIterations) { scoped_ptr<Animation> anim(CreateAnimation(0)); anim->SetRunState(Animation::Running, 0.0); diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc index 08e2db7..04920ac 100644 --- a/cc/animation/layer_animation_controller.cc +++ b/cc/animation/layer_animation_controller.cc @@ -671,16 +671,6 @@ void LayerAnimationController::TickAnimations(double monotonic_time) { double trimmed = active_animations_[i]->TrimTimeToCurrentIteration(monotonic_time); - // Animation assumes its initial value until it gets the synchronized - // start time from the impl thread and can start ticking. - if (active_animations_[i]->needs_synchronized_start_time()) - trimmed = 0; - - // A just-started animation assumes its initial value. - if (active_animations_[i]->run_state() == Animation::Starting && - !active_animations_[i]->has_set_start_time()) - trimmed = 0; - switch (active_animations_[i]->target_property()) { case Animation::Transform: { const TransformAnimationCurve* transform_animation_curve = |