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

Side by Side Diff: ui/gfx/compositor/layer_animation_sequence.h

Issue 8395046: Allows observers to be notified when layer animations complete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with master Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/observer_list.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "ui/gfx/compositor/compositor_export.h" 14 #include "ui/gfx/compositor/compositor_export.h"
14 #include "ui/gfx/compositor/layer_animation_element.h" 15 #include "ui/gfx/compositor/layer_animation_element.h"
15 16
16 namespace ui { 17 namespace ui {
17 18
18 class LayerAnimationDelegate; 19 class LayerAnimationDelegate;
20 class LayerAnimationObserver;
19 21
20 // Contains a collection of layer animation elements to be played one after 22 // Contains a collection of layer animation elements to be played one after
21 // another. Although it has a similar interface to LayerAnimationElement, it is 23 // 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 24 // 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 25 // a sequence). Sequences own their elements, and sequences are themselves owned
24 // by a LayerAnimator. 26 // by a LayerAnimator.
25 // 27 //
26 // TODO(vollick) Create a 'blended' sequence for transitioning between 28 // TODO(vollick) Create a 'blended' sequence for transitioning between
27 // sequences. 29 // sequences.
28 class COMPOSITOR_EXPORT LayerAnimationSequence { 30 class COMPOSITOR_EXPORT LayerAnimationSequence {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 62
61 // Sequences can be looped indefinitely. 63 // Sequences can be looped indefinitely.
62 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } 64 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; }
63 bool is_cyclic() const { return is_cyclic_; } 65 bool is_cyclic() const { return is_cyclic_; }
64 66
65 // Returns true if this sequence has at least one element affecting a 67 // Returns true if this sequence has at least one element affecting a
66 // property in |other|. 68 // property in |other|.
67 bool HasCommonProperty( 69 bool HasCommonProperty(
68 const LayerAnimationElement::AnimatableProperties& other) const; 70 const LayerAnimationElement::AnimatableProperties& other) const;
69 71
72 // These functions are used for adding or removing observers from the observer
73 // list. The observers are notified when animations end.
74 void AddObserver(LayerAnimationObserver* observer);
75 void RemoveObserver(LayerAnimationObserver* observer);
76
77 // Notifies the observers that this sequence has ended.
78 void NotifyEnded();
79
70 private: 80 private:
71 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; 81 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements;
72 82
73 // The sum of the durations of all the elements in the sequence. 83 // The sum of the durations of all the elements in the sequence.
74 base::TimeDelta duration_; 84 base::TimeDelta duration_;
75 85
76 // The union of all the properties modified by all elements in the sequence. 86 // The union of all the properties modified by all elements in the sequence.
77 LayerAnimationElement::AnimatableProperties properties_; 87 LayerAnimationElement::AnimatableProperties properties_;
78 88
79 // The elements in the sequence. 89 // The elements in the sequence.
80 Elements elements_; 90 Elements elements_;
81 91
82 // True if the sequence should be looped forever. 92 // True if the sequence should be looped forever.
83 bool is_cyclic_; 93 bool is_cyclic_;
84 94
85 // These are used when animating to efficiently find the next element. 95 // These are used when animating to efficiently find the next element.
86 size_t last_element_; 96 size_t last_element_;
87 base::TimeDelta last_start_; 97 base::TimeDelta last_start_;
88 98
99 // These parties are notified when layer animations end.
100 ObserverList<LayerAnimationObserver> observers_;
101
89 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); 102 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence);
90 }; 103 };
91 104
92 } // namespace ui 105 } // namespace ui
93 106
94 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 107 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698