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 "cc/output/copy_output_request.h" |
14 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
15 | 16 |
| 17 namespace cc { |
| 18 class CopyOutputResult; |
| 19 } // namespace cc |
| 20 |
16 namespace ui { | 21 namespace ui { |
17 class AnimationMetricsReporter; | 22 class AnimationMetricsReporter; |
| 23 class CallbackLayerAnimationObserver; |
18 class Layer; | 24 class Layer; |
19 class LayerTreeOwner; | 25 class LayerTreeOwner; |
20 } // namespace ui | 26 } // namespace ui |
21 | 27 |
22 namespace ash { | 28 namespace ash { |
23 namespace test { | 29 namespace test { |
24 class ScreenRotationAnimatorTestApi; | 30 class ScreenRotationAnimatorTestApi; |
25 } // namespace test | 31 } // namespace test |
26 | 32 |
27 class ScreenRotationAnimatorObserver; | 33 class ScreenRotationAnimatorObserver; |
(...skipping 24 matching lines...) Expand all Loading... |
52 | 58 |
53 // When screen rotation animation is ended or aborted, calls |Rotate()| with | 59 // When screen rotation animation is ended or aborted, calls |Rotate()| with |
54 // the pending rotation request if the request queue is not empty. Otherwise | 60 // the pending rotation request if the request queue is not empty. Otherwise |
55 // notifies |screen_rotation_animator_observer_|. | 61 // notifies |screen_rotation_animator_observer_|. |
56 void ProcessAnimationQueue(); | 62 void ProcessAnimationQueue(); |
57 | 63 |
58 private: | 64 private: |
59 friend class ash::test::ScreenRotationAnimatorTestApi; | 65 friend class ash::test::ScreenRotationAnimatorTestApi; |
60 struct ScreenRotationRequest; | 66 struct ScreenRotationRequest; |
61 | 67 |
62 // Set the screen orientation to |new_rotation| and animate the change. The | 68 void StartRotationAnimation( |
| 69 std::unique_ptr<ScreenRotationRequest> rotation_request); |
| 70 |
| 71 // The fallback plan if copy output request failed, such as the request is |
| 72 // canceled. |
| 73 void StartSlowAnimation( |
| 74 std::unique_ptr<ScreenRotationRequest> rotation_request); |
| 75 |
| 76 // This is an asynchronous call to request copy output of root layer. |
| 77 void RequestCopyRootLayerByName( |
| 78 const std::string& layer_name, |
| 79 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback); |
| 80 |
| 81 // The callback for the first CopyOutputRequest before screen rotation. |
| 82 void OnRootLayerCopiedBeforeRotation( |
| 83 std::unique_ptr<ScreenRotationRequest> rotation_request, |
| 84 std::unique_ptr<cc::CopyOutputResult> result); |
| 85 |
| 86 // The callback for the second CopyOutputRequest after screen rotation. |
| 87 void OnRootLayerCopiedAfterRotation( |
| 88 std::unique_ptr<ScreenRotationRequest> rotation_request, |
| 89 std::unique_ptr<cc::CopyOutputResult> result); |
| 90 |
| 91 // Recreates all |root_window| layers. |
| 92 void CreateOldLayerTree(); |
| 93 |
| 94 // Creates a copy layer from cc::CopyOutputResult |result|. |
| 95 std::unique_ptr<ui::LayerTreeOwner> CopyLayerTree( |
| 96 const std::string& layer_name, |
| 97 std::unique_ptr<cc::CopyOutputResult> result); |
| 98 |
| 99 void SetRotation(const display::Display::Rotation& new_rotation, |
| 100 const display::Display::Rotation& old_rotation, |
| 101 const display::Display::RotationSource& source); |
| 102 |
| 103 // Sets the screen orientation to |new_rotation| and animate the change. The |
63 // animation will rotate the initial orientation's layer towards the new | 104 // animation will rotate the initial orientation's layer towards the new |
64 // orientation through |rotation_degrees| while fading out, and the new | 105 // orientation through |rotation_degrees| while fading out, and the new |
65 // orientation's layer will be rotated in to the |new_orientation| through | 106 // orientation's layer will be rotated in to the |new_orientation| through |
66 // |rotation_degrees| arc. | 107 // |rotation_degrees| arc. |
67 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); | 108 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); |
68 | 109 |
69 void set_disable_animation_timers_for_test(bool disable_timers); | 110 void set_disable_animation_timers_for_test(bool disable_timers); |
70 | 111 |
71 void StopAnimating(); | 112 void StopAnimating(); |
72 | 113 |
73 // The id of the display to rotate. | 114 // The id of the display to rotate. |
74 int64_t display_id_; | 115 int64_t display_id_; |
75 bool is_rotating_; | 116 bool is_rotating_; |
76 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_; | 117 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_; |
77 // Only set in unittest to disable animation timers. | 118 // Only set in unittest to disable animation timers. |
78 bool disable_animation_timers_for_test_; | 119 bool disable_animation_timers_for_test_; |
79 base::ObserverList<ScreenRotationAnimatorObserver> | 120 base::ObserverList<ScreenRotationAnimatorObserver> |
80 screen_rotation_animator_observers_; | 121 screen_rotation_animator_observers_; |
81 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; | 122 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; |
| 123 std::unique_ptr<ui::LayerTreeOwner> new_layer_tree_owner_; |
82 std::unique_ptr<ScreenRotationRequest> last_pending_request_; | 124 std::unique_ptr<ScreenRotationRequest> last_pending_request_; |
83 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; | 125 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; |
84 | 126 |
85 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); | 127 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); |
86 }; | 128 }; |
87 | 129 |
88 } // namespace ash | 130 } // namespace ash |
89 | 131 |
90 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ | 132 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ |
OLD | NEW |