Index: ui/compositor/layer_animator.cc |
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc |
index ce2b0ff364d9d7b5150ba90fa8879c5f8f46cc04..7fa9007b44526ae1dc2fcf496d4c75ceddc9db07 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/gfx/animation/animation_container.h" |
+#include "ui/compositor/layer_animator_collection.h" |
#include "ui/gfx/frame_time.h" |
#define SAFE_INVOKE_VOID(function, running_anim, ...) \ |
@@ -31,22 +31,9 @@ |
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 |
@@ -181,8 +168,9 @@ void LayerAnimator::StartTogether( |
adding_animations_ = true; |
if (!is_animating()) { |
- if (GetAnimationContainer()->is_running()) |
- last_step_time_ = GetAnimationContainer()->last_tick_time(); |
+ LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); |
+ if (collection && collection->HasActiveAnimators()) |
+ last_step_time_ = collection->last_tick_time(); |
else |
last_step_time_ = gfx::FrameTime::Now(); |
} |
@@ -395,14 +383,6 @@ 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()) { |
@@ -431,12 +411,16 @@ void LayerAnimator::UpdateAnimationState() { |
return; |
const bool should_start = is_animating(); |
- if (should_start && !is_started_) |
- GetAnimationContainer()->Start(this); |
- else if (!should_start && is_started_) |
- GetAnimationContainer()->Stop(this); |
- |
- is_started_ = should_start; |
+ 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; |
+ } |
} |
LayerAnimationSequence* LayerAnimator::RemoveAnimation( |
@@ -753,14 +737,15 @@ 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 AnimationContainer. Use the |
+ // All LayerAnimators share the same LayerAnimatorCollection. 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 (GetAnimationContainer()->is_running()) |
- start_time = GetAnimationContainer()->last_tick_time(); |
+ else if (collection && collection->HasActiveAnimators()) |
+ start_time = collection->last_tick_time(); |
else |
start_time = gfx::FrameTime::Now(); |
@@ -839,6 +824,10 @@ void LayerAnimator::PurgeDeletedAnimations() { |
} |
} |
+LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() { |
+ return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL; |
+} |
+ |
LayerAnimator::RunningAnimation::RunningAnimation( |
const base::WeakPtr<LayerAnimationSequence>& sequence) |
: sequence_(sequence) { |