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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 | 909 |
910 // Should only have one render pass in resourceless software mode. | 910 // Should only have one render pass in resourceless software mode. |
911 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || | 911 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || |
912 frame->render_passes.size() == 1u) | 912 frame->render_passes.size() == 1u) |
913 << frame->render_passes.size(); | 913 << frame->render_passes.size(); |
914 | 914 |
915 return draw_result; | 915 return draw_result; |
916 } | 916 } |
917 | 917 |
918 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 918 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 919 if (top_controls_manager_) |
| 920 top_controls_manager_->MainThreadHasStoppedFlinging(); |
919 if (input_handler_client_) | 921 if (input_handler_client_) |
920 input_handler_client_->MainThreadHasStoppedFlinging(); | 922 input_handler_client_->MainThreadHasStoppedFlinging(); |
921 } | 923 } |
922 | 924 |
923 void LayerTreeHostImpl::DidAnimateScrollOffset() { | 925 void LayerTreeHostImpl::DidAnimateScrollOffset() { |
924 client_->SetNeedsCommitOnImplThread(); | 926 client_->SetNeedsCommitOnImplThread(); |
925 client_->RenewTreePriority(); | 927 client_->RenewTreePriority(); |
926 } | 928 } |
927 | 929 |
928 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { | 930 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { |
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3105 if (scroll.IsZero()) | 3107 if (scroll.IsZero()) |
3106 return; | 3108 return; |
3107 | 3109 |
3108 ScrollViewportBy(gfx::ScaleVector2d( | 3110 ScrollViewportBy(gfx::ScaleVector2d( |
3109 scroll, 1.f / active_tree_->current_page_scale_factor())); | 3111 scroll, 1.f / active_tree_->current_page_scale_factor())); |
3110 SetNeedsRedraw(); | 3112 SetNeedsRedraw(); |
3111 client_->SetNeedsCommitOnImplThread(); | 3113 client_->SetNeedsCommitOnImplThread(); |
3112 client_->RenewTreePriority(); | 3114 client_->RenewTreePriority(); |
3113 } | 3115 } |
3114 | 3116 |
| 3117 void LayerTreeHostImpl::AnimateScrollbars(base::TimeTicks monotonic_time) { |
| 3118 if (scrollbar_animation_controllers_.empty()) |
| 3119 return; |
| 3120 |
| 3121 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateScrollbars"); |
| 3122 std::set<ScrollbarAnimationController*> controllers_copy = |
| 3123 scrollbar_animation_controllers_; |
| 3124 for (auto& it : controllers_copy) |
| 3125 it->Animate(monotonic_time); |
| 3126 |
| 3127 SetNeedsAnimate(); |
| 3128 } |
| 3129 |
3115 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 3130 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
3116 if (!settings_.accelerated_animation_enabled || | 3131 if (!settings_.accelerated_animation_enabled || |
3117 !needs_animate_layers() || | 3132 !needs_animate_layers() || |
3118 !active_tree_->root_layer()) | 3133 !active_tree_->root_layer()) |
3119 return; | 3134 return; |
3120 | 3135 |
3121 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 3136 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
3122 AnimationRegistrar::AnimationControllerMap copy = | 3137 AnimationRegistrar::AnimationControllerMap controllers_copy = |
3123 animation_registrar_->active_animation_controllers(); | 3138 animation_registrar_->active_animation_controllers(); |
3124 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 3139 for (auto& it : controllers_copy) |
3125 iter != copy.end(); | 3140 it.second->Animate(monotonic_time); |
3126 ++iter) | |
3127 (*iter).second->Animate(monotonic_time); | |
3128 | 3141 |
3129 SetNeedsAnimate(); | 3142 SetNeedsAnimate(); |
3130 } | 3143 } |
3131 | 3144 |
3132 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 3145 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
3133 if (!settings_.accelerated_animation_enabled || | 3146 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || |
3134 !needs_animate_layers() || | |
3135 !active_tree_->root_layer()) | 3147 !active_tree_->root_layer()) |
3136 return; | 3148 return; |
3137 | 3149 |
3138 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); | 3150 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); |
3139 scoped_ptr<AnimationEventsVector> events = | 3151 scoped_ptr<AnimationEventsVector> events = |
3140 make_scoped_ptr(new AnimationEventsVector); | 3152 make_scoped_ptr(new AnimationEventsVector); |
3141 AnimationRegistrar::AnimationControllerMap copy = | 3153 AnimationRegistrar::AnimationControllerMap active_controllers_copy = |
3142 animation_registrar_->active_animation_controllers(); | 3154 animation_registrar_->active_animation_controllers(); |
3143 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 3155 for (auto& it : active_controllers_copy) |
3144 iter != copy.end(); | 3156 it.second->UpdateState(start_ready_animations, events.get()); |
3145 ++iter) | |
3146 (*iter).second->UpdateState(start_ready_animations, events.get()); | |
3147 | 3157 |
3148 if (!events->empty()) { | 3158 if (!events->empty()) { |
3149 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); | 3159 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); |
3150 } | 3160 } |
3151 | 3161 |
3152 SetNeedsAnimate(); | 3162 SetNeedsAnimate(); |
3153 } | 3163 } |
3154 | 3164 |
3155 void LayerTreeHostImpl::ActivateAnimations() { | 3165 void LayerTreeHostImpl::ActivateAnimations() { |
3156 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || | 3166 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || |
3157 !active_tree_->root_layer()) | 3167 !active_tree_->root_layer()) |
3158 return; | 3168 return; |
3159 | 3169 |
3160 TRACE_EVENT0("cc", "LayerTreeHostImpl::ActivateAnimations"); | 3170 TRACE_EVENT0("cc", "LayerTreeHostImpl::ActivateAnimations"); |
3161 AnimationRegistrar::AnimationControllerMap copy = | 3171 AnimationRegistrar::AnimationControllerMap active_controllers_copy = |
3162 animation_registrar_->active_animation_controllers(); | 3172 animation_registrar_->active_animation_controllers(); |
3163 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 3173 for (auto& it : active_controllers_copy) |
3164 iter != copy.end(); | 3174 it.second->ActivateAnimations(); |
3165 ++iter) | |
3166 (*iter).second->ActivateAnimations(); | |
3167 | 3175 |
3168 SetNeedsAnimate(); | 3176 SetNeedsAnimate(); |
3169 } | 3177 } |
3170 | 3178 |
3171 std::string LayerTreeHostImpl::LayerTreeAsJson() const { | 3179 std::string LayerTreeHostImpl::LayerTreeAsJson() const { |
3172 std::string str; | 3180 std::string str; |
3173 if (active_tree_->root_layer()) { | 3181 if (active_tree_->root_layer()) { |
3174 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); | 3182 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); |
3175 base::JSONWriter::WriteWithOptions( | 3183 base::JSONWriter::WriteWithOptions( |
3176 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3184 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
3177 } | 3185 } |
3178 return str; | 3186 return str; |
3179 } | 3187 } |
3180 | 3188 |
3181 int LayerTreeHostImpl::SourceAnimationFrameNumber() const { | 3189 int LayerTreeHostImpl::SourceAnimationFrameNumber() const { |
3182 return fps_counter_->current_frame_number(); | 3190 return fps_counter_->current_frame_number(); |
3183 } | 3191 } |
3184 | 3192 |
3185 void LayerTreeHostImpl::AnimateScrollbars(base::TimeTicks time) { | 3193 void LayerTreeHostImpl::StartAnimatingScrollbarAnimationController( |
3186 AnimateScrollbarsRecursive(active_tree_->root_layer(), time); | 3194 ScrollbarAnimationController* controller) { |
3187 } | 3195 scrollbar_animation_controllers_.insert(controller); |
3188 | |
3189 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, | |
3190 base::TimeTicks time) { | |
3191 if (!layer) | |
3192 return; | |
3193 | |
3194 ScrollbarAnimationController* scrollbar_controller = | |
3195 layer->scrollbar_animation_controller(); | |
3196 if (scrollbar_controller) | |
3197 scrollbar_controller->Animate(time); | |
3198 | |
3199 for (size_t i = 0; i < layer->children().size(); ++i) | |
3200 AnimateScrollbarsRecursive(layer->children()[i], time); | |
3201 } | |
3202 | |
3203 void LayerTreeHostImpl::PostDelayedScrollbarFade( | |
3204 const base::Closure& start_fade, | |
3205 base::TimeDelta delay) { | |
3206 client_->PostDelayedScrollbarFadeOnImplThread(start_fade, delay); | |
3207 } | |
3208 | |
3209 void LayerTreeHostImpl::SetNeedsScrollbarAnimationFrame() { | |
3210 TRACE_EVENT_INSTANT0( | |
3211 "cc", | |
3212 "LayerTreeHostImpl::SetNeedsRedraw due to scrollbar fade", | |
3213 TRACE_EVENT_SCOPE_THREAD); | |
3214 SetNeedsAnimate(); | 3196 SetNeedsAnimate(); |
3215 } | 3197 } |
3216 | 3198 |
| 3199 void LayerTreeHostImpl::StopAnimatingScrollbarAnimationController( |
| 3200 ScrollbarAnimationController* controller) { |
| 3201 scrollbar_animation_controllers_.erase(controller); |
| 3202 } |
| 3203 |
| 3204 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( |
| 3205 const base::Closure& task, |
| 3206 base::TimeDelta delay) { |
| 3207 client_->PostDelayedAnimationTaskOnImplThread(task, delay); |
| 3208 } |
| 3209 |
| 3210 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { |
| 3211 SetNeedsRedraw(); |
| 3212 } |
| 3213 |
3217 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 3214 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
3218 if (!tile_manager_) | 3215 if (!tile_manager_) |
3219 return; | 3216 return; |
3220 | 3217 |
3221 if (global_tile_state_.tree_priority == priority) | 3218 if (global_tile_state_.tree_priority == priority) |
3222 return; | 3219 return; |
3223 global_tile_state_.tree_priority = priority; | 3220 global_tile_state_.tree_priority = priority; |
3224 DidModifyTilePriorities(); | 3221 DidModifyTilePriorities(); |
3225 } | 3222 } |
3226 | 3223 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3469 (*it)->OnSetNeedsRedrawOnImpl(); | 3466 (*it)->OnSetNeedsRedrawOnImpl(); |
3470 } | 3467 } |
3471 | 3468 |
3472 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3469 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3473 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3470 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3474 for (; it != swap_promise_monitor_.end(); it++) | 3471 for (; it != swap_promise_monitor_.end(); it++) |
3475 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3472 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3476 } | 3473 } |
3477 | 3474 |
3478 } // namespace cc | 3475 } // namespace cc |
OLD | NEW |