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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 page_scale_animation_->ZoomWithAnchor(anchor, | 464 page_scale_animation_->ZoomWithAnchor(anchor, |
465 page_scale, | 465 page_scale, |
466 duration.InSecondsF()); | 466 duration.InSecondsF()); |
467 } else { | 467 } else { |
468 gfx::Vector2dF scaled_target_offset = target_offset; | 468 gfx::Vector2dF scaled_target_offset = target_offset; |
469 page_scale_animation_->ZoomTo(scaled_target_offset, | 469 page_scale_animation_->ZoomTo(scaled_target_offset, |
470 page_scale, | 470 page_scale, |
471 duration.InSecondsF()); | 471 duration.InSecondsF()); |
472 } | 472 } |
473 | 473 |
474 SetNeedsRedraw(); | 474 SetNeedsAnimate(); |
475 client_->SetNeedsCommitOnImplThread(); | 475 client_->SetNeedsCommitOnImplThread(); |
476 client_->RenewTreePriority(); | 476 client_->RenewTreePriority(); |
477 } | 477 } |
478 | 478 |
479 void LayerTreeHostImpl::ScheduleAnimation() { | |
480 SetNeedsRedraw(); | |
481 } | |
482 | |
483 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( | 479 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( |
484 const gfx::Point& viewport_point) { | 480 const gfx::Point& viewport_point) { |
485 if (!settings_.touch_hit_testing) | 481 if (!settings_.touch_hit_testing) |
486 return true; | 482 return true; |
487 if (!EnsureRenderSurfaceLayerList()) | 483 if (!EnsureRenderSurfaceLayerList()) |
488 return false; | 484 return false; |
489 | 485 |
490 gfx::PointF device_viewport_point = | 486 gfx::PointF device_viewport_point = |
491 gfx::ScalePoint(viewport_point, device_scale_factor_); | 487 gfx::ScalePoint(viewport_point, device_scale_factor_); |
492 | 488 |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 // draw or timer tick. | 1714 // draw or timer tick. |
1719 if (!visible_) | 1715 if (!visible_) |
1720 ManageTiles(); | 1716 ManageTiles(); |
1721 | 1717 |
1722 if (!renderer_) | 1718 if (!renderer_) |
1723 return; | 1719 return; |
1724 | 1720 |
1725 renderer_->SetVisible(visible); | 1721 renderer_->SetVisible(visible); |
1726 } | 1722 } |
1727 | 1723 |
| 1724 void LayerTreeHostImpl::SetNeedsAnimate() { |
| 1725 client_->SetNeedsAnimateOnImplThread(); |
| 1726 } |
| 1727 |
1728 void LayerTreeHostImpl::SetNeedsRedraw() { | 1728 void LayerTreeHostImpl::SetNeedsRedraw() { |
1729 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1729 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
1730 client_->SetNeedsRedrawOnImplThread(); | 1730 client_->SetNeedsRedrawOnImplThread(); |
1731 } | 1731 } |
1732 | 1732 |
1733 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { | 1733 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { |
1734 ManagedMemoryPolicy actual = cached_managed_memory_policy_; | 1734 ManagedMemoryPolicy actual = cached_managed_memory_policy_; |
1735 // TODO(ernstm): The second condition disables pre-painting for all layers | 1735 // TODO(ernstm): The second condition disables pre-painting for all layers |
1736 // when GPU rasterization is enabled. Once we selectively enable GPU | 1736 // when GPU rasterization is enabled. Once we selectively enable GPU |
1737 // rasterization per layer, we also need to disable pre-painting selectively: | 1737 // rasterization per layer, we also need to disable pre-painting selectively: |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2756 monotonic_time_for_cc_animations); | 2756 monotonic_time_for_cc_animations); |
2757 | 2757 |
2758 ScrollViewportBy(next_scroll - scroll_total); | 2758 ScrollViewportBy(next_scroll - scroll_total); |
2759 SetNeedsRedraw(); | 2759 SetNeedsRedraw(); |
2760 | 2760 |
2761 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2761 if (page_scale_animation_->IsAnimationCompleteAtTime( |
2762 monotonic_time_for_cc_animations)) { | 2762 monotonic_time_for_cc_animations)) { |
2763 page_scale_animation_.reset(); | 2763 page_scale_animation_.reset(); |
2764 client_->SetNeedsCommitOnImplThread(); | 2764 client_->SetNeedsCommitOnImplThread(); |
2765 client_->RenewTreePriority(); | 2765 client_->RenewTreePriority(); |
| 2766 } else { |
| 2767 SetNeedsAnimate(); |
2766 } | 2768 } |
2767 } | 2769 } |
2768 | 2770 |
2769 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2771 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
2770 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2772 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
2771 return; | 2773 return; |
2772 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2774 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
2773 if (active_tree_->TotalScrollOffset().y() == 0.f) | 2775 if (active_tree_->TotalScrollOffset().y() == 0.f) |
2774 return; | 2776 return; |
2775 if (scroll.IsZero()) { | 2777 if (!scroll.IsZero()) { |
2776 // This may happen on the first animation step. Force redraw otherwise | |
2777 // the animation would stop because of no new frames. | |
2778 SetNeedsRedraw(); | |
2779 } else { | |
2780 ScrollViewportBy(gfx::ScaleVector2d( | 2778 ScrollViewportBy(gfx::ScaleVector2d( |
2781 scroll, 1.f / active_tree_->total_page_scale_factor())); | 2779 scroll, 1.f / active_tree_->total_page_scale_factor())); |
| 2780 SetNeedsRedraw(); |
2782 } | 2781 } |
| 2782 SetNeedsAnimate(); |
2783 } | 2783 } |
2784 | 2784 |
2785 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2785 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
2786 if (!settings_.accelerated_animation_enabled || | 2786 if (!settings_.accelerated_animation_enabled || |
2787 !needs_animate_layers() || | 2787 !needs_animate_layers() || |
2788 !active_tree_->root_layer()) | 2788 !active_tree_->root_layer()) |
2789 return; | 2789 return; |
2790 | 2790 |
2791 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2791 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
2792 | 2792 |
2793 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | 2793 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic |
2794 // time. | 2794 // time. |
2795 double monotonic_time_for_cc_animations = | 2795 double monotonic_time_for_cc_animations = |
2796 (monotonic_time - base::TimeTicks()).InSecondsF(); | 2796 (monotonic_time - base::TimeTicks()).InSecondsF(); |
2797 AnimationRegistrar::AnimationControllerMap copy = | 2797 AnimationRegistrar::AnimationControllerMap copy = |
2798 animation_registrar_->active_animation_controllers(); | 2798 animation_registrar_->active_animation_controllers(); |
2799 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2799 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
2800 iter != copy.end(); | 2800 iter != copy.end(); |
2801 ++iter) | 2801 ++iter) |
2802 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2802 (*iter).second->Animate(monotonic_time_for_cc_animations); |
2803 | 2803 |
2804 SetNeedsRedraw(); | 2804 SetNeedsAnimate(); |
2805 } | 2805 } |
2806 | 2806 |
2807 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2807 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
2808 if (!settings_.accelerated_animation_enabled || | 2808 if (!settings_.accelerated_animation_enabled || |
2809 !needs_animate_layers() || | 2809 !needs_animate_layers() || |
2810 !active_tree_->root_layer()) | 2810 !active_tree_->root_layer()) |
2811 return; | 2811 return; |
2812 | 2812 |
2813 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); | 2813 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); |
2814 scoped_ptr<AnimationEventsVector> events = | 2814 scoped_ptr<AnimationEventsVector> events = |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2904 | 2904 |
2905 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, | 2905 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, |
2906 base::TimeTicks time) { | 2906 base::TimeTicks time) { |
2907 if (!layer) | 2907 if (!layer) |
2908 return; | 2908 return; |
2909 | 2909 |
2910 ScrollbarAnimationController* scrollbar_controller = | 2910 ScrollbarAnimationController* scrollbar_controller = |
2911 layer->scrollbar_animation_controller(); | 2911 layer->scrollbar_animation_controller(); |
2912 if (scrollbar_controller && scrollbar_controller->Animate(time)) { | 2912 if (scrollbar_controller && scrollbar_controller->Animate(time)) { |
2913 TRACE_EVENT_INSTANT0( | 2913 TRACE_EVENT_INSTANT0( |
2914 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars", | 2914 "cc", |
| 2915 "LayerTreeHostImpl::SetNeedsAnimate due to AnimateScrollbars", |
2915 TRACE_EVENT_SCOPE_THREAD); | 2916 TRACE_EVENT_SCOPE_THREAD); |
2916 SetNeedsRedraw(); | 2917 SetNeedsAnimate(); |
2917 } | 2918 } |
2918 | 2919 |
2919 for (size_t i = 0; i < layer->children().size(); ++i) | 2920 for (size_t i = 0; i < layer->children().size(); ++i) |
2920 AnimateScrollbarsRecursive(layer->children()[i], time); | 2921 AnimateScrollbarsRecursive(layer->children()[i], time); |
2921 } | 2922 } |
2922 | 2923 |
2923 void LayerTreeHostImpl::StartScrollbarAnimation() { | 2924 void LayerTreeHostImpl::StartScrollbarAnimation() { |
2924 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); | 2925 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); |
2925 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); | 2926 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); |
2926 } | 2927 } |
2927 | 2928 |
2928 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, | 2929 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, |
2929 base::TimeTicks time) { | 2930 base::TimeTicks time) { |
2930 if (!layer) | 2931 if (!layer) |
2931 return; | 2932 return; |
2932 | 2933 |
2933 ScrollbarAnimationController* scrollbar_controller = | 2934 ScrollbarAnimationController* scrollbar_controller = |
2934 layer->scrollbar_animation_controller(); | 2935 layer->scrollbar_animation_controller(); |
2935 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { | 2936 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { |
2936 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); | 2937 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); |
2937 if (delay > base::TimeDelta()) | 2938 if (delay > base::TimeDelta()) { |
2938 client_->RequestScrollbarAnimationOnImplThread(delay); | 2939 client_->RequestScrollbarAnimationOnImplThread(delay); |
2939 else if (scrollbar_controller->Animate(time)) | 2940 } else if (scrollbar_controller->Animate(time)) { |
2940 SetNeedsRedraw(); | 2941 SetNeedsAnimate(); |
| 2942 } |
2941 } | 2943 } |
2942 | 2944 |
2943 for (size_t i = 0; i < layer->children().size(); ++i) | 2945 for (size_t i = 0; i < layer->children().size(); ++i) |
2944 StartScrollbarAnimationRecursive(layer->children()[i], time); | 2946 StartScrollbarAnimationRecursive(layer->children()[i], time); |
2945 } | 2947 } |
2946 | 2948 |
2947 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 2949 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
2948 if (!tile_manager_) | 2950 if (!tile_manager_) |
2949 return; | 2951 return; |
2950 | 2952 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3121 swap_promise_monitor_.erase(monitor); | 3123 swap_promise_monitor_.erase(monitor); |
3122 } | 3124 } |
3123 | 3125 |
3124 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3126 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3125 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3127 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3126 for (; it != swap_promise_monitor_.end(); it++) | 3128 for (; it != swap_promise_monitor_.end(); it++) |
3127 (*it)->OnSetNeedsRedrawOnImpl(); | 3129 (*it)->OnSetNeedsRedrawOnImpl(); |
3128 } | 3130 } |
3129 | 3131 |
3130 } // namespace cc | 3132 } // namespace cc |
OLD | NEW |