OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE: | 242 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE: |
243 AnimateHideWindow_BrightnessGrayscale(window); | 243 AnimateHideWindow_BrightnessGrayscale(window); |
244 return true; | 244 return true; |
245 default: | 245 default: |
246 NOTREACHED(); | 246 NOTREACHED(); |
247 return false; | 247 return false; |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 // Observer for a window cross-fade animation. If either the window closes or | 251 // Observer for a window cross-fade animation. If either the window closes or |
252 // the layer's animation completes or compositing is aborted due to GPU crash, | 252 // the layer's animation completes, it deletes the layer and removes itself as |
253 // it deletes the layer and removes itself as an observer. | 253 // an observer. |
254 class CrossFadeObserver : public ui::CompositorObserver, | 254 class CrossFadeObserver : public ui::CompositorObserver, |
255 public aura::WindowObserver, | 255 public aura::WindowObserver, |
256 public ui::ImplicitAnimationObserver { | 256 public ui::ImplicitAnimationObserver { |
257 public: | 257 public: |
258 // Observes |window| for destruction, but does not take ownership. | 258 // Observes |window| for destruction, but does not take ownership. |
259 // Takes ownership of |layer| and its child layers. | 259 // Takes ownership of |layer| and its child layers. |
260 CrossFadeObserver(aura::Window* window, | 260 CrossFadeObserver(aura::Window* window, |
261 std::unique_ptr<ui::LayerTreeOwner> layer_owner) | 261 std::unique_ptr<ui::LayerTreeOwner> layer_owner) |
262 : window_(window), layer_owner_(std::move(layer_owner)) { | 262 : window_(window), layer_owner_(std::move(layer_owner)) { |
263 window_->AddObserver(this); | 263 window_->AddObserver(this); |
264 layer_owner_->root()->GetCompositor()->AddObserver(this); | 264 layer_owner_->root()->GetCompositor()->AddObserver(this); |
265 } | 265 } |
266 ~CrossFadeObserver() override { | 266 ~CrossFadeObserver() override { |
267 window_->RemoveObserver(this); | 267 window_->RemoveObserver(this); |
268 window_ = NULL; | 268 window_ = NULL; |
269 layer_owner_->root()->GetCompositor()->RemoveObserver(this); | 269 layer_owner_->root()->GetCompositor()->RemoveObserver(this); |
270 } | 270 } |
271 | 271 |
272 // ui::CompositorObserver overrides: | 272 // ui::CompositorObserver overrides: |
273 void OnCompositingDidCommit(ui::Compositor* compositor) override {} | 273 void OnCompositingDidCommit(ui::Compositor* compositor) override {} |
274 void OnCompositingStarted(ui::Compositor* compositor, | 274 void OnCompositingStarted(ui::Compositor* compositor, |
275 base::TimeTicks start_time) override {} | 275 base::TimeTicks start_time) override {} |
276 void OnCompositingEnded(ui::Compositor* compositor) override {} | 276 void OnCompositingEnded(ui::Compositor* compositor) override {} |
277 void OnCompositingAborted(ui::Compositor* compositor) override { | |
278 // Triggers OnImplicitAnimationsCompleted() to be called and deletes us. | |
279 layer_owner_->root()->GetAnimator()->StopAnimating(); | |
280 } | |
281 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} | 277 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
282 void OnCompositingShuttingDown(ui::Compositor* compositor) override {} | 278 void OnCompositingShuttingDown(ui::Compositor* compositor) override {} |
oshima
2016/10/21 23:33:25
nit: looks like we can remove CompositorObserver f
danakj
2016/10/21 23:37:42
Agreed! Done.
| |
283 | 279 |
284 // aura::WindowObserver overrides: | 280 // aura::WindowObserver overrides: |
285 void OnWindowDestroying(aura::Window* window) override { | 281 void OnWindowDestroying(aura::Window* window) override { |
286 // Triggers OnImplicitAnimationsCompleted() to be called and deletes us. | 282 // Triggers OnImplicitAnimationsCompleted() to be called and deletes us. |
287 layer_owner_->root()->GetAnimator()->StopAnimating(); | 283 layer_owner_->root()->GetAnimator()->StopAnimating(); |
288 } | 284 } |
289 void OnWindowRemovingFromRootWindow(aura::Window* window, | 285 void OnWindowRemovingFromRootWindow(aura::Window* window, |
290 aura::Window* new_root) override { | 286 aura::Window* new_root) override { |
291 layer_owner_->root()->GetAnimator()->StopAnimating(); | 287 layer_owner_->root()->GetAnimator()->StopAnimating(); |
292 } | 288 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 case SHELF_ALIGNMENT_LEFT: | 462 case SHELF_ALIGNMENT_LEFT: |
467 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); | 463 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); |
468 case SHELF_ALIGNMENT_RIGHT: | 464 case SHELF_ALIGNMENT_RIGHT: |
469 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); | 465 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); |
470 } | 466 } |
471 NOTREACHED(); | 467 NOTREACHED(); |
472 return gfx::Rect(); | 468 return gfx::Rect(); |
473 } | 469 } |
474 | 470 |
475 } // namespace ash | 471 } // namespace ash |
OLD | NEW |