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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (EvictedUIResourcesExist()) { | 372 if (EvictedUIResourcesExist()) { |
373 TRACE_EVENT_INSTANT0( | 373 TRACE_EVENT_INSTANT0( |
374 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", | 374 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", |
375 TRACE_EVENT_SCOPE_THREAD); | 375 TRACE_EVENT_SCOPE_THREAD); |
376 return false; | 376 return false; |
377 } | 377 } |
378 return true; | 378 return true; |
379 } | 379 } |
380 | 380 |
381 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { | 381 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { |
382 if (input_handler_client_) | 382 if (!root_layer_scroll_offset_delegate_ || |
383 input_handler_client_->Animate(monotonic_time); | 383 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && |
| 384 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { |
| 385 AnimateInput(monotonic_time); |
| 386 } |
384 AnimatePageScale(monotonic_time); | 387 AnimatePageScale(monotonic_time); |
385 AnimateLayers(monotonic_time); | 388 AnimateLayers(monotonic_time); |
386 AnimateScrollbars(monotonic_time); | 389 AnimateScrollbars(monotonic_time); |
387 AnimateTopControls(monotonic_time); | 390 AnimateTopControls(monotonic_time); |
388 } | 391 } |
389 | 392 |
390 void LayerTreeHostImpl::PrepareTiles() { | 393 void LayerTreeHostImpl::PrepareTiles() { |
391 if (!tile_manager_) | 394 if (!tile_manager_) |
392 return; | 395 return; |
393 if (!tile_priorities_dirty_) | 396 if (!tile_priorities_dirty_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 page_scale_animation_->ZoomTo(scaled_target_offset, | 435 page_scale_animation_->ZoomTo(scaled_target_offset, |
433 page_scale, | 436 page_scale, |
434 duration.InSecondsF()); | 437 duration.InSecondsF()); |
435 } | 438 } |
436 | 439 |
437 SetNeedsAnimate(); | 440 SetNeedsAnimate(); |
438 client_->SetNeedsCommitOnImplThread(); | 441 client_->SetNeedsCommitOnImplThread(); |
439 client_->RenewTreePriority(); | 442 client_->RenewTreePriority(); |
440 } | 443 } |
441 | 444 |
| 445 void LayerTreeHostImpl::SetNeedsAnimateInput() { |
| 446 if (root_layer_scroll_offset_delegate_ && |
| 447 (CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
| 448 CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { |
| 449 if (root_layer_animation_callback_.is_null()) { |
| 450 root_layer_animation_callback_ = |
| 451 base::Bind(&LayerTreeHostImpl::AnimateInput, AsWeakPtr()); |
| 452 } |
| 453 root_layer_scroll_offset_delegate_->SetNeedsAnimate( |
| 454 root_layer_animation_callback_); |
| 455 return; |
| 456 } |
| 457 |
| 458 SetNeedsAnimate(); |
| 459 } |
| 460 |
442 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( | 461 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( |
443 const gfx::Point& viewport_point, | 462 const gfx::Point& viewport_point, |
444 InputHandler::ScrollInputType type) { | 463 InputHandler::ScrollInputType type) { |
445 if (!CurrentlyScrollingLayer()) | 464 if (!CurrentlyScrollingLayer()) |
446 return false; | 465 return false; |
447 | 466 |
448 gfx::PointF device_viewport_point = | 467 gfx::PointF device_viewport_point = |
449 gfx::ScalePoint(viewport_point, device_scale_factor_); | 468 gfx::ScalePoint(viewport_point, device_scale_factor_); |
450 | 469 |
451 LayerImpl* layer_impl = | 470 LayerImpl* layer_impl = |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 void LayerTreeHostImpl::ScrollEnd() { | 2836 void LayerTreeHostImpl::ScrollEnd() { |
2818 if (top_controls_manager_) | 2837 if (top_controls_manager_) |
2819 top_controls_manager_->ScrollEnd(); | 2838 top_controls_manager_->ScrollEnd(); |
2820 ClearCurrentlyScrollingLayer(); | 2839 ClearCurrentlyScrollingLayer(); |
2821 } | 2840 } |
2822 | 2841 |
2823 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2842 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2824 if (!active_tree_->CurrentlyScrollingLayer()) | 2843 if (!active_tree_->CurrentlyScrollingLayer()) |
2825 return SCROLL_IGNORED; | 2844 return SCROLL_IGNORED; |
2826 | 2845 |
2827 if (settings_.ignore_root_layer_flings && | 2846 if (false && settings_.ignore_root_layer_flings && |
2828 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | 2847 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
2829 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { | 2848 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { |
2830 ClearCurrentlyScrollingLayer(); | 2849 ClearCurrentlyScrollingLayer(); |
2831 return SCROLL_IGNORED; | 2850 return SCROLL_IGNORED; |
2832 } | 2851 } |
2833 | 2852 |
2834 if (!wheel_scrolling_) { | 2853 if (!wheel_scrolling_) { |
2835 // Allow the fling to lock to the first layer that moves after the initial | 2854 // Allow the fling to lock to the first layer that moves after the initial |
2836 // fling |ScrollBy()| event. | 2855 // fling |ScrollBy()| event. |
2837 did_lock_scrolling_layer_ = false; | 2856 did_lock_scrolling_layer_ = false; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3058 LayerImpl* scroll_layer = OuterViewportScrollLayer() | 3077 LayerImpl* scroll_layer = OuterViewportScrollLayer() |
3059 ? OuterViewportScrollLayer() | 3078 ? OuterViewportScrollLayer() |
3060 : InnerViewportScrollLayer(); | 3079 : InnerViewportScrollLayer(); |
3061 | 3080 |
3062 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 3081 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
3063 | 3082 |
3064 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 3083 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
3065 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 3084 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
3066 } | 3085 } |
3067 | 3086 |
| 3087 void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) { |
| 3088 DCHECK(proxy_->IsImplThread()); |
| 3089 // TODO(jdduke): Skip when scrolling the root layer with an offset delegate? |
| 3090 if (input_handler_client_) |
| 3091 input_handler_client_->Animate(monotonic_time); |
| 3092 } |
| 3093 |
3068 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 3094 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
3069 if (!page_scale_animation_) | 3095 if (!page_scale_animation_) |
3070 return; | 3096 return; |
3071 | 3097 |
3072 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 3098 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
3073 | 3099 |
3074 if (!page_scale_animation_->IsAnimationStarted()) | 3100 if (!page_scale_animation_->IsAnimationStarted()) |
3075 page_scale_animation_->StartAnimation(monotonic_time); | 3101 page_scale_animation_->StartAnimation(monotonic_time); |
3076 | 3102 |
3077 active_tree_->SetPageScaleOnActiveTree( | 3103 active_tree_->SetPageScaleOnActiveTree( |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 (*it)->OnSetNeedsRedrawOnImpl(); | 3492 (*it)->OnSetNeedsRedrawOnImpl(); |
3467 } | 3493 } |
3468 | 3494 |
3469 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3495 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3470 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3496 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3471 for (; it != swap_promise_monitor_.end(); it++) | 3497 for (; it != swap_promise_monitor_.end(); it++) |
3472 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3498 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3473 } | 3499 } |
3474 | 3500 |
3475 } // namespace cc | 3501 } // namespace cc |
OLD | NEW |