| 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 2765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2776 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2776 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
| 2777 | 2777 |
| 2778 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2778 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
| 2779 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2779 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
| 2780 } | 2780 } |
| 2781 | 2781 |
| 2782 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 2782 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
| 2783 if (!page_scale_animation_) | 2783 if (!page_scale_animation_) |
| 2784 return; | 2784 return; |
| 2785 | 2785 |
| 2786 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
| 2787 // time. | |
| 2788 double monotonic_time_for_cc_animations = | |
| 2789 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
| 2790 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); | 2786 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); |
| 2791 | 2787 |
| 2792 if (!page_scale_animation_->IsAnimationStarted()) | 2788 if (!page_scale_animation_->IsAnimationStarted()) |
| 2793 page_scale_animation_->StartAnimation(monotonic_time_for_cc_animations); | 2789 page_scale_animation_->StartAnimation(monotonic_time); |
| 2794 | 2790 |
| 2795 active_tree_->SetPageScaleDelta(page_scale_animation_->PageScaleFactorAtTime( | 2791 active_tree_->SetPageScaleDelta( |
| 2796 monotonic_time_for_cc_animations) / | 2792 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
| 2797 active_tree_->page_scale_factor()); | 2793 active_tree_->page_scale_factor()); |
| 2798 gfx::Vector2dF next_scroll = page_scale_animation_->ScrollOffsetAtTime( | 2794 gfx::Vector2dF next_scroll = |
| 2799 monotonic_time_for_cc_animations); | 2795 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
| 2800 | 2796 |
| 2801 ScrollViewportBy(next_scroll - scroll_total); | 2797 ScrollViewportBy(next_scroll - scroll_total); |
| 2802 SetNeedsRedraw(); | 2798 SetNeedsRedraw(); |
| 2803 | 2799 |
| 2804 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2800 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
| 2805 monotonic_time_for_cc_animations)) { | |
| 2806 page_scale_animation_.reset(); | 2801 page_scale_animation_.reset(); |
| 2807 client_->SetNeedsCommitOnImplThread(); | 2802 client_->SetNeedsCommitOnImplThread(); |
| 2808 client_->RenewTreePriority(); | 2803 client_->RenewTreePriority(); |
| 2809 } else { | 2804 } else { |
| 2810 SetNeedsAnimate(); | 2805 SetNeedsAnimate(); |
| 2811 } | 2806 } |
| 2812 } | 2807 } |
| 2813 | 2808 |
| 2814 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2809 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
| 2815 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2810 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
| 2816 return; | 2811 return; |
| 2817 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2812 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
| 2818 if (active_tree_->TotalScrollOffset().y() == 0.f) | 2813 if (active_tree_->TotalScrollOffset().y() == 0.f) |
| 2819 return; | 2814 return; |
| 2820 if (!scroll.IsZero()) { | 2815 if (!scroll.IsZero()) { |
| 2821 ScrollViewportBy(gfx::ScaleVector2d( | 2816 ScrollViewportBy(gfx::ScaleVector2d( |
| 2822 scroll, 1.f / active_tree_->total_page_scale_factor())); | 2817 scroll, 1.f / active_tree_->total_page_scale_factor())); |
| 2823 SetNeedsRedraw(); | 2818 SetNeedsRedraw(); |
| 2824 } | 2819 } |
| 2825 SetNeedsAnimate(); | 2820 SetNeedsAnimate(); |
| 2826 } | 2821 } |
| 2827 | 2822 |
| 2828 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2823 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
| 2829 if (!settings_.accelerated_animation_enabled || | 2824 if (!settings_.accelerated_animation_enabled || |
| 2830 !needs_animate_layers() || | 2825 !needs_animate_layers() || |
| 2831 !active_tree_->root_layer()) | 2826 !active_tree_->root_layer()) |
| 2832 return; | 2827 return; |
| 2833 | 2828 |
| 2834 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2829 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
| 2835 | |
| 2836 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
| 2837 // time. | |
| 2838 double monotonic_time_for_cc_animations = | |
| 2839 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
| 2840 AnimationRegistrar::AnimationControllerMap copy = | 2830 AnimationRegistrar::AnimationControllerMap copy = |
| 2841 animation_registrar_->active_animation_controllers(); | 2831 animation_registrar_->active_animation_controllers(); |
| 2842 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2832 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
| 2843 iter != copy.end(); | 2833 iter != copy.end(); |
| 2844 ++iter) | 2834 ++iter) |
| 2845 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2835 (*iter).second->Animate(monotonic_time); |
| 2846 | 2836 |
| 2847 SetNeedsAnimate(); | 2837 SetNeedsAnimate(); |
| 2848 } | 2838 } |
| 2849 | 2839 |
| 2850 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2840 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
| 2851 if (!settings_.accelerated_animation_enabled || | 2841 if (!settings_.accelerated_animation_enabled || |
| 2852 !needs_animate_layers() || | 2842 !needs_animate_layers() || |
| 2853 !active_tree_->root_layer()) | 2843 !active_tree_->root_layer()) |
| 2854 return; | 2844 return; |
| 2855 | 2845 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3151 swap_promise_monitor_.erase(monitor); | 3141 swap_promise_monitor_.erase(monitor); |
| 3152 } | 3142 } |
| 3153 | 3143 |
| 3154 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3144 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3155 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3145 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3156 for (; it != swap_promise_monitor_.end(); it++) | 3146 for (; it != swap_promise_monitor_.end(); it++) |
| 3157 (*it)->OnSetNeedsRedrawOnImpl(); | 3147 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3158 } | 3148 } |
| 3159 | 3149 |
| 3160 } // namespace cc | 3150 } // namespace cc |
| OLD | NEW |