diff options
author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 19:17:48 +0000 |
---|---|---|
committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 19:17:48 +0000 |
commit | 3489a61484501935cd2a20ee9c646eea92659b59 (patch) | |
tree | 863c65c9ab4b310ce462dd7723eef472c0072124 /ui | |
parent | 56c25275ef0a5d233c7e09c696f2c8f28009977b (diff) | |
download | chromium_src-3489a61484501935cd2a20ee9c646eea92659b59.zip chromium_src-3489a61484501935cd2a20ee9c646eea92659b59.tar.gz chromium_src-3489a61484501935cd2a20ee9c646eea92659b59.tar.bz2 |
Let the layer animator's slow animation mode affect all animations.
Currently, this setting will only affect implicit animations. If you explicitly create an animation with a duration, it will not slow down. With this patch, we alter the duration of layer animation elements in the same way we do when disabling animations for tests: we hijack and possibly replace the duration in the layer animation element's constructor.
BUG=None
TEST=Manual -- hold shift when minimizing a window in aura.
Review URL: https://chromiumcodereview.appspot.com/10537143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141929 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/layer_animation_element.cc | 15 | ||||
-rw-r--r-- | ui/compositor/layer_animation_element.h | 7 | ||||
-rw-r--r-- | ui/compositor/layer_animator.cc | 6 | ||||
-rw-r--r-- | ui/compositor/layer_animator.h | 4 |
4 files changed, 27 insertions, 5 deletions
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc index b5ebc03..dde0b48 100644 --- a/ui/compositor/layer_animation_element.cc +++ b/ui/compositor/layer_animation_element.cc @@ -256,8 +256,7 @@ LayerAnimationElement::LayerAnimationElement( base::TimeDelta duration) : first_frame_(true), properties_(properties), - duration_(LayerAnimator::disable_animations_for_test() - ? base::TimeDelta() : duration), + duration_(GetEffectiveDuration(duration)), tween_type_(Tween::LINEAR) { } @@ -283,6 +282,18 @@ void LayerAnimationElement::Abort() { } // static +base::TimeDelta LayerAnimationElement::GetEffectiveDuration( + const base::TimeDelta& duration) { + if (LayerAnimator::disable_animations_for_test()) + return base::TimeDelta(); + + if (LayerAnimator::slow_animation_mode()) + return duration * LayerAnimator::slow_animation_scale_factor(); + + return duration; +} + +// static LayerAnimationElement* LayerAnimationElement::CreateTransformElement( const Transform& transform, base::TimeDelta duration) { return new TransformTransition(transform, duration); diff --git a/ui/compositor/layer_animation_element.h b/ui/compositor/layer_animation_element.h index 419ee93..91e919e 100644 --- a/ui/compositor/layer_animation_element.h +++ b/ui/compositor/layer_animation_element.h @@ -110,7 +110,7 @@ class COMPOSITOR_EXPORT LayerAnimationElement { base::TimeDelta duration() const { return duration_; } Tween::Type tween_type() const { return tween_type_; } - void set_tween_type(Tween::Type tween_type) { tween_type_ = tween_type;} + void set_tween_type(Tween::Type tween_type) { tween_type_ = tween_type; } protected: // Called once each time the animation element is run before any call to @@ -121,6 +121,11 @@ class COMPOSITOR_EXPORT LayerAnimationElement { virtual void OnAbort() = 0; private: + // For debugging purposes, we sometimes alter the duration we actually use. + // For example, during tests we often set duration = 0, and it is sometimes + // useful to slow animations down to see them more clearly. + base::TimeDelta GetEffectiveDuration(const base::TimeDelta& delta); + bool first_frame_; const AnimatableProperties properties_; const base::TimeDelta duration_; diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc index 79aebc7..a8af80f 100644 --- a/ui/compositor/layer_animator.cc +++ b/ui/compositor/layer_animator.cc @@ -231,6 +231,10 @@ void LayerAnimator::RemoveObserver(LayerAnimationObserver* observer) { } } +int LayerAnimator::slow_animation_scale_factor() { + return kSlowAnimationScaleFactor; +} + // LayerAnimator protected ----------------------------------------------------- bool LayerAnimator::ProgressAnimation(LayerAnimationSequence* sequence, @@ -587,8 +591,6 @@ void LayerAnimator::OnScheduled(LayerAnimationSequence* sequence) { } base::TimeDelta LayerAnimator::GetTransitionDuration() const { - if (slow_animation_mode_) - return transition_duration_ * kSlowAnimationScaleFactor; return transition_duration_; } diff --git a/ui/compositor/layer_animator.h b/ui/compositor/layer_animator.h index 130af0e..d360354 100644 --- a/ui/compositor/layer_animator.h +++ b/ui/compositor/layer_animator.h @@ -139,6 +139,10 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement { static void set_slow_animation_mode(bool slow) { slow_animation_mode_ = slow; } + static bool slow_animation_mode() { return slow_animation_mode_; } + + // When in slow animation mode, animation durations a scaled by this value. + static int slow_animation_scale_factor(); // When set to true, all animations complete immediately. static void set_disable_animations_for_test(bool disable_animations) { |