OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 double time_offset) { | 36 double time_offset) { |
37 for (size_t i = 0; i < active_animations_.size(); ++i) { | 37 for (size_t i = 0; i < active_animations_.size(); ++i) { |
38 if (active_animations_[i]->id() == animation_id) { | 38 if (active_animations_[i]->id() == animation_id) { |
39 active_animations_[i]->SetRunState( | 39 active_animations_[i]->SetRunState( |
40 Animation::Paused, time_offset + active_animations_[i]->start_time()); | 40 Animation::Paused, time_offset + active_animations_[i]->start_time()); |
41 } | 41 } |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 struct HasAnimationId { | 45 struct HasAnimationId { |
46 HasAnimationId(int id) : id_(id) {} | 46 explicit HasAnimationId(int id) : id_(id) {} |
47 bool operator()(Animation* animation) const { | 47 bool operator()(Animation* animation) const { |
48 return animation->id() == id_; | 48 return animation->id() == id_; |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 int id_; | 52 int id_; |
53 }; | 53 }; |
54 | 54 |
55 void LayerAnimationController::RemoveAnimation(int animation_id) { | 55 void LayerAnimationController::RemoveAnimation(int animation_id) { |
56 ScopedPtrVector<Animation>& animations = active_animations_; | 56 ScopedPtrVector<Animation>& animations = active_animations_; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (animation->target_property() == Animation::Opacity) { | 153 if (animation->target_property() == Animation::Opacity) { |
154 AnimationEvent event(AnimationEvent::PropertyUpdate, | 154 AnimationEvent event(AnimationEvent::PropertyUpdate, |
155 id_, | 155 id_, |
156 animation->group(), | 156 animation->group(), |
157 Animation::Opacity, | 157 Animation::Opacity, |
158 monotonic_time); | 158 monotonic_time); |
159 event.opacity = animation->curve()->ToFloatAnimationCurve()->GetValue( | 159 event.opacity = animation->curve()->ToFloatAnimationCurve()->GetValue( |
160 monotonic_time); | 160 monotonic_time); |
161 | 161 |
162 events->push_back(event); | 162 events->push_back(event); |
163 } | 163 } else if (animation->target_property() == Animation::Transform) { |
164 else if (animation->target_property() == Animation::Transform) { | |
165 AnimationEvent event(AnimationEvent::PropertyUpdate, | 164 AnimationEvent event(AnimationEvent::PropertyUpdate, |
166 id_, | 165 id_, |
167 animation->group(), | 166 animation->group(), |
168 Animation::Transform, | 167 Animation::Transform, |
169 monotonic_time); | 168 monotonic_time); |
170 event.transform = | 169 event.transform = |
171 animation->curve()->ToTransformAnimationCurve()->GetValue( | 170 animation->curve()->ToTransformAnimationCurve()->GetValue( |
172 monotonic_time); | 171 monotonic_time); |
173 events->push_back(event); | 172 events->push_back(event); |
174 } | 173 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 Animation::WaitingForTargetAvailability; | 297 Animation::WaitingForTargetAvailability; |
299 double start_time = 0; | 298 double start_time = 0; |
300 scoped_ptr<Animation> to_add(active_animations_[i]->CloneAndInitialize( | 299 scoped_ptr<Animation> to_add(active_animations_[i]->CloneAndInitialize( |
301 Animation::ControllingInstance, initial_run_state, start_time)); | 300 Animation::ControllingInstance, initial_run_state, start_time)); |
302 DCHECK(!to_add->needs_synchronized_start_time()); | 301 DCHECK(!to_add->needs_synchronized_start_time()); |
303 controller_impl->AddAnimation(to_add.Pass()); | 302 controller_impl->AddAnimation(to_add.Pass()); |
304 } | 303 } |
305 } | 304 } |
306 | 305 |
307 struct IsCompleted { | 306 struct IsCompleted { |
308 IsCompleted(const LayerAnimationController& main_thread_controller) | 307 explicit IsCompleted(const LayerAnimationController& main_thread_controller) |
309 : main_thread_controller_(main_thread_controller) {} | 308 : main_thread_controller_(main_thread_controller) {} |
310 bool operator()(Animation* animation) const { | 309 bool operator()(Animation* animation) const { |
311 if (animation->is_impl_only()) | 310 if (animation->is_impl_only()) |
312 return false; | 311 return false; |
313 return !main_thread_controller_.GetAnimation(animation->group(), | 312 return !main_thread_controller_.GetAnimation(animation->group(), |
314 animation->target_property()); | 313 animation->target_property()); |
315 } | 314 } |
316 | 315 |
317 private: | 316 private: |
318 const LayerAnimationController& main_thread_controller_; | 317 const LayerAnimationController& main_thread_controller_; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // start time from the impl thread and can start ticking. | 556 // start time from the impl thread and can start ticking. |
558 if (active_animations_[i]->needs_synchronized_start_time()) | 557 if (active_animations_[i]->needs_synchronized_start_time()) |
559 trimmed = 0; | 558 trimmed = 0; |
560 | 559 |
561 // A just-started animation assumes its initial value. | 560 // A just-started animation assumes its initial value. |
562 if (active_animations_[i]->run_state() == Animation::Starting && | 561 if (active_animations_[i]->run_state() == Animation::Starting && |
563 !active_animations_[i]->has_set_start_time()) | 562 !active_animations_[i]->has_set_start_time()) |
564 trimmed = 0; | 563 trimmed = 0; |
565 | 564 |
566 switch (active_animations_[i]->target_property()) { | 565 switch (active_animations_[i]->target_property()) { |
567 | |
568 case Animation::Transform: { | 566 case Animation::Transform: { |
569 const TransformAnimationCurve* transform_animation_curve = | 567 const TransformAnimationCurve* transform_animation_curve = |
570 active_animations_[i]->curve()->ToTransformAnimationCurve(); | 568 active_animations_[i]->curve()->ToTransformAnimationCurve(); |
571 const gfx::Transform transform = | 569 const gfx::Transform transform = |
572 transform_animation_curve->GetValue(trimmed); | 570 transform_animation_curve->GetValue(trimmed); |
573 NotifyObserversTransformAnimated(transform); | 571 NotifyObserversTransformAnimated(transform); |
574 break; | 572 break; |
575 } | 573 } |
576 | 574 |
577 case Animation::Opacity: { | 575 case Animation::Opacity: { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 ObserverListBase<LayerAnimationValueObserver>::Iterator it(observers_); | 617 ObserverListBase<LayerAnimationValueObserver>::Iterator it(observers_); |
620 LayerAnimationValueObserver* obs; | 618 LayerAnimationValueObserver* obs; |
621 while ((obs = it.GetNext()) != NULL) | 619 while ((obs = it.GetNext()) != NULL) |
622 if (obs->IsActive()) | 620 if (obs->IsActive()) |
623 return true; | 621 return true; |
624 } | 622 } |
625 return false; | 623 return false; |
626 } | 624 } |
627 | 625 |
628 } // namespace cc | 626 } // namespace cc |
OLD | NEW |