| Index: ui/compositor/layer_animator.cc
|
| diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
|
| index 39585a7c946e5a7656d46f02739826e1754e8a69..ce2b0ff364d9d7b5150ba90fa8879c5f8f46cc04 100644
|
| --- a/ui/compositor/layer_animator.cc
|
| +++ b/ui/compositor/layer_animator.cc
|
| @@ -14,7 +14,7 @@
|
| #include "ui/compositor/layer_animation_delegate.h"
|
| #include "ui/compositor/layer_animation_observer.h"
|
| #include "ui/compositor/layer_animation_sequence.h"
|
| -#include "ui/compositor/layer_animator_collection.h"
|
| +#include "ui/gfx/animation/animation_container.h"
|
| #include "ui/gfx/frame_time.h"
|
|
|
| #define SAFE_INVOKE_VOID(function, running_anim, ...) \
|
| @@ -31,9 +31,22 @@
|
|
|
| namespace ui {
|
|
|
| +class LayerAnimator;
|
| +
|
| namespace {
|
|
|
| const int kDefaultTransitionDurationMs = 120;
|
| +const int kTimerIntervalMs = 10;
|
| +
|
| +// Returns the AnimationContainer we're added to.
|
| +gfx::AnimationContainer* GetAnimationContainer() {
|
| + static gfx::AnimationContainer* container = NULL;
|
| + if (!container) {
|
| + container = new gfx::AnimationContainer();
|
| + container->AddRef();
|
| + }
|
| + return container;
|
| +}
|
|
|
| } // namespace
|
|
|
| @@ -111,17 +124,7 @@ base::TimeDelta LayerAnimator::GetTransitionDuration() const {
|
| }
|
|
|
| void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
|
| - if (delegate_ && is_started_) {
|
| - LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
|
| - if (collection)
|
| - collection->StopAnimator(this);
|
| - }
|
| delegate_ = delegate;
|
| - if (delegate_ && is_started_) {
|
| - LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
|
| - if (collection)
|
| - collection->StartAnimator(this);
|
| - }
|
| }
|
|
|
| void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) {
|
| @@ -178,9 +181,8 @@ void LayerAnimator::StartTogether(
|
|
|
| adding_animations_ = true;
|
| if (!is_animating()) {
|
| - LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
|
| - if (collection && collection->HasActiveAnimators())
|
| - last_step_time_ = collection->last_tick_time();
|
| + if (GetAnimationContainer()->is_running())
|
| + last_step_time_ = GetAnimationContainer()->last_tick_time();
|
| else
|
| last_step_time_ = gfx::FrameTime::Now();
|
| }
|
| @@ -341,20 +343,6 @@ void LayerAnimator::OnThreadedAnimationStarted(
|
| }
|
| }
|
|
|
| -void LayerAnimator::AddToCollection(LayerAnimatorCollection* collection) {
|
| - if (is_animating() && !is_started_) {
|
| - collection->StartAnimator(this);
|
| - is_started_ = true;
|
| - }
|
| -}
|
| -
|
| -void LayerAnimator::RemoveFromCollection(LayerAnimatorCollection* collection) {
|
| - if (is_animating() && is_started_) {
|
| - collection->StopAnimator(this);
|
| - is_started_ = false;
|
| - }
|
| -}
|
| -
|
| // LayerAnimator protected -----------------------------------------------------
|
|
|
| void LayerAnimator::ProgressAnimation(LayerAnimationSequence* sequence,
|
| @@ -407,6 +395,14 @@ void LayerAnimator::Step(base::TimeTicks now) {
|
| }
|
| }
|
|
|
| +void LayerAnimator::SetStartTime(base::TimeTicks start_time) {
|
| + // Do nothing.
|
| +}
|
| +
|
| +base::TimeDelta LayerAnimator::GetTimerInterval() const {
|
| + return base::TimeDelta::FromMilliseconds(kTimerIntervalMs);
|
| +}
|
| +
|
| void LayerAnimator::StopAnimatingInternal(bool abort) {
|
| scoped_refptr<LayerAnimator> retain(this);
|
| while (is_animating()) {
|
| @@ -435,16 +431,12 @@ void LayerAnimator::UpdateAnimationState() {
|
| return;
|
|
|
| const bool should_start = is_animating();
|
| - LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
|
| - if (collection) {
|
| - if (should_start && !is_started_)
|
| - collection->StartAnimator(this);
|
| - else if (!should_start && is_started_)
|
| - collection->StopAnimator(this);
|
| - is_started_ = should_start;
|
| - } else {
|
| - is_started_ = false;
|
| - }
|
| + if (should_start && !is_started_)
|
| + GetAnimationContainer()->Start(this);
|
| + else if (!should_start && is_started_)
|
| + GetAnimationContainer()->Stop(this);
|
| +
|
| + is_started_ = should_start;
|
| }
|
|
|
| LayerAnimationSequence* LayerAnimator::RemoveAnimation(
|
| @@ -761,15 +753,14 @@ 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).
|
| - // All LayerAnimators share the same LayerAnimatorCollection. Use the
|
| + // 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;
|
| - LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
|
| if (is_animating() || adding_animations_)
|
| start_time = last_step_time_;
|
| - else if (collection && collection->HasActiveAnimators())
|
| - start_time = collection->last_tick_time();
|
| + else if (GetAnimationContainer()->is_running())
|
| + start_time = GetAnimationContainer()->last_tick_time();
|
| else
|
| start_time = gfx::FrameTime::Now();
|
|
|
| @@ -848,10 +839,6 @@ void LayerAnimator::PurgeDeletedAnimations() {
|
| }
|
| }
|
|
|
| -LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() {
|
| - return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL;
|
| -}
|
| -
|
| LayerAnimator::RunningAnimation::RunningAnimation(
|
| const base::WeakPtr<LayerAnimationSequence>& sequence)
|
| : sequence_(sequence) {
|
|
|