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

Side by Side Diff: ui/compositor/layer_animation_element.h

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP Created 7 years, 1 month 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 | « ui/compositor/compositor_observer.h ('k') | 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/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "cc/animation/animation.h" 12 #include "cc/animation/animation.h"
13 #include "cc/animation/animation_events.h" 13 #include "cc/animation/animation_events.h"
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/compositor/compositor_export.h" 15 #include "ui/compositor/compositor_export.h"
16 #include "ui/gfx/animation/tween.h" 16 #include "ui/gfx/animation/tween.h"
17 #include "ui/gfx/frame_time.h"
17 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
18 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
19 20
20 namespace ui { 21 namespace ui {
21 22
22 class InterpolatedTransform; 23 class InterpolatedTransform;
23 class LayerAnimationDelegate; 24 class LayerAnimationDelegate;
24 25
25 // LayerAnimationElements represent one segment of an animation between two 26 // LayerAnimationElements represent one segment of an animation between two
26 // keyframes. They know how to update a LayerAnimationDelegate given a value 27 // keyframes. They know how to update a LayerAnimationDelegate given a value
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 130
130 // Creates an element that transitions to the given color. The caller owns the 131 // Creates an element that transitions to the given color. The caller owns the
131 // return value. 132 // return value.
132 static LayerAnimationElement* CreateColorElement( 133 static LayerAnimationElement* CreateColorElement(
133 SkColor color, 134 SkColor color,
134 base::TimeDelta duration); 135 base::TimeDelta duration);
135 136
136 // Sets the start time for the animation. This must be called before the first 137 // Sets the start time for the animation. This must be called before the first
137 // call to {Start, IsFinished}. Once the animation is finished, this must 138 // call to {Start, IsFinished}. Once the animation is finished, this must
138 // be called again in order to restart the animation. 139 // be called again in order to restart the animation.
139 void set_requested_start_time(base::TimeTicks start_time) { 140 void set_requested_start_time(gfx::FrameTime start_time) {
140 requested_start_time_ = start_time; 141 requested_start_time_ = start_time;
141 } 142 }
142 base::TimeTicks requested_start_time() const { return requested_start_time_; } 143 gfx::FrameTime requested_start_time() const { return requested_start_time_; }
143 144
144 // Sets the actual start time for the animation, taking into account any 145 // Sets the actual start time for the animation, taking into account any
145 // queueing delays. 146 // queueing delays.
146 void set_effective_start_time(base::TimeTicks start_time) { 147 void set_effective_start_time(gfx::FrameTime start_time) {
147 effective_start_time_ = start_time; 148 effective_start_time_ = start_time;
148 } 149 }
149 base::TimeTicks effective_start_time() const { return effective_start_time_; } 150 gfx::FrameTime effective_start_time() const { return effective_start_time_; }
150 151
151 // This must be called before the first call to Progress. If starting the 152 // This must be called before the first call to Progress. If starting the
152 // animation involves dispatching to another thread, then this will proceed 153 // animation involves dispatching to another thread, then this will proceed
153 // with that dispatch, ultimately resulting in the animation getting an 154 // with that dispatch, ultimately resulting in the animation getting an
154 // effective start time (the time the animation starts on the other thread). 155 // effective start time (the time the animation starts on the other thread).
155 void Start(LayerAnimationDelegate* delegate, int animation_group_id); 156 void Start(LayerAnimationDelegate* delegate, int animation_group_id);
156 157
157 // Returns true if the animation has started but hasn't finished. 158 // Returns true if the animation has started but hasn't finished.
158 bool Started() { return !first_frame_; } 159 bool Started() { return !first_frame_; }
159 160
160 // Updates the delegate to the appropriate value for |now|. Returns true 161 // Updates the delegate to the appropriate value for |now|. Returns true
161 // if a redraw is required. 162 // if a redraw is required.
162 bool Progress(base::TimeTicks now, LayerAnimationDelegate* delegate); 163 bool Progress(gfx::FrameTime now, LayerAnimationDelegate* delegate);
163 164
164 // If calling Progress now, with the given time, will finish the animation, 165 // If calling Progress now, with the given time, will finish the animation,
165 // returns true and sets |end_duration| to the actual duration for this 166 // returns true and sets |end_duration| to the actual duration for this
166 // animation, incuding any queueing delays. 167 // animation, incuding any queueing delays.
167 bool IsFinished(base::TimeTicks time, base::TimeDelta* total_duration); 168 bool IsFinished(gfx::FrameTime time, base::TimeDelta* total_duration);
168 169
169 // Updates the delegate to the end of the animation. Returns true if a 170 // Updates the delegate to the end of the animation. Returns true if a
170 // redraw is required. 171 // redraw is required.
171 bool ProgressToEnd(LayerAnimationDelegate* delegate); 172 bool ProgressToEnd(LayerAnimationDelegate* delegate);
172 173
173 // Called if the animation is not allowed to complete. This may be called 174 // Called if the animation is not allowed to complete. This may be called
174 // before OnStarted or Progress. 175 // before OnStarted or Progress.
175 void Abort(LayerAnimationDelegate* delegate); 176 void Abort(LayerAnimationDelegate* delegate);
176 177
177 // Assigns the target value to |target|. 178 // Assigns the target value to |target|.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 LayerAnimationElement(const LayerAnimationElement& element); 214 LayerAnimationElement(const LayerAnimationElement& element);
214 215
215 private: 216 private:
216 // For debugging purposes, we sometimes alter the duration we actually use. 217 // For debugging purposes, we sometimes alter the duration we actually use.
217 // For example, during tests we often set duration = 0, and it is sometimes 218 // For example, during tests we often set duration = 0, and it is sometimes
218 // useful to slow animations down to see them more clearly. 219 // useful to slow animations down to see them more clearly.
219 base::TimeDelta GetEffectiveDuration(const base::TimeDelta& delta); 220 base::TimeDelta GetEffectiveDuration(const base::TimeDelta& delta);
220 221
221 bool first_frame_; 222 bool first_frame_;
222 const AnimatableProperties properties_; 223 const AnimatableProperties properties_;
223 base::TimeTicks requested_start_time_; 224 gfx::FrameTime requested_start_time_;
224 225
225 // When the animation actually started, taking into account queueing delays. 226 // When the animation actually started, taking into account queueing delays.
226 base::TimeTicks effective_start_time_; 227 gfx::FrameTime effective_start_time_;
227 const base::TimeDelta duration_; 228 const base::TimeDelta duration_;
228 gfx::Tween::Type tween_type_; 229 gfx::Tween::Type tween_type_;
229 230
230 const int animation_id_; 231 const int animation_id_;
231 int animation_group_id_; 232 int animation_group_id_;
232 233
233 double last_progressed_fraction_; 234 double last_progressed_fraction_;
234 235
235 base::WeakPtrFactory<LayerAnimationElement> weak_ptr_factory_; 236 base::WeakPtrFactory<LayerAnimationElement> weak_ptr_factory_;
236 237
237 DISALLOW_ASSIGN(LayerAnimationElement); 238 DISALLOW_ASSIGN(LayerAnimationElement);
238 }; 239 };
239 240
240 } // namespace ui 241 } // namespace ui
241 242
242 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ 243 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositor_observer.h ('k') | ui/compositor/layer_animation_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698