| 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_animation_element.h" | 5 #include "ui/compositor/layer_animation_element.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "ui/compositor/float_animation_curve_adapter.h" | 10 #include "ui/compositor/float_animation_curve_adapter.h" |
| 11 #include "ui/compositor/layer.h" | 11 #include "ui/compositor/layer.h" |
| 12 #include "ui/compositor/layer_animation_delegate.h" | 12 #include "ui/compositor/layer_animation_delegate.h" |
| 13 #include "ui/compositor/layer_animator.h" | 13 #include "ui/compositor/layer_animator.h" |
| 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 15 #include "ui/compositor/transform_animation_curve_adapter.h" | 15 #include "ui/compositor/transform_animation_curve_adapter.h" |
| 16 #include "ui/gfx/animation/tween.h" | 16 #include "ui/gfx/animation/tween.h" |
| 17 #include "ui/gfx/interpolated_transform.h" | 17 #include "ui/gfx/interpolated_transform.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // The factor by which duration is scaled up or down when | 23 // The factor by which duration is scaled up or down when using |
| 24 // ScopedAnimationDurationScaleMode::duration_scale_mode() is SLOW_DURATION or | 24 // ScopedAnimationDurationScaleMode. |
| 25 // FAST_DURATION. | 25 const int kSlowDurationScaleMultiplier = 4; |
| 26 const int kSlowDurationScaleFactor = 4; | 26 const int kFastDurationScaleDivisor = 4; |
| 27 const int kFastDurationScaleFactor = 4; | 27 const int kTestDurationScaleDivisor = 100; |
| 28 | 28 |
| 29 // Pause ----------------------------------------------------------------------- | 29 // Pause ----------------------------------------------------------------------- |
| 30 class Pause : public LayerAnimationElement { | 30 class Pause : public LayerAnimationElement { |
| 31 public: | 31 public: |
| 32 Pause(AnimatableProperties properties, base::TimeDelta duration) | 32 Pause(AnimatableProperties properties, base::TimeDelta duration) |
| 33 : LayerAnimationElement(properties, duration) { | 33 : LayerAnimationElement(properties, duration) { |
| 34 } | 34 } |
| 35 virtual ~Pause() {} | 35 virtual ~Pause() {} |
| 36 | 36 |
| 37 private: | 37 private: |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 754 } |
| 755 } | 755 } |
| 756 | 756 |
| 757 // static | 757 // static |
| 758 base::TimeDelta LayerAnimationElement::GetEffectiveDuration( | 758 base::TimeDelta LayerAnimationElement::GetEffectiveDuration( |
| 759 const base::TimeDelta& duration) { | 759 const base::TimeDelta& duration) { |
| 760 switch (ScopedAnimationDurationScaleMode::duration_scale_mode()) { | 760 switch (ScopedAnimationDurationScaleMode::duration_scale_mode()) { |
| 761 case ScopedAnimationDurationScaleMode::NORMAL_DURATION: | 761 case ScopedAnimationDurationScaleMode::NORMAL_DURATION: |
| 762 return duration; | 762 return duration; |
| 763 case ScopedAnimationDurationScaleMode::FAST_DURATION: | 763 case ScopedAnimationDurationScaleMode::FAST_DURATION: |
| 764 return duration / kFastDurationScaleFactor; | 764 return duration / kFastDurationScaleDivisor; |
| 765 case ScopedAnimationDurationScaleMode::SLOW_DURATION: | 765 case ScopedAnimationDurationScaleMode::SLOW_DURATION: |
| 766 return duration * kSlowDurationScaleFactor; | 766 return duration * kSlowDurationScaleMultiplier; |
| 767 case ScopedAnimationDurationScaleMode::TEST_DURATION: |
| 768 return duration / kTestDurationScaleDivisor; |
| 767 case ScopedAnimationDurationScaleMode::ZERO_DURATION: | 769 case ScopedAnimationDurationScaleMode::ZERO_DURATION: |
| 768 return base::TimeDelta(); | 770 return base::TimeDelta(); |
| 769 default: | 771 default: |
| 770 NOTREACHED(); | 772 NOTREACHED(); |
| 771 return base::TimeDelta(); | 773 return base::TimeDelta(); |
| 772 } | 774 } |
| 773 } | 775 } |
| 774 | 776 |
| 775 // static | 777 // static |
| 776 LayerAnimationElement* LayerAnimationElement::CreateTransformElement( | 778 LayerAnimationElement* LayerAnimationElement::CreateTransformElement( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 845 } |
| 844 | 846 |
| 845 // static | 847 // static |
| 846 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 848 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
| 847 SkColor color, | 849 SkColor color, |
| 848 base::TimeDelta duration) { | 850 base::TimeDelta duration) { |
| 849 return new ColorTransition(color, duration); | 851 return new ColorTransition(color, duration); |
| 850 } | 852 } |
| 851 | 853 |
| 852 } // namespace ui | 854 } // namespace ui |
| OLD | NEW |