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

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

Issue 2550933002: Make all LayerAnimationElement::Create*Element return unique_ptr (Closed)
Patch Set: More change and typo fix Created 4 years 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
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 // TODO(vollick) Eventually, the LayerAnimator will switch to a model where new 34 // TODO(vollick) Eventually, the LayerAnimator will switch to a model where new
35 // work is scheduled rather than calling methods directly. This should make it 35 // work is scheduled rather than calling methods directly. This should make it
36 // impossible for temporary pointers to running animations to go stale. When 36 // impossible for temporary pointers to running animations to go stale. When
37 // this happens, there will be no need for LayerAnimationSequences to support 37 // this happens, there will be no need for LayerAnimationSequences to support
38 // weak pointers. 38 // weak pointers.
39 class COMPOSITOR_EXPORT LayerAnimationSequence 39 class COMPOSITOR_EXPORT LayerAnimationSequence
40 : public base::SupportsWeakPtr<LayerAnimationSequence> { 40 : public base::SupportsWeakPtr<LayerAnimationSequence> {
41 public: 41 public:
42 LayerAnimationSequence(); 42 LayerAnimationSequence();
43 // Takes ownership of the given element and adds it to the sequence. 43 // Takes ownership of the given element and adds it to the sequence.
44 explicit LayerAnimationSequence(LayerAnimationElement* element); 44 explicit LayerAnimationSequence(
45 std::unique_ptr<LayerAnimationElement> element);
45 virtual ~LayerAnimationSequence(); 46 virtual ~LayerAnimationSequence();
46 47
47 // Sets the start time for the animation. This must be called before the 48 // Sets the start time for the animation. This must be called before the
48 // first call to {Start, IsFinished}. Once the animation is finished, this 49 // first call to {Start, IsFinished}. Once the animation is finished, this
49 // must be called again in order to restart the animation. 50 // must be called again in order to restart the animation.
50 void set_start_time(base::TimeTicks start_time) { start_time_ = start_time; } 51 void set_start_time(base::TimeTicks start_time) { start_time_ = start_time; }
51 base::TimeTicks start_time() const { return start_time_; } 52 base::TimeTicks start_time() const { return start_time_; }
52 53
53 // Sets a flag indicating that this sequence will start together with other 54 // Sets a flag indicating that this sequence will start together with other
54 // sequences, and at least one of the sequences in this group has a threaded 55 // sequences, and at least one of the sequences in this group has a threaded
(...skipping 28 matching lines...) Expand all
83 // Aborts the given animation. 84 // Aborts the given animation.
84 void Abort(LayerAnimationDelegate* delegate); 85 void Abort(LayerAnimationDelegate* delegate);
85 86
86 // All properties modified by the sequence. 87 // All properties modified by the sequence.
87 LayerAnimationElement::AnimatableProperties properties() const { 88 LayerAnimationElement::AnimatableProperties properties() const {
88 return properties_; 89 return properties_;
89 } 90 }
90 91
91 // Adds an element to the sequence. The sequences takes ownership of this 92 // Adds an element to the sequence. The sequences takes ownership of this
92 // element. 93 // element.
93 void AddElement(LayerAnimationElement* element); 94 void AddElement(std::unique_ptr<LayerAnimationElement> element);
94 95
95 // Sequences can be looped indefinitely. 96 // Sequences can be looped indefinitely.
96 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } 97 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; }
97 bool is_cyclic() const { return is_cyclic_; } 98 bool is_cyclic() const { return is_cyclic_; }
98 99
99 // Returns true if this sequence has at least one element conflicting with a 100 // Returns true if this sequence has at least one element conflicting with a
100 // property in |other|. 101 // property in |other|.
101 bool HasConflictingProperty( 102 bool HasConflictingProperty(
102 LayerAnimationElement::AnimatableProperties other) const; 103 LayerAnimationElement::AnimatableProperties other) const;
103 104
(...skipping 26 matching lines...) Expand all
130 // by this sequence. Returns 0.0 if no elements have been progressed. 131 // by this sequence. Returns 0.0 if no elements have been progressed.
131 double last_progressed_fraction() const { return last_progressed_fraction_; } 132 double last_progressed_fraction() const { return last_progressed_fraction_; }
132 133
133 size_t size() const; 134 size_t size() const;
134 135
135 LayerAnimationElement* FirstElement() const; 136 LayerAnimationElement* FirstElement() const;
136 137
137 private: 138 private:
138 friend class LayerAnimatorTestController; 139 friend class LayerAnimatorTestController;
139 140
140 typedef std::vector<linked_ptr<LayerAnimationElement> > Elements; 141 using Elements = std::vector<std::unique_ptr<LayerAnimationElement>>;
loyso (OOO) 2016/12/13 02:26:54 Could you erase linked_ptr include dependency? It
141 142
142 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest, 143 FRIEND_TEST_ALL_PREFIXES(LayerAnimatorTest,
143 ObserverReleasedBeforeAnimationSequenceEnds); 144 ObserverReleasedBeforeAnimationSequenceEnds);
144 145
145 // Notifies the observers that this sequence has been scheduled. 146 // Notifies the observers that this sequence has been scheduled.
146 void NotifyScheduled(); 147 void NotifyScheduled();
147 148
148 // Notifies the observers that this sequence has been started. 149 // Notifies the observers that this sequence has been started.
149 void NotifyStarted(); 150 void NotifyStarted();
150 151
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 double last_progressed_fraction_; 192 double last_progressed_fraction_;
192 193
193 base::WeakPtrFactory<LayerAnimationSequence> weak_ptr_factory_; 194 base::WeakPtrFactory<LayerAnimationSequence> weak_ptr_factory_;
194 195
195 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); 196 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence);
196 }; 197 };
197 198
198 } // namespace ui 199 } // namespace ui
199 200
200 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ 201 #endif // UI_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698