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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (EvictedUIResourcesExist()) { | 383 if (EvictedUIResourcesExist()) { |
384 TRACE_EVENT_INSTANT0( | 384 TRACE_EVENT_INSTANT0( |
385 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", | 385 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", |
386 TRACE_EVENT_SCOPE_THREAD); | 386 TRACE_EVENT_SCOPE_THREAD); |
387 return false; | 387 return false; |
388 } | 388 } |
389 return true; | 389 return true; |
390 } | 390 } |
391 | 391 |
392 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { | 392 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { |
393 if (input_handler_client_) | 393 if (!root_layer_scroll_offset_delegate_ || |
394 input_handler_client_->Animate(monotonic_time); | 394 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && |
| 395 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { |
| 396 AnimateInput(monotonic_time); |
| 397 } |
395 AnimatePageScale(monotonic_time); | 398 AnimatePageScale(monotonic_time); |
396 AnimateLayers(monotonic_time); | 399 AnimateLayers(monotonic_time); |
397 AnimateScrollbars(monotonic_time); | 400 AnimateScrollbars(monotonic_time); |
398 AnimateTopControls(monotonic_time); | 401 AnimateTopControls(monotonic_time); |
399 } | 402 } |
400 | 403 |
401 void LayerTreeHostImpl::PrepareTiles() { | 404 void LayerTreeHostImpl::PrepareTiles() { |
402 if (!tile_manager_) | 405 if (!tile_manager_) |
403 return; | 406 return; |
404 if (!tile_priorities_dirty_) | 407 if (!tile_priorities_dirty_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 page_scale_animation_->ZoomTo(scaled_target_offset, | 446 page_scale_animation_->ZoomTo(scaled_target_offset, |
444 page_scale, | 447 page_scale, |
445 duration.InSecondsF()); | 448 duration.InSecondsF()); |
446 } | 449 } |
447 | 450 |
448 SetNeedsAnimate(); | 451 SetNeedsAnimate(); |
449 client_->SetNeedsCommitOnImplThread(); | 452 client_->SetNeedsCommitOnImplThread(); |
450 client_->RenewTreePriority(); | 453 client_->RenewTreePriority(); |
451 } | 454 } |
452 | 455 |
| 456 void LayerTreeHostImpl::SetNeedsAnimateInput() { |
| 457 if (root_layer_scroll_offset_delegate_ && |
| 458 (CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
| 459 CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { |
| 460 if (root_layer_animation_callback_.is_null()) { |
| 461 root_layer_animation_callback_ = |
| 462 base::Bind(&LayerTreeHostImpl::AnimateInput, AsWeakPtr()); |
| 463 } |
| 464 root_layer_scroll_offset_delegate_->SetNeedsAnimate( |
| 465 root_layer_animation_callback_); |
| 466 return; |
| 467 } |
| 468 |
| 469 SetNeedsAnimate(); |
| 470 } |
| 471 |
453 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( | 472 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( |
454 const gfx::Point& viewport_point, | 473 const gfx::Point& viewport_point, |
455 InputHandler::ScrollInputType type) { | 474 InputHandler::ScrollInputType type) { |
456 if (!CurrentlyScrollingLayer()) | 475 if (!CurrentlyScrollingLayer()) |
457 return false; | 476 return false; |
458 | 477 |
459 gfx::PointF device_viewport_point = | 478 gfx::PointF device_viewport_point = |
460 gfx::ScalePoint(viewport_point, device_scale_factor_); | 479 gfx::ScalePoint(viewport_point, device_scale_factor_); |
461 | 480 |
462 LayerImpl* layer_impl = | 481 LayerImpl* layer_impl = |
(...skipping 2242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 | 2724 |
2706 void LayerTreeHostImpl::ScrollEnd() { | 2725 void LayerTreeHostImpl::ScrollEnd() { |
2707 top_controls_manager_->ScrollEnd(); | 2726 top_controls_manager_->ScrollEnd(); |
2708 ClearCurrentlyScrollingLayer(); | 2727 ClearCurrentlyScrollingLayer(); |
2709 } | 2728 } |
2710 | 2729 |
2711 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2730 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2712 if (!active_tree_->CurrentlyScrollingLayer()) | 2731 if (!active_tree_->CurrentlyScrollingLayer()) |
2713 return SCROLL_IGNORED; | 2732 return SCROLL_IGNORED; |
2714 | 2733 |
2715 if (settings_.ignore_root_layer_flings && | |
2716 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | |
2717 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { | |
2718 ClearCurrentlyScrollingLayer(); | |
2719 return SCROLL_IGNORED; | |
2720 } | |
2721 | |
2722 if (!wheel_scrolling_) { | 2734 if (!wheel_scrolling_) { |
2723 // Allow the fling to lock to the first layer that moves after the initial | 2735 // Allow the fling to lock to the first layer that moves after the initial |
2724 // fling |ScrollBy()| event. | 2736 // fling |ScrollBy()| event. |
2725 did_lock_scrolling_layer_ = false; | 2737 did_lock_scrolling_layer_ = false; |
2726 should_bubble_scrolls_ = false; | 2738 should_bubble_scrolls_ = false; |
2727 } | 2739 } |
2728 | 2740 |
2729 return SCROLL_STARTED; | 2741 return SCROLL_STARTED; |
2730 } | 2742 } |
2731 | 2743 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 LayerImpl* scroll_layer = OuterViewportScrollLayer() | 2956 LayerImpl* scroll_layer = OuterViewportScrollLayer() |
2945 ? OuterViewportScrollLayer() | 2957 ? OuterViewportScrollLayer() |
2946 : InnerViewportScrollLayer(); | 2958 : InnerViewportScrollLayer(); |
2947 | 2959 |
2948 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2960 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
2949 | 2961 |
2950 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2962 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
2951 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2963 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
2952 } | 2964 } |
2953 | 2965 |
| 2966 void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) { |
| 2967 DCHECK(proxy_->IsImplThread()); |
| 2968 // TODO(jdduke): Skip when scrolling the root layer with an offset delegate? |
| 2969 if (input_handler_client_) |
| 2970 input_handler_client_->Animate(monotonic_time); |
| 2971 } |
| 2972 |
2954 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 2973 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
2955 if (!page_scale_animation_) | 2974 if (!page_scale_animation_) |
2956 return; | 2975 return; |
2957 | 2976 |
2958 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 2977 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
2959 | 2978 |
2960 if (!page_scale_animation_->IsAnimationStarted()) | 2979 if (!page_scale_animation_->IsAnimationStarted()) |
2961 page_scale_animation_->StartAnimation(monotonic_time); | 2980 page_scale_animation_->StartAnimation(monotonic_time); |
2962 | 2981 |
2963 active_tree_->SetPageScaleOnActiveTree( | 2982 active_tree_->SetPageScaleOnActiveTree( |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3393 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3375 | 3394 |
3376 curve->UpdateTarget( | 3395 curve->UpdateTarget( |
3377 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3396 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3378 .InSecondsF(), | 3397 .InSecondsF(), |
3379 new_target); | 3398 new_target); |
3380 | 3399 |
3381 return true; | 3400 return true; |
3382 } | 3401 } |
3383 } // namespace cc | 3402 } // namespace cc |
OLD | NEW |