Chromium Code Reviews| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 void Rotate(display::Display::Rotation new_rotation, | 42 void Rotate(display::Display::Rotation new_rotation, |
| 43 display::Display::RotationSource source); | 43 display::Display::RotationSource source); |
| 44 | 44 |
| 45 int64_t display_id() const { return display_id_; } | 45 int64_t display_id() const { return display_id_; } |
| 46 | 46 |
| 47 void AddScreenRotationAnimatorObserver( | 47 void AddScreenRotationAnimatorObserver( |
| 48 ScreenRotationAnimatorObserver* observer); | 48 ScreenRotationAnimatorObserver* observer); |
| 49 void RemoveScreenRotationAnimatorObserver( | 49 void RemoveScreenRotationAnimatorObserver( |
| 50 ScreenRotationAnimatorObserver* observer); | 50 ScreenRotationAnimatorObserver* observer); |
| 51 | 51 |
| 52 void OnLayerAnimationEnded(); | 52 // When screen rotation animation is ended or aborted, calls |Rotate()| with |
| 53 | 53 // the pending rotation request if the request queue is not empty. Otherwise |
| 54 void OnLayerAnimationAborted(); | 54 // notifies |screen_rotation_animator_observer_|. |
| 55 void ProcessAnimationQueue(); | |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 friend class ash::test::ScreenRotationAnimatorTestApi; | 58 friend class ash::test::ScreenRotationAnimatorTestApi; |
| 58 struct ScreenRotationRequest; | 59 struct ScreenRotationRequest; |
| 60 class ScreenRotationAnimationMetricsReporter; | |
| 59 | 61 |
| 60 // Set the screen orientation to |new_rotation| and animate the change. The | 62 // Set the screen orientation to |new_rotation| and animate the change. The |
| 61 // animation will rotate the initial orientation's layer towards the new | 63 // animation will rotate the initial orientation's layer towards the new |
| 62 // orientation through |rotation_degrees| while fading out, and the new | 64 // orientation through |rotation_degrees| while fading out, and the new |
| 63 // orientation's layer will be rotated in to the |new_orientation| through | 65 // orientation's layer will be rotated in to the |new_orientation| through |
| 64 // |rotation_degrees| arc. | 66 // |rotation_degrees| arc. |
| 65 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); | 67 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); |
| 66 | 68 |
| 67 // When screen rotation animation is ended or aborted, if the request queue is | |
| 68 // not empty, it will call |Rotate()| with the pending rotation request. | |
| 69 // Otherwise it will notify |screen_rotation_animator_observer_|. | |
| 70 void ProcessAnimationQueue(); | |
| 71 | |
| 72 void set_disable_animation_timers_for_test(bool disable_timers); | 69 void set_disable_animation_timers_for_test(bool disable_timers); |
| 73 | 70 |
| 74 void StopAnimating(); | 71 void StopAnimating(); |
| 75 | 72 |
| 76 // The id of the display to rotate. | 73 // The id of the display to rotate. |
| 77 int64_t display_id_; | 74 int64_t display_id_; |
| 78 bool is_rotating_; | 75 bool is_rotating_; |
| 76 std::unique_ptr<ScreenRotationAnimationMetricsReporter> metrics_reporter_; | |
|
oshima
2017/03/24 22:46:00
nit: you can just use ui::AnimationMetricsReporter
wutao
2017/03/24 23:50:55
Good suggestion. Done and Thanks.
| |
| 79 // Only set in unittest to disable animation timers. | 77 // Only set in unittest to disable animation timers. |
| 80 bool disable_animation_timers_for_test_; | 78 bool disable_animation_timers_for_test_; |
| 81 base::ObserverList<ScreenRotationAnimatorObserver> | 79 base::ObserverList<ScreenRotationAnimatorObserver> |
| 82 screen_rotation_animator_observers_; | 80 screen_rotation_animator_observers_; |
| 83 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; | 81 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| 84 std::unique_ptr<ScreenRotationRequest> last_pending_request_; | 82 std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
| 85 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; | 83 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
| 86 | 84 |
| 87 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); | 85 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |
| 88 }; | 86 }; |
| 89 | 87 |
| 90 } // namespace ash | 88 } // namespace ash |
| 91 | 89 |
| 92 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ | 90 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ |
| OLD | NEW |