OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 3103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 client_->RenewTreePriority(); | 3114 client_->RenewTreePriority(); |
3115 } | 3115 } |
3116 | 3116 |
3117 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 3117 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
3118 if (!settings_.accelerated_animation_enabled || | 3118 if (!settings_.accelerated_animation_enabled || |
3119 !needs_animate_layers() || | 3119 !needs_animate_layers() || |
3120 !active_tree_->root_layer()) | 3120 !active_tree_->root_layer()) |
3121 return; | 3121 return; |
3122 | 3122 |
3123 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 3123 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
3124 AnimationRegistrar::AnimationControllerMap copy = | 3124 AnimationRegistrar::AnimationControllerMap controllers_copy = |
3125 animation_registrar_->active_animation_controllers(); | 3125 animation_registrar_->active_animation_controllers(); |
3126 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 3126 for (auto& it : controllers_copy) |
3127 iter != copy.end(); | 3127 it.second->Animate(monotonic_time); |
3128 ++iter) | |
3129 (*iter).second->Animate(monotonic_time); | |
3130 | 3128 |
3131 SetNeedsAnimate(); | 3129 SetNeedsAnimate(); |
3132 } | 3130 } |
3133 | 3131 |
3134 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 3132 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
3135 if (!settings_.accelerated_animation_enabled || | 3133 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || |
3136 !needs_animate_layers() || | |
3137 !active_tree_->root_layer()) | 3134 !active_tree_->root_layer()) |
3138 return; | 3135 return; |
3139 | 3136 |
3140 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); | 3137 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); |
3141 scoped_ptr<AnimationEventsVector> events = | 3138 scoped_ptr<AnimationEventsVector> events = |
3142 make_scoped_ptr(new AnimationEventsVector); | 3139 make_scoped_ptr(new AnimationEventsVector); |
3143 AnimationRegistrar::AnimationControllerMap copy = | 3140 AnimationRegistrar::AnimationControllerMap active_controllers_copy = |
3144 animation_registrar_->active_animation_controllers(); | 3141 animation_registrar_->active_animation_controllers(); |
3145 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 3142 for (auto& it : active_controllers_copy) |
3146 iter != copy.end(); | 3143 it.second->UpdateState(start_ready_animations, events.get()); |
3147 ++iter) | |
3148 (*iter).second->UpdateState(start_ready_animations, events.get()); | |
3149 | 3144 |
3150 if (!events->empty()) { | 3145 if (!events->empty()) { |
3151 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); | 3146 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); |
3152 } | 3147 } |
3153 | 3148 |
3154 SetNeedsAnimate(); | 3149 SetNeedsAnimate(); |
3155 } | 3150 } |
3156 | 3151 |
3157 void LayerTreeHostImpl::ActivateAnimations() { | 3152 void LayerTreeHostImpl::ActivateAnimations() { |
3158 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || | 3153 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || |
3159 !active_tree_->root_layer()) | 3154 !active_tree_->root_layer()) |
3160 return; | 3155 return; |
3161 | 3156 |
3162 TRACE_EVENT0("cc", "LayerTreeHostImpl::ActivateAnimations"); | 3157 TRACE_EVENT0("cc", "LayerTreeHostImpl::ActivateAnimations"); |
3163 AnimationRegistrar::AnimationControllerMap copy = | 3158 AnimationRegistrar::AnimationControllerMap active_controllers_copy = |
3164 animation_registrar_->active_animation_controllers(); | 3159 animation_registrar_->active_animation_controllers(); |
3165 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 3160 for (auto& it : active_controllers_copy) |
3166 iter != copy.end(); | 3161 it.second->ActivateAnimations(); |
3167 ++iter) | |
3168 (*iter).second->ActivateAnimations(); | |
3169 | 3162 |
3170 SetNeedsAnimate(); | 3163 SetNeedsAnimate(); |
3171 } | 3164 } |
3172 | 3165 |
3173 std::string LayerTreeHostImpl::LayerTreeAsJson() const { | 3166 std::string LayerTreeHostImpl::LayerTreeAsJson() const { |
3174 std::string str; | 3167 std::string str; |
3175 if (active_tree_->root_layer()) { | 3168 if (active_tree_->root_layer()) { |
3176 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); | 3169 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); |
3177 base::JSONWriter::WriteWithOptions( | 3170 base::JSONWriter::WriteWithOptions( |
3178 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3171 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3471 (*it)->OnSetNeedsRedrawOnImpl(); | 3464 (*it)->OnSetNeedsRedrawOnImpl(); |
3472 } | 3465 } |
3473 | 3466 |
3474 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3467 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3475 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3468 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3476 for (; it != swap_promise_monitor_.end(); it++) | 3469 for (; it != swap_promise_monitor_.end(); it++) |
3477 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3470 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3478 } | 3471 } |
3479 | 3472 |
3480 } // namespace cc | 3473 } // namespace cc |
OLD | NEW |