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

Side by Side Diff: ui/compositor/layer_animation_sequence.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
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_SEQUENCE_H_ 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
6 #define UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 6 #define UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 23 matching lines...) Expand all
34 // this happens, there will be no need for LayerAnimationSequences to support 34 // this happens, there will be no need for LayerAnimationSequences to support
35 // weak pointers. 35 // weak pointers.
36 class COMPOSITOR_EXPORT LayerAnimationSequence 36 class COMPOSITOR_EXPORT LayerAnimationSequence
37 : public base::SupportsWeakPtr<LayerAnimationSequence> { 37 : public base::SupportsWeakPtr<LayerAnimationSequence> {
38 public: 38 public:
39 LayerAnimationSequence(); 39 LayerAnimationSequence();
40 // Takes ownership of the given element and adds it to the sequence. 40 // Takes ownership of the given element and adds it to the sequence.
41 explicit LayerAnimationSequence(LayerAnimationElement* element); 41 explicit LayerAnimationSequence(LayerAnimationElement* element);
42 virtual ~LayerAnimationSequence(); 42 virtual ~LayerAnimationSequence();
43 43
44 // Updates the delegate to the appropriate value for |elapsed|, which is in 44 // Updates the delegate to the appropriate value for |elapsed|. Requests a
45 // the range [0, Duration()]. If the animation is not aborted, it is 45 // redraw if it is required.
46 // guaranteed that Animate will be called with elapsed = Duration(). Requests
47 // a redraw if it is required.
48 void Progress(base::TimeDelta elapsed, LayerAnimationDelegate* delegate); 46 void Progress(base::TimeDelta elapsed, LayerAnimationDelegate* delegate);
49 47
48 // Returns true if calling Progress now, with the given elapsed time, will
49 // finish the animation.
50 bool IsFinished(base::TimeDelta elapsed);
51
52 // Updates the delegate to the end of the animation; if this sequence is
53 // cyclic, updates the delegate to the end of one cycle of the sequence.
54 void ProgressToEnd(LayerAnimationDelegate* delegate);
55
50 // Sets the target value to the value that would have been set had 56 // Sets the target value to the value that would have been set had
51 // the sequence completed. Does nothing if the sequence is cyclic. 57 // the sequence completed. Does nothing if the sequence is cyclic.
52 void GetTargetValue(LayerAnimationElement::TargetValue* target) const; 58 void GetTargetValue(LayerAnimationElement::TargetValue* target) const;
53 59
54 // Aborts the given animation. 60 // Aborts the given animation.
55 void Abort(); 61 void Abort();
56 62
57 // All properties modified by the sequence. 63 // All properties modified by the sequence.
58 const LayerAnimationElement::AnimatableProperties& properties() const { 64 const LayerAnimationElement::AnimatableProperties& properties() const {
59 return properties_; 65 return properties_;
60 } 66 }
61 67
62 // The total, finite duration of one cycle of the sequence.
63 base::TimeDelta duration() const {
64 return duration_;
65 }
66
67 // Adds an element to the sequence. The sequences takes ownership of this 68 // Adds an element to the sequence. The sequences takes ownership of this
68 // element. 69 // element.
69 void AddElement(LayerAnimationElement* element); 70 void AddElement(LayerAnimationElement* element);
70 71
71 // Sequences can be looped indefinitely. 72 // Sequences can be looped indefinitely.
72 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } 73 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; }
73 bool is_cyclic() const { return is_cyclic_; } 74 bool is_cyclic() const { return is_cyclic_; }
74 75
75 // Returns true if this sequence has at least one element affecting a 76 // Returns true if this sequence has at least one element affecting a
76 // property in |other|. 77 // property in |other|.
(...skipping 19 matching lines...) Expand all
96 97
97 // Notifies the observers that this sequence has been scheduled. 98 // Notifies the observers that this sequence has been scheduled.
98 void NotifyScheduled(); 99 void NotifyScheduled();
99 100
100 // Notifies the observers that this sequence has ended. 101 // Notifies the observers that this sequence has ended.
101 void NotifyEnded(); 102 void NotifyEnded();
102 103
103 // Notifies the observers that this sequence has been aborted. 104 // Notifies the observers that this sequence has been aborted.
104 void NotifyAborted(); 105 void NotifyAborted();
105 106
106 // The sum of the durations of all the elements in the sequence.
107 base::TimeDelta duration_;
108
109 // The union of all the properties modified by all elements in the sequence. 107 // The union of all the properties modified by all elements in the sequence.
110 LayerAnimationElement::AnimatableProperties properties_; 108 LayerAnimationElement::AnimatableProperties properties_;
111 109
112 // The elements in the sequence. 110 // The elements in the sequence.
113 Elements elements_; 111 Elements elements_;
114 112
115 // True if the sequence should be looped forever. 113 // True if the sequence should be looped forever.
116 bool is_cyclic_; 114 bool is_cyclic_;
117 115
118 // These are used when animating to efficiently find the next element. 116 // These are used when animating to efficiently find the next element.
119 size_t last_element_; 117 size_t last_element_;
120 base::TimeDelta last_start_; 118 base::TimeDelta last_start_;
121 119
122 // These parties are notified when layer animations end. 120 // These parties are notified when layer animations end.
123 ObserverList<LayerAnimationObserver> observers_; 121 ObserverList<LayerAnimationObserver> observers_;
124 122
125 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); 123 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence);
126 }; 124 };
127 125
128 } // namespace ui 126 } // namespace ui
129 127
130 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 128 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_element_unittest.cc ('k') | ui/compositor/layer_animation_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698