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..69f9c22dc24e6b2758cbf8bad3e0f9bf86dcfdb5 100644 |
| --- a/ash/rotator/screen_rotation_animator.h |
| +++ b/ash/rotator/screen_rotation_animator.h |
| @@ -9,9 +9,20 @@ |
| #include "ash/ash_export.h" |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.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 +30,59 @@ 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. Clients should only call |Rotate()| when can animate. For |
| + // example an animation is not possible if |display_id_| specifies a |
| + // display::Display that is not currently active. See www.crbug.com/479503. |
| + // |screen_rotation_animator_observer_| will be notified when rotation is |
| + // finished and there is no more pending rotation request. Otherwise, any |
| + // ongoging animation will be stoped and progressed to the 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 SetScreenRotationAnimatorObserver( |
| + ScreenRotationAnimatorObserver* observer) { |
| + screen_rotation_animator_observer_ = observer; |
| + } |
| + |
| + void RemoveScreenRotationAnimatorObserver() { |
| + screen_rotation_animator_observer_ = nullptr; |
| + } |
| + |
| + void OnLayerAnimationEnded(); |
| + |
| + void OnLayerAnimationAborted(); |
| + |
| + base::WeakPtr<ScreenRotationAnimator> WeakPtr(); |
|
bruthig
2017/03/15 23:12:38
Is this required or can you use weak_factory_.GetW
wutao
2017/03/16 07:37:59
I can use weak_factory_.GetWeakPtr().
|
| + |
| private: |
| + friend class ash::test::ScreenRotationAnimatorTestApi; |
| + |
| // The id of the display to rotate. |
| int64_t display_id_; |
| + bool is_rotating_; |
| + bool disable_animation_timers_for_test_; |
|
bruthig
2017/03/15 23:12:37
This could use a doc.
wutao
2017/03/16 07:37:59
Done.
|
| + ScreenRotationAnimatorObserver* screen_rotation_animator_observer_; |
| + std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| + struct ScreenRotationRequest; |
| + std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
| + |
| + void AnimateRotation(const ScreenRotationRequest& rotation_request); |
|
bruthig
2017/03/15 23:12:37
Function declarations should go before member vari
wutao
2017/03/16 07:37:59
Done.
|
| + |
| + // Get the root layer of the old layer tree. |
| + ui::Layer* GetOldLayerTreeRootLayer(); |
| + |
| + void ProcessAnimationQueue(); |
|
bruthig
2017/03/15 23:12:37
Docs?
wutao
2017/03/16 07:37:59
Done.
|
| + |
| + void set_disable_animation_timers_for_test(bool disable_timers); |
| + |
| + void StopAnimating(); |
| + |
| + base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |
| }; |