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 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 return false; | 395 return false; |
396 } | 396 } |
397 return true; | 397 return true; |
398 } | 398 } |
399 | 399 |
400 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { | 400 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { |
401 // mithro(TODO): Enable these checks. | 401 // mithro(TODO): Enable these checks. |
402 // DCHECK(!current_begin_frame_tracker_.HasFinished()); | 402 // DCHECK(!current_begin_frame_tracker_.HasFinished()); |
403 // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time) | 403 // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time) |
404 // << "Called animate with unknown frame time!?"; | 404 // << "Called animate with unknown frame time!?"; |
405 if (input_handler_client_) | 405 if (!root_layer_scroll_offset_delegate_ || |
406 input_handler_client_->Animate(monotonic_time); | 406 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && |
| 407 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { |
| 408 AnimateInput(monotonic_time); |
| 409 } |
407 AnimatePageScale(monotonic_time); | 410 AnimatePageScale(monotonic_time); |
408 AnimateLayers(monotonic_time); | 411 AnimateLayers(monotonic_time); |
409 AnimateScrollbars(monotonic_time); | 412 AnimateScrollbars(monotonic_time); |
410 AnimateTopControls(monotonic_time); | 413 AnimateTopControls(monotonic_time); |
411 } | 414 } |
412 | 415 |
413 void LayerTreeHostImpl::PrepareTiles() { | 416 void LayerTreeHostImpl::PrepareTiles() { |
414 if (!tile_manager_) | 417 if (!tile_manager_) |
415 return; | 418 return; |
416 if (!tile_priorities_dirty_) | 419 if (!tile_priorities_dirty_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 page_scale_animation_->ZoomTo(scaled_target_offset, | 458 page_scale_animation_->ZoomTo(scaled_target_offset, |
456 page_scale, | 459 page_scale, |
457 duration.InSecondsF()); | 460 duration.InSecondsF()); |
458 } | 461 } |
459 | 462 |
460 SetNeedsAnimate(); | 463 SetNeedsAnimate(); |
461 client_->SetNeedsCommitOnImplThread(); | 464 client_->SetNeedsCommitOnImplThread(); |
462 client_->RenewTreePriority(); | 465 client_->RenewTreePriority(); |
463 } | 466 } |
464 | 467 |
| 468 void LayerTreeHostImpl::SetNeedsAnimateInput() { |
| 469 if (root_layer_scroll_offset_delegate_ && |
| 470 (CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
| 471 CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { |
| 472 if (root_layer_animation_callback_.is_null()) { |
| 473 root_layer_animation_callback_ = |
| 474 base::Bind(&LayerTreeHostImpl::AnimateInput, AsWeakPtr()); |
| 475 } |
| 476 root_layer_scroll_offset_delegate_->SetNeedsAnimate( |
| 477 root_layer_animation_callback_); |
| 478 return; |
| 479 } |
| 480 |
| 481 SetNeedsAnimate(); |
| 482 } |
| 483 |
465 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( | 484 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( |
466 const gfx::Point& viewport_point, | 485 const gfx::Point& viewport_point, |
467 InputHandler::ScrollInputType type) { | 486 InputHandler::ScrollInputType type) { |
468 if (!CurrentlyScrollingLayer()) | 487 if (!CurrentlyScrollingLayer()) |
469 return false; | 488 return false; |
470 | 489 |
471 gfx::PointF device_viewport_point = | 490 gfx::PointF device_viewport_point = |
472 gfx::ScalePoint(viewport_point, device_scale_factor_); | 491 gfx::ScalePoint(viewport_point, device_scale_factor_); |
473 | 492 |
474 LayerImpl* layer_impl = | 493 LayerImpl* layer_impl = |
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 return active_tree_->OuterViewportScrollLayer(); | 1836 return active_tree_->OuterViewportScrollLayer(); |
1818 } | 1837 } |
1819 | 1838 |
1820 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { | 1839 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { |
1821 return active_tree_->CurrentlyScrollingLayer(); | 1840 return active_tree_->CurrentlyScrollingLayer(); |
1822 } | 1841 } |
1823 | 1842 |
1824 bool LayerTreeHostImpl::IsActivelyScrolling() const { | 1843 bool LayerTreeHostImpl::IsActivelyScrolling() const { |
1825 return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) || | 1844 return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) || |
1826 (InnerViewportScrollLayer() && | 1845 (InnerViewportScrollLayer() && |
1827 InnerViewportScrollLayer()->IsExternalFlingActive()) || | 1846 InnerViewportScrollLayer()->IsExternalScrollActive()) || |
1828 (OuterViewportScrollLayer() && | 1847 (OuterViewportScrollLayer() && |
1829 OuterViewportScrollLayer()->IsExternalFlingActive()); | 1848 OuterViewportScrollLayer()->IsExternalScrollActive()); |
1830 } | 1849 } |
1831 | 1850 |
1832 // Content layers can be either directly scrollable or contained in an outer | 1851 // Content layers can be either directly scrollable or contained in an outer |
1833 // scrolling layer which applies the scroll transform. Given a content layer, | 1852 // scrolling layer which applies the scroll transform. Given a content layer, |
1834 // this function returns the associated scroll layer if any. | 1853 // this function returns the associated scroll layer if any. |
1835 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { | 1854 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { |
1836 if (!layer_impl) | 1855 if (!layer_impl) |
1837 return NULL; | 1856 return NULL; |
1838 | 1857 |
1839 if (layer_impl->scrollable()) | 1858 if (layer_impl->scrollable()) |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2797 | 2816 |
2798 void LayerTreeHostImpl::ScrollEnd() { | 2817 void LayerTreeHostImpl::ScrollEnd() { |
2799 top_controls_manager_->ScrollEnd(); | 2818 top_controls_manager_->ScrollEnd(); |
2800 ClearCurrentlyScrollingLayer(); | 2819 ClearCurrentlyScrollingLayer(); |
2801 } | 2820 } |
2802 | 2821 |
2803 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2822 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2804 if (!active_tree_->CurrentlyScrollingLayer()) | 2823 if (!active_tree_->CurrentlyScrollingLayer()) |
2805 return SCROLL_IGNORED; | 2824 return SCROLL_IGNORED; |
2806 | 2825 |
2807 if (settings_.ignore_root_layer_flings && | |
2808 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | |
2809 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { | |
2810 ClearCurrentlyScrollingLayer(); | |
2811 return SCROLL_IGNORED; | |
2812 } | |
2813 | |
2814 if (!wheel_scrolling_) { | 2826 if (!wheel_scrolling_) { |
2815 // Allow the fling to lock to the first layer that moves after the initial | 2827 // Allow the fling to lock to the first layer that moves after the initial |
2816 // fling |ScrollBy()| event. | 2828 // fling |ScrollBy()| event. |
2817 did_lock_scrolling_layer_ = false; | 2829 did_lock_scrolling_layer_ = false; |
2818 should_bubble_scrolls_ = false; | 2830 should_bubble_scrolls_ = false; |
2819 } | 2831 } |
2820 | 2832 |
2821 return SCROLL_STARTED; | 2833 return SCROLL_STARTED; |
2822 } | 2834 } |
2823 | 2835 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 LayerImpl* scroll_layer = OuterViewportScrollLayer() | 3048 LayerImpl* scroll_layer = OuterViewportScrollLayer() |
3037 ? OuterViewportScrollLayer() | 3049 ? OuterViewportScrollLayer() |
3038 : InnerViewportScrollLayer(); | 3050 : InnerViewportScrollLayer(); |
3039 | 3051 |
3040 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 3052 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
3041 | 3053 |
3042 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 3054 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
3043 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 3055 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
3044 } | 3056 } |
3045 | 3057 |
| 3058 void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) { |
| 3059 DCHECK(proxy_->IsImplThread()); |
| 3060 if (input_handler_client_) |
| 3061 input_handler_client_->Animate(monotonic_time); |
| 3062 } |
| 3063 |
3046 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 3064 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
3047 if (!page_scale_animation_) | 3065 if (!page_scale_animation_) |
3048 return; | 3066 return; |
3049 | 3067 |
3050 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 3068 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
3051 | 3069 |
3052 if (!page_scale_animation_->IsAnimationStarted()) | 3070 if (!page_scale_animation_->IsAnimationStarted()) |
3053 page_scale_animation_->StartAnimation(monotonic_time); | 3071 page_scale_animation_->StartAnimation(monotonic_time); |
3054 | 3072 |
3055 active_tree_->SetPageScaleOnActiveTree( | 3073 active_tree_->SetPageScaleOnActiveTree( |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3465 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3448 | 3466 |
3449 curve->UpdateTarget( | 3467 curve->UpdateTarget( |
3450 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3468 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3451 .InSecondsF(), | 3469 .InSecondsF(), |
3452 new_target); | 3470 new_target); |
3453 | 3471 |
3454 return true; | 3472 return true; |
3455 } | 3473 } |
3456 } // namespace cc | 3474 } // namespace cc |
OLD | NEW |