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

Side by Side Diff: ash/wm/window_animations.cc

Issue 10911172: Changes launcher so that when animating hidden the background doesn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_animations.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 public: 623 public:
624 // Observes |window| for destruction, but does not take ownership. 624 // Observes |window| for destruction, but does not take ownership.
625 // Takes ownership of |layer| and its child layers. 625 // Takes ownership of |layer| and its child layers.
626 CrossFadeObserver(Window* window, Layer* layer) 626 CrossFadeObserver(Window* window, Layer* layer)
627 : window_(window), 627 : window_(window),
628 layer_(layer) { 628 layer_(layer) {
629 window_->AddObserver(this); 629 window_->AddObserver(this);
630 layer_->GetCompositor()->AddObserver(this); 630 layer_->GetCompositor()->AddObserver(this);
631 } 631 }
632 virtual ~CrossFadeObserver() { 632 virtual ~CrossFadeObserver() {
633 Cleanup(); 633 window_->RemoveObserver(this);
634 window_ = NULL;
635 layer_->GetCompositor()->RemoveObserver(this);
636 wm::DeepDeleteLayers(layer_);
637 layer_ = NULL;
634 } 638 }
635 639
636 // ui::CompositorObserver overrides: 640 // ui::CompositorObserver overrides:
637 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE { 641 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE {
638 } 642 }
639 virtual void OnCompositingWillStart(ui::Compositor* compositor) OVERRIDE { 643 virtual void OnCompositingWillStart(ui::Compositor* compositor) OVERRIDE {
640 } 644 }
641 virtual void OnCompositingStarted(ui::Compositor* compositor) OVERRIDE { 645 virtual void OnCompositingStarted(ui::Compositor* compositor) OVERRIDE {
642 } 646 }
643 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE { 647 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE {
644 } 648 }
645 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE { 649 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE {
646 // Something went wrong with compositing and our layers are now invalid. 650 // Triggers OnImplicitAnimationsCompleted() to be called and deletes us.
647 if (layer_) 651 layer_->GetAnimator()->StopAnimating();
648 layer_->GetAnimator()->StopAnimating();
649 // Delete is scheduled in OnImplicitAnimationsCompleted().
650 Cleanup();
651 } 652 }
652 653
653 // aura::WindowObserver overrides: 654 // aura::WindowObserver overrides:
654 virtual void OnWindowDestroying(Window* window) OVERRIDE { 655 virtual void OnWindowDestroying(Window* window) OVERRIDE {
655 if (layer_) 656 // Triggers OnImplicitAnimationsCompleted() to be called and deletes us.
656 layer_->GetAnimator()->StopAnimating(); 657 layer_->GetAnimator()->StopAnimating();
657 // Delete is scheduled in OnImplicitAnimationsCompleted().
658 Cleanup();
659 } 658 }
660 659
661 // ui::ImplicitAnimationObserver overrides: 660 // ui::ImplicitAnimationObserver overrides:
662 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 661 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
663 delete this; 662 delete this;
664 } 663 }
665 664
666 private: 665 private:
667 // Can be called multiple times if the window is closed or the compositor
668 // fails in the middle of the animation.
669 void Cleanup() {
670 if (window_) {
671 window_->RemoveObserver(this);
672 window_ = NULL;
673 }
674 if (layer_) {
675 layer_->GetCompositor()->RemoveObserver(this);
676 wm::DeepDeleteLayers(layer_);
677 layer_ = NULL;
678 }
679 }
680
681 Window* window_; // not owned 666 Window* window_; // not owned
682 Layer* layer_; // owned 667 Layer* layer_; // owned
683 668
684 DISALLOW_COPY_AND_ASSIGN(CrossFadeObserver); 669 DISALLOW_COPY_AND_ASSIGN(CrossFadeObserver);
685 }; 670 };
686 671
687 } // namespace 672 } // namespace
688 } // namespace internal 673 } // namespace internal
689 674
690 namespace { 675 namespace {
691 676
677 // Duration of cross fades when workspace2 is enabled.
678 const int kWorkspaceCrossFadeDurationMs = 333;
679
680 // Scales for workspaces above/below current workspace.
681 const float kWorkspaceScaleAbove = 1.1f;
682 const float kWorkspaceScaleBelow = .9f;
683
692 // TODO: leaving in for now since Nicholas wants to play with this, remove if we 684 // TODO: leaving in for now since Nicholas wants to play with this, remove if we
693 // leave it at 0. 685 // leave it at 0.
694 const int kPauseTimeMS = 0; 686 const int kPauseTimeMS = 0;
695 687
696 // Duration of cross fades when workspace2 is enabled. 688 } // namespace
697 const int kWorkspaceCrossFadeDurationMs = 333;
698 689
699 // Amount of time for animating a workspace in or out. 690 // Amount of time for animating a workspace in or out.
700 const int kWorkspaceSwitchTimeMS = 333 + kPauseTimeMS; 691 const int kWorkspaceSwitchTimeMS = 333 + kPauseTimeMS;
701 692
702 // Scales for workspaces above/below current workspace. 693 namespace {
703 const float kWorkspaceScaleAbove = 1.1f;
704 const float kWorkspaceScaleBelow = .9f;
705 694
706 enum WorkspaceScaleType { 695 enum WorkspaceScaleType {
707 WORKSPACE_SCALE_ABOVE, 696 WORKSPACE_SCALE_ABOVE,
708 WORKSPACE_SCALE_BELOW, 697 WORKSPACE_SCALE_BELOW,
709 }; 698 };
710 699
711 void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) { 700 void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) {
712 const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove : 701 const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove :
713 kWorkspaceScaleBelow; 702 kWorkspaceScaleBelow;
714 ui::Transform transform; 703 ui::Transform transform;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 return AnimateShowWindow(window); 1036 return AnimateShowWindow(window);
1048 } else { 1037 } else {
1049 // Don't start hiding the window again if it's already being hidden. 1038 // Don't start hiding the window again if it's already being hidden.
1050 return window->layer()->GetTargetOpacity() != 0.0f && 1039 return window->layer()->GetTargetOpacity() != 0.0f &&
1051 AnimateHideWindow(window); 1040 AnimateHideWindow(window);
1052 } 1041 }
1053 } 1042 }
1054 1043
1055 } // namespace internal 1044 } // namespace internal
1056 } // namespace ash 1045 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698