OLD | NEW |
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 Loading... |
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 |
98 private: | 120 private: |
99 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; | 121 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; |
100 | 122 |
101 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest, | 123 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest, |
(...skipping 17 matching lines...) Expand all Loading... |
119 // True if the sequence should be looped forever. | 141 // True if the sequence should be looped forever. |
120 bool is_cyclic_; | 142 bool is_cyclic_; |
121 | 143 |
122 // These are used when animating to efficiently find the next element. | 144 // These are used when animating to efficiently find the next element. |
123 size_t last_element_; | 145 size_t last_element_; |
124 base::TimeTicks last_start_; | 146 base::TimeTicks last_start_; |
125 | 147 |
126 // The start time of the current run of the sequence. | 148 // The start time of the current run of the sequence. |
127 base::TimeTicks start_time_; | 149 base::TimeTicks start_time_; |
128 | 150 |
| 151 // True if this sequence will start together with other sequences, and at |
| 152 // least one of the sequences in this group has a threaded first element. |
| 153 bool waiting_for_group_start_; |
| 154 |
| 155 // Identifies groups of sequences that are supposed to start together. |
| 156 int animation_group_id_; |
| 157 |
129 // These parties are notified when layer animations end. | 158 // These parties are notified when layer animations end. |
130 ObserverList<LayerAnimationObserver> observers_; | 159 ObserverList<LayerAnimationObserver> observers_; |
131 | 160 |
132 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); | 161 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); |
133 }; | 162 }; |
134 | 163 |
135 } // namespace ui | 164 } // namespace ui |
136 | 165 |
137 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ | 166 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
OLD | NEW |