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..f3d5ba93bab92551c8e9ea5d4da4816582d502ca 100644 |
| --- a/ash/rotator/screen_rotation_animator.h |
| +++ b/ash/rotator/screen_rotation_animator.h |
| @@ -9,6 +9,8 @@ |
| #include "ash/ash_export.h" |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "ui/compositor/layer_tree_owner.h" |
|
bruthig
2017/03/10 22:34:08
nit: Can you forward declare this instead?
wutao
2017/03/14 16:46:38
Done.
|
| #include "ui/display/display.h" |
| namespace ash { |
| @@ -16,15 +18,28 @@ namespace ash { |
| // Utility to perform a screen rotation with an animation. |
| class ASH_EXPORT ScreenRotationAnimator { |
| public: |
| + class ASH_EXPORT ScreenRotationAnimatorObserver { |
| + public: |
| + ScreenRotationAnimatorObserver(); |
| + |
| + virtual void OnEndedOrAbortedScreenRotationAnimation( |
| + ScreenRotationAnimator* animator); |
| + |
| + protected: |
| + virtual ~ScreenRotationAnimatorObserver(); |
| + }; |
| + |
| + struct ScreenRotationRequest { |
|
bruthig
2017/03/10 22:34:08
If you make Rotate() a member function, I think yo
wutao
2017/03/14 16:46:38
It is already in ScreenRotationAnimator class :)
I
|
| + ScreenRotationAnimator* animator; |
| + int64_t display_id; |
| + display::Display::Rotation initial_rotation; |
| + display::Display::Rotation new_rotation; |
| + display::Display::RotationSource source; |
| + }; |
| + |
| 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. |
| @@ -32,9 +47,51 @@ class ASH_EXPORT ScreenRotationAnimator { |
| void Rotate(display::Display::Rotation new_rotation, |
|
bruthig
2017/03/10 22:34:08
Can you document when the |observer_| will and wil
wutao
2017/03/14 16:46:38
Done.
|
| 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 set_old_layer_tree_owner(ui::LayerTreeOwner* layer_tree_owner) { |
|
bruthig
2017/03/10 22:34:08
Instead of making set_old_layer_tree_owner() and G
wutao
2017/03/14 16:46:38
Done.
|
| + old_layer_tree_owner_.reset(layer_tree_owner); |
| + } |
| + |
| + // Get the root layer of the old layer tree. |
| + ui::Layer* GetOldLayerTreeRootLayer(); |
| + |
| + void OnLayerAnimationEnded(); |
| + |
| + void OnLayerAnimationAborted(); |
| + |
| + bool is_rotating_for_test() const { return is_rotating_; } |
| + |
| + base::WeakPtr<ScreenRotationAnimator> WeakPtr() { |
| + return weak_factory_.GetWeakPtr(); |
| + } |
| + |
| private: |
| // The id of the display to rotate. |
| int64_t display_id_; |
| + bool is_rotating_; |
| + ScreenRotationAnimatorObserver* screen_rotation_animator_observer_; |
| + std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| + std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
| + |
| + void ContinueOrCleanUp(); |
|
bruthig
2017/03/10 22:34:08
Some docs here would be helpful or a rename of Pro
wutao
2017/03/14 16:46:38
Renamed. A doc will be a little redundant when I a
|
| + |
| + // Aborts the active animations of the layer, and recurses upon its child |
| + // layers. |
| + void AbortAnimations(ui::Layer* layer); |
| + |
| + void StopAnimating(); |
| + |
| + base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |
| }; |