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