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 b541106e88030c68a5217cc03451e46268688eae..fba7f7f416514e5b10a04b4096c16e6ceaa05607 100644 |
| --- a/ash/rotator/screen_rotation_animator.h |
| +++ b/ash/rotator/screen_rotation_animator.h |
| @@ -13,6 +13,11 @@ |
| #include "base/observer_list.h" |
| #include "ui/display/display.h" |
| +namespace cc { |
| +class CopyOutputRequest; |
| +class CopyOutputResult; |
| +} // namespace cc |
| + |
| namespace ui { |
| class AnimationMetricsReporter; |
| class Layer; |
| @@ -30,7 +35,7 @@ class ScreenRotationAnimatorObserver; |
| class ASH_EXPORT ScreenRotationAnimator { |
| public: |
| explicit ScreenRotationAnimator(int64_t display_id); |
| - ~ScreenRotationAnimator(); |
| + virtual ~ScreenRotationAnimator(); |
| // Rotates the display::Display specified by |display_id_| to the |
| // |new_rotation| orientation, for the given |source|. The rotation will also |
| @@ -55,11 +60,44 @@ class ASH_EXPORT ScreenRotationAnimator { |
| // notifies |screen_rotation_animator_observer_|. |
| void ProcessAnimationQueue(); |
| + protected: |
| + struct ScreenRotationRequest { |
| + ScreenRotationRequest(display::Display::Rotation to_rotation, |
| + display::Display::RotationSource from_source) |
| + : new_rotation(to_rotation), source(from_source) {} |
| + display::Display::Rotation new_rotation; |
| + display::Display::RotationSource source; |
| + }; |
|
oshima
2017/04/04 20:23:13
can you move the definition to .cc?
wutao
2017/04/05 00:09:22
Tested, but have error: invalid application of 'si
|
| + |
| + // This function can be overridden in unit test to test removing external |
| + // display. |
| + virtual std::unique_ptr<cc::CopyOutputRequest> CreateAfterCopyCallback( |
| + std::unique_ptr<ScreenRotationRequest> rotation_request); |
|
oshima
2017/04/04 20:23:13
you should be able to just call
OnceClosure Crea
wutao
2017/04/05 00:09:22
Done. But I need to specify the callback type, can
|
| + |
| + // The callback in |RequestCopyRootLayerAndAnimateRotation()|. |
| + void OnRootLayerCopiedBeforeRotation( |
| + std::unique_ptr<ScreenRotationRequest> rotation_request, |
| + std::unique_ptr<cc::CopyOutputResult> result); |
| + |
| private: |
| friend class ash::test::ScreenRotationAnimatorTestApi; |
| - struct ScreenRotationRequest; |
| - // Set the screen orientation to |new_rotation| and animate the change. The |
| + void StartRotationAnimation( |
| + std::unique_ptr<ScreenRotationRequest> rotation_request); |
| + |
| + // This is an asynchronous call to request copy output of root layer. |
| + void RequestCopyRootLayerAndAnimateRotation( |
| + std::unique_ptr<ScreenRotationRequest> rotation_request); |
| + |
| + // Recreates all |root_window| layers. |
| + void CreateOldLayerTree(); |
| + |
| + // Requests a copy of |root_window| root layer output. |
| + void CopyOldLayerTree(std::unique_ptr<cc::CopyOutputResult> result); |
| + |
| + // Note: Only call this function when the |old_layer_tree_owner_| is set up |
| + // properly. |
| + // Sets 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 |
| @@ -68,6 +106,8 @@ class ASH_EXPORT ScreenRotationAnimator { |
| void set_disable_animation_timers_for_test(bool disable_timers); |
| + void set_enable_smooth_rotation_for_test(bool enable_smooth_rotation); |
| + |
| void StopAnimating(); |
| // The id of the display to rotate. |
| @@ -76,6 +116,8 @@ class ASH_EXPORT ScreenRotationAnimator { |
| std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_; |
| // Only set in unittest to disable animation timers. |
| bool disable_animation_timers_for_test_; |
| + // Only set in unittest to enable smooth rotation. |
| + bool enable_smooth_rotation_for_test_; |
| base::ObserverList<ScreenRotationAnimatorObserver> |
| screen_rotation_animator_observers_; |
| std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |