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 ce77673d356d949614e4d4f6714cc5ee5bc0b357..4788bfce59764d3d6832703414bc445bfc56f815 100644 |
| --- a/ash/rotator/screen_rotation_animator.h |
| +++ b/ash/rotator/screen_rotation_animator.h |
| @@ -14,13 +14,19 @@ |
| #include "base/observer_list.h" |
| #include "ui/display/display.h" |
| +namespace aura { |
| +class Window; |
| +} // namesapce aura |
| + |
| namespace cc { |
| +class CopyOutputRequest; |
| class CopyOutputResult; |
| } // namespace cc |
| namespace ui { |
| class AnimationMetricsReporter; |
| class Layer; |
| +class LayerOwner; |
| class LayerTreeOwner; |
| } // namespace ui |
| @@ -69,13 +75,19 @@ class ASH_EXPORT ScreenRotationAnimator { |
| display::Display::RotationSource from_source) |
| : id(id), new_rotation(to_rotation), source(from_source) {} |
| int64_t id; |
| + display::Display::Rotation old_rotation; |
| display::Display::Rotation new_rotation; |
| display::Display::RotationSource source; |
| }; |
| // This function can be overridden in unit test to test removing external |
| // display. |
| - virtual CopyCallback CreateAfterCopyCallback( |
| + virtual CopyCallback CreateAfterCopyCallbackBeforeRotation( |
| + std::unique_ptr<ScreenRotationRequest> rotation_request); |
| + |
| + // This function can be overridden in unit test to test removing external |
| + // display. |
| + virtual CopyCallback CreateAfterCopyCallbackAfterRotation( |
| std::unique_ptr<ScreenRotationRequest> rotation_request); |
| private: |
| @@ -84,20 +96,44 @@ class ASH_EXPORT ScreenRotationAnimator { |
| void StartRotationAnimation( |
| std::unique_ptr<ScreenRotationRequest> rotation_request); |
| - // This is an asynchronous call to request copy output of root layer. |
| - void RequestCopyRootLayerAndAnimateRotation( |
| + // The code path to start "slow animation". The difference between the "slow" |
| + // and "smooth" animation, is that "slow animation" will recreate all the |
| + // layers before rotation and use the recreated layers and rotated layers for |
| + // cross-fading animation. This is slow by adding multiple layer animation |
| + // elements. The "smooth animation" copies the layer output before and after |
| + // rotation, and use them for cross-fading animation. The output copy layer |
| + // flatten the layer hierarchy and makes the animation smooth. |
| + void StartSlowAnimation( |
| std::unique_ptr<ScreenRotationRequest> rotation_request); |
| - // The callback in |RequestCopyRootLayerAndAnimateRotation()|. |
| - void OnRootLayerCopiedBeforeRotation( |
| + // A wrapper to call |display_manager| to set screen rotation and rotate the |
| + // |old_layer_tree| to the |old_rotation|. |
| + void SetRotation(display::Display::Rotation old_rotation, |
| + display::Display::Rotation new_rotation, |
| + display::Display::RotationSource source); |
| + |
| + // This is an asynchronous call to request copy output of root layer. |
| + void RequestCopyScreenRotationContainerLayer( |
| + std::unique_ptr<cc::CopyOutputRequest> copy_output_request); |
| + |
| + // The callback in |RequestCopyScreenRotationContainerLayer()| before screen |
| + // rotation. |
| + void OnScreenRotationContainerLayerCopiedBeforeRotation( |
| std::unique_ptr<ScreenRotationRequest> rotation_request, |
| std::unique_ptr<cc::CopyOutputResult> result); |
| - // Recreates all |root_window| layers. |
| - void CreateOldLayerTree(); |
| + // The callback in |RequestCopyScreenRotationContainerLayer()| after screen |
| + // rotation. |
| + void OnScreenRotationContainerLayerCopiedAfterRotation( |
| + std::unique_ptr<ScreenRotationRequest> rotation_request, |
| + std::unique_ptr<cc::CopyOutputResult> result); |
| - // Requests a copy of |root_window| root layer output. |
| - void CopyOldLayerTree(std::unique_ptr<cc::CopyOutputResult> result); |
| + // Recreates all |root_window| layers and their layer tree owner. |
| + void CreateOldLayerTreeForSlowAnimation(); |
| + |
| + // Creates a new layer and its layer tree owner from |CopyOutputResult|. |
| + std::unique_ptr<ui::LayerTreeOwner> CopyLayerTree( |
| + std::unique_ptr<cc::CopyOutputResult> result); |
| // Note: Only call this function when the |old_layer_tree_owner_| is set up |
| // properly. |
| @@ -108,7 +144,13 @@ class ASH_EXPORT ScreenRotationAnimator { |
| // |rotation_degrees| arc. |
| void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); |
| - void set_disable_animation_timers_for_test(bool disable_timers); |
| + void set_disable_animation_timers_for_test(bool disable_timers) { |
| + disable_animation_timers_for_test_ = disable_timers; |
| + } |
| + |
| + void set_switch_smooth_rotation_for_test(bool enable) { |
| + has_switch_ash_enable_smooth_screen_rotation_ = enable; |
| + } |
|
oshima
2017/04/19 22:56:52
last one. instead, just append switch in the SetUp
wutao
2017/04/20 00:32:52
Separate the two test sets for slow/smooth animati
|
| void StopAnimating(); |
| @@ -135,7 +177,12 @@ class ASH_EXPORT ScreenRotationAnimator { |
| base::ObserverList<ScreenRotationAnimatorObserver> |
| screen_rotation_animator_observers_; |
| std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| + std::unique_ptr<ui::LayerTreeOwner> new_layer_tree_owner_; |
| + std::unique_ptr<ui::LayerOwner> black_mask_layer_owner_; |
| std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
| + bool has_switch_ash_enable_smooth_screen_rotation_; |
| + aura::Window* root_window_; |
| + ui::Layer* screen_rotation_container_layer_; |
| base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |