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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 window_->AddObserver(this); | 142 window_->AddObserver(this); |
143 } | 143 } |
144 virtual ~HidingWindowAnimationObserver() { | 144 virtual ~HidingWindowAnimationObserver() { |
145 STLDeleteElements(&layers_); | 145 STLDeleteElements(&layers_); |
146 } | 146 } |
147 | 147 |
148 private: | 148 private: |
149 // Overridden from ui::ImplicitAnimationObserver: | 149 // Overridden from ui::ImplicitAnimationObserver: |
150 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 150 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
151 // Window may have been destroyed by this point. | 151 // Window may have been destroyed by this point. |
152 if (window_) | 152 if (window_) { |
153 window_->layer()->SetVisible(false); | |
sky
2012/08/10 15:47:39
If you do this then the TargetVisibility is true a
alexst (slow to review)
2012/08/10 17:50:55
Ah, this was the wrong solution to a real problem.
| |
153 window_->RemoveObserver(this); | 154 window_->RemoveObserver(this); |
155 } | |
154 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 156 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
155 } | 157 } |
156 | 158 |
157 // Overridden from aura::WindowObserver: | 159 // Overridden from aura::WindowObserver: |
158 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 160 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { |
159 DCHECK_EQ(window, window_); | 161 DCHECK_EQ(window, window_); |
160 DCHECK(layers_.empty()); | 162 DCHECK(layers_.empty()); |
161 AcquireAllLayers(window_); | 163 AcquireAllLayers(window_); |
162 | 164 |
163 // If the Widget has views with layers, then it is necessary to take | 165 // If the Widget has views with layers, then it is necessary to take |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 scoped_ptr<ui::LayerAnimationElement> transition( | 442 scoped_ptr<ui::LayerAnimationElement> transition( |
441 ui::LayerAnimationElement::CreateInterpolatedTransformElement( | 443 ui::LayerAnimationElement::CreateInterpolatedTransformElement( |
442 rotation_about_pivot.release(), duration)); | 444 rotation_about_pivot.release(), duration)); |
443 | 445 |
444 transition->set_tween_type( | 446 transition->set_tween_type( |
445 show ? ui::Tween::EASE_IN : ui::Tween::EASE_IN_OUT); | 447 show ? ui::Tween::EASE_IN : ui::Tween::EASE_IN_OUT); |
446 | 448 |
447 window->layer()->GetAnimator()->ScheduleAnimation( | 449 window->layer()->GetAnimator()->ScheduleAnimation( |
448 new ui::LayerAnimationSequence(transition.release())); | 450 new ui::LayerAnimationSequence(transition.release())); |
449 | 451 |
452 // When hiding a window, turn off blending until the animation is | |
453 // 3 / 4 done to save bandwidth and reduce jank | |
454 if (!show) { | |
455 ui::LayerAnimationElement::AnimatableProperties propertiesToPause; | |
456 propertiesToPause.insert(ui::LayerAnimationElement::OPACITY); | |
457 window->layer()->GetAnimator()->ScheduleAnimation( | |
458 new ui::LayerAnimationSequence( | |
459 ui::LayerAnimationElement::CreatePauseElement( | |
460 propertiesToPause, (duration * 3 ) / 4))); | |
461 } | |
462 | |
463 // Fade in and out quickly when the window is small to reduce jank | |
450 float opacity = show ? 1.0f : 0.0f; | 464 float opacity = show ? 1.0f : 0.0f; |
451 window->layer()->GetAnimator()->ScheduleAnimation( | 465 window->layer()->GetAnimator()->ScheduleAnimation( |
452 new ui::LayerAnimationSequence( | 466 new ui::LayerAnimationSequence( |
453 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration))); | 467 ui::LayerAnimationElement::CreateOpacityElement( |
468 opacity, duration / 4))); | |
454 } | 469 } |
455 | 470 |
456 void AnimateShowWindow_Minimize(aura::Window* window) { | 471 void AnimateShowWindow_Minimize(aura::Window* window) { |
457 window->layer()->set_delegate(window); | 472 window->layer()->set_delegate(window); |
458 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 473 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
459 AddLayerAnimationsForMinimize(window, true); | 474 AddLayerAnimationsForMinimize(window, true); |
460 | 475 |
461 // Now that the window has been restored, we need to clear its animation style | 476 // Now that the window has been restored, we need to clear its animation style |
462 // to default so that normal animation applies. | 477 // to default so that normal animation applies. |
463 SetWindowVisibilityAnimationType( | 478 SetWindowVisibilityAnimationType( |
464 window, WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); | 479 window, WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); |
465 } | 480 } |
466 | 481 |
467 void AnimateHideWindow_Minimize(aura::Window* window) { | 482 void AnimateHideWindow_Minimize(aura::Window* window) { |
468 window->layer()->set_delegate(NULL); | 483 window->layer()->set_delegate(NULL); |
469 | 484 |
470 // Property sets within this scope will be implicitly animated. | 485 // Property sets within this scope will be implicitly animated. |
471 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 486 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
472 settings.AddObserver(new HidingWindowAnimationObserver(window)); | 487 settings.AddObserver(new HidingWindowAnimationObserver(window)); |
473 window->layer()->SetVisible(false); | |
474 | 488 |
475 AddLayerAnimationsForMinimize(window, false); | 489 AddLayerAnimationsForMinimize(window, false); |
476 } | 490 } |
477 | 491 |
478 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, | 492 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, |
479 bool show) { | 493 bool show) { |
480 window->layer()->set_delegate(window); | 494 window->layer()->set_delegate(window); |
481 | 495 |
482 float start_value, end_value; | 496 float start_value, end_value; |
483 if (show) { | 497 if (show) { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 AnimateHideWindow(window); | 868 AnimateHideWindow(window); |
855 } | 869 } |
856 } | 870 } |
857 | 871 |
858 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) { | 872 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) { |
859 delayed_old_layer_deletion_in_cross_fade_for_test_ = value; | 873 delayed_old_layer_deletion_in_cross_fade_for_test_ = value; |
860 } | 874 } |
861 | 875 |
862 } // namespace internal | 876 } // namespace internal |
863 } // namespace ash | 877 } // namespace ash |
OLD | NEW |