This source file includes following definitions.
- GetAnimationContainer
- adding_animations_
- CreateDefaultAnimator
- CreateImplicitAnimator
- GetTransitionDuration
- SetDelegate
- StartAnimation
- ScheduleAnimation
- StartTogether
- ScheduleTogether
- SchedulePauseForProperties
- IsAnimatingProperty
- StopAnimatingProperty
- AddObserver
- RemoveObserver
- OnThreadedAnimationStarted
- ProgressAnimation
- ProgressAnimationToEnd
- HasAnimation
- Step
- SetStartTime
- GetTimerInterval
- StopAnimatingInternal
- UpdateAnimationState
- RemoveAnimation
- FinishAnimation
- FinishAnyAnimationWithZeroDuration
- ClearAnimations
- GetRunningAnimation
- AddToQueueIfNotPresent
- RemoveAllAnimationsWithACommonProperty
- ImmediatelySetNewTarget
- ImmediatelyAnimateToNewTarget
- EnqueueNewAnimation
- ReplaceQueuedAnimations
- ProcessQueue
- StartSequenceImmediately
- GetTargetValue
- OnScheduled
- SetTransitionDuration
- ClearAnimationsInternal
- PurgeDeletedAnimations
#include "ui/compositor/layer_animator.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/output/begin_frame_args.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#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/gfx/frame_time.h"
#define SAFE_INVOKE_VOID(function, running_anim, ...) \
if (running_anim.is_sequence_alive()) \
function(running_anim.sequence(), ##__VA_ARGS__)
#define SAFE_INVOKE_BOOL(function, running_anim) \
((running_anim.is_sequence_alive()) \
? function(running_anim.sequence()) \
: false)
#define SAFE_INVOKE_PTR(function, running_anim) \
((running_anim.is_sequence_alive()) \
? function(running_anim.sequence()) \
: NULL)
namespace ui {
class LayerAnimator;
namespace {
const int kDefaultTransitionDurationMs = 120;
const int kTimerIntervalMs = 10;
gfx::AnimationContainer* GetAnimationContainer() {
static gfx::AnimationContainer* container = NULL;
if (!container) {
container = new gfx::AnimationContainer();
container->AddRef();
}
return container;
}
}
LayerAnimator::LayerAnimator(base::TimeDelta transition_duration)
: delegate_(NULL),
preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET),
is_transition_duration_locked_(false),
transition_duration_(transition_duration),
tween_type_(gfx::Tween::LINEAR),
is_started_(false),
disable_timer_for_test_(false),
adding_animations_(false) {
}
LayerAnimator::~LayerAnimator() {
for (size_t i = 0; i < running_animations_.size(); ++i) {
if (running_animations_[i].is_sequence_alive())
running_animations_[i].sequence()->OnAnimatorDestroyed();
}
ClearAnimationsInternal();
delegate_ = NULL;
}
LayerAnimator* LayerAnimator::CreateDefaultAnimator() {
return new LayerAnimator(base::TimeDelta::FromMilliseconds(0));
}
LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
return new LayerAnimator(
base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs));
}
#define ANIMATED_PROPERTY(type, property, name, member_type, member) \
void LayerAnimator::Set##name(type value) { \
base::TimeDelta duration = GetTransitionDuration(); \
if (duration == base::TimeDelta() && delegate() && \
(preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \
StopAnimatingProperty(LayerAnimationElement::property); \
delegate()->Set##name##FromAnimation(value); \
return; \
} \
scoped_ptr<LayerAnimationElement> element( \
LayerAnimationElement::Create##name##Element(value, duration)); \
element->set_tween_type(tween_type_); \
StartAnimation(new LayerAnimationSequence(element.release())); \
} \
\
member_type LayerAnimator::GetTarget##name() const { \
LayerAnimationElement::TargetValue target(delegate()); \
GetTargetValue(&target); \
return target.member; \
}
ANIMATED_PROPERTY(
const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform);
ANIMATED_PROPERTY(const gfx::Rect&, BOUNDS, Bounds, gfx::Rect, bounds);
ANIMATED_PROPERTY(float, OPACITY, Opacity, float, opacity);
ANIMATED_PROPERTY(bool, VISIBILITY, Visibility, bool, visibility);
ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness);
ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale);
ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color);
base::TimeDelta LayerAnimator::GetTransitionDuration() const {
return transition_duration_;
}
void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
delegate_ = delegate;
}
void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) {
scoped_refptr<LayerAnimator> retain(this);
OnScheduled(animation);
if (!StartSequenceImmediately(animation)) {
switch (preemption_strategy_) {
case IMMEDIATELY_SET_NEW_TARGET:
ImmediatelySetNewTarget(animation);
break;
case IMMEDIATELY_ANIMATE_TO_NEW_TARGET:
ImmediatelyAnimateToNewTarget(animation);
break;
case ENQUEUE_NEW_ANIMATION:
EnqueueNewAnimation(animation);
break;
case REPLACE_QUEUED_ANIMATIONS:
ReplaceQueuedAnimations(animation);
break;
case BLEND_WITH_CURRENT_ANIMATION: {
NOTIMPLEMENTED();
break;
}
}
}
FinishAnyAnimationWithZeroDuration();
UpdateAnimationState();
}
void LayerAnimator::ScheduleAnimation(LayerAnimationSequence* animation) {
scoped_refptr<LayerAnimator> retain(this);
OnScheduled(animation);
if (is_animating()) {
animation_queue_.push_back(make_linked_ptr(animation));
ProcessQueue();
} else {
StartSequenceImmediately(animation);
}
UpdateAnimationState();
}
void LayerAnimator::StartTogether(
const std::vector<LayerAnimationSequence*>& animations) {
scoped_refptr<LayerAnimator> retain(this);
if (preemption_strategy_ == IMMEDIATELY_SET_NEW_TARGET) {
std::vector<LayerAnimationSequence*>::const_iterator iter;
for (iter = animations.begin(); iter != animations.end(); ++iter) {
StartAnimation(*iter);
}
return;
}
adding_animations_ = true;
if (!is_animating()) {
if (GetAnimationContainer()->is_running())
last_step_time_ = GetAnimationContainer()->last_tick_time();
else
last_step_time_ = gfx::FrameTime::Now();
}
LayerAnimationElement::AnimatableProperties animated_properties =
LayerAnimationElement::UNKNOWN;
std::vector<LayerAnimationSequence*>::const_iterator iter;
for (iter = animations.begin(); iter != animations.end(); ++iter)
animated_properties |= (*iter)->properties();
StartAnimation(new LayerAnimationSequence(
LayerAnimationElement::CreatePauseElement(animated_properties,
base::TimeDelta())));
bool wait_for_group_start = false;
for (iter = animations.begin(); iter != animations.end(); ++iter)
wait_for_group_start |= (*iter)->IsFirstElementThreaded();
int group_id = cc::AnimationIdProvider::NextGroupId();
for (iter = animations.begin(); iter != animations.end(); ++iter) {
(*iter)->set_animation_group_id(group_id);
(*iter)->set_waiting_for_group_start(wait_for_group_start);
ScheduleAnimation(*iter);
}
adding_animations_ = false;
UpdateAnimationState();
}
void LayerAnimator::ScheduleTogether(
const std::vector<LayerAnimationSequence*>& animations) {
scoped_refptr<LayerAnimator> retain(this);
LayerAnimationElement::AnimatableProperties animated_properties =
LayerAnimationElement::UNKNOWN;
std::vector<LayerAnimationSequence*>::const_iterator iter;
for (iter = animations.begin(); iter != animations.end(); ++iter)
animated_properties |= (*iter)->properties();
ScheduleAnimation(new LayerAnimationSequence(
LayerAnimationElement::CreatePauseElement(animated_properties,
base::TimeDelta())));
bool wait_for_group_start = false;
for (iter = animations.begin(); iter != animations.end(); ++iter)
wait_for_group_start |= (*iter)->IsFirstElementThreaded();
int group_id = cc::AnimationIdProvider::NextGroupId();
for (iter = animations.begin(); iter != animations.end(); ++iter) {
(*iter)->set_animation_group_id(group_id);
(*iter)->set_waiting_for_group_start(wait_for_group_start);
ScheduleAnimation(*iter);
}
UpdateAnimationState();
}
void LayerAnimator::SchedulePauseForProperties(
base::TimeDelta duration,
LayerAnimationElement::AnimatableProperties properties_to_pause) {
ScheduleAnimation(new ui::LayerAnimationSequence(
ui::LayerAnimationElement::CreatePauseElement(
properties_to_pause, duration)));
}
bool LayerAnimator::IsAnimatingProperty(
LayerAnimationElement::AnimatableProperty property) const {
for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
if ((*queue_iter)->properties() & property)
return true;
}
return false;
}
void LayerAnimator::StopAnimatingProperty(
LayerAnimationElement::AnimatableProperty property) {
scoped_refptr<LayerAnimator> retain(this);
while (true) {
RunningAnimation* running = GetRunningAnimation(property);
if (!running)
break;
DCHECK(running->is_sequence_alive());
FinishAnimation(running->sequence(), false);
}
}
void LayerAnimator::AddObserver(LayerAnimationObserver* observer) {
if (!observers_.HasObserver(observer))
observers_.AddObserver(observer);
}
void LayerAnimator::RemoveObserver(LayerAnimationObserver* observer) {
observers_.RemoveObserver(observer);
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
(*queue_iter)->RemoveObserver(observer);
}
}
void LayerAnimator::OnThreadedAnimationStarted(
const cc::AnimationEvent& event) {
LayerAnimationElement::AnimatableProperty property =
LayerAnimationElement::ToAnimatableProperty(event.target_property);
RunningAnimation* running = GetRunningAnimation(property);
if (!running)
return;
DCHECK(running->is_sequence_alive());
if (running->sequence()->animation_group_id() != event.group_id)
return;
running->sequence()->OnThreadedAnimationStarted(event);
if (!running->sequence()->waiting_for_group_start())
return;
base::TimeTicks start_time = base::TimeTicks::FromInternalValue(
event.monotonic_time * base::Time::kMicrosecondsPerSecond);
running->sequence()->set_waiting_for_group_start(false);
for (RunningAnimations::iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if (((*iter).sequence()->animation_group_id() == event.group_id) &&
!(*iter).sequence()->IsFirstElementThreaded() &&
(*iter).sequence()->waiting_for_group_start()) {
(*iter).sequence()->set_start_time(start_time);
(*iter).sequence()->set_waiting_for_group_start(false);
(*iter).sequence()->Start(delegate());
}
}
}
void LayerAnimator::ProgressAnimation(LayerAnimationSequence* sequence,
base::TimeTicks now) {
if (!delegate() || sequence->waiting_for_group_start())
return;
sequence->Progress(now, delegate());
}
void LayerAnimator::ProgressAnimationToEnd(LayerAnimationSequence* sequence) {
if (!delegate())
return;
sequence->ProgressToEnd(delegate());
}
bool LayerAnimator::HasAnimation(LayerAnimationSequence* sequence) const {
for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
if ((*queue_iter).get() == sequence)
return true;
}
return false;
}
void LayerAnimator::Step(base::TimeTicks now) {
TRACE_EVENT0("ui", "LayerAnimator::Step");
scoped_refptr<LayerAnimator> retain(this);
last_step_time_ = now;
PurgeDeletedAnimations();
RunningAnimations running_animations_copy = running_animations_;
for (size_t i = 0; i < running_animations_copy.size(); ++i) {
if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
continue;
if (running_animations_copy[i].sequence()->IsFinished(now)) {
SAFE_INVOKE_VOID(FinishAnimation, running_animations_copy[i], false);
} else {
SAFE_INVOKE_VOID(ProgressAnimation, running_animations_copy[i], now);
}
}
}
void LayerAnimator::SetStartTime(base::TimeTicks start_time) {
}
base::TimeDelta LayerAnimator::GetTimerInterval() const {
return base::TimeDelta::FromMilliseconds(kTimerIntervalMs);
}
void LayerAnimator::StopAnimatingInternal(bool abort) {
scoped_refptr<LayerAnimator> retain(this);
while (is_animating()) {
PurgeDeletedAnimations();
if (running_animations_.empty())
ProcessQueue();
DCHECK(!running_animations_.empty());
if (running_animations_.empty()) {
ClearAnimationsInternal();
break;
}
SAFE_INVOKE_VOID(FinishAnimation, running_animations_[0], abort);
}
}
void LayerAnimator::UpdateAnimationState() {
if (disable_timer_for_test_)
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;
}
LayerAnimationSequence* LayerAnimator::RemoveAnimation(
LayerAnimationSequence* sequence) {
linked_ptr<LayerAnimationSequence> to_return;
bool is_running = false;
for (RunningAnimations::iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if ((*iter).sequence() == sequence) {
running_animations_.erase(iter);
is_running = true;
break;
}
}
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
if ((*queue_iter) == sequence) {
to_return = *queue_iter;
animation_queue_.erase(queue_iter);
break;
}
}
if (!to_return.get() ||
!to_return->waiting_for_group_start() ||
!to_return->IsFirstElementThreaded())
return to_return.release();
bool is_wait_still_needed = false;
int group_id = to_return->animation_group_id();
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
if (((*queue_iter)->animation_group_id() == group_id) &&
(*queue_iter)->IsFirstElementThreaded()) {
is_wait_still_needed = true;
break;
}
}
if (is_wait_still_needed)
return to_return.release();
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
if ((*queue_iter)->animation_group_id() == group_id &&
(*queue_iter)->waiting_for_group_start()) {
(*queue_iter)->set_waiting_for_group_start(false);
if (is_running) {
(*queue_iter)->set_start_time(last_step_time_);
(*queue_iter)->Start(delegate());
}
}
}
return to_return.release();
}
void LayerAnimator::FinishAnimation(
LayerAnimationSequence* sequence, bool abort) {
scoped_refptr<LayerAnimator> retain(this);
scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence));
if (abort)
sequence->Abort(delegate());
else
ProgressAnimationToEnd(sequence);
ProcessQueue();
UpdateAnimationState();
}
void LayerAnimator::FinishAnyAnimationWithZeroDuration() {
scoped_refptr<LayerAnimator> retain(this);
RunningAnimations running_animations_copy = running_animations_;
for (size_t i = 0; i < running_animations_copy.size(); ++i) {
if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
continue;
if (running_animations_copy[i].sequence()->IsFinished(
running_animations_copy[i].sequence()->start_time())) {
SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]);
scoped_ptr<LayerAnimationSequence> removed(
SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i]));
}
}
ProcessQueue();
UpdateAnimationState();
}
void LayerAnimator::ClearAnimations() {
scoped_refptr<LayerAnimator> retain(this);
ClearAnimationsInternal();
}
LayerAnimator::RunningAnimation* LayerAnimator::GetRunningAnimation(
LayerAnimationElement::AnimatableProperty property) {
PurgeDeletedAnimations();
for (RunningAnimations::iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if ((*iter).sequence()->properties() & property)
return &(*iter);
}
return NULL;
}
void LayerAnimator::AddToQueueIfNotPresent(LayerAnimationSequence* animation) {
bool found_sequence = false;
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
if ((*queue_iter) == animation) {
found_sequence = true;
break;
}
}
if (!found_sequence)
animation_queue_.push_front(make_linked_ptr(animation));
}
void LayerAnimator::RemoveAllAnimationsWithACommonProperty(
LayerAnimationSequence* sequence, bool abort) {
RunningAnimations running_animations_copy = running_animations_;
for (size_t i = 0; i < running_animations_copy.size(); ++i) {
if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
continue;
if (running_animations_copy[i].sequence()->HasConflictingProperty(
sequence->properties())) {
scoped_ptr<LayerAnimationSequence> removed(
SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i]));
if (abort)
running_animations_copy[i].sequence()->Abort(delegate());
else
SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]);
}
}
std::vector<base::WeakPtr<LayerAnimationSequence> > sequences;
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter)
sequences.push_back((*queue_iter)->AsWeakPtr());
for (size_t i = 0; i < sequences.size(); ++i) {
if (!sequences[i].get() || !HasAnimation(sequences[i].get()))
continue;
if (sequences[i]->HasConflictingProperty(sequence->properties())) {
scoped_ptr<LayerAnimationSequence> removed(
RemoveAnimation(sequences[i].get()));
if (abort)
sequences[i]->Abort(delegate());
else
ProgressAnimationToEnd(sequences[i].get());
}
}
}
void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) {
base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
sequence->AsWeakPtr();
const bool abort = false;
RemoveAllAnimationsWithACommonProperty(sequence, abort);
if (!weak_sequence_ptr.get())
return;
LayerAnimationSequence* removed = RemoveAnimation(sequence);
DCHECK(removed == NULL || removed == sequence);
if (!weak_sequence_ptr.get())
return;
ProgressAnimationToEnd(sequence);
if (!weak_sequence_ptr.get())
return;
delete sequence;
}
void LayerAnimator::ImmediatelyAnimateToNewTarget(
LayerAnimationSequence* sequence) {
base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
sequence->AsWeakPtr();
const bool abort = true;
RemoveAllAnimationsWithACommonProperty(sequence, abort);
if (!weak_sequence_ptr.get())
return;
AddToQueueIfNotPresent(sequence);
if (!weak_sequence_ptr.get())
return;
StartSequenceImmediately(sequence);
}
void LayerAnimator::EnqueueNewAnimation(LayerAnimationSequence* sequence) {
animation_queue_.push_back(make_linked_ptr(sequence));
ProcessQueue();
}
void LayerAnimator::ReplaceQueuedAnimations(LayerAnimationSequence* sequence) {
base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
sequence->AsWeakPtr();
for (size_t i = 0; i < animation_queue_.size();) {
if (!weak_sequence_ptr.get())
break;
PurgeDeletedAnimations();
bool is_running = false;
for (RunningAnimations::const_iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if ((*iter).sequence() == animation_queue_[i].get()) {
is_running = true;
break;
}
}
if (!is_running)
delete RemoveAnimation(animation_queue_[i].get());
else
++i;
}
animation_queue_.push_back(make_linked_ptr(sequence));
ProcessQueue();
}
void LayerAnimator::ProcessQueue() {
bool started_sequence = false;
do {
started_sequence = false;
LayerAnimationElement::AnimatableProperties animated =
LayerAnimationElement::UNKNOWN;
for (RunningAnimations::const_iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if (!(*iter).is_sequence_alive())
continue;
animated |= (*iter).sequence()->properties();
}
std::vector<base::WeakPtr<LayerAnimationSequence> > sequences;
for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter)
sequences.push_back((*queue_iter)->AsWeakPtr());
for (size_t i = 0; i < sequences.size(); ++i) {
if (!sequences[i].get() || !HasAnimation(sequences[i].get()))
continue;
if (!sequences[i]->HasConflictingProperty(animated)) {
StartSequenceImmediately(sequences[i].get());
started_sequence = true;
break;
}
animated |= sequences[i]->properties();
}
} while (started_sequence);
}
bool LayerAnimator::StartSequenceImmediately(LayerAnimationSequence* sequence) {
PurgeDeletedAnimations();
for (RunningAnimations::const_iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if ((*iter).sequence()->HasConflictingProperty(sequence->properties()))
return false;
}
base::TimeTicks start_time;
if (is_animating() || adding_animations_)
start_time = last_step_time_;
else if (GetAnimationContainer()->is_running())
start_time = GetAnimationContainer()->last_tick_time();
else
start_time = gfx::FrameTime::Now();
if (!sequence->animation_group_id())
sequence->set_animation_group_id(cc::AnimationIdProvider::NextGroupId());
if (!sequence->waiting_for_group_start() ||
sequence->IsFirstElementThreaded()) {
sequence->set_start_time(start_time);
sequence->Start(delegate());
}
running_animations_.push_back(
RunningAnimation(sequence->AsWeakPtr()));
AddToQueueIfNotPresent(sequence);
Step(start_time);
return true;
}
void LayerAnimator::GetTargetValue(
LayerAnimationElement::TargetValue* target) const {
for (AnimationQueue::const_iterator iter = animation_queue_.begin();
iter != animation_queue_.end(); ++iter) {
(*iter)->GetTargetValue(target);
}
}
void LayerAnimator::OnScheduled(LayerAnimationSequence* sequence) {
if (observers_.might_have_observers()) {
ObserverListBase<LayerAnimationObserver>::Iterator it(observers_);
LayerAnimationObserver* obs;
while ((obs = it.GetNext()) != NULL) {
sequence->AddObserver(obs);
}
}
sequence->OnScheduled();
}
void LayerAnimator::SetTransitionDuration(base::TimeDelta duration) {
if (is_transition_duration_locked_)
return;
transition_duration_ = duration;
}
void LayerAnimator::ClearAnimationsInternal() {
PurgeDeletedAnimations();
RunningAnimations running_animations_copy = running_animations_;
for (size_t i = 0; i < running_animations_copy.size(); ++i) {
if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
continue;
scoped_ptr<LayerAnimationSequence> removed(
RemoveAnimation(running_animations_copy[i].sequence()));
if (removed.get())
removed->Abort(delegate());
}
DCHECK(running_animations_.empty());
running_animations_.clear();
animation_queue_.clear();
UpdateAnimationState();
}
void LayerAnimator::PurgeDeletedAnimations() {
for (size_t i = 0; i < running_animations_.size();) {
if (!running_animations_[i].is_sequence_alive())
running_animations_.erase(running_animations_.begin() + i);
else
i++;
}
}
LayerAnimator::RunningAnimation::RunningAnimation(
const base::WeakPtr<LayerAnimationSequence>& sequence)
: sequence_(sequence) {
}
LayerAnimator::RunningAnimation::~RunningAnimation() { }
}