OLD | NEW |
---|---|
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 #include "ui/compositor/layer_animation_sequence.h" | 5 #include "ui/compositor/layer_animation_sequence.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
11 #include "cc/animation/animation_id_provider.h" | 11 #include "cc/animation/animation_id_provider.h" |
12 #include "ui/compositor/layer_animation_delegate.h" | 12 #include "ui/compositor/layer_animation_delegate.h" |
13 #include "ui/compositor/layer_animation_element.h" | 13 #include "ui/compositor/layer_animation_element.h" |
14 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 LayerAnimationSequence::LayerAnimationSequence() | 18 LayerAnimationSequence::LayerAnimationSequence() |
19 : properties_(LayerAnimationElement::UNKNOWN), | 19 : properties_(LayerAnimationElement::UNKNOWN), |
20 is_cyclic_(false), | 20 is_cyclic_(false), |
21 last_element_(0), | 21 last_element_(0), |
22 waiting_for_group_start_(false), | 22 waiting_for_group_start_(false), |
23 animation_group_id_(0), | 23 animation_group_id_(0), |
24 last_progressed_fraction_(0.0), | 24 last_progressed_fraction_(0.0), |
25 weak_ptr_factory_(this) { | 25 weak_ptr_factory_(this) { |
26 } | 26 } |
27 | 27 |
28 LayerAnimationSequence::LayerAnimationSequence(LayerAnimationElement* element) | 28 LayerAnimationSequence::LayerAnimationSequence( |
29 std::unique_ptr<LayerAnimationElement> element) | |
29 : properties_(LayerAnimationElement::UNKNOWN), | 30 : properties_(LayerAnimationElement::UNKNOWN), |
30 is_cyclic_(false), | 31 is_cyclic_(false), |
31 last_element_(0), | 32 last_element_(0), |
32 waiting_for_group_start_(false), | 33 waiting_for_group_start_(false), |
33 animation_group_id_(0), | 34 animation_group_id_(0), |
34 last_progressed_fraction_(0.0), | 35 last_progressed_fraction_(0.0), |
35 weak_ptr_factory_(this) { | 36 weak_ptr_factory_(this) { |
36 AddElement(element); | 37 AddElement(std::move(element)); |
37 } | 38 } |
38 | 39 |
39 LayerAnimationSequence::~LayerAnimationSequence() { | 40 LayerAnimationSequence::~LayerAnimationSequence() { |
40 for (auto& observer : observers_) | 41 for (auto& observer : observers_) |
41 observer.DetachedFromSequence(this, true); | 42 observer.DetachedFromSequence(this, true); |
42 } | 43 } |
43 | 44 |
44 void LayerAnimationSequence::Start(LayerAnimationDelegate* delegate) { | 45 void LayerAnimationSequence::Start(LayerAnimationDelegate* delegate) { |
45 DCHECK(start_time_ != base::TimeTicks()); | 46 DCHECK(start_time_ != base::TimeTicks()); |
46 last_progressed_fraction_ = 0.0; | 47 last_progressed_fraction_ = 0.0; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 size_t current_index = last_element_ % elements_.size(); | 176 size_t current_index = last_element_ % elements_.size(); |
176 while (current_index < elements_.size()) { | 177 while (current_index < elements_.size()) { |
177 elements_[current_index]->Abort(delegate); | 178 elements_[current_index]->Abort(delegate); |
178 ++current_index; | 179 ++current_index; |
179 } | 180 } |
180 last_element_ = 0; | 181 last_element_ = 0; |
181 waiting_for_group_start_ = false; | 182 waiting_for_group_start_ = false; |
182 NotifyAborted(); | 183 NotifyAborted(); |
183 } | 184 } |
184 | 185 |
185 void LayerAnimationSequence::AddElement(LayerAnimationElement* element) { | 186 void LayerAnimationSequence::AddElement( |
187 std::unique_ptr<LayerAnimationElement> element) { | |
186 properties_ |= element->properties(); | 188 properties_ |= element->properties(); |
187 elements_.push_back(make_linked_ptr(element)); | 189 elements_.push_back(std::move(element)); |
sky
2016/12/15 16:42:18
push_back->emplace_back?
Sunny
2016/12/16 10:53:49
Emm...Do you prefer emplace_back(std::move(element
danakj
2016/12/16 14:20:31
Never use release() unless you really have to. Sin
| |
188 } | 190 } |
189 | 191 |
190 bool LayerAnimationSequence::HasConflictingProperty( | 192 bool LayerAnimationSequence::HasConflictingProperty( |
191 LayerAnimationElement::AnimatableProperties other) const { | 193 LayerAnimationElement::AnimatableProperties other) const { |
192 return (properties_ & other) != LayerAnimationElement::UNKNOWN; | 194 return (properties_ & other) != LayerAnimationElement::UNKNOWN; |
193 } | 195 } |
194 | 196 |
195 bool LayerAnimationSequence::IsFirstElementThreaded() const { | 197 bool LayerAnimationSequence::IsFirstElementThreaded() const { |
196 if (!elements_.empty()) | 198 if (!elements_.empty()) |
197 return elements_[0]->IsThreaded(); | 199 return elements_[0]->IsThreaded(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 | 277 |
276 LayerAnimationElement* LayerAnimationSequence::CurrentElement() const { | 278 LayerAnimationElement* LayerAnimationSequence::CurrentElement() const { |
277 if (elements_.empty()) | 279 if (elements_.empty()) |
278 return NULL; | 280 return NULL; |
279 | 281 |
280 size_t current_index = last_element_ % elements_.size(); | 282 size_t current_index = last_element_ % elements_.size(); |
281 return elements_[current_index].get(); | 283 return elements_[current_index].get(); |
282 } | 284 } |
283 | 285 |
284 } // namespace ui | 286 } // namespace ui |
OLD | NEW |