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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 return active_tree_->OuterViewportScrollLayer(); | 1829 return active_tree_->OuterViewportScrollLayer(); |
1811 } | 1830 } |
1812 | 1831 |
1813 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { | 1832 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { |
1814 return active_tree_->CurrentlyScrollingLayer(); | 1833 return active_tree_->CurrentlyScrollingLayer(); |
1815 } | 1834 } |
1816 | 1835 |
1817 bool LayerTreeHostImpl::IsActivelyScrolling() const { | 1836 bool LayerTreeHostImpl::IsActivelyScrolling() const { |
1818 return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) || | 1837 return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) || |
1819 (InnerViewportScrollLayer() && | 1838 (InnerViewportScrollLayer() && |
1820 InnerViewportScrollLayer()->IsExternalFlingActive()) || | 1839 InnerViewportScrollLayer()->IsExternalScrollActive()) || |
1821 (OuterViewportScrollLayer() && | 1840 (OuterViewportScrollLayer() && |
1822 OuterViewportScrollLayer()->IsExternalFlingActive()); | 1841 OuterViewportScrollLayer()->IsExternalScrollActive()); |
1823 } | 1842 } |
1824 | 1843 |
1825 // Content layers can be either directly scrollable or contained in an outer | 1844 // Content layers can be either directly scrollable or contained in an outer |
1826 // scrolling layer which applies the scroll transform. Given a content layer, | 1845 // scrolling layer which applies the scroll transform. Given a content layer, |
1827 // this function returns the associated scroll layer if any. | 1846 // this function returns the associated scroll layer if any. |
1828 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { | 1847 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { |
1829 if (!layer_impl) | 1848 if (!layer_impl) |
1830 return NULL; | 1849 return NULL; |
1831 | 1850 |
1832 if (layer_impl->scrollable()) | 1851 if (layer_impl->scrollable()) |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 | 2800 |
2782 void LayerTreeHostImpl::ScrollEnd() { | 2801 void LayerTreeHostImpl::ScrollEnd() { |
2783 top_controls_manager_->ScrollEnd(); | 2802 top_controls_manager_->ScrollEnd(); |
2784 ClearCurrentlyScrollingLayer(); | 2803 ClearCurrentlyScrollingLayer(); |
2785 } | 2804 } |
2786 | 2805 |
2787 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2806 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2788 if (!active_tree_->CurrentlyScrollingLayer()) | 2807 if (!active_tree_->CurrentlyScrollingLayer()) |
2789 return SCROLL_IGNORED; | 2808 return SCROLL_IGNORED; |
2790 | 2809 |
2791 if (settings_.ignore_root_layer_flings && | |
2792 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | |
2793 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { | |
2794 ClearCurrentlyScrollingLayer(); | |
2795 return SCROLL_IGNORED; | |
2796 } | |
2797 | |
2798 if (!wheel_scrolling_) { | 2810 if (!wheel_scrolling_) { |
2799 // Allow the fling to lock to the first layer that moves after the initial | 2811 // Allow the fling to lock to the first layer that moves after the initial |
2800 // fling |ScrollBy()| event. | 2812 // fling |ScrollBy()| event. |
2801 did_lock_scrolling_layer_ = false; | 2813 did_lock_scrolling_layer_ = false; |
2802 should_bubble_scrolls_ = false; | 2814 should_bubble_scrolls_ = false; |
2803 } | 2815 } |
2804 | 2816 |
2805 return SCROLL_STARTED; | 2817 return SCROLL_STARTED; |
2806 } | 2818 } |
2807 | 2819 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 LayerImpl* scroll_layer = OuterViewportScrollLayer() | 3032 LayerImpl* scroll_layer = OuterViewportScrollLayer() |
3021 ? OuterViewportScrollLayer() | 3033 ? OuterViewportScrollLayer() |
3022 : InnerViewportScrollLayer(); | 3034 : InnerViewportScrollLayer(); |
3023 | 3035 |
3024 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 3036 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
3025 | 3037 |
3026 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 3038 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
3027 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 3039 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
3028 } | 3040 } |
3029 | 3041 |
| 3042 void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) { |
| 3043 DCHECK(proxy_->IsImplThread()); |
| 3044 if (input_handler_client_) |
| 3045 input_handler_client_->Animate(monotonic_time); |
| 3046 } |
| 3047 |
3030 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 3048 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
3031 if (!page_scale_animation_) | 3049 if (!page_scale_animation_) |
3032 return; | 3050 return; |
3033 | 3051 |
3034 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 3052 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
3035 | 3053 |
3036 if (!page_scale_animation_->IsAnimationStarted()) | 3054 if (!page_scale_animation_->IsAnimationStarted()) |
3037 page_scale_animation_->StartAnimation(monotonic_time); | 3055 page_scale_animation_->StartAnimation(monotonic_time); |
3038 | 3056 |
3039 active_tree_->SetPageScaleOnActiveTree( | 3057 active_tree_->SetPageScaleOnActiveTree( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3435 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3453 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3436 | 3454 |
3437 curve->UpdateTarget( | 3455 curve->UpdateTarget( |
3438 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3456 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3439 .InSecondsF(), | 3457 .InSecondsF(), |
3440 new_target); | 3458 new_target); |
3441 | 3459 |
3442 return true; | 3460 return true; |
3443 } | 3461 } |
3444 } // namespace cc | 3462 } // namespace cc |
OLD | NEW |