summaryrefslogtreecommitdiffstats
path: root/ui/compositor
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-06 04:31:19 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-06 04:31:19 +0000
commit1778cbc87e3366f5b3f51bd69bccb9e98cca316d (patch)
tree06c68ec0649297f44625d9feb0626cb495848246 /ui/compositor
parent55de57d694ebb3037775d8ae049792123579c049 (diff)
downloadchromium_src-1778cbc87e3366f5b3f51bd69bccb9e98cca316d.zip
chromium_src-1778cbc87e3366f5b3f51bd69bccb9e98cca316d.tar.gz
chromium_src-1778cbc87e3366f5b3f51bd69bccb9e98cca316d.tar.bz2
Makes LayerAnimator use the last tick time from the
AnimationContainer. Without this animations scheduled for the same amount of time during the same event won't necessarily complete at the same time. BUG=none TEST=none R=vollick@chromium.org Review URL: https://chromiumcodereview.appspot.com/10905119 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/compositor')
-rw-r--r--ui/compositor/layer_animator.cc34
1 files changed, 23 insertions, 11 deletions
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index fbb298a..57b7f72 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -26,6 +26,16 @@ static const base::TimeDelta kDefaultTransitionDuration =
static const base::TimeDelta kTimerInterval =
base::TimeDelta::FromMilliseconds(10);
+// Returns the AnimationContainer we're added to.
+ui::AnimationContainer* GetAnimationContainer() {
+ static ui::AnimationContainer* container = NULL;
+ if (!container) {
+ container = new AnimationContainer();
+ container->AddRef();
+ }
+ return container;
+}
+
} // namespace
// static
@@ -298,6 +308,7 @@ void LayerAnimator::Step(base::TimeTicks now) {
TRACE_EVENT0("ui", "LayerAnimator::Step");
last_step_time_ = now;
+
// We need to make a copy of the running animations because progressing them
// and finishing them may indirectly affect the collection of running
// animations.
@@ -331,17 +342,11 @@ void LayerAnimator::UpdateAnimationState() {
if (disable_timer_for_test_)
return;
- static ui::AnimationContainer* container = NULL;
- if (!container) {
- container = new AnimationContainer();
- container->AddRef();
- }
-
const bool should_start = is_animating();
if (should_start && !is_started_)
- container->Start(this);
+ GetAnimationContainer()->Start(this);
else if (!should_start && is_started_)
- container->Stop(this);
+ GetAnimationContainer()->Stop(this);
is_started_ = should_start;
}
@@ -595,9 +600,16 @@ bool LayerAnimator::StartSequenceImmediately(LayerAnimationSequence* sequence) {
// a resolution that can be as bad as 15ms. If this causes glitches in the
// animations, this can be switched to HighResNow() (animation uses Now()
// internally).
- base::TimeTicks start_time = is_animating()
- ? last_step_time_
- : base::TimeTicks::Now();
+ // All LayerAnimators share the same AnimationContainer. Use the
+ // last_tick_time() from there to ensure animations started during the same
+ // event complete at the same time.
+ base::TimeTicks start_time;
+ if (is_animating())
+ start_time = last_step_time_;
+ else if (GetAnimationContainer()->is_running())
+ start_time = GetAnimationContainer()->last_tick_time();
+ else
+ start_time = base::TimeTicks::Now();
running_animations_.push_back(RunningAnimation(sequence, start_time));