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

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

Issue 2728803002: Handles users rotating screen too early (Closed)
Patch Set: Add MultiLayerAnimatorTestController to controll test animation. Created 3 years, 9 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 #include "ash/rotator/screen_rotation_animator.h" 5 #include "ash/rotator/screen_rotation_animator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/display/window_tree_host_manager.h" 11 #include "ash/display/window_tree_host_manager.h"
12 #include "ash/rotator/screen_rotation_animation.h" 12 #include "ash/rotator/screen_rotation_animation.h"
13 #include "ash/rotator/screen_rotation_animator_observer.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
19 #include "ui/compositor/layer_animation_observer.h" 20 #include "ui/compositor/layer_animation_observer.h"
20 #include "ui/compositor/layer_animation_sequence.h" 21 #include "ui/compositor/layer_animation_sequence.h"
21 #include "ui/compositor/layer_animator.h" 22 #include "ui/compositor/layer_animator.h"
22 #include "ui/compositor/layer_owner.h" 23 #include "ui/compositor/layer_owner.h"
(...skipping 12 matching lines...) Expand all
35 namespace ash { 36 namespace ash {
36 37
37 namespace { 38 namespace {
38 39
39 // The number of degrees that the rotation animations animate through. 40 // The number of degrees that the rotation animations animate through.
40 const int kRotationDegrees = 20; 41 const int kRotationDegrees = 20;
41 42
42 // The time it takes for the rotation animations to run. 43 // The time it takes for the rotation animations to run.
43 const int kRotationDurationInMs = 250; 44 const int kRotationDurationInMs = 250;
44 45
45 // Gets the current display rotation for the display with the specified 46 // The rotation directions
46 // |display_id|. 47 const int kCounterClockWiseRotation = 1;
47 display::Display::Rotation GetCurrentRotation(int64_t display_id) { 48 const int kClockWiseRotation = -1;
49
50 // Aborts the active animations of the layer, and recurses upon its child
51 // layers.
52 void AbortAnimations(ui::Layer* layer) {
53 for (ui::Layer* child_layer : layer->children())
54 AbortAnimations(child_layer);
55 layer->GetAnimator()->AbortAllAnimations();
56 }
57
58 display::Display::Rotation GetCurrentScreenRotation(int64_t display_id) {
48 return Shell::GetInstance() 59 return Shell::GetInstance()
49 ->display_manager() 60 ->display_manager()
50 ->GetDisplayInfo(display_id) 61 ->GetDisplayInfo(display_id)
51 .GetActiveRotation(); 62 .GetActiveRotation();
52 } 63 }
53 64
65 int GetRotationFactor(display::Display::Rotation initial_rotation,
66 display::Display::Rotation new_rotation) {
67 return (initial_rotation + 3) % 4 == new_rotation ? kCounterClockWiseRotation
68 : kClockWiseRotation;
69 }
70
71 aura::Window* GetRootWindow(int64_t display_id) {
72 return Shell::GetInstance()
73 ->window_tree_host_manager()
74 ->GetRootWindowForDisplayId(display_id);
75 }
76
54 // Returns true if the rotation between |initial_rotation| and |new_rotation| is 77 // Returns true if the rotation between |initial_rotation| and |new_rotation| is
55 // 180 degrees. 78 // 180 degrees.
56 bool Is180DegreeFlip(display::Display::Rotation initial_rotation, 79 bool Is180DegreeFlip(display::Display::Rotation initial_rotation,
57 display::Display::Rotation new_rotation) { 80 display::Display::Rotation new_rotation) {
58 return (initial_rotation + 2) % 4 == new_rotation; 81 return (initial_rotation + 2) % 4 == new_rotation;
59 } 82 }
60 83
61 // A LayerAnimationObserver that will destroy the contained LayerTreeOwner when 84 // Returns the initial degrees the old layer animation to begin with.
62 // notified that a layer animation has ended or was aborted. 85 int GetInitialDegrees(display::Display::Rotation initial_rotation,
86 display::Display::Rotation new_rotation) {
87 return (Is180DegreeFlip(initial_rotation, new_rotation) ? 180 : 90);
88 }
89
90 // A LayerAnimationObserver that will destroy the contained LayerTreeOwner
91 // when notified that a layer animation has ended or was aborted.
63 class LayerCleanupObserver : public ui::LayerAnimationObserver { 92 class LayerCleanupObserver : public ui::LayerAnimationObserver {
64 public: 93 public:
65 explicit LayerCleanupObserver( 94 explicit LayerCleanupObserver(base::WeakPtr<ScreenRotationAnimator> animator);
bruthig 2017/03/15 23:12:37 Docs for accepts an |animator| and why it is a Wea
wutao 2017/03/16 07:37:59 Done.
66 std::unique_ptr<ui::LayerTreeOwner> layer_tree_owner);
67 ~LayerCleanupObserver() override; 95 ~LayerCleanupObserver() override;
68 96
69 // Get the root layer of the owned layer tree.
70 ui::Layer* GetRootLayer();
71
72 // ui::LayerAnimationObserver: 97 // ui::LayerAnimationObserver:
73 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override; 98 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override;
74 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override; 99 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override;
75 void OnLayerAnimationScheduled( 100 void OnLayerAnimationScheduled(
76 ui::LayerAnimationSequence* sequence) override {} 101 ui::LayerAnimationSequence* sequence) override {}
77 102
78 protected: 103 protected:
79 // ui::LayerAnimationObserver: 104 // ui::LayerAnimationObserver:
80 bool RequiresNotificationWhenAnimatorDestroyed() const override { 105 bool RequiresNotificationWhenAnimatorDestroyed() const override {
81 return true; 106 return true;
82 } 107 }
83 void OnAttachedToSequence(ui::LayerAnimationSequence* sequence) override; 108 void OnAttachedToSequence(ui::LayerAnimationSequence* sequence) override;
84 void OnDetachedFromSequence(ui::LayerAnimationSequence* sequence) override; 109 void OnDetachedFromSequence(ui::LayerAnimationSequence* sequence) override;
85 110
86 private: 111 private:
87 // Aborts the active animations of the layer, and recurses upon its child 112 base::WeakPtr<ScreenRotationAnimator> animator_;
88 // layers.
89 void AbortAnimations(ui::Layer* layer);
90
91 // The owned layer tree.
92 std::unique_ptr<ui::LayerTreeOwner> layer_tree_owner_;
93 113
94 // The LayerAnimationSequence that |this| has been attached to. Defaults to 114 // The LayerAnimationSequence that |this| has been attached to. Defaults to
95 // nullptr. 115 // nullptr.
96 ui::LayerAnimationSequence* sequence_; 116 ui::LayerAnimationSequence* sequence_;
97 117
98 DISALLOW_COPY_AND_ASSIGN(LayerCleanupObserver); 118 DISALLOW_COPY_AND_ASSIGN(LayerCleanupObserver);
99 }; 119 };
100 120
101 LayerCleanupObserver::LayerCleanupObserver( 121 LayerCleanupObserver::LayerCleanupObserver(
102 std::unique_ptr<ui::LayerTreeOwner> layer_tree_owner) 122 base::WeakPtr<ScreenRotationAnimator> animator)
103 : layer_tree_owner_(std::move(layer_tree_owner)), sequence_(nullptr) {} 123 : animator_(animator), sequence_(nullptr) {}
104 124
105 LayerCleanupObserver::~LayerCleanupObserver() { 125 LayerCleanupObserver::~LayerCleanupObserver() {
106 // We must eplicitly detach from |sequence_| because we return true from 126 // We must eplicitly detach from |sequence_| because we return true from
107 // RequiresNotificationWhenAnimatorDestroyed. 127 // RequiresNotificationWhenAnimatorDestroyed.
108 if (sequence_) 128 if (sequence_)
109 sequence_->RemoveObserver(this); 129 sequence_->RemoveObserver(this);
110 AbortAnimations(layer_tree_owner_->root());
111 }
112
113 ui::Layer* LayerCleanupObserver::GetRootLayer() {
114 return layer_tree_owner_->root();
115 } 130 }
116 131
117 void LayerCleanupObserver::OnLayerAnimationEnded( 132 void LayerCleanupObserver::OnLayerAnimationEnded(
118 ui::LayerAnimationSequence* sequence) { 133 ui::LayerAnimationSequence* sequence) {
134 if (animator_)
135 animator_->OnLayerAnimationEnded();
136
119 delete this; 137 delete this;
120 } 138 }
121 139
122 void LayerCleanupObserver::OnLayerAnimationAborted( 140 void LayerCleanupObserver::OnLayerAnimationAborted(
123 ui::LayerAnimationSequence* sequence) { 141 ui::LayerAnimationSequence* sequence) {
142 if (animator_)
143 animator_->OnLayerAnimationAborted();
144
124 delete this; 145 delete this;
125 } 146 }
126 147
127 void LayerCleanupObserver::OnAttachedToSequence( 148 void LayerCleanupObserver::OnAttachedToSequence(
128 ui::LayerAnimationSequence* sequence) { 149 ui::LayerAnimationSequence* sequence) {
129 sequence_ = sequence; 150 sequence_ = sequence;
130 } 151 }
131 152
132 void LayerCleanupObserver::OnDetachedFromSequence( 153 void LayerCleanupObserver::OnDetachedFromSequence(
133 ui::LayerAnimationSequence* sequence) { 154 ui::LayerAnimationSequence* sequence) {
134 DCHECK_EQ(sequence, sequence_); 155 DCHECK_EQ(sequence, sequence_);
135 sequence_ = nullptr; 156 sequence_ = nullptr;
136 } 157 }
137 158
138 void LayerCleanupObserver::AbortAnimations(ui::Layer* layer) { 159 } // namespace
139 for (ui::Layer* child_layer : layer->children())
140 AbortAnimations(child_layer);
141 layer->GetAnimator()->AbortAllAnimations();
142 }
143 160
144 // Set the screen orientation for the given |display_id| to |new_rotation| and 161 struct ScreenRotationAnimator::ScreenRotationRequest {
145 // animate the change. The animation will rotate the initial orientation's 162 display::Display::Rotation new_rotation;
146 // layer towards the new orientation through |rotation_degrees| while fading 163 display::Display::RotationSource source;
147 // out, and the new orientation's layer will be rotated in to the 164 };
148 // |new_orientation| through |rotation_degrees| arc.
149 void RotateScreen(int64_t display_id,
150 display::Display::Rotation new_rotation,
151 display::Display::RotationSource source) {
152 aura::Window* root_window = Shell::GetInstance()
153 ->window_tree_host_manager()
154 ->GetRootWindowForDisplayId(display_id);
155 165
156 const display::Display::Rotation initial_orientation = 166 ScreenRotationAnimator::ScreenRotationAnimator(int64_t display_id)
157 GetCurrentRotation(display_id); 167 : display_id_(display_id),
168 is_rotating_(false),
169 disable_animation_timers_for_test_(false),
170 screen_rotation_animator_observer_(nullptr),
171 weak_factory_(this) {}
172
173 ScreenRotationAnimator::~ScreenRotationAnimator() {}
174
175 // Set the screen orientation to |new_rotation| and animate the change. The
bruthig 2017/03/15 23:12:37 Should these docs be moved to the .h file?
wutao 2017/03/16 07:37:59 Done.
176 // animation will rotate the initial orientation's layer towards the new
177 // orientation through |rotation_degrees| while fading out, and the new
178 // orientation's layer will be rotated in to the |new_orientation| through
179 // |rotation_degrees| arc.
180 void ScreenRotationAnimator::AnimateRotation(
181 const ScreenRotationRequest& rotation_request) {
182 aura::Window* root_window = GetRootWindow(display_id_);
158 183
159 const gfx::Rect original_screen_bounds = root_window->GetTargetBounds(); 184 const gfx::Rect original_screen_bounds = root_window->GetTargetBounds();
160 // 180 degree rotations should animate clock-wise. 185 // 180 degree rotations should animate clock-wise.
161 const int rotation_factor = 186 const int rotation_factor = GetRotationFactor(
162 (initial_orientation + 3) % 4 == new_rotation ? 1 : -1; 187 GetCurrentScreenRotation(display_id_), rotation_request.new_rotation);
163 188
164 const int old_layer_initial_rotation_degrees = 189 const int old_layer_initial_rotation_degrees = GetInitialDegrees(
165 (Is180DegreeFlip(initial_orientation, new_rotation) ? 180 : 90); 190 GetCurrentScreenRotation(display_id_), rotation_request.new_rotation);
166 191
167 const base::TimeDelta duration = 192 const base::TimeDelta duration =
168 base::TimeDelta::FromMilliseconds(kRotationDurationInMs); 193 base::TimeDelta::FromMilliseconds(kRotationDurationInMs);
169 194
170 const gfx::Tween::Type tween_type = gfx::Tween::FAST_OUT_LINEAR_IN; 195 const gfx::Tween::Type tween_type = gfx::Tween::FAST_OUT_LINEAR_IN;
171 196
172 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree = 197 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree =
173 ::wm::RecreateLayers(root_window); 198 ::wm::RecreateLayers(root_window);
199 old_layer_tree->root()->set_name("ScreenRotationAnimator:old_layer_tree");
174 200
175 // Add the cloned layer tree in to the root, so it will be rendered. 201 // Add the cloned layer tree in to the root, so it will be rendered.
176 root_window->layer()->Add(old_layer_tree->root()); 202 root_window->layer()->Add(old_layer_tree->root());
177 root_window->layer()->StackAtTop(old_layer_tree->root()); 203 root_window->layer()->StackAtTop(old_layer_tree->root());
178 204
179 std::unique_ptr<LayerCleanupObserver> layer_cleanup_observer( 205 old_layer_tree_owner_.reset(old_layer_tree.release());
180 new LayerCleanupObserver(std::move(old_layer_tree))); 206 std::unique_ptr<LayerCleanupObserver> old_layer_cleanup_observer(
207 new LayerCleanupObserver(WeakPtr()));
181 208
182 Shell::GetInstance()->display_manager()->SetDisplayRotation( 209 Shell::GetInstance()->display_manager()->SetDisplayRotation(
183 display_id, new_rotation, source); 210 display_id_, rotation_request.new_rotation, rotation_request.source);
184 211
185 const gfx::Rect rotated_screen_bounds = root_window->GetTargetBounds(); 212 const gfx::Rect rotated_screen_bounds = root_window->GetTargetBounds();
186 const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2, 213 const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2,
187 rotated_screen_bounds.height() / 2); 214 rotated_screen_bounds.height() / 2);
188 215
189 // We must animate each non-cloned child layer individually because the cloned 216 // We must animate each non-cloned child layer individually because the cloned
190 // layer was added as a child to |root_window|'s layer so that it will be 217 // layer was added as a child to |root_window|'s layer so that it will be
191 // rendered. 218 // rendered.
192 // TODO(bruthig): Add a NOT_DRAWN layer in between the root_window's layer and 219 // TODO(bruthig): Add a NOT_DRAWN layer in between the root_window's layer and
193 // its current children so that we only need to initiate two 220 // its current children so that we only need to initiate two
194 // LayerAnimationSequences. One for the new layers and one for the old layer. 221 // LayerAnimationSequences. One for the new layers and one for the old layer.
195 for (ui::Layer* child_layer : root_window->layer()->children()) { 222 for (ui::Layer* child_layer : root_window->layer()->children()) {
196 // Skip the cloned layer because it has a different animation. 223 // Skip the cloned layer because it has a different animation.
197 if (child_layer == layer_cleanup_observer->GetRootLayer()) 224 if (child_layer == GetOldLayerTreeRootLayer())
198 continue; 225 continue;
199 226
200 std::unique_ptr<ScreenRotationAnimation> screen_rotation = 227 std::unique_ptr<ScreenRotationAnimation> screen_rotation =
201 base::MakeUnique<ScreenRotationAnimation>( 228 base::MakeUnique<ScreenRotationAnimation>(
202 child_layer, kRotationDegrees * rotation_factor, 229 child_layer, kRotationDegrees * rotation_factor,
203 0 /* end_degrees */, child_layer->opacity(), 230 0 /* end_degrees */, child_layer->opacity(),
204 1.0f /* target_opacity */, pivot, duration, tween_type); 231 1.0f /* target_opacity */, pivot, duration, tween_type);
205 232
206 ui::LayerAnimator* animator = child_layer->GetAnimator(); 233 ui::LayerAnimator* animator = child_layer->GetAnimator();
207 animator->set_preemption_strategy( 234 animator->set_preemption_strategy(
208 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 235 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
209 std::unique_ptr<ui::LayerAnimationSequence> animation_sequence = 236 std::unique_ptr<ui::LayerAnimationSequence> animation_sequence =
210 base::MakeUnique<ui::LayerAnimationSequence>( 237 base::MakeUnique<ui::LayerAnimationSequence>(
211 std::move(screen_rotation)); 238 std::move(screen_rotation));
212 animator->StartAnimation(animation_sequence.release()); 239 animator->StartAnimation(animation_sequence.release());
213 } 240 }
214 241
215 // The old layer will also be transformed into the new orientation. We will 242 // The old layer will also be transformed into the new orientation. We will
216 // translate it so that the old layer's center point aligns with the new 243 // translate it so that the old layer's center point aligns with the new
217 // orientation's center point and use that center point as the pivot for the 244 // orientation's center point and use that center point as the pivot for the
218 // rotation animation. 245 // rotation animation.
219 gfx::Transform translate_transform; 246 gfx::Transform translate_transform;
220 translate_transform.Translate( 247 translate_transform.Translate(
221 (rotated_screen_bounds.width() - original_screen_bounds.width()) / 2, 248 (rotated_screen_bounds.width() - original_screen_bounds.width()) / 2,
222 (rotated_screen_bounds.height() - original_screen_bounds.height()) / 2); 249 (rotated_screen_bounds.height() - original_screen_bounds.height()) / 2);
223 layer_cleanup_observer->GetRootLayer()->SetTransform(translate_transform); 250 GetOldLayerTreeRootLayer()->SetTransform(translate_transform);
224 251
225 std::unique_ptr<ScreenRotationAnimation> screen_rotation = 252 std::unique_ptr<ScreenRotationAnimation> screen_rotation =
226 base::MakeUnique<ScreenRotationAnimation>( 253 base::MakeUnique<ScreenRotationAnimation>(
227 layer_cleanup_observer->GetRootLayer(), 254 GetOldLayerTreeRootLayer(),
228 old_layer_initial_rotation_degrees * rotation_factor, 255 old_layer_initial_rotation_degrees * rotation_factor,
229 (old_layer_initial_rotation_degrees - kRotationDegrees) * 256 (old_layer_initial_rotation_degrees - kRotationDegrees) *
230 rotation_factor, 257 rotation_factor,
231 layer_cleanup_observer->GetRootLayer()->opacity(), 258 GetOldLayerTreeRootLayer()->opacity(), 0.0f /* target_opacity */,
232 0.0f /* target_opacity */, pivot, duration, tween_type); 259 pivot, duration, tween_type);
233 260
234 ui::LayerAnimator* animator = 261 ui::LayerAnimator* animator = GetOldLayerTreeRootLayer()->GetAnimator();
235 layer_cleanup_observer->GetRootLayer()->GetAnimator();
236 animator->set_preemption_strategy( 262 animator->set_preemption_strategy(
237 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 263 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
238 std::unique_ptr<ui::LayerAnimationSequence> animation_sequence = 264 std::unique_ptr<ui::LayerAnimationSequence> animation_sequence =
239 base::MakeUnique<ui::LayerAnimationSequence>(std::move(screen_rotation)); 265 base::MakeUnique<ui::LayerAnimationSequence>(std::move(screen_rotation));
240 // Add an observer so that the cloned layers can be cleaned up with the 266 // Add an observer so that the cloned layers can be cleaned up with the
241 // animation completes/aborts. 267 // animation completes/aborts.
242 animation_sequence->AddObserver(layer_cleanup_observer.release()); 268 animation_sequence->AddObserver(old_layer_cleanup_observer.release());
269 // In unit test, we can use ui::test::MultiLayerAnimatorTestController to
270 // controll the animation.
bruthig 2017/03/15 23:12:37 nit: 'controll' -> 'control'
wutao 2017/03/16 07:37:59 Done.
271 if (disable_animation_timers_for_test_)
272 animator->set_disable_timer_for_test(true);
243 animator->StartAnimation(animation_sequence.release()); 273 animator->StartAnimation(animation_sequence.release());
244 } 274 }
245 275
246 } // namespace
247
248 ScreenRotationAnimator::ScreenRotationAnimator(int64_t display_id)
249 : display_id_(display_id) {}
250
251 ScreenRotationAnimator::~ScreenRotationAnimator() {}
252
253 bool ScreenRotationAnimator::CanAnimate() const {
254 return Shell::GetInstance()
255 ->display_manager()
256 ->GetDisplayForId(display_id_)
257 .is_valid();
258 }
259
260 void ScreenRotationAnimator::Rotate(display::Display::Rotation new_rotation, 276 void ScreenRotationAnimator::Rotate(display::Display::Rotation new_rotation,
261 display::Display::RotationSource source) { 277 display::Display::RotationSource source) {
262 const display::Display::Rotation current_rotation = 278 if (GetCurrentScreenRotation(display_id_) == new_rotation)
263 GetCurrentRotation(display_id_);
264
265 if (current_rotation == new_rotation)
266 return; 279 return;
267 280
268 RotateScreen(display_id_, new_rotation, source); 281 std::unique_ptr<ScreenRotationRequest> rotation_request =
282 base::MakeUnique<ScreenRotationRequest>();
283 rotation_request->new_rotation = new_rotation;
284 rotation_request->source = source;
285
286 if (is_rotating_) {
287 last_pending_request_.reset(rotation_request.release());
288 StopAnimating();
bruthig 2017/03/15 23:12:37 nit: A comment here explaining that the queue will
wutao 2017/03/16 07:37:59 Done.
289 } else {
290 last_pending_request_.reset();
291 is_rotating_ = true;
292 AnimateRotation(*rotation_request);
293 rotation_request.reset();
294 }
295 }
296
297 void ScreenRotationAnimator::OnLayerAnimationEnded() {
298 ProcessAnimationQueue();
299 }
300
301 void ScreenRotationAnimator::OnLayerAnimationAborted() {
302 AbortAnimations(old_layer_tree_owner_->root());
303 ProcessAnimationQueue();
304 }
305
306 base::WeakPtr<ScreenRotationAnimator> ScreenRotationAnimator::WeakPtr() {
307 return weak_factory_.GetWeakPtr();
308 }
309
310 ui::Layer* ScreenRotationAnimator::GetOldLayerTreeRootLayer() {
311 if (old_layer_tree_owner_) {
312 return old_layer_tree_owner_->root();
313 } else {
314 NOTREACHED();
315 return nullptr;
316 }
317 }
318
319 void ScreenRotationAnimator::ProcessAnimationQueue() {
320 is_rotating_ = false;
321 old_layer_tree_owner_.reset();
322 if (last_pending_request_)
323 Rotate(last_pending_request_->new_rotation, last_pending_request_->source);
bruthig 2017/03/15 23:12:37 Can we pop the request off the queue here or does
wutao 2017/03/16 07:37:59 We might. We can make a copy and reset the last_pe
bruthig 2017/03/16 20:41:57 I think it would be easier to follow if you pop it
324
325 if (screen_rotation_animator_observer_) {
326 screen_rotation_animator_observer_->OnEndedOrAbortedScreenRotationAnimation(
327 this);
328 }
329 }
330
331 void ScreenRotationAnimator::set_disable_animation_timers_for_test(
332 bool disable_timers) {
333 disable_animation_timers_for_test_ = disable_timers;
334 }
335
336 void ScreenRotationAnimator::StopAnimating() {
337 aura::Window* root_window = GetRootWindow(display_id_);
338 for (ui::Layer* child_layer : root_window->layer()->children()) {
339 if (child_layer == old_layer_tree_owner_->root())
340 continue;
341
342 child_layer->GetAnimator()->StopAnimating();
343 }
344
345 old_layer_tree_owner_->root()->GetAnimator()->StopAnimating();
269 } 346 }
270 347
271 } // namespace ash 348 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698