OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
| 6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/time.h" |
| 13 #include "ui/gfx/compositor/compositor_export.h" |
| 14 #include "ui/gfx/compositor/layer_animation_element.h" |
| 15 |
| 16 namespace ui { |
| 17 |
| 18 class LayerAnimationDelegate; |
| 19 |
| 20 // Contains a collection of layer animation elements to be played one after |
| 21 // another. Although it has a similar interface to LayerAnimationElement, it is |
| 22 // not a LayerAnimationElement (i.e., it is not permitted to have a sequence in |
| 23 // a sequence). Sequences own their elements, and sequences are themselves owned |
| 24 // by a LayerAnimator. |
| 25 // |
| 26 // TODO(vollick) Create a 'blended' sequence for transitioning between |
| 27 // sequences. |
| 28 class COMPOSITOR_EXPORT LayerAnimationSequence { |
| 29 public: |
| 30 LayerAnimationSequence(); |
| 31 // Takes ownership of the given element and adds it to the sequence. |
| 32 explicit LayerAnimationSequence(LayerAnimationElement* element); |
| 33 virtual ~LayerAnimationSequence(); |
| 34 |
| 35 // Updates the delegate to the appropriate value for |elapsed|, which is in |
| 36 // the range [0, Duration()]. If the animation is not aborted, it is |
| 37 // guaranteed that Animate will be called with elapsed = Duration(). |
| 38 void Progress(base::TimeDelta elapsed, LayerAnimationDelegate* delegate); |
| 39 |
| 40 // Aborts the given animation. |
| 41 void Abort(); |
| 42 |
| 43 // All properties modified by the sequence. |
| 44 const LayerAnimationElement::AnimatableProperties& properties() const { |
| 45 return properties_; |
| 46 } |
| 47 |
| 48 // The total, finite duration of one cycle of the sequence. |
| 49 base::TimeDelta duration() const { |
| 50 return duration_; |
| 51 } |
| 52 |
| 53 // Adds an element to the sequence. The sequences takes ownership of this |
| 54 // element. |
| 55 void AddElement(LayerAnimationElement* element); |
| 56 |
| 57 // Sequences can be looped indefinitely. |
| 58 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } |
| 59 bool is_cyclic() const { return is_cyclic_; } |
| 60 |
| 61 // Returns true if this sequence has at least one element affecting a |
| 62 // property in |other|. |
| 63 bool HasCommonProperty( |
| 64 const LayerAnimationElement::AnimatableProperties& other) const; |
| 65 |
| 66 private: |
| 67 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; |
| 68 |
| 69 // The sum of the durations of all the elements in the sequence. |
| 70 base::TimeDelta duration_; |
| 71 |
| 72 // The union of all the properties modified by all elements in the sequence. |
| 73 LayerAnimationElement::AnimatableProperties properties_; |
| 74 |
| 75 // The elements in the sequence. |
| 76 Elements elements_; |
| 77 |
| 78 // True if the sequence should be looped forever. |
| 79 bool is_cyclic_; |
| 80 |
| 81 // These are used when animating to efficiently find the next element. |
| 82 size_t last_element_; |
| 83 base::TimeDelta last_start_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); |
| 86 }; |
| 87 |
| 88 } // namespace ui |
| 89 |
| 90 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
OLD | NEW |