Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 90 base::TimeDelta duration = GetTransitionDuration(); \ | 91 base::TimeDelta duration = GetTransitionDuration(); \ |
| 91 if (duration.is_zero() && delegate() && \ | 92 if (duration.is_zero() && delegate() && \ |
| 92 (preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \ | 93 (preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \ |
| 93 StopAnimatingProperty(LayerAnimationElement::property); \ | 94 StopAnimatingProperty(LayerAnimationElement::property); \ |
| 94 delegate()->Set##name##FromAnimation(value); \ | 95 delegate()->Set##name##FromAnimation(value); \ |
| 95 return; \ | 96 return; \ |
| 96 } \ | 97 } \ |
| 97 std::unique_ptr<LayerAnimationElement> element = \ | 98 std::unique_ptr<LayerAnimationElement> element = \ |
| 98 LayerAnimationElement::Create##name##Element(value, duration); \ | 99 LayerAnimationElement::Create##name##Element(value, duration); \ |
| 99 element->set_tween_type(tween_type_); \ | 100 element->set_tween_type(tween_type_); \ |
| 100 StartAnimation(new LayerAnimationSequence(std::move(element))); \ | 101 LayerAnimationSequence* sequence = \ |
| 102 new LayerAnimationSequence(std::move(element)); \ | |
| 103 sequence->SetAnimationMetricsReporter(animation_metrics_reporter_); \ | |
| 104 StartAnimation(sequence); \ | |
|
sadrul
2017/01/20 17:29:43
Does this cover all the cases? e.g. what if LayerA
ajuma
2017/01/20 23:02:06
This is a good point, what about moving this logic
| |
| 101 } \ | 105 } \ |
| 102 \ | 106 \ |
| 103 member_type LayerAnimator::GetTarget##name() const { \ | 107 member_type LayerAnimator::GetTarget##name() const { \ |
| 104 LayerAnimationElement::TargetValue target(delegate()); \ | 108 LayerAnimationElement::TargetValue target(delegate()); \ |
| 105 GetTargetValue(&target); \ | 109 GetTargetValue(&target); \ |
| 106 return target.member; \ | 110 return target.member; \ |
| 107 } | 111 } |
| 108 | 112 |
| 109 ANIMATED_PROPERTY( | 113 ANIMATED_PROPERTY( |
| 110 const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform); | 114 const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform); |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 const base::WeakPtr<LayerAnimationSequence>& sequence) | 935 const base::WeakPtr<LayerAnimationSequence>& sequence) |
| 932 : sequence_(sequence) { | 936 : sequence_(sequence) { |
| 933 } | 937 } |
| 934 | 938 |
| 935 LayerAnimator::RunningAnimation::RunningAnimation( | 939 LayerAnimator::RunningAnimation::RunningAnimation( |
| 936 const RunningAnimation& other) = default; | 940 const RunningAnimation& other) = default; |
| 937 | 941 |
| 938 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 942 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
| 939 | 943 |
| 940 } // namespace ui | 944 } // namespace ui |
| OLD | NEW |