Index: ui/gfx/compositor/layer_animation_sequence.h |
diff --git a/ui/gfx/compositor/layer_animation_sequence.h b/ui/gfx/compositor/layer_animation_sequence.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..26b25a20dd380215ee586aa32bf13d054a8289a1 |
--- /dev/null |
+++ b/ui/gfx/compositor/layer_animation_sequence.h |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
+#define UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |
+#pragma once |
+ |
+#include <vector> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/time.h" |
+#include "ui/gfx/compositor/layer_animation_element.h" |
+ |
+namespace ui { |
+ |
+class LayerAnimationDelegate; |
+ |
+// Contains a collection of layer animation elements. Although it has a similar |
sky
2011/10/14 16:39:52
Clarify this runs the elements one after another.
|
+// interface to LayerAnimationElement, it is not a LayerAnimationElement (i.e., |
+// it is not permitted to have a sequence in a sequence). |
sky
2011/10/14 16:39:52
Also document who owns these
|
+// |
+// TODO(vollick) Create a 'blended' sequence for transitioning between |
+// sequences. |
+class LayerAnimationSequence : public base::RefCounted<LayerAnimationSequence> { |
sky
2011/10/14 16:39:52
same comment about refcounted here.
|
+ public: |
+ typedef std::vector<scoped_refptr<LayerAnimationElement> > Elements; |
+ |
+ LayerAnimationSequence(); |
+ LayerAnimationSequence(LayerAnimationElement* element); |
sky
2011/10/14 16:39:52
explicit
|
+ |
+ // Updates the delegate to the appropriate value for |elapsed|, which is in |
+ // the range [0, Duration()]. If the animation is not aborted, it is |
+ // guaranteed that Animate will be called with elapsed = Duration(). |
+ void Progress(base::TimeDelta elapsed, LayerAnimationDelegate* delegate); |
+ |
+ // Aborts the given animation. |
+ void Abort(); |
+ |
+ // All properties modified by the sequence. |
+ const LayerAnimationElement::AnimatableProperties& properties() const { |
+ return properties_; |
+ } |
+ |
+ // The total, finite duration of one cycle of the sequence. |
+ base::TimeDelta duration() const { |
+ return duration_; |
+ } |
+ |
+ // Adds an element to the sequence. |
+ void AddElement(LayerAnimationElement* element); |
+ |
+ // Sequences can be looped indefinitely. |
+ void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } |
+ bool is_cyclic() const { return is_cyclic_; } |
+ |
+ // Returns true, if the sequences share a common property |
sky
2011/10/14 16:39:52
nit: end with '.'.
|
+ bool HasCommonProperty(const LayerAnimationSequence& other) const; |
+ |
+ private: |
+ friend class base::RefCounted<LayerAnimationSequence>; |
+ virtual ~LayerAnimationSequence(); |
+ |
+ base::TimeDelta duration_; |
+ LayerAnimationElement::AnimatableProperties properties_; |
+ Elements elements_; |
+ bool is_cyclic_; |
+ |
+ // these are used when animating to efficiently find the next element |
+ Elements::size_type last_element_; |
+ base::TimeDelta last_start_; |
sky
2011/10/14 16:39:52
I think you want timeticks for this sort of stuff.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ |