| 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 #ifndef UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ | 5 #ifndef UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ |
| 6 #define UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ | 6 #define UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/compositor/compositor_export.h" | 12 #include "ui/compositor/compositor_export.h" |
| 13 #include "ui/compositor/layer_animation_element.h" |
| 13 #include "ui/compositor/layer_animator.h" | 14 #include "ui/compositor/layer_animator.h" |
| 14 #include "ui/gfx/animation/tween.h" | 15 #include "ui/gfx/animation/tween.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 class ImplicitAnimationObserver; | 19 class ImplicitAnimationObserver; |
| 19 | 20 |
| 20 // Scoped settings allow you to temporarily change the animator's settings and | 21 // Scoped settings allow you to temporarily change the animator's settings and |
| 21 // these changes are reverted when the object is destroyed. NOTE: when the | 22 // these changes are reverted when the object is destroyed. NOTE: when the |
| 22 // settings object is created, it applies the default transition duration | 23 // settings object is created, it applies the default transition duration |
| 23 // (200ms). | 24 // (200ms). |
| 24 class COMPOSITOR_EXPORT ScopedLayerAnimationSettings { | 25 class COMPOSITOR_EXPORT ScopedLayerAnimationSettings { |
| 25 public: | 26 public: |
| 26 explicit ScopedLayerAnimationSettings(scoped_refptr<LayerAnimator> animator); | 27 explicit ScopedLayerAnimationSettings(scoped_refptr<LayerAnimator> animator); |
| 27 virtual ~ScopedLayerAnimationSettings(); | 28 virtual ~ScopedLayerAnimationSettings(); |
| 28 | 29 |
| 29 void AddObserver(ImplicitAnimationObserver* observer); | 30 void AddObserver(ImplicitAnimationObserver* observer); |
| 30 | 31 |
| 32 void SetAnimationMetricsReporter(AnimationMetricsReporter* reporter); |
| 31 void SetTransitionDuration(base::TimeDelta duration); | 33 void SetTransitionDuration(base::TimeDelta duration); |
| 32 base::TimeDelta GetTransitionDuration() const; | 34 base::TimeDelta GetTransitionDuration() const; |
| 33 | 35 |
| 34 // Locks transition duration in |animator_|. When transition duration | 36 // Locks transition duration in |animator_|. When transition duration |
| 35 // is locked any subsequent changes to it are ignored until the | 37 // is locked any subsequent changes to it are ignored until the |
| 36 // ScopedLayerAnimationSettings object that has locked the duration goes out | 38 // ScopedLayerAnimationSettings object that has locked the duration goes out |
| 37 // of scope. | 39 // of scope. |
| 38 void LockTransitionDuration(); | 40 void LockTransitionDuration(); |
| 39 | 41 |
| 40 void SetTweenType(gfx::Tween::Type tween_type); | 42 void SetTweenType(gfx::Tween::Type tween_type); |
| 41 gfx::Tween::Type GetTweenType() const; | 43 gfx::Tween::Type GetTweenType() const; |
| 42 | 44 |
| 43 void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy); | 45 void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy); |
| 44 LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const; | 46 LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const; |
| 45 | 47 |
| 46 private: | 48 private: |
| 47 scoped_refptr<LayerAnimator> animator_; | 49 scoped_refptr<LayerAnimator> animator_; |
| 48 bool old_is_transition_duration_locked_; | 50 bool old_is_transition_duration_locked_; |
| 49 base::TimeDelta old_transition_duration_; | 51 base::TimeDelta old_transition_duration_; |
| 50 gfx::Tween::Type old_tween_type_; | 52 gfx::Tween::Type old_tween_type_; |
| 51 LayerAnimator::PreemptionStrategy old_preemption_strategy_; | 53 LayerAnimator::PreemptionStrategy old_preemption_strategy_; |
| 52 std::set<ImplicitAnimationObserver*> observers_; | 54 std::set<ImplicitAnimationObserver*> observers_; |
| 53 | 55 |
| 54 DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings); | 56 DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace ui | 59 } // namespace ui |
| 58 | 60 |
| 59 #endif // UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ | 61 #endif // UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_ |
| OLD | NEW |