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: ui/compositor/layer_animation_element.h

Issue 11316315: Remove ui::LayerAnimationSequence::duration and ui::LayerAnimationElement::duration. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make unit tests use IsFinished() instead of duration() Created 8 years 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
« no previous file with comments | « no previous file | ui/compositor/layer_animation_element.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 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
6 #define UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ 6 #define UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 static LayerAnimationElement* CreatePauseElement( 106 static LayerAnimationElement* CreatePauseElement(
107 const AnimatableProperties& properties, 107 const AnimatableProperties& properties,
108 base::TimeDelta duration); 108 base::TimeDelta duration);
109 109
110 // Creates an element that transitions to the given color. The caller owns the 110 // Creates an element that transitions to the given color. The caller owns the
111 // return value. 111 // return value.
112 static LayerAnimationElement* CreateColorElement( 112 static LayerAnimationElement* CreateColorElement(
113 SkColor color, 113 SkColor color,
114 base::TimeDelta duration); 114 base::TimeDelta duration);
115 115
116 // Updates the delegate to the appropriate value for |t|, which is in the 116 // Updates the delegate to the appropriate value for |elapsed|. Returns true
117 // range [0, 1] (0 for initial, and 1 for final). If the animation is not 117 // if a redraw is required.
118 // aborted, it is guaranteed that Progress will eventually be called with 118 bool Progress(base::TimeDelta elapsed, LayerAnimationDelegate* delegate);
119 // t = 1.0. Returns true if a redraw is required. 119
120 bool Progress(double t, LayerAnimationDelegate* delegate); 120 // If calling Progress now, with the given elapsed time, will finish the
121 // animation, returns true and sets |total_duration| to the actual duration
122 // for this animation, incuding any queueing delays.
123 bool IsFinished(base::TimeDelta elapsed, base::TimeDelta* total_duration);
124
125 // Updates the delegate to the end of the animation. Returns true if a
126 // redraw is required.
127 bool ProgressToEnd(LayerAnimationDelegate* delegate);
121 128
122 // Called if the animation is not allowed to complete. This may be called 129 // Called if the animation is not allowed to complete. This may be called
123 // before OnStarted or Progress. 130 // before OnStarted or Progress.
124 void Abort(); 131 void Abort();
125 132
126 // Assigns the target value to |target|. 133 // Assigns the target value to |target|.
127 void GetTargetValue(TargetValue* target) const; 134 void GetTargetValue(TargetValue* target) const;
128 135
129 // The properties that the element modifies. 136 // The properties that the element modifies.
130 const AnimatableProperties& properties() const { return properties_; } 137 const AnimatableProperties& properties() const { return properties_; }
131 138
132 // The duration of the animation
133 base::TimeDelta duration() const { return duration_; }
134
135 Tween::Type tween_type() const { return tween_type_; } 139 Tween::Type tween_type() const { return tween_type_; }
136 void set_tween_type(Tween::Type tween_type) { tween_type_ = tween_type; } 140 void set_tween_type(Tween::Type tween_type) { tween_type_ = tween_type; }
137 141
138 protected: 142 protected:
139 // Called once each time the animation element is run before any call to 143 // Called once each time the animation element is run before any call to
140 // OnProgress. 144 // OnProgress.
141 virtual void OnStart(LayerAnimationDelegate* delegate) = 0; 145 virtual void OnStart(LayerAnimationDelegate* delegate) = 0;
142 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) = 0; 146 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) = 0;
143 virtual void OnGetTarget(TargetValue* target) const = 0; 147 virtual void OnGetTarget(TargetValue* target) const = 0;
144 virtual void OnAbort() = 0; 148 virtual void OnAbort() = 0;
145 149
146 private: 150 private:
147 // For debugging purposes, we sometimes alter the duration we actually use. 151 // For debugging purposes, we sometimes alter the duration we actually use.
148 // For example, during tests we often set duration = 0, and it is sometimes 152 // For example, during tests we often set duration = 0, and it is sometimes
149 // useful to slow animations down to see them more clearly. 153 // useful to slow animations down to see them more clearly.
150 base::TimeDelta GetEffectiveDuration(const base::TimeDelta& delta); 154 base::TimeDelta GetEffectiveDuration(const base::TimeDelta& delta);
151 155
152 bool first_frame_; 156 bool first_frame_;
153 const AnimatableProperties properties_; 157 const AnimatableProperties properties_;
154 const base::TimeDelta duration_; 158 const base::TimeDelta duration_;
155 Tween::Type tween_type_; 159 Tween::Type tween_type_;
156 160
157 DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement); 161 DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement);
158 }; 162 };
159 163
160 } // namespace ui 164 } // namespace ui
161 165
162 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ 166 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/layer_animation_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698