Chromium Code Reviews| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 new ui::InterpolatedTranslation( | 105 new ui::InterpolatedTranslation( |
| 106 gfx::PointF(), gfx::PointF(target_bounds.x() - bounds.x(), | 106 gfx::PointF(), gfx::PointF(target_bounds.x() - bounds.x(), |
| 107 target_bounds.y() - bounds.y()))); | 107 target_bounds.y() - bounds.y()))); |
| 108 | 108 |
| 109 scale->SetChild(translation.release()); | 109 scale->SetChild(translation.release()); |
| 110 scale->SetReversed(show); | 110 scale->SetReversed(show); |
| 111 | 111 |
| 112 base::TimeDelta duration = | 112 base::TimeDelta duration = |
| 113 window->layer()->GetAnimator()->GetTransitionDuration(); | 113 window->layer()->GetAnimator()->GetTransitionDuration(); |
| 114 | 114 |
| 115 std::unique_ptr<ui::LayerAnimationElement> transition( | 115 std::unique_ptr<ui::LayerAnimationElement> transition = |
| 116 ui::LayerAnimationElement::CreateInterpolatedTransformElement( | 116 ui::LayerAnimationElement::CreateInterpolatedTransformElement( |
| 117 scale.release(), duration)); | 117 scale.release(), duration); |
|
loyso (OOO)
2016/12/08 00:05:21
std::move(scale) ?
| |
| 118 | 118 |
| 119 transition->set_tween_type(show ? gfx::Tween::EASE_IN | 119 transition->set_tween_type(show ? gfx::Tween::EASE_IN |
| 120 : gfx::Tween::EASE_IN_OUT); | 120 : gfx::Tween::EASE_IN_OUT); |
| 121 | 121 |
| 122 window->layer()->GetAnimator()->ScheduleAnimation( | 122 window->layer()->GetAnimator()->ScheduleAnimation( |
| 123 new ui::LayerAnimationSequence(transition.release())); | 123 new ui::LayerAnimationSequence(std::move(transition))); |
| 124 | 124 |
| 125 // When hiding a window, turn off blending until the animation is 3 / 4 done | 125 // When hiding a window, turn off blending until the animation is 3 / 4 done |
| 126 // to save bandwidth and reduce jank. | 126 // to save bandwidth and reduce jank. |
| 127 if (!show) { | 127 if (!show) { |
| 128 window->layer()->GetAnimator()->SchedulePauseForProperties( | 128 window->layer()->GetAnimator()->SchedulePauseForProperties( |
| 129 (duration * 3) / 4, ui::LayerAnimationElement::OPACITY); | 129 (duration * 3) / 4, ui::LayerAnimationElement::OPACITY); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Fade in and out quickly when the window is small to reduce jank. | 132 // Fade in and out quickly when the window is small to reduce jank. |
| 133 float opacity = show ? 1.0f : 0.0f; | 133 float opacity = show ? 1.0f : 0.0f; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 return AnimateShowWindow(window); | 380 return AnimateShowWindow(window); |
| 381 // Don't start hiding the window again if it's already being hidden. | 381 // Don't start hiding the window again if it's already being hidden. |
| 382 return window->layer()->GetTargetOpacity() != 0.0f && | 382 return window->layer()->GetTargetOpacity() != 0.0f && |
| 383 AnimateHideWindow(window); | 383 AnimateHideWindow(window); |
| 384 } | 384 } |
| 385 | 385 |
| 386 std::vector<ui::LayerAnimationSequence*> | 386 std::vector<ui::LayerAnimationSequence*> |
| 387 CreateBrightnessGrayscaleAnimationSequence(float target_value, | 387 CreateBrightnessGrayscaleAnimationSequence(float target_value, |
| 388 base::TimeDelta duration) { | 388 base::TimeDelta duration) { |
| 389 gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT; | 389 gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT; |
| 390 std::unique_ptr<ui::LayerAnimationSequence> brightness_sequence( | 390 auto brightness_sequence = base::MakeUnique<ui::LayerAnimationSequence>(); |
| 391 new ui::LayerAnimationSequence()); | 391 auto grayscale_sequence = base::MakeUnique<ui::LayerAnimationSequence>(); |
| 392 std::unique_ptr<ui::LayerAnimationSequence> grayscale_sequence( | |
| 393 new ui::LayerAnimationSequence()); | |
| 394 | 392 |
| 395 std::unique_ptr<ui::LayerAnimationElement> brightness_element( | 393 std::unique_ptr<ui::LayerAnimationElement> brightness_element = |
| 396 ui::LayerAnimationElement::CreateBrightnessElement(target_value, | 394 ui::LayerAnimationElement::CreateBrightnessElement(target_value, |
| 397 duration)); | 395 duration); |
| 398 brightness_element->set_tween_type(animation_type); | 396 brightness_element->set_tween_type(animation_type); |
| 399 brightness_sequence->AddElement(brightness_element.release()); | 397 brightness_sequence->AddElement(std::move(brightness_element)); |
| 400 | 398 |
| 401 std::unique_ptr<ui::LayerAnimationElement> grayscale_element( | 399 std::unique_ptr<ui::LayerAnimationElement> grayscale_element = |
| 402 ui::LayerAnimationElement::CreateGrayscaleElement(target_value, | 400 ui::LayerAnimationElement::CreateGrayscaleElement(target_value, duration); |
| 403 duration)); | |
| 404 grayscale_element->set_tween_type(animation_type); | 401 grayscale_element->set_tween_type(animation_type); |
| 405 grayscale_sequence->AddElement(grayscale_element.release()); | 402 grayscale_sequence->AddElement(std::move(grayscale_element)); |
| 406 | 403 |
| 407 std::vector<ui::LayerAnimationSequence*> animations; | 404 std::vector<ui::LayerAnimationSequence*> animations; |
| 408 animations.push_back(brightness_sequence.release()); | 405 animations.push_back(brightness_sequence.release()); |
| 409 animations.push_back(grayscale_sequence.release()); | 406 animations.push_back(grayscale_sequence.release()); |
| 410 | 407 |
| 411 return animations; | 408 return animations; |
| 412 } | 409 } |
| 413 | 410 |
| 414 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) { | 411 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) { |
| 415 WmWindow* wm_window = WmWindowAura::Get(window); | 412 WmWindow* wm_window = WmWindowAura::Get(window); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 case SHELF_ALIGNMENT_LEFT: | 448 case SHELF_ALIGNMENT_LEFT: |
| 452 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); | 449 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); |
| 453 case SHELF_ALIGNMENT_RIGHT: | 450 case SHELF_ALIGNMENT_RIGHT: |
| 454 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); | 451 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); |
| 455 } | 452 } |
| 456 NOTREACHED(); | 453 NOTREACHED(); |
| 457 return gfx::Rect(); | 454 return gfx::Rect(); |
| 458 } | 455 } |
| 459 | 456 |
| 460 } // namespace ash | 457 } // namespace ash |
| OLD | NEW |