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

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: Address reviewer comments. 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 // Called when the animator schedules this sequence.
78 void OnScheduled();
79
70 private: 80 private:
71 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; 81 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements;
72 82
83 // Notifies the observers that this sequence has been scheduled.
84 void NotifyScheduled();
85
86 // Notifies the observers that this sequence has ended.
87 void NotifyEnded();
88
89 // Notifies the observers that this sequence has been aborted.
90 void NotifyAborted();
91
73 // The sum of the durations of all the elements in the sequence. 92 // The sum of the durations of all the elements in the sequence.
74 base::TimeDelta duration_; 93 base::TimeDelta duration_;
75 94
76 // The union of all the properties modified by all elements in the sequence. 95 // The union of all the properties modified by all elements in the sequence.
77 LayerAnimationElement::AnimatableProperties properties_; 96 LayerAnimationElement::AnimatableProperties properties_;
78 97
79 // The elements in the sequence. 98 // The elements in the sequence.
80 Elements elements_; 99 Elements elements_;
81 100
82 // True if the sequence should be looped forever. 101 // True if the sequence should be looped forever.
83 bool is_cyclic_; 102 bool is_cyclic_;
84 103
85 // These are used when animating to efficiently find the next element. 104 // These are used when animating to efficiently find the next element.
86 size_t last_element_; 105 size_t last_element_;
87 base::TimeDelta last_start_; 106 base::TimeDelta last_start_;
88 107
108 // These parties are notified when layer animations end.
sky 2011/10/28 22:11:38 parties -> observers
109 ObserverList<LayerAnimationObserver> observers_;
110
89 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); 111 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence);
90 }; 112 };
91 113
92 } // namespace ui 114 } // namespace ui
93 115
94 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 116 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698