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

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: Use cc layer's opacity instead of ui::Layer::opacity_ 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 29 matching lines...) Expand all
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 {Progress, 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 // If starting the animation involves dispatching to another thread, then
59 // proceed with that dispatch.
60 void ProgressToEffectiveStart(LayerAnimationDelegate* delegate);
61
50 // Updates the delegate to the appropriate value for |now|. Requests a 62 // Updates the delegate to the appropriate value for |now|. Requests a
51 // redraw if it is required. 63 // redraw if it is required.
52 void Progress(base::TimeTicks now, LayerAnimationDelegate* delegate); 64 void Progress(base::TimeTicks now, LayerAnimationDelegate* delegate);
53 65
54 // Returns true if calling Progress now, with the given time, will finish 66 // Returns true if calling Progress now, with the given time, will finish
55 // the animation. 67 // the animation.
56 bool IsFinished(base::TimeTicks time); 68 bool IsFinished(base::TimeTicks time);
57 69
58 // Updates the delegate to the end of the animation; if this sequence is 70 // 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. 71 // cyclic, updates the delegate to the end of one cycle of the sequence.
60 void ProgressToEnd(LayerAnimationDelegate* delegate); 72 void ProgressToEnd(LayerAnimationDelegate* delegate);
61 73
62 // Sets the target value to the value that would have been set had 74 // Sets the target value to the value that would have been set had
63 // the sequence completed. Does nothing if the sequence is cyclic. 75 // the sequence completed. Does nothing if the sequence is cyclic.
64 void GetTargetValue(LayerAnimationElement::TargetValue* target) const; 76 void GetTargetValue(LayerAnimationElement::TargetValue* target) const;
65 77
66 // Aborts the given animation. 78 // Aborts the given animation.
67 void Abort(); 79 void Abort(LayerAnimationDelegate* delegate);
68 80
69 // All properties modified by the sequence. 81 // All properties modified by the sequence.
70 const LayerAnimationElement::AnimatableProperties& properties() const { 82 const LayerAnimationElement::AnimatableProperties& properties() const {
71 return properties_; 83 return properties_;
72 } 84 }
73 85
74 // Adds an element to the sequence. The sequences takes ownership of this 86 // Adds an element to the sequence. The sequences takes ownership of this
75 // element. 87 // element.
76 void AddElement(LayerAnimationElement* element); 88 void AddElement(LayerAnimationElement* element);
77 89
78 // Sequences can be looped indefinitely. 90 // Sequences can be looped indefinitely.
79 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } 91 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; }
80 bool is_cyclic() const { return is_cyclic_; } 92 bool is_cyclic() const { return is_cyclic_; }
81 93
82 // Returns true if this sequence has at least one element affecting a 94 // Returns true if this sequence has at least one element affecting a
83 // property in |other|. 95 // property in |other|.
84 bool HasCommonProperty( 96 bool HasCommonProperty(
85 const LayerAnimationElement::AnimatableProperties& other) const; 97 const LayerAnimationElement::AnimatableProperties& other) const;
86 98
99 // Returns true if the first element animates on the compositor thread.
100 bool IsFirstElementThreaded() const;
101
102 // Used to identify groups of sequences that are supposed to start together.
103 int animation_group_id() const { return animation_group_id_; }
104 void set_animation_group_id(int id) { animation_group_id_ = id; }
105
87 // These functions are used for adding or removing observers from the observer 106 // These functions are used for adding or removing observers from the observer
88 // list. The observers are notified when animations end. 107 // list. The observers are notified when animations end.
89 void AddObserver(LayerAnimationObserver* observer); 108 void AddObserver(LayerAnimationObserver* observer);
90 void RemoveObserver(LayerAnimationObserver* observer); 109 void RemoveObserver(LayerAnimationObserver* observer);
91 110
111 // Called when a threaded animation is actually started.
112 void OnThreadedAnimationStarted(const cc::AnimationEvent& event);
113
92 // Called when the animator schedules this sequence. 114 // Called when the animator schedules this sequence.
93 void OnScheduled(); 115 void OnScheduled();
94 116
95 // Called when the animator is destroyed. 117 // Called when the animator is destroyed.
96 void OnAnimatorDestroyed(); 118 void OnAnimatorDestroyed();
97 119
120 // The last_progressed_fraction of the element most recently progressed by
121 // by this sequence. Returns 0.0 if no elements have been progressed.
122 double last_progressed_fraction() const { return last_progressed_fraction_; }
123
98 private: 124 private:
99 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; 125 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements;
100 126
101 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest, 127 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest,
102 ObserverReleasedBeforeAnimationSequenceEnds); 128 ObserverReleasedBeforeAnimationSequenceEnds);
103 129
104 // Notifies the observers that this sequence has been scheduled. 130 // Notifies the observers that this sequence has been scheduled.
105 void NotifyScheduled(); 131 void NotifyScheduled();
106 132
107 // Notifies the observers that this sequence has ended. 133 // Notifies the observers that this sequence has ended.
(...skipping 11 matching lines...) Expand all
119 // True if the sequence should be looped forever. 145 // True if the sequence should be looped forever.
120 bool is_cyclic_; 146 bool is_cyclic_;
121 147
122 // These are used when animating to efficiently find the next element. 148 // These are used when animating to efficiently find the next element.
123 size_t last_element_; 149 size_t last_element_;
124 base::TimeTicks last_start_; 150 base::TimeTicks last_start_;
125 151
126 // The start time of the current run of the sequence. 152 // The start time of the current run of the sequence.
127 base::TimeTicks start_time_; 153 base::TimeTicks start_time_;
128 154
155 // True if this sequence will start together with other sequences, and at
156 // least one of the sequences in this group has a threaded first element.
157 bool waiting_for_group_start_;
158
159 // Identifies groups of sequences that are supposed to start together.
160 int animation_group_id_;
161
129 // These parties are notified when layer animations end. 162 // These parties are notified when layer animations end.
130 ObserverList<LayerAnimationObserver> observers_; 163 ObserverList<LayerAnimationObserver> observers_;
131 164
165 // Tracks the last_progressed_fraction() of the most recently progressed
166 // element.
167 double last_progressed_fraction_;
168
132 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); 169 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence);
133 }; 170 };
134 171
135 } // namespace ui 172 } // namespace ui
136 173
137 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 174 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698