Chromium Code Reviews| Index: ash/rotator/screen_rotation_animator.h |
| diff --git a/ash/rotator/screen_rotation_animator.h b/ash/rotator/screen_rotation_animator.h |
| index f5b25d69298505c1d7d3d14e4ecb3631b1cb791d..df301744f5fd849420c82a5ad07bdfbf9e935670 100644 |
| --- a/ash/rotator/screen_rotation_animator.h |
| +++ b/ash/rotator/screen_rotation_animator.h |
| @@ -9,9 +9,21 @@ |
| #include "ash/ash_export.h" |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/observer_list.h" |
| #include "ui/display/display.h" |
| +namespace ui { |
| +class Layer; |
| +class LayerTreeOwner; |
| +} // namespace ui |
| + |
| namespace ash { |
| +namespace test { |
| +class ScreenRotationAnimatorTestApi; |
| +} // namespace test |
| + |
| +class ScreenRotationAnimatorObserver; |
| // Utility to perform a screen rotation with an animation. |
| class ASH_EXPORT ScreenRotationAnimator { |
| @@ -19,22 +31,58 @@ class ASH_EXPORT ScreenRotationAnimator { |
| explicit ScreenRotationAnimator(int64_t display_id); |
| ~ScreenRotationAnimator(); |
| - // Returns true if the screen rotation animation can be completed |
| - // successfully. For example an animation is not possible if |display_id_| |
| - // specifies a display::Display that is not currently active. See |
| - // www.crbug.com/479503. |
| - bool CanAnimate() const; |
| - |
| // Rotates the display::Display specified by |display_id_| to the |
| - // |new_rotation| |
| - // orientation, for the given |source|. The rotation will also become active. |
| - // Clients should only call |Rotate()| if |CanAnimate()| returns true. |
| + // |new_rotation| orientation, for the given |source|. The rotation will also |
| + // become active. Should only be called when |display_id_| references a valid |
| + // display::Display. |screen_rotation_animator_observer_| will be notified |
| + // when rotation is finished and there is no more pending rotation request. |
| + // Otherwise, any ongoing animation will be stoped and progressed to the |
|
bruthig
2017/03/17 00:38:44
nit: stoped -> stopped
wutao
2017/03/17 20:35:01
Done.
|
| + // target position, followed by a new |Rotate()| call with the pending |
| + // rotation request. |
| void Rotate(display::Display::Rotation new_rotation, |
| display::Display::RotationSource source); |
| + int64_t display_id() const { return display_id_; } |
| + |
| + void AddScreenRotationAnimatorObserver( |
| + ScreenRotationAnimatorObserver* observer); |
| + void RemoveScreenRotationAnimatorObserver( |
| + ScreenRotationAnimatorObserver* observer); |
| + |
| + void OnLayerAnimationEnded(); |
| + |
| + void OnLayerAnimationAborted(); |
| + |
| private: |
| + friend class ash::test::ScreenRotationAnimatorTestApi; |
| + struct ScreenRotationRequest; |
| + |
| + // Set the screen orientation to |new_rotation| and animate the change. The |
| + // animation will rotate the initial orientation's layer towards the new |
| + // orientation through |rotation_degrees| while fading out, and the new |
| + // orientation's layer will be rotated in to the |new_orientation| through |
| + // |rotation_degrees| arc. |
| + void AnimateRotation(const ScreenRotationRequest& rotation_request); |
| + |
| + // When screen rotation animation is ended or aborted, if the request queue is |
| + // not empty, it will call |Rotate()| with the pending rotation request. |
| + // Otherwise it will notify |screen_rotation_animator_observer_|. |
| + void ProcessAnimationQueue(); |
| + |
| + void set_disable_animation_timers_for_test(bool disable_timers); |
| + |
| + void StopAnimating(); |
| + |
| // The id of the display to rotate. |
| int64_t display_id_; |
| + bool is_rotating_; |
| + // Only set in unittest to disable animation timers. |
| + bool disable_animation_timers_for_test_; |
| + base::ObserverList<ScreenRotationAnimatorObserver> |
| + screen_rotation_animator_observers_; |
| + std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| + std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
| + base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |
| }; |