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

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

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 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/system_gesture_event_filter.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Brightness/grayscale values for hide/show window animations. 53 // Brightness/grayscale values for hide/show window animations.
54 const float kWindowAnimation_HideBrightnessGrayscale = 1.f; 54 const float kWindowAnimation_HideBrightnessGrayscale = 1.f;
55 const float kWindowAnimation_ShowBrightnessGrayscale = 0.f; 55 const float kWindowAnimation_ShowBrightnessGrayscale = 0.f;
56 56
57 const float kWindowAnimation_HideOpacity = 0.f; 57 const float kWindowAnimation_HideOpacity = 0.f;
58 const float kWindowAnimation_ShowOpacity = 1.f; 58 const float kWindowAnimation_ShowOpacity = 1.f;
59 // TODO(sky): if we end up sticking with 0, nuke the code doing the rotation. 59 // TODO(sky): if we end up sticking with 0, nuke the code doing the rotation.
60 const float kWindowAnimation_MinimizeRotate = 0.f; 60 const float kWindowAnimation_MinimizeRotate = 0.f;
61 61
62 // Tween type when cross fading a workspace window. 62 // Tween type when cross fading a workspace window.
63 const ui::Tween::Type kCrossFadeTweenType = ui::Tween::EASE_IN_OUT; 63 const gfx::Tween::Type kCrossFadeTweenType = gfx::Tween::EASE_IN_OUT;
64 64
65 // Scales for AshWindow above/below current workspace. 65 // Scales for AshWindow above/below current workspace.
66 const float kLayerScaleAboveSize = 1.1f; 66 const float kLayerScaleAboveSize = 1.1f;
67 const float kLayerScaleBelowSize = .9f; 67 const float kLayerScaleBelowSize = .9f;
68 68
69 int64 Round64(float f) { 69 int64 Round64(float f) {
70 return static_cast<int64>(f + 0.5f); 70 return static_cast<int64>(f + 0.5f);
71 } 71 }
72 72
73 } // namespace 73 } // namespace
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 rotation_about_pivot->SetReversed(show); 109 rotation_about_pivot->SetReversed(show);
110 110
111 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 111 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
112 kLayerAnimationsForMinimizeDurationMS); 112 kLayerAnimationsForMinimizeDurationMS);
113 113
114 scoped_ptr<ui::LayerAnimationElement> transition( 114 scoped_ptr<ui::LayerAnimationElement> transition(
115 ui::LayerAnimationElement::CreateInterpolatedTransformElement( 115 ui::LayerAnimationElement::CreateInterpolatedTransformElement(
116 rotation_about_pivot.release(), duration)); 116 rotation_about_pivot.release(), duration));
117 117
118 transition->set_tween_type( 118 transition->set_tween_type(
119 show ? ui::Tween::EASE_IN : ui::Tween::EASE_IN_OUT); 119 show ? gfx::Tween::EASE_IN : gfx::Tween::EASE_IN_OUT);
120 120
121 window->layer()->GetAnimator()->ScheduleAnimation( 121 window->layer()->GetAnimator()->ScheduleAnimation(
122 new ui::LayerAnimationSequence(transition.release())); 122 new ui::LayerAnimationSequence(transition.release()));
123 123
124 // When hiding a window, turn off blending until the animation is 3 / 4 done 124 // When hiding a window, turn off blending until the animation is 3 / 4 done
125 // to save bandwidth and reduce jank. 125 // to save bandwidth and reduce jank.
126 if (!show) { 126 if (!show) {
127 window->layer()->GetAnimator()->SchedulePauseForProperties( 127 window->layer()->GetAnimator()->SchedulePauseForProperties(
128 (duration * 3) / 4, ui::LayerAnimationElement::OPACITY, -1); 128 (duration * 3) / 4, ui::LayerAnimationElement::OPACITY, -1);
129 } 129 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 DISALLOW_COPY_AND_ASSIGN(CrossFadeObserver); 311 DISALLOW_COPY_AND_ASSIGN(CrossFadeObserver);
312 }; 312 };
313 313
314 // Implementation of cross fading. Window is the window being cross faded. It 314 // Implementation of cross fading. Window is the window being cross faded. It
315 // should be at the target bounds. |old_layer| the previous layer from |window|. 315 // should be at the target bounds. |old_layer| the previous layer from |window|.
316 // This takes ownership of |old_layer| and deletes when the animation is done. 316 // This takes ownership of |old_layer| and deletes when the animation is done.
317 // |pause_duration| is the duration to pause at the current bounds before 317 // |pause_duration| is the duration to pause at the current bounds before
318 // animating. Returns the duration of the fade. 318 // animating. Returns the duration of the fade.
319 base::TimeDelta CrossFadeImpl(aura::Window* window, 319 base::TimeDelta CrossFadeImpl(aura::Window* window,
320 ui::Layer* old_layer, 320 ui::Layer* old_layer,
321 ui::Tween::Type tween_type) { 321 gfx::Tween::Type tween_type) {
322 const gfx::Rect old_bounds(old_layer->bounds()); 322 const gfx::Rect old_bounds(old_layer->bounds());
323 const gfx::Rect new_bounds(window->bounds()); 323 const gfx::Rect new_bounds(window->bounds());
324 const bool old_on_top = (old_bounds.width() > new_bounds.width()); 324 const bool old_on_top = (old_bounds.width() > new_bounds.width());
325 325
326 // Shorten the animation if there's not much visual movement. 326 // Shorten the animation if there's not much visual movement.
327 const base::TimeDelta duration = GetCrossFadeDuration(old_bounds, new_bounds); 327 const base::TimeDelta duration = GetCrossFadeDuration(old_bounds, new_bounds);
328 328
329 // Scale up the old layer while translating to new position. 329 // Scale up the old layer while translating to new position.
330 { 330 {
331 old_layer->GetAnimator()->StopAnimating(); 331 old_layer->GetAnimator()->StopAnimating();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // Resize the window to the new size, which will force a layout and paint. 406 // Resize the window to the new size, which will force a layout and paint.
407 window->SetBounds(new_bounds); 407 window->SetBounds(new_bounds);
408 408
409 // Ensure the higher-resolution layer is on top. 409 // Ensure the higher-resolution layer is on top.
410 bool old_on_top = (old_bounds.width() > new_bounds.width()); 410 bool old_on_top = (old_bounds.width() > new_bounds.width());
411 if (old_on_top) 411 if (old_on_top)
412 old_layer->parent()->StackBelow(new_layer, old_layer); 412 old_layer->parent()->StackBelow(new_layer, old_layer);
413 else 413 else
414 old_layer->parent()->StackAbove(new_layer, old_layer); 414 old_layer->parent()->StackAbove(new_layer, old_layer);
415 415
416 CrossFadeImpl(window, old_layer, ui::Tween::EASE_OUT); 416 CrossFadeImpl(window, old_layer, gfx::Tween::EASE_OUT);
417 } 417 }
418 418
419 void CrossFadeWindowBetweenWorkspaces(aura::Window* new_workspace, 419 void CrossFadeWindowBetweenWorkspaces(aura::Window* new_workspace,
420 aura::Window* window, 420 aura::Window* window,
421 ui::Layer* old_layer) { 421 ui::Layer* old_layer) {
422 ui::Layer* layer_parent = new_workspace->layer()->parent(); 422 ui::Layer* layer_parent = new_workspace->layer()->parent();
423 layer_parent->Add(old_layer); 423 layer_parent->Add(old_layer);
424 const bool restoring = old_layer->bounds().width() > window->bounds().width(); 424 const bool restoring = old_layer->bounds().width() > window->bounds().width();
425 if (restoring) 425 if (restoring)
426 layer_parent->StackAbove(old_layer, new_workspace->layer()); 426 layer_parent->StackAbove(old_layer, new_workspace->layer());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (visible) 466 if (visible)
467 return AnimateShowWindow(window); 467 return AnimateShowWindow(window);
468 // Don't start hiding the window again if it's already being hidden. 468 // Don't start hiding the window again if it's already being hidden.
469 return window->layer()->GetTargetOpacity() != 0.0f && 469 return window->layer()->GetTargetOpacity() != 0.0f &&
470 AnimateHideWindow(window); 470 AnimateHideWindow(window);
471 } 471 }
472 472
473 std::vector<ui::LayerAnimationSequence*> 473 std::vector<ui::LayerAnimationSequence*>
474 CreateBrightnessGrayscaleAnimationSequence(float target_value, 474 CreateBrightnessGrayscaleAnimationSequence(float target_value,
475 base::TimeDelta duration) { 475 base::TimeDelta duration) {
476 ui::Tween::Type animation_type = ui::Tween::EASE_OUT; 476 gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT;
477 scoped_ptr<ui::LayerAnimationSequence> brightness_sequence( 477 scoped_ptr<ui::LayerAnimationSequence> brightness_sequence(
478 new ui::LayerAnimationSequence()); 478 new ui::LayerAnimationSequence());
479 scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence( 479 scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
480 new ui::LayerAnimationSequence()); 480 new ui::LayerAnimationSequence());
481 481
482 scoped_ptr<ui::LayerAnimationElement> brightness_element( 482 scoped_ptr<ui::LayerAnimationElement> brightness_element(
483 ui::LayerAnimationElement::CreateBrightnessElement( 483 ui::LayerAnimationElement::CreateBrightnessElement(
484 target_value, duration)); 484 target_value, duration));
485 brightness_element->set_tween_type(animation_type); 485 brightness_element->set_tween_type(animation_type);
486 brightness_sequence->AddElement(brightness_element.release()); 486 brightness_sequence->AddElement(brightness_element.release());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 554 }
555 555
556 // Assume the launcher is overflowed, zoom off to the bottom right of the 556 // Assume the launcher is overflowed, zoom off to the bottom right of the
557 // work area. 557 // work area.
558 gfx::Rect work_area = 558 gfx::Rect work_area =
559 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); 559 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
560 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); 560 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0);
561 } 561 }
562 562
563 } // namespace ash 563 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_gesture_event_filter.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698