Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: ash/rotator/screen_rotation_animator.h

Issue 2837773003: Flip the flag to enable smooth screen rotation by default. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 void AddScreenRotationAnimatorObserver( 59 void AddScreenRotationAnimatorObserver(
60 ScreenRotationAnimatorObserver* observer); 60 ScreenRotationAnimatorObserver* observer);
61 void RemoveScreenRotationAnimatorObserver( 61 void RemoveScreenRotationAnimatorObserver(
62 ScreenRotationAnimatorObserver* observer); 62 ScreenRotationAnimatorObserver* observer);
63 63
64 // When screen rotation animation is ended or aborted, calls |Rotate()| with 64 // When screen rotation animation is ended or aborted, calls |Rotate()| with
65 // the pending rotation request if the request queue is not empty. Otherwise 65 // the pending rotation request if the request queue is not empty. Otherwise
66 // notifies |screen_rotation_animator_observer_|. 66 // notifies |screen_rotation_animator_observer_|.
67 void ProcessAnimationQueue(); 67 void ProcessAnimationQueue();
68 68
69 bool CanAnimate() const { return enable_animation_; }
70
69 protected: 71 protected:
70 using CopyCallback = 72 using CopyCallback =
71 base::Callback<void(std::unique_ptr<cc::CopyOutputResult> result)>; 73 base::Callback<void(std::unique_ptr<cc::CopyOutputResult> result)>;
72 struct ScreenRotationRequest { 74 struct ScreenRotationRequest {
73 ScreenRotationRequest(int64_t id, 75 ScreenRotationRequest(int64_t id,
74 display::Display::Rotation to_rotation, 76 display::Display::Rotation to_rotation,
75 display::Display::RotationSource from_source) 77 display::Display::RotationSource from_source)
76 : id(id), new_rotation(to_rotation), source(from_source) {} 78 : id(id), new_rotation(to_rotation), source(from_source) {}
77 int64_t id; 79 int64_t id;
78 display::Display::Rotation old_rotation; 80 display::Display::Rotation old_rotation;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // animation will rotate the initial orientation's layer towards the new 143 // animation will rotate the initial orientation's layer towards the new
142 // orientation through |rotation_degrees| while fading out, and the new 144 // orientation through |rotation_degrees| while fading out, and the new
143 // orientation's layer will be rotated in to the |new_orientation| through 145 // orientation's layer will be rotated in to the |new_orientation| through
144 // |rotation_degrees| arc. 146 // |rotation_degrees| arc.
145 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); 147 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request);
146 148
147 void set_disable_animation_timers_for_test(bool disable_timers) { 149 void set_disable_animation_timers_for_test(bool disable_timers) {
148 disable_animation_timers_for_test_ = disable_timers; 150 disable_animation_timers_for_test_ = disable_timers;
149 } 151 }
150 152
153 void set_enable_animation_for_test(bool enable_animation) {
154 enable_animation_ = enable_animation;
155 }
156
151 void StopAnimating(); 157 void StopAnimating();
152 158
153 // The id of the display to rotate. 159 // The id of the display to rotate.
154 int64_t display_id_; 160 int64_t display_id_;
155 161
156 // For current slow rotation animation, there are two states |ROTATING| and 162 // For current slow rotation animation, there are two states |ROTATING| and
157 // |IDLE|. For the smooth rotation animation, we need to send copy request 163 // |IDLE|. For the smooth rotation animation, we need to send copy request
158 // and get copy result before animating. 164 // and get copy result before animating.
159 enum ScreenRotationState { 165 enum ScreenRotationState {
160 COPY_REQUESTED, 166 COPY_REQUESTED,
161 ROTATING, 167 ROTATING,
162 IDLE, 168 IDLE,
163 }; 169 };
164 ScreenRotationState screen_rotation_state_; 170 ScreenRotationState screen_rotation_state_;
165 171
166 // Rotation request id, used to ignore copy request callback if we decide to 172 // Rotation request id, used to ignore copy request callback if we decide to
167 // cancel the previous rotation request. 173 // cancel the previous rotation request.
168 int64_t rotation_request_id_; 174 int64_t rotation_request_id_;
169 175
170 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_; 176 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_;
171 // Only set in unittest to disable animation timers. 177 // Only set in unittest to disable animation timers.
172 bool disable_animation_timers_for_test_; 178 bool disable_animation_timers_for_test_;
179 // Enables or disables animation.
180 bool enable_animation_;
173 base::ObserverList<ScreenRotationAnimatorObserver> 181 base::ObserverList<ScreenRotationAnimatorObserver>
174 screen_rotation_animator_observers_; 182 screen_rotation_animator_observers_;
175 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; 183 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_;
176 std::unique_ptr<ui::LayerTreeOwner> new_layer_tree_owner_; 184 std::unique_ptr<ui::LayerTreeOwner> new_layer_tree_owner_;
177 std::unique_ptr<ui::LayerOwner> black_mask_layer_owner_; 185 std::unique_ptr<ui::LayerOwner> black_mask_layer_owner_;
178 std::unique_ptr<ScreenRotationRequest> last_pending_request_; 186 std::unique_ptr<ScreenRotationRequest> last_pending_request_;
179 bool has_switch_ash_enable_smooth_screen_rotation_; 187 bool has_switch_ash_disable_smooth_screen_rotation_;
180 aura::Window* root_window_; 188 aura::Window* root_window_;
181 ui::Layer* screen_rotation_container_layer_; 189 ui::Layer* screen_rotation_container_layer_;
182 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; 190 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_;
183 191
184 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); 192 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator);
185 }; 193 };
186 194
187 } // namespace ash 195 } // namespace ash
188 196
189 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ 197 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698