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

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

Issue 11896017: Thread ui opacity animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix ash_unittests Created 7 years, 10 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
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 24 matching lines...) Expand all
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 // Sets the start time for the animation. This must be called before the 44 // Sets the start time for the animation. This must be called before the
45 // first call to {Progress, IsFinished}. Once the animation is finished, this 45 // first call to {Start, IsFinished}. Once the animation is finished, this
46 // must be called again in order to restart the animation. 46 // must be called again in order to restart the animation.
47 void set_start_time(base::TimeTicks start_time) { start_time_ = start_time; } 47 void set_start_time(base::TimeTicks start_time) { start_time_ = start_time; }
48 base::TimeTicks start_time() const { return start_time_; } 48 base::TimeTicks start_time() const { return start_time_; }
49 49
50 // Sets a flag indicating that this sequence will start together with other
51 // sequences, and at least one of the sequences in this group has a threaded
52 // first element.
53 void set_waiting_for_group_start(bool waiting) {
54 waiting_for_group_start_ = waiting;
55 }
56 bool waiting_for_group_start() { return waiting_for_group_start_; }
57
58 // This must be called before the first call to Progress. If starting the
59 // animation involves dispatching to another thread, then this will proceed
60 // with that dispatch, ultimately resulting in the animation getting an
61 // effective start time (the time the animation starts on the other thread).
62 void Start(LayerAnimationDelegate* delegate);
63
50 // Updates the delegate to the appropriate value for |now|. Requests a 64 // Updates the delegate to the appropriate value for |now|. Requests a
51 // redraw if it is required. 65 // redraw if it is required.
52 void Progress(base::TimeTicks now, LayerAnimationDelegate* delegate); 66 void Progress(base::TimeTicks now, LayerAnimationDelegate* delegate);
53 67
54 // Returns true if calling Progress now, with the given time, will finish 68 // Returns true if calling Progress now, with the given time, will finish
55 // the animation. 69 // the animation.
56 bool IsFinished(base::TimeTicks time); 70 bool IsFinished(base::TimeTicks time);
57 71
58 // Updates the delegate to the end of the animation; if this sequence is 72 // Updates the delegate to the end of the animation; if this sequence is
59 // cyclic, updates the delegate to the end of one cycle of the sequence. 73 // cyclic, updates the delegate to the end of one cycle of the sequence.
60 void ProgressToEnd(LayerAnimationDelegate* delegate); 74 void ProgressToEnd(LayerAnimationDelegate* delegate);
61 75
62 // Sets the target value to the value that would have been set had 76 // Sets the target value to the value that would have been set had
63 // the sequence completed. Does nothing if the sequence is cyclic. 77 // the sequence completed. Does nothing if the sequence is cyclic.
64 void GetTargetValue(LayerAnimationElement::TargetValue* target) const; 78 void GetTargetValue(LayerAnimationElement::TargetValue* target) const;
65 79
66 // Aborts the given animation. 80 // Aborts the given animation.
67 void Abort(); 81 void Abort(LayerAnimationDelegate* delegate);
68 82
69 // All properties modified by the sequence. 83 // All properties modified by the sequence.
70 const LayerAnimationElement::AnimatableProperties& properties() const { 84 const LayerAnimationElement::AnimatableProperties& properties() const {
71 return properties_; 85 return properties_;
72 } 86 }
73 87
74 // Adds an element to the sequence. The sequences takes ownership of this 88 // Adds an element to the sequence. The sequences takes ownership of this
75 // element. 89 // element.
76 void AddElement(LayerAnimationElement* element); 90 void AddElement(LayerAnimationElement* element);
77 91
78 // Sequences can be looped indefinitely. 92 // Sequences can be looped indefinitely.
79 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } 93 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; }
80 bool is_cyclic() const { return is_cyclic_; } 94 bool is_cyclic() const { return is_cyclic_; }
81 95
82 // Returns true if this sequence has at least one element affecting a 96 // Returns true if this sequence has at least one element affecting a
83 // property in |other|. 97 // property in |other|.
84 bool HasCommonProperty( 98 bool HasCommonProperty(
85 const LayerAnimationElement::AnimatableProperties& other) const; 99 const LayerAnimationElement::AnimatableProperties& other) const;
86 100
101 // Returns true if the first element animates on the compositor thread.
102 bool IsFirstElementThreaded() const;
103
104 // Used to identify groups of sequences that are supposed to start together.
105 int animation_group_id() const { return animation_group_id_; }
106 void set_animation_group_id(int id) { animation_group_id_ = id; }
107
87 // These functions are used for adding or removing observers from the observer 108 // These functions are used for adding or removing observers from the observer
88 // list. The observers are notified when animations end. 109 // list. The observers are notified when animations end.
89 void AddObserver(LayerAnimationObserver* observer); 110 void AddObserver(LayerAnimationObserver* observer);
90 void RemoveObserver(LayerAnimationObserver* observer); 111 void RemoveObserver(LayerAnimationObserver* observer);
91 112
113 // Called when a threaded animation is actually started.
114 void OnThreadedAnimationStarted(const cc::AnimationEvent& event);
115
92 // Called when the animator schedules this sequence. 116 // Called when the animator schedules this sequence.
93 void OnScheduled(); 117 void OnScheduled();
94 118
95 // Called when the animator is destroyed. 119 // Called when the animator is destroyed.
96 void OnAnimatorDestroyed(); 120 void OnAnimatorDestroyed();
97 121
122 // The last_progressed_fraction of the element most recently progressed by
123 // by this sequence. Returns 0.0 if no elements have been progressed.
124 double last_progressed_fraction() const { return last_progressed_fraction_; }
125
98 private: 126 private:
127 friend class LayerAnimatorTestController;
128
99 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; 129 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements;
100 130
101 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest, 131 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest,
102 ObserverReleasedBeforeAnimationSequenceEnds); 132 ObserverReleasedBeforeAnimationSequenceEnds);
103 133
104 // Notifies the observers that this sequence has been scheduled. 134 // Notifies the observers that this sequence has been scheduled.
105 void NotifyScheduled(); 135 void NotifyScheduled();
106 136
107 // Notifies the observers that this sequence has ended. 137 // Notifies the observers that this sequence has ended.
108 void NotifyEnded(); 138 void NotifyEnded();
109 139
110 // Notifies the observers that this sequence has been aborted. 140 // Notifies the observers that this sequence has been aborted.
111 void NotifyAborted(); 141 void NotifyAborted();
112 142
143 // The currently animating element.
144 LayerAnimationElement* CurrentElement();
145
113 // The union of all the properties modified by all elements in the sequence. 146 // The union of all the properties modified by all elements in the sequence.
114 LayerAnimationElement::AnimatableProperties properties_; 147 LayerAnimationElement::AnimatableProperties properties_;
115 148
116 // The elements in the sequence. 149 // The elements in the sequence.
117 Elements elements_; 150 Elements elements_;
118 151
119 // True if the sequence should be looped forever. 152 // True if the sequence should be looped forever.
120 bool is_cyclic_; 153 bool is_cyclic_;
121 154
122 // These are used when animating to efficiently find the next element. 155 // These are used when animating to efficiently find the next element.
123 size_t last_element_; 156 size_t last_element_;
124 base::TimeTicks last_start_; 157 base::TimeTicks last_start_;
125 158
126 // The start time of the current run of the sequence. 159 // The start time of the current run of the sequence.
127 base::TimeTicks start_time_; 160 base::TimeTicks start_time_;
128 161
162 // True if this sequence will start together with other sequences, and at
163 // least one of the sequences in this group has a threaded first element.
164 bool waiting_for_group_start_;
165
166 // Identifies groups of sequences that are supposed to start together.
167 int animation_group_id_;
168
129 // These parties are notified when layer animations end. 169 // These parties are notified when layer animations end.
130 ObserverList<LayerAnimationObserver> observers_; 170 ObserverList<LayerAnimationObserver> observers_;
131 171
172 // Tracks the last_progressed_fraction() of the most recently progressed
173 // element.
174 double last_progressed_fraction_;
175
132 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); 176 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence);
133 }; 177 };
134 178
135 } // namespace ui 179 } // namespace ui
136 180
137 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 181 #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