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