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 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2755 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2755 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
2756 | 2756 |
2757 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2757 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
2758 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2758 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
2759 } | 2759 } |
2760 | 2760 |
2761 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 2761 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
2762 if (!page_scale_animation_) | 2762 if (!page_scale_animation_) |
2763 return; | 2763 return; |
2764 | 2764 |
2765 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2766 // time. | |
2767 double monotonic_time_for_cc_animations = | |
2768 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2769 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); | 2765 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); |
2770 | 2766 |
2771 if (!page_scale_animation_->IsAnimationStarted()) | 2767 if (!page_scale_animation_->IsAnimationStarted()) |
2772 page_scale_animation_->StartAnimation(monotonic_time_for_cc_animations); | 2768 page_scale_animation_->StartAnimation(monotonic_time); |
2773 | 2769 |
2774 active_tree_->SetPageScaleDelta(page_scale_animation_->PageScaleFactorAtTime( | 2770 active_tree_->SetPageScaleDelta( |
2775 monotonic_time_for_cc_animations) / | 2771 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
2776 active_tree_->page_scale_factor()); | 2772 active_tree_->page_scale_factor()); |
2777 gfx::Vector2dF next_scroll = page_scale_animation_->ScrollOffsetAtTime( | 2773 gfx::Vector2dF next_scroll = |
2778 monotonic_time_for_cc_animations); | 2774 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
2779 | 2775 |
2780 ScrollViewportBy(next_scroll - scroll_total); | 2776 ScrollViewportBy(next_scroll - scroll_total); |
2781 SetNeedsRedraw(); | 2777 SetNeedsRedraw(); |
2782 | 2778 |
2783 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2779 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
2784 monotonic_time_for_cc_animations)) { | |
2785 page_scale_animation_.reset(); | 2780 page_scale_animation_.reset(); |
2786 client_->SetNeedsCommitOnImplThread(); | 2781 client_->SetNeedsCommitOnImplThread(); |
2787 client_->RenewTreePriority(); | 2782 client_->RenewTreePriority(); |
2788 } else { | 2783 } else { |
2789 SetNeedsAnimate(); | 2784 SetNeedsAnimate(); |
2790 } | 2785 } |
2791 } | 2786 } |
2792 | 2787 |
2793 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2788 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
2794 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2789 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
2795 return; | 2790 return; |
2796 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2791 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
2797 if (active_tree_->TotalScrollOffset().y() == 0.f) | 2792 if (active_tree_->TotalScrollOffset().y() == 0.f) |
2798 return; | 2793 return; |
2799 if (!scroll.IsZero()) { | 2794 if (!scroll.IsZero()) { |
2800 ScrollViewportBy(gfx::ScaleVector2d( | 2795 ScrollViewportBy(gfx::ScaleVector2d( |
2801 scroll, 1.f / active_tree_->total_page_scale_factor())); | 2796 scroll, 1.f / active_tree_->total_page_scale_factor())); |
2802 SetNeedsRedraw(); | 2797 SetNeedsRedraw(); |
2803 } | 2798 } |
2804 SetNeedsAnimate(); | 2799 SetNeedsAnimate(); |
2805 } | 2800 } |
2806 | 2801 |
2807 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2802 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
2808 if (!settings_.accelerated_animation_enabled || | 2803 if (!settings_.accelerated_animation_enabled || |
2809 !needs_animate_layers() || | 2804 !needs_animate_layers() || |
2810 !active_tree_->root_layer()) | 2805 !active_tree_->root_layer()) |
2811 return; | 2806 return; |
2812 | 2807 |
2813 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2808 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
2814 | |
2815 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2816 // time. | |
2817 double monotonic_time_for_cc_animations = | |
2818 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2819 AnimationRegistrar::AnimationControllerMap copy = | 2809 AnimationRegistrar::AnimationControllerMap copy = |
2820 animation_registrar_->active_animation_controllers(); | 2810 animation_registrar_->active_animation_controllers(); |
2821 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2811 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
2822 iter != copy.end(); | 2812 iter != copy.end(); |
2823 ++iter) | 2813 ++iter) |
2824 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2814 (*iter).second->Animate(monotonic_time); |
2825 | 2815 |
2826 SetNeedsAnimate(); | 2816 SetNeedsAnimate(); |
2827 } | 2817 } |
2828 | 2818 |
2829 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2819 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
2830 if (!settings_.accelerated_animation_enabled || | 2820 if (!settings_.accelerated_animation_enabled || |
2831 !needs_animate_layers() || | 2821 !needs_animate_layers() || |
2832 !active_tree_->root_layer()) | 2822 !active_tree_->root_layer()) |
2833 return; | 2823 return; |
2834 | 2824 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 swap_promise_monitor_.erase(monitor); | 3109 swap_promise_monitor_.erase(monitor); |
3120 } | 3110 } |
3121 | 3111 |
3122 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3112 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3123 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3113 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3124 for (; it != swap_promise_monitor_.end(); it++) | 3114 for (; it != swap_promise_monitor_.end(); it++) |
3125 (*it)->OnSetNeedsRedrawOnImpl(); | 3115 (*it)->OnSetNeedsRedrawOnImpl(); |
3126 } | 3116 } |
3127 | 3117 |
3128 } // namespace cc | 3118 } // namespace cc |
OLD | NEW |