| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/compositor/layer_animator.h" | 5 #include "ui/compositor/layer_animator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // LayerAnimator public -------------------------------------------------------- | 46 // LayerAnimator public -------------------------------------------------------- |
| 47 | 47 |
| 48 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) | 48 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) |
| 49 : delegate_(NULL), | 49 : delegate_(NULL), |
| 50 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), | 50 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), |
| 51 is_transition_duration_locked_(false), | 51 is_transition_duration_locked_(false), |
| 52 transition_duration_(transition_duration), | 52 transition_duration_(transition_duration), |
| 53 tween_type_(gfx::Tween::LINEAR), | 53 tween_type_(gfx::Tween::LINEAR), |
| 54 is_started_(false), | 54 is_started_(false), |
| 55 disable_timer_for_test_(false), | 55 disable_timer_for_test_(false), |
| 56 adding_animations_(false) { | 56 adding_animations_(false), |
| 57 animation_metrics_reporter_(nullptr) { |
| 57 animation_player_ = | 58 animation_player_ = |
| 58 cc::AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId()); | 59 cc::AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 LayerAnimator::~LayerAnimator() { | 62 LayerAnimator::~LayerAnimator() { |
| 62 for (size_t i = 0; i < running_animations_.size(); ++i) { | 63 for (size_t i = 0; i < running_animations_.size(); ++i) { |
| 63 if (running_animations_[i].is_sequence_alive()) | 64 if (running_animations_[i].is_sequence_alive()) |
| 64 running_animations_[i].sequence()->OnAnimatorDestroyed(); | 65 running_animations_[i].sequence()->OnAnimatorDestroyed(); |
| 65 } | 66 } |
| 66 ClearAnimationsInternal(); | 67 ClearAnimationsInternal(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void LayerAnimator::RemoveThreadedAnimation(int animation_id) { | 189 void LayerAnimator::RemoveThreadedAnimation(int animation_id) { |
| 189 animation_player_->RemoveAnimation(animation_id); | 190 animation_player_->RemoveAnimation(animation_id); |
| 190 } | 191 } |
| 191 | 192 |
| 192 cc::AnimationPlayer* LayerAnimator::GetAnimationPlayerForTesting() const { | 193 cc::AnimationPlayer* LayerAnimator::GetAnimationPlayerForTesting() const { |
| 193 return animation_player_.get(); | 194 return animation_player_.get(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { | 197 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { |
| 197 scoped_refptr<LayerAnimator> retain(this); | 198 scoped_refptr<LayerAnimator> retain(this); |
| 199 if (animation_metrics_reporter_) |
| 200 animation->SetAnimationMetricsReporter(animation_metrics_reporter_); |
| 198 OnScheduled(animation); | 201 OnScheduled(animation); |
| 199 if (!StartSequenceImmediately(animation)) { | 202 if (!StartSequenceImmediately(animation)) { |
| 200 // Attempt to preempt a running animation. | 203 // Attempt to preempt a running animation. |
| 201 switch (preemption_strategy_) { | 204 switch (preemption_strategy_) { |
| 202 case IMMEDIATELY_SET_NEW_TARGET: | 205 case IMMEDIATELY_SET_NEW_TARGET: |
| 203 ImmediatelySetNewTarget(animation); | 206 ImmediatelySetNewTarget(animation); |
| 204 break; | 207 break; |
| 205 case IMMEDIATELY_ANIMATE_TO_NEW_TARGET: | 208 case IMMEDIATELY_ANIMATE_TO_NEW_TARGET: |
| 206 ImmediatelyAnimateToNewTarget(animation); | 209 ImmediatelyAnimateToNewTarget(animation); |
| 207 break; | 210 break; |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 const base::WeakPtr<LayerAnimationSequence>& sequence) | 934 const base::WeakPtr<LayerAnimationSequence>& sequence) |
| 932 : sequence_(sequence) { | 935 : sequence_(sequence) { |
| 933 } | 936 } |
| 934 | 937 |
| 935 LayerAnimator::RunningAnimation::RunningAnimation( | 938 LayerAnimator::RunningAnimation::RunningAnimation( |
| 936 const RunningAnimation& other) = default; | 939 const RunningAnimation& other) = default; |
| 937 | 940 |
| 938 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 941 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
| 939 | 942 |
| 940 } // namespace ui | 943 } // namespace ui |
| OLD | NEW |