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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 if (EvictedUIResourcesExist()) { | 387 if (EvictedUIResourcesExist()) { |
388 TRACE_EVENT_INSTANT0( | 388 TRACE_EVENT_INSTANT0( |
389 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", | 389 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", |
390 TRACE_EVENT_SCOPE_THREAD); | 390 TRACE_EVENT_SCOPE_THREAD); |
391 return false; | 391 return false; |
392 } | 392 } |
393 return true; | 393 return true; |
394 } | 394 } |
395 | 395 |
396 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { | 396 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { |
397 if (input_handler_client_) | 397 if (!root_layer_scroll_offset_delegate_ || |
398 input_handler_client_->Animate(monotonic_time); | 398 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && |
| 399 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { |
| 400 AnimateInput(monotonic_time); |
| 401 } |
399 AnimatePageScale(monotonic_time); | 402 AnimatePageScale(monotonic_time); |
400 AnimateLayers(monotonic_time); | 403 AnimateLayers(monotonic_time); |
401 AnimateScrollbars(monotonic_time); | 404 AnimateScrollbars(monotonic_time); |
402 AnimateTopControls(monotonic_time); | 405 AnimateTopControls(monotonic_time); |
403 } | 406 } |
404 | 407 |
405 void LayerTreeHostImpl::PrepareTiles() { | 408 void LayerTreeHostImpl::PrepareTiles() { |
406 if (!tile_manager_) | 409 if (!tile_manager_) |
407 return; | 410 return; |
408 if (!tile_priorities_dirty_) | 411 if (!tile_priorities_dirty_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 page_scale_animation_->ZoomTo(scaled_target_offset, | 450 page_scale_animation_->ZoomTo(scaled_target_offset, |
448 page_scale, | 451 page_scale, |
449 duration.InSecondsF()); | 452 duration.InSecondsF()); |
450 } | 453 } |
451 | 454 |
452 SetNeedsAnimate(); | 455 SetNeedsAnimate(); |
453 client_->SetNeedsCommitOnImplThread(); | 456 client_->SetNeedsCommitOnImplThread(); |
454 client_->RenewTreePriority(); | 457 client_->RenewTreePriority(); |
455 } | 458 } |
456 | 459 |
| 460 void LayerTreeHostImpl::SetNeedsAnimateInput() { |
| 461 if (root_layer_scroll_offset_delegate_ && |
| 462 (CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
| 463 CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { |
| 464 if (root_layer_animation_callback_.is_null()) { |
| 465 root_layer_animation_callback_ = |
| 466 base::Bind(&LayerTreeHostImpl::AnimateInput, AsWeakPtr()); |
| 467 } |
| 468 root_layer_scroll_offset_delegate_->SetNeedsAnimate( |
| 469 root_layer_animation_callback_); |
| 470 return; |
| 471 } |
| 472 |
| 473 SetNeedsAnimate(); |
| 474 } |
| 475 |
457 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( | 476 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( |
458 const gfx::Point& viewport_point, | 477 const gfx::Point& viewport_point, |
459 InputHandler::ScrollInputType type) { | 478 InputHandler::ScrollInputType type) { |
460 if (!CurrentlyScrollingLayer()) | 479 if (!CurrentlyScrollingLayer()) |
461 return false; | 480 return false; |
462 | 481 |
463 gfx::PointF device_viewport_point = | 482 gfx::PointF device_viewport_point = |
464 gfx::ScalePoint(viewport_point, device_scale_factor_); | 483 gfx::ScalePoint(viewport_point, device_scale_factor_); |
465 | 484 |
466 LayerImpl* layer_impl = | 485 LayerImpl* layer_impl = |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1778 return active_tree_->OuterViewportScrollLayer(); | 1797 return active_tree_->OuterViewportScrollLayer(); |
1779 } | 1798 } |
1780 | 1799 |
1781 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { | 1800 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { |
1782 return active_tree_->CurrentlyScrollingLayer(); | 1801 return active_tree_->CurrentlyScrollingLayer(); |
1783 } | 1802 } |
1784 | 1803 |
1785 bool LayerTreeHostImpl::IsActivelyScrolling() const { | 1804 bool LayerTreeHostImpl::IsActivelyScrolling() const { |
1786 return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) || | 1805 return (did_lock_scrolling_layer_ && CurrentlyScrollingLayer()) || |
1787 (InnerViewportScrollLayer() && | 1806 (InnerViewportScrollLayer() && |
1788 InnerViewportScrollLayer()->IsExternalFlingActive()) || | 1807 InnerViewportScrollLayer()->IsExternalScrollActive()) || |
1789 (OuterViewportScrollLayer() && | 1808 (OuterViewportScrollLayer() && |
1790 OuterViewportScrollLayer()->IsExternalFlingActive()); | 1809 OuterViewportScrollLayer()->IsExternalScrollActive()); |
1791 } | 1810 } |
1792 | 1811 |
1793 // Content layers can be either directly scrollable or contained in an outer | 1812 // Content layers can be either directly scrollable or contained in an outer |
1794 // scrolling layer which applies the scroll transform. Given a content layer, | 1813 // scrolling layer which applies the scroll transform. Given a content layer, |
1795 // this function returns the associated scroll layer if any. | 1814 // this function returns the associated scroll layer if any. |
1796 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { | 1815 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { |
1797 if (!layer_impl) | 1816 if (!layer_impl) |
1798 return NULL; | 1817 return NULL; |
1799 | 1818 |
1800 if (layer_impl->scrollable()) | 1819 if (layer_impl->scrollable()) |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 | 2760 |
2742 void LayerTreeHostImpl::ScrollEnd() { | 2761 void LayerTreeHostImpl::ScrollEnd() { |
2743 top_controls_manager_->ScrollEnd(); | 2762 top_controls_manager_->ScrollEnd(); |
2744 ClearCurrentlyScrollingLayer(); | 2763 ClearCurrentlyScrollingLayer(); |
2745 } | 2764 } |
2746 | 2765 |
2747 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2766 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2748 if (!active_tree_->CurrentlyScrollingLayer()) | 2767 if (!active_tree_->CurrentlyScrollingLayer()) |
2749 return SCROLL_IGNORED; | 2768 return SCROLL_IGNORED; |
2750 | 2769 |
2751 if (settings_.ignore_root_layer_flings && | |
2752 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | |
2753 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { | |
2754 ClearCurrentlyScrollingLayer(); | |
2755 return SCROLL_IGNORED; | |
2756 } | |
2757 | |
2758 if (!wheel_scrolling_) { | 2770 if (!wheel_scrolling_) { |
2759 // Allow the fling to lock to the first layer that moves after the initial | 2771 // Allow the fling to lock to the first layer that moves after the initial |
2760 // fling |ScrollBy()| event. | 2772 // fling |ScrollBy()| event. |
2761 did_lock_scrolling_layer_ = false; | 2773 did_lock_scrolling_layer_ = false; |
2762 should_bubble_scrolls_ = false; | 2774 should_bubble_scrolls_ = false; |
2763 } | 2775 } |
2764 | 2776 |
2765 return SCROLL_STARTED; | 2777 return SCROLL_STARTED; |
2766 } | 2778 } |
2767 | 2779 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 LayerImpl* scroll_layer = OuterViewportScrollLayer() | 2992 LayerImpl* scroll_layer = OuterViewportScrollLayer() |
2981 ? OuterViewportScrollLayer() | 2993 ? OuterViewportScrollLayer() |
2982 : InnerViewportScrollLayer(); | 2994 : InnerViewportScrollLayer(); |
2983 | 2995 |
2984 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2996 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
2985 | 2997 |
2986 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2998 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
2987 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2999 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
2988 } | 3000 } |
2989 | 3001 |
| 3002 void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) { |
| 3003 DCHECK(proxy_->IsImplThread()); |
| 3004 if (input_handler_client_) |
| 3005 input_handler_client_->Animate(monotonic_time); |
| 3006 } |
| 3007 |
2990 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 3008 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
2991 if (!page_scale_animation_) | 3009 if (!page_scale_animation_) |
2992 return; | 3010 return; |
2993 | 3011 |
2994 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 3012 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
2995 | 3013 |
2996 if (!page_scale_animation_->IsAnimationStarted()) | 3014 if (!page_scale_animation_->IsAnimationStarted()) |
2997 page_scale_animation_->StartAnimation(monotonic_time); | 3015 page_scale_animation_->StartAnimation(monotonic_time); |
2998 | 3016 |
2999 active_tree_->SetPageScaleOnActiveTree( | 3017 active_tree_->SetPageScaleOnActiveTree( |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3417 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3400 | 3418 |
3401 curve->UpdateTarget( | 3419 curve->UpdateTarget( |
3402 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3420 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3403 .InSecondsF(), | 3421 .InSecondsF(), |
3404 new_target); | 3422 new_target); |
3405 | 3423 |
3406 return true; | 3424 return true; |
3407 } | 3425 } |
3408 } // namespace cc | 3426 } // namespace cc |
OLD | NEW |