| 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" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "ui/compositor/compositor_export.h" | 15 #include "ui/compositor/compositor_export.h" |
| 16 #include "ui/compositor/layer_animation_element.h" | 16 #include "ui/compositor/layer_animation_element.h" |
| 17 #include "ui/gfx/frame_time.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 20 class LayerAnimationDelegate; | 21 class LayerAnimationDelegate; |
| 21 class LayerAnimationObserver; | 22 class LayerAnimationObserver; |
| 22 | 23 |
| 23 // Contains a collection of layer animation elements to be played one after | 24 // Contains a collection of layer animation elements to be played one after |
| 24 // another. Although it has a similar interface to LayerAnimationElement, it is | 25 // another. Although it has a similar interface to LayerAnimationElement, it is |
| 25 // not a LayerAnimationElement (i.e., it is not permitted to have a sequence in | 26 // not a LayerAnimationElement (i.e., it is not permitted to have a sequence in |
| 26 // a sequence). Sequences own their elements, and sequences are themselves owned | 27 // a sequence). Sequences own their elements, and sequences are themselves owned |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 : public base::SupportsWeakPtr<LayerAnimationSequence> { | 38 : public base::SupportsWeakPtr<LayerAnimationSequence> { |
| 38 public: | 39 public: |
| 39 LayerAnimationSequence(); | 40 LayerAnimationSequence(); |
| 40 // Takes ownership of the given element and adds it to the sequence. | 41 // Takes ownership of the given element and adds it to the sequence. |
| 41 explicit LayerAnimationSequence(LayerAnimationElement* element); | 42 explicit LayerAnimationSequence(LayerAnimationElement* element); |
| 42 virtual ~LayerAnimationSequence(); | 43 virtual ~LayerAnimationSequence(); |
| 43 | 44 |
| 44 // Sets the start time for the animation. This must be called before the | 45 // Sets the start time for the animation. This must be called before the |
| 45 // first call to {Start, IsFinished}. Once the animation is finished, this | 46 // first call to {Start, IsFinished}. Once the animation is finished, this |
| 46 // must be called again in order to restart the animation. | 47 // must be called again in order to restart the animation. |
| 47 void set_start_time(base::TimeTicks start_time) { start_time_ = start_time; } | 48 void set_start_time(gfx::FrameTime start_time) { start_time_ = start_time; } |
| 48 base::TimeTicks start_time() const { return start_time_; } | 49 gfx::FrameTime start_time() const { return start_time_; } |
| 49 | 50 |
| 50 // Sets a flag indicating that this sequence will start together with other | 51 // 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 // sequences, and at least one of the sequences in this group has a threaded |
| 52 // first element. | 53 // first element. |
| 53 void set_waiting_for_group_start(bool waiting) { | 54 void set_waiting_for_group_start(bool waiting) { |
| 54 waiting_for_group_start_ = waiting; | 55 waiting_for_group_start_ = waiting; |
| 55 } | 56 } |
| 56 bool waiting_for_group_start() { return waiting_for_group_start_; } | 57 bool waiting_for_group_start() { return waiting_for_group_start_; } |
| 57 | 58 |
| 58 // This must be called before the first call to Progress. If starting the | 59 // 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 // animation involves dispatching to another thread, then this will proceed |
| 60 // with that dispatch, ultimately resulting in the animation getting an | 61 // with that dispatch, ultimately resulting in the animation getting an |
| 61 // effective start time (the time the animation starts on the other thread). | 62 // effective start time (the time the animation starts on the other thread). |
| 62 void Start(LayerAnimationDelegate* delegate); | 63 void Start(LayerAnimationDelegate* delegate); |
| 63 | 64 |
| 64 // Updates the delegate to the appropriate value for |now|. Requests a | 65 // Updates the delegate to the appropriate value for |now|. Requests a |
| 65 // redraw if it is required. | 66 // redraw if it is required. |
| 66 void Progress(base::TimeTicks now, LayerAnimationDelegate* delegate); | 67 void Progress(gfx::FrameTime now, LayerAnimationDelegate* delegate); |
| 67 | 68 |
| 68 // Returns true if calling Progress now, with the given time, will finish | 69 // Returns true if calling Progress now, with the given time, will finish |
| 69 // the animation. | 70 // the animation. |
| 70 bool IsFinished(base::TimeTicks time); | 71 bool IsFinished(gfx::FrameTime time); |
| 71 | 72 |
| 72 // Updates the delegate to the end of the animation; if this sequence is | 73 // Updates the delegate to the end of the animation; if this sequence is |
| 73 // cyclic, updates the delegate to the end of one cycle of the sequence. | 74 // cyclic, updates the delegate to the end of one cycle of the sequence. |
| 74 void ProgressToEnd(LayerAnimationDelegate* delegate); | 75 void ProgressToEnd(LayerAnimationDelegate* delegate); |
| 75 | 76 |
| 76 // Sets the target value to the value that would have been set had | 77 // Sets the target value to the value that would have been set had |
| 77 // the sequence completed. Does nothing if the sequence is cyclic. | 78 // the sequence completed. Does nothing if the sequence is cyclic. |
| 78 void GetTargetValue(LayerAnimationElement::TargetValue* target) const; | 79 void GetTargetValue(LayerAnimationElement::TargetValue* target) const; |
| 79 | 80 |
| 80 // Aborts the given animation. | 81 // Aborts the given animation. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 LayerAnimationElement::AnimatableProperties properties_; | 154 LayerAnimationElement::AnimatableProperties properties_; |
| 154 | 155 |
| 155 // The elements in the sequence. | 156 // The elements in the sequence. |
| 156 Elements elements_; | 157 Elements elements_; |
| 157 | 158 |
| 158 // True if the sequence should be looped forever. | 159 // True if the sequence should be looped forever. |
| 159 bool is_cyclic_; | 160 bool is_cyclic_; |
| 160 | 161 |
| 161 // These are used when animating to efficiently find the next element. | 162 // These are used when animating to efficiently find the next element. |
| 162 size_t last_element_; | 163 size_t last_element_; |
| 163 base::TimeTicks last_start_; | 164 gfx::FrameTime last_start_; |
| 164 | 165 |
| 165 // The start time of the current run of the sequence. | 166 // The start time of the current run of the sequence. |
| 166 base::TimeTicks start_time_; | 167 gfx::FrameTime start_time_; |
| 167 | 168 |
| 168 // True if this sequence will start together with other sequences, and at | 169 // True if this sequence will start together with other sequences, and at |
| 169 // least one of the sequences in this group has a threaded first element. | 170 // least one of the sequences in this group has a threaded first element. |
| 170 bool waiting_for_group_start_; | 171 bool waiting_for_group_start_; |
| 171 | 172 |
| 172 // Identifies groups of sequences that are supposed to start together. | 173 // Identifies groups of sequences that are supposed to start together. |
| 173 // Also used to identify the owner of a particular threaded animation; any | 174 // Also used to identify the owner of a particular threaded animation; any |
| 174 // in-progress threaded animation owned by this sequence will have this | 175 // in-progress threaded animation owned by this sequence will have this |
| 175 // group id. | 176 // group id. |
| 176 int animation_group_id_; | 177 int animation_group_id_; |
| 177 | 178 |
| 178 // These parties are notified when layer animations end. | 179 // These parties are notified when layer animations end. |
| 179 ObserverList<LayerAnimationObserver> observers_; | 180 ObserverList<LayerAnimationObserver> observers_; |
| 180 | 181 |
| 181 // Tracks the last_progressed_fraction() of the most recently progressed | 182 // Tracks the last_progressed_fraction() of the most recently progressed |
| 182 // element. | 183 // element. |
| 183 double last_progressed_fraction_; | 184 double last_progressed_fraction_; |
| 184 | 185 |
| 185 base::WeakPtrFactory<LayerAnimationSequence> weak_ptr_factory_; | 186 base::WeakPtrFactory<LayerAnimationSequence> weak_ptr_factory_; |
| 186 | 187 |
| 187 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); | 188 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); |
| 188 }; | 189 }; |
| 189 | 190 |
| 190 } // namespace ui | 191 } // namespace ui |
| 191 | 192 |
| 192 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ | 193 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
| OLD | NEW |