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

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 10444014: ash: Improved window maximize/restore animations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix workspace mgr, remove ignore_window, cleanup Created 8 years, 6 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
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 "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/animation/animation_container.h" 10 #include "ui/base/animation/animation_container.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 LayerAnimator::~LayerAnimator() { 42 LayerAnimator::~LayerAnimator() {
43 for (size_t i = 0; i < running_animations_.size(); ++i) 43 for (size_t i = 0; i < running_animations_.size(); ++i)
44 running_animations_[i].sequence->OnAnimatorDestroyed(); 44 running_animations_[i].sequence->OnAnimatorDestroyed();
45 ClearAnimations(); 45 ClearAnimations();
46 } 46 }
47 47
48 // static 48 // static
49 bool LayerAnimator::disable_animations_for_test_ = false; 49 bool LayerAnimator::disable_animations_for_test_ = false;
50 // static
51 int LayerAnimator::time_scale_for_test_ = 1;
50 52
51 // static 53 // static
52 LayerAnimator* LayerAnimator::CreateDefaultAnimator() { 54 LayerAnimator* LayerAnimator::CreateDefaultAnimator() {
53 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); 55 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0));
54 } 56 }
55 57
56 // static 58 // static
57 LayerAnimator* LayerAnimator::CreateImplicitAnimator() { 59 LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
58 return new LayerAnimator(kDefaultTransitionDuration); 60 return new LayerAnimator(kDefaultTransitionDuration);
59 } 61 }
60 62
61 void LayerAnimator::SetTransform(const Transform& transform) { 63 void LayerAnimator::SetTransform(const Transform& transform) {
62 base::TimeDelta duration = transition_duration_; 64 base::TimeDelta duration = transition_duration_ * time_scale_for_test_;
63 scoped_ptr<LayerAnimationElement> element( 65 scoped_ptr<LayerAnimationElement> element(
64 LayerAnimationElement::CreateTransformElement(transform, duration)); 66 LayerAnimationElement::CreateTransformElement(transform, duration));
65 element->set_tween_type(tween_type_); 67 element->set_tween_type(tween_type_);
66 StartAnimation(new LayerAnimationSequence(element.release())); 68 StartAnimation(new LayerAnimationSequence(element.release()));
67 } 69 }
68 70
69 Transform LayerAnimator::GetTargetTransform() const { 71 Transform LayerAnimator::GetTargetTransform() const {
70 LayerAnimationElement::TargetValue target(delegate()); 72 LayerAnimationElement::TargetValue target(delegate());
71 GetTargetValue(&target); 73 GetTargetValue(&target);
72 return target.transform; 74 return target.transform;
73 } 75 }
74 76
75 void LayerAnimator::SetBounds(const gfx::Rect& bounds) { 77 void LayerAnimator::SetBounds(const gfx::Rect& bounds) {
76 base::TimeDelta duration = transition_duration_; 78 base::TimeDelta duration = transition_duration_ * time_scale_for_test_;
77 scoped_ptr<LayerAnimationElement> element( 79 scoped_ptr<LayerAnimationElement> element(
78 LayerAnimationElement::CreateBoundsElement(bounds, duration)); 80 LayerAnimationElement::CreateBoundsElement(bounds, duration));
79 element->set_tween_type(tween_type_); 81 element->set_tween_type(tween_type_);
80 StartAnimation(new LayerAnimationSequence(element.release())); 82 StartAnimation(new LayerAnimationSequence(element.release()));
81 } 83 }
82 84
83 gfx::Rect LayerAnimator::GetTargetBounds() const { 85 gfx::Rect LayerAnimator::GetTargetBounds() const {
84 LayerAnimationElement::TargetValue target(delegate()); 86 LayerAnimationElement::TargetValue target(delegate());
85 GetTargetValue(&target); 87 GetTargetValue(&target);
86 return target.bounds; 88 return target.bounds;
87 } 89 }
88 90
89 void LayerAnimator::SetOpacity(float opacity) { 91 void LayerAnimator::SetOpacity(float opacity) {
90 base::TimeDelta duration = transition_duration_; 92 base::TimeDelta duration = transition_duration_ * time_scale_for_test_;
91 scoped_ptr<LayerAnimationElement> element( 93 scoped_ptr<LayerAnimationElement> element(
92 LayerAnimationElement::CreateOpacityElement(opacity, duration)); 94 LayerAnimationElement::CreateOpacityElement(opacity, duration));
93 element->set_tween_type(tween_type_); 95 element->set_tween_type(tween_type_);
94 StartAnimation(new LayerAnimationSequence(element.release())); 96 StartAnimation(new LayerAnimationSequence(element.release()));
95 } 97 }
96 98
97 float LayerAnimator::GetTargetOpacity() const { 99 float LayerAnimator::GetTargetOpacity() const {
98 LayerAnimationElement::TargetValue target(delegate()); 100 LayerAnimationElement::TargetValue target(delegate());
99 GetTargetValue(&target); 101 GetTargetValue(&target);
100 return target.opacity; 102 return target.opacity;
101 } 103 }
102 104
103 void LayerAnimator::SetVisibility(bool visibility) { 105 void LayerAnimator::SetVisibility(bool visibility) {
104 base::TimeDelta duration = transition_duration_; 106 base::TimeDelta duration = transition_duration_ * time_scale_for_test_;
105 107
106 // Tween type doesn't matter for visibility. 108 // Tween type doesn't matter for visibility.
107 StartAnimation(new LayerAnimationSequence( 109 StartAnimation(new LayerAnimationSequence(
108 LayerAnimationElement::CreateVisibilityElement( 110 LayerAnimationElement::CreateVisibilityElement(
109 visibility, duration))); 111 visibility, duration)));
110 } 112 }
111 113
112 bool LayerAnimator::GetTargetVisibility() const { 114 bool LayerAnimator::GetTargetVisibility() const {
113 LayerAnimationElement::TargetValue target(delegate()); 115 LayerAnimationElement::TargetValue target(delegate());
114 GetTargetValue(&target); 116 GetTargetValue(&target);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); 577 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_);
576 LayerAnimationObserver* obs; 578 LayerAnimationObserver* obs;
577 while ((obs = it.GetNext()) != NULL) { 579 while ((obs = it.GetNext()) != NULL) {
578 sequence->AddObserver(obs); 580 sequence->AddObserver(obs);
579 } 581 }
580 } 582 }
581 sequence->OnScheduled(); 583 sequence->OnScheduled();
582 } 584 }
583 585
584 } // namespace ui 586 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698