| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ | 5 #ifndef ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ |
| 6 #define ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ | 6 #define ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
| 15 | 15 |
| 16 namespace cc { |
| 17 class CopyOutputResult; |
| 18 } // namespace cc |
| 19 |
| 16 namespace ui { | 20 namespace ui { |
| 17 class AnimationMetricsReporter; | 21 class AnimationMetricsReporter; |
| 18 class Layer; | 22 class Layer; |
| 19 class LayerTreeOwner; | 23 class LayerTreeOwner; |
| 20 } // namespace ui | 24 } // namespace ui |
| 21 | 25 |
| 22 namespace ash { | 26 namespace ash { |
| 23 namespace test { | 27 namespace test { |
| 24 class ScreenRotationAnimatorTestApi; | 28 class ScreenRotationAnimatorTestApi; |
| 25 } // namespace test | 29 } // namespace test |
| (...skipping 26 matching lines...) Expand all Loading... |
| 52 | 56 |
| 53 // When screen rotation animation is ended or aborted, calls |Rotate()| with | 57 // When screen rotation animation is ended or aborted, calls |Rotate()| with |
| 54 // the pending rotation request if the request queue is not empty. Otherwise | 58 // the pending rotation request if the request queue is not empty. Otherwise |
| 55 // notifies |screen_rotation_animator_observer_|. | 59 // notifies |screen_rotation_animator_observer_|. |
| 56 void ProcessAnimationQueue(); | 60 void ProcessAnimationQueue(); |
| 57 | 61 |
| 58 private: | 62 private: |
| 59 friend class ash::test::ScreenRotationAnimatorTestApi; | 63 friend class ash::test::ScreenRotationAnimatorTestApi; |
| 60 struct ScreenRotationRequest; | 64 struct ScreenRotationRequest; |
| 61 | 65 |
| 62 // Set the screen orientation to |new_rotation| and animate the change. The | 66 void StartRotationAnimation( |
| 67 std::unique_ptr<ScreenRotationRequest> rotation_request); |
| 68 |
| 69 // This is an asynchronous call to request copy output of root layer. In the |
| 70 // callback, either succeeded or fail, it will call |AnimateRotation()|. |
| 71 void RequestCopyRootLayerAndAnimateRotation( |
| 72 std::unique_ptr<ScreenRotationRequest> rotation_request); |
| 73 |
| 74 // The callback in |RequestCopyRootLayerAndAnimateRotation()|. No matter the |
| 75 // request is succeeded or fail, it will call |AnimateRotation()|. |
| 76 void OnRootLayerCopiedBeforeRotation( |
| 77 std::unique_ptr<ScreenRotationRequest> rotation_request, |
| 78 std::unique_ptr<cc::CopyOutputResult> result); |
| 79 |
| 80 // Recreates all |root_window| layers. |
| 81 void CreateOldLayerTree(); |
| 82 |
| 83 // Requests a copy of |root_window| root layer output. |
| 84 void CopyOldLayerTree(std::unique_ptr<cc::CopyOutputResult> result); |
| 85 |
| 86 // Note: Only call this function when the |old_layer_tree_owner_| is set up |
| 87 // properly. |
| 88 // Sets the screen orientation to |new_rotation| and animate the change. The |
| 63 // animation will rotate the initial orientation's layer towards the new | 89 // animation will rotate the initial orientation's layer towards the new |
| 64 // orientation through |rotation_degrees| while fading out, and the new | 90 // orientation through |rotation_degrees| while fading out, and the new |
| 65 // orientation's layer will be rotated in to the |new_orientation| through | 91 // orientation's layer will be rotated in to the |new_orientation| through |
| 66 // |rotation_degrees| arc. | 92 // |rotation_degrees| arc. |
| 67 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); | 93 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); |
| 68 | 94 |
| 69 void set_disable_animation_timers_for_test(bool disable_timers); | 95 void set_disable_animation_timers_for_test(bool disable_timers); |
| 70 | 96 |
| 71 void StopAnimating(); | 97 void StopAnimating(); |
| 72 | 98 |
| 73 // The id of the display to rotate. | 99 // The id of the display to rotate. |
| 74 int64_t display_id_; | 100 int64_t display_id_; |
| 75 bool is_rotating_; | 101 bool is_rotating_; |
| 76 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_; | 102 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_; |
| 77 // Only set in unittest to disable animation timers. | 103 // Only set in unittest to disable animation timers. |
| 78 bool disable_animation_timers_for_test_; | 104 bool disable_animation_timers_for_test_; |
| 79 base::ObserverList<ScreenRotationAnimatorObserver> | 105 base::ObserverList<ScreenRotationAnimatorObserver> |
| 80 screen_rotation_animator_observers_; | 106 screen_rotation_animator_observers_; |
| 81 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; | 107 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| 82 std::unique_ptr<ScreenRotationRequest> last_pending_request_; | 108 std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
| 83 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; | 109 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
| 84 | 110 |
| 85 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); | 111 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |
| 86 }; | 112 }; |
| 87 | 113 |
| 88 } // namespace ash | 114 } // namespace ash |
| 89 | 115 |
| 90 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ | 116 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ |
| OLD | NEW |