| 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/animation_registrar.h" | 5 #include "cc/animation/animation_registrar.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| 11 #include "cc/animation/animation_events.h" |
| 11 #include "cc/animation/layer_animation_controller.h" | 12 #include "cc/animation/layer_animation_controller.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 AnimationRegistrar::AnimationRegistrar() : supports_scroll_animations_(false) { | 16 AnimationRegistrar::AnimationRegistrar() : supports_scroll_animations_(false) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 AnimationRegistrar::~AnimationRegistrar() { | 19 AnimationRegistrar::~AnimationRegistrar() { |
| 19 AnimationControllerMap copy = all_animation_controllers_; | 20 AnimationControllerMap copy = all_animation_controllers_; |
| 20 for (AnimationControllerMap::iterator iter = copy.begin(); | 21 for (AnimationControllerMap::iterator iter = copy.begin(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 79 |
| 79 TRACE_EVENT0("cc", "AnimationRegistrar::AnimateLayers"); | 80 TRACE_EVENT0("cc", "AnimationRegistrar::AnimateLayers"); |
| 80 AnimationControllerMap controllers_copy = active_animation_controllers_; | 81 AnimationControllerMap controllers_copy = active_animation_controllers_; |
| 81 for (auto& it : controllers_copy) | 82 for (auto& it : controllers_copy) |
| 82 it.second->Animate(monotonic_time); | 83 it.second->Animate(monotonic_time); |
| 83 | 84 |
| 84 return true; | 85 return true; |
| 85 } | 86 } |
| 86 | 87 |
| 87 bool AnimationRegistrar::UpdateAnimationState(bool start_ready_animations, | 88 bool AnimationRegistrar::UpdateAnimationState(bool start_ready_animations, |
| 88 AnimationEventsVector* events) { | 89 AnimationEvents* events) { |
| 89 if (!needs_animate_layers()) | 90 if (!needs_animate_layers()) |
| 90 return false; | 91 return false; |
| 91 | 92 |
| 92 TRACE_EVENT0("cc", "AnimationRegistrar::UpdateAnimationState"); | 93 TRACE_EVENT0("cc", "AnimationRegistrar::UpdateAnimationState"); |
| 93 AnimationControllerMap active_controllers_copy = | 94 AnimationControllerMap active_controllers_copy = |
| 94 active_animation_controllers_; | 95 active_animation_controllers_; |
| 95 for (auto& it : active_controllers_copy) | 96 for (auto& it : active_controllers_copy) |
| 96 it.second->UpdateState(start_ready_animations, events); | 97 it.second->UpdateState(start_ready_animations, events); |
| 97 | 98 |
| 98 return true; | 99 return true; |
| 99 } | 100 } |
| 100 | 101 |
| 102 scoped_ptr<AnimationEvents> AnimationRegistrar::CreateEvents() { |
| 103 return make_scoped_ptr(new AnimationEvents()); |
| 104 } |
| 105 |
| 101 void AnimationRegistrar::SetAnimationEvents( | 106 void AnimationRegistrar::SetAnimationEvents( |
| 102 scoped_ptr<AnimationEventsVector> events) { | 107 scoped_ptr<AnimationEvents> events) { |
| 103 for (size_t event_index = 0; event_index < events->size(); ++event_index) { | 108 for (size_t event_index = 0; event_index < events->events_.size(); |
| 104 int event_layer_id = (*events)[event_index].layer_id; | 109 ++event_index) { |
| 110 int event_layer_id = events->events_[event_index].layer_id; |
| 105 | 111 |
| 106 // Use the map of all controllers, not just active ones, since non-active | 112 // Use the map of all controllers, not just active ones, since non-active |
| 107 // controllers may still receive events for impl-only animations. | 113 // controllers may still receive events for impl-only animations. |
| 108 const AnimationRegistrar::AnimationControllerMap& animation_controllers = | 114 const AnimationRegistrar::AnimationControllerMap& animation_controllers = |
| 109 all_animation_controllers_; | 115 all_animation_controllers_; |
| 110 auto iter = animation_controllers.find(event_layer_id); | 116 auto iter = animation_controllers.find(event_layer_id); |
| 111 if (iter != animation_controllers.end()) { | 117 if (iter != animation_controllers.end()) { |
| 112 switch ((*events)[event_index].type) { | 118 switch (events->events_[event_index].type) { |
| 113 case AnimationEvent::STARTED: | 119 case AnimationEvent::STARTED: |
| 114 (*iter).second->NotifyAnimationStarted((*events)[event_index]); | 120 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); |
| 115 break; | 121 break; |
| 116 | 122 |
| 117 case AnimationEvent::FINISHED: | 123 case AnimationEvent::FINISHED: |
| 118 (*iter).second->NotifyAnimationFinished((*events)[event_index]); | 124 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); |
| 119 break; | 125 break; |
| 120 | 126 |
| 121 case AnimationEvent::ABORTED: | 127 case AnimationEvent::ABORTED: |
| 122 (*iter).second->NotifyAnimationAborted((*events)[event_index]); | 128 (*iter).second->NotifyAnimationAborted(events->events_[event_index]); |
| 123 break; | 129 break; |
| 124 | 130 |
| 125 case AnimationEvent::PROPERTY_UPDATE: | 131 case AnimationEvent::PROPERTY_UPDATE: |
| 126 (*iter).second->NotifyAnimationPropertyUpdate((*events)[event_index]); | 132 (*iter).second->NotifyAnimationPropertyUpdate( |
| 133 events->events_[event_index]); |
| 127 break; | 134 break; |
| 128 } | 135 } |
| 129 } | 136 } |
| 130 } | 137 } |
| 131 } | 138 } |
| 132 | 139 |
| 133 } // namespace cc | 140 } // namespace cc |
| OLD | NEW |