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

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

Issue 134453004: Use a bitfield to store animatable properties. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another win build error (signed/unsigned comp). Created 6 years, 11 months 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) 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/debug/trace_event.h" 10 #include "base/debug/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 : is_cyclic_(false), 19 : properties_(LayerAnimationElement::UNKNOWN),
20 is_cyclic_(false),
20 last_element_(0), 21 last_element_(0),
21 waiting_for_group_start_(false), 22 waiting_for_group_start_(false),
22 animation_group_id_(0), 23 animation_group_id_(0),
23 last_progressed_fraction_(0.0), 24 last_progressed_fraction_(0.0),
24 weak_ptr_factory_(this) { 25 weak_ptr_factory_(this) {
25 } 26 }
26 27
27 LayerAnimationSequence::LayerAnimationSequence(LayerAnimationElement* element) 28 LayerAnimationSequence::LayerAnimationSequence(LayerAnimationElement* element)
28 : is_cyclic_(false), 29 : properties_(LayerAnimationElement::UNKNOWN),
30 is_cyclic_(false),
29 last_element_(0), 31 last_element_(0),
30 waiting_for_group_start_(false), 32 waiting_for_group_start_(false),
31 animation_group_id_(0), 33 animation_group_id_(0),
32 last_progressed_fraction_(0.0), 34 last_progressed_fraction_(0.0),
33 weak_ptr_factory_(this) { 35 weak_ptr_factory_(this) {
34 AddElement(element); 36 AddElement(element);
35 } 37 }
36 38
37 LayerAnimationSequence::~LayerAnimationSequence() { 39 LayerAnimationSequence::~LayerAnimationSequence() {
38 FOR_EACH_OBSERVER(LayerAnimationObserver, 40 FOR_EACH_OBSERVER(LayerAnimationObserver,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 while (current_index < elements_.size()) { 173 while (current_index < elements_.size()) {
172 elements_[current_index]->Abort(delegate); 174 elements_[current_index]->Abort(delegate);
173 ++current_index; 175 ++current_index;
174 } 176 }
175 last_element_ = 0; 177 last_element_ = 0;
176 waiting_for_group_start_ = false; 178 waiting_for_group_start_ = false;
177 NotifyAborted(); 179 NotifyAborted();
178 } 180 }
179 181
180 void LayerAnimationSequence::AddElement(LayerAnimationElement* element) { 182 void LayerAnimationSequence::AddElement(LayerAnimationElement* element) {
181 properties_.insert(element->properties().begin(), 183 properties_ |= element->properties();
182 element->properties().end());
183 elements_.push_back(make_linked_ptr(element)); 184 elements_.push_back(make_linked_ptr(element));
184 } 185 }
185 186
186 bool LayerAnimationSequence::HasConflictingProperty( 187 bool LayerAnimationSequence::HasConflictingProperty(
187 const LayerAnimationElement::AnimatableProperties& other) const { 188 LayerAnimationElement::AnimatableProperties other) const {
188 LayerAnimationElement::AnimatableProperties intersection; 189 return (properties_ & other) != LayerAnimationElement::UNKNOWN;
189 std::insert_iterator<LayerAnimationElement::AnimatableProperties> ii(
190 intersection, intersection.begin());
191 std::set_intersection(properties_.begin(), properties_.end(),
192 other.begin(), other.end(),
193 ii);
194 return (intersection.size() > 0);
195 } 190 }
196 191
197 bool LayerAnimationSequence::IsFirstElementThreaded() const { 192 bool LayerAnimationSequence::IsFirstElementThreaded() const {
198 if (!elements_.empty()) 193 if (!elements_.empty())
199 return elements_[0]->IsThreaded(); 194 return elements_[0]->IsThreaded();
200 195
201 return false; 196 return false;
202 } 197 }
203 198
204 void LayerAnimationSequence::AddObserver(LayerAnimationObserver* observer) { 199 void LayerAnimationSequence::AddObserver(LayerAnimationObserver* observer) {
205 if (!observers_.HasObserver(observer)) { 200 if (!observers_.HasObserver(observer)) {
206 observers_.AddObserver(observer); 201 observers_.AddObserver(observer);
207 observer->AttachedToSequence(this); 202 observer->AttachedToSequence(this);
208 } 203 }
209 } 204 }
210 205
211 void LayerAnimationSequence::RemoveObserver(LayerAnimationObserver* observer) { 206 void LayerAnimationSequence::RemoveObserver(LayerAnimationObserver* observer) {
212 observers_.RemoveObserver(observer); 207 observers_.RemoveObserver(observer);
213 observer->DetachedFromSequence(this, true); 208 observer->DetachedFromSequence(this, true);
214 } 209 }
215 210
216 void LayerAnimationSequence::OnThreadedAnimationStarted( 211 void LayerAnimationSequence::OnThreadedAnimationStarted(
217 const cc::AnimationEvent& event) { 212 const cc::AnimationEvent& event) {
218 if (elements_.empty() || event.group_id != animation_group_id_) 213 if (elements_.empty() || event.group_id != animation_group_id_)
219 return; 214 return;
220 215
221 size_t current_index = last_element_ % elements_.size(); 216 size_t current_index = last_element_ % elements_.size();
222 const LayerAnimationElement::AnimatableProperties& element_properties = 217 LayerAnimationElement::AnimatableProperties element_properties =
223 elements_[current_index]->properties(); 218 elements_[current_index]->properties();
224 LayerAnimationElement::AnimatableProperty event_property = 219 LayerAnimationElement::AnimatableProperty event_property =
225 LayerAnimationElement::ToAnimatableProperty(event.target_property); 220 LayerAnimationElement::ToAnimatableProperty(event.target_property);
226 DCHECK(element_properties.find(event_property) != element_properties.end()); 221 DCHECK(element_properties & event_property);
227 elements_[current_index]->set_effective_start_time( 222 elements_[current_index]->set_effective_start_time(
228 base::TimeTicks::FromInternalValue( 223 base::TimeTicks::FromInternalValue(
229 event.monotonic_time * base::Time::kMicrosecondsPerSecond)); 224 event.monotonic_time * base::Time::kMicrosecondsPerSecond));
230 } 225 }
231 226
232 void LayerAnimationSequence::OnScheduled() { 227 void LayerAnimationSequence::OnScheduled() {
233 NotifyScheduled(); 228 NotifyScheduled();
234 } 229 }
235 230
236 void LayerAnimationSequence::OnAnimatorDestroyed() { 231 void LayerAnimationSequence::OnAnimatorDestroyed() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 274
280 LayerAnimationElement* LayerAnimationSequence::CurrentElement() const { 275 LayerAnimationElement* LayerAnimationSequence::CurrentElement() const {
281 if (elements_.empty()) 276 if (elements_.empty())
282 return NULL; 277 return NULL;
283 278
284 size_t current_index = last_element_ % elements_.size(); 279 size_t current_index = last_element_ % elements_.size();
285 return elements_[current_index].get(); 280 return elements_[current_index].get();
286 } 281 }
287 282
288 } // namespace ui 283 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_sequence.h ('k') | ui/compositor/layer_animation_sequence_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698