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 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2714 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2714 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
2715 | 2715 |
2716 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2716 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
2717 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2717 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
2718 } | 2718 } |
2719 | 2719 |
2720 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 2720 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
2721 if (!page_scale_animation_) | 2721 if (!page_scale_animation_) |
2722 return; | 2722 return; |
2723 | 2723 |
2724 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2725 // time. | |
2726 double monotonic_time_for_cc_animations = | |
2727 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2728 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); | 2724 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); |
2729 | 2725 |
2730 if (!page_scale_animation_->IsAnimationStarted()) | 2726 if (!page_scale_animation_->IsAnimationStarted()) |
2731 page_scale_animation_->StartAnimation(monotonic_time_for_cc_animations); | 2727 page_scale_animation_->StartAnimation(monotonic_time); |
2732 | 2728 |
2733 active_tree_->SetPageScaleDelta(page_scale_animation_->PageScaleFactorAtTime( | 2729 active_tree_->SetPageScaleDelta( |
2734 monotonic_time_for_cc_animations) / | 2730 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
2735 active_tree_->page_scale_factor()); | 2731 active_tree_->page_scale_factor()); |
2736 gfx::Vector2dF next_scroll = page_scale_animation_->ScrollOffsetAtTime( | 2732 gfx::Vector2dF next_scroll = |
2737 monotonic_time_for_cc_animations); | 2733 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
2738 | 2734 |
2739 ScrollViewportBy(next_scroll - scroll_total); | 2735 ScrollViewportBy(next_scroll - scroll_total); |
2740 SetNeedsRedraw(); | 2736 SetNeedsRedraw(); |
2741 | 2737 |
2742 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2738 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
2743 monotonic_time_for_cc_animations)) { | |
2744 page_scale_animation_.reset(); | 2739 page_scale_animation_.reset(); |
2745 client_->SetNeedsCommitOnImplThread(); | 2740 client_->SetNeedsCommitOnImplThread(); |
2746 client_->RenewTreePriority(); | 2741 client_->RenewTreePriority(); |
2747 } | 2742 } |
2748 } | 2743 } |
2749 | 2744 |
2750 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2745 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
2751 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2746 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
2752 return; | 2747 return; |
2753 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2748 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
2754 if (active_tree_->TotalScrollOffset().y() == 0.f) | 2749 if (active_tree_->TotalScrollOffset().y() == 0.f) |
2755 return; | 2750 return; |
2756 if (scroll.IsZero()) { | 2751 if (scroll.IsZero()) { |
2757 // This may happen on the first animation step. Force redraw otherwise | 2752 // This may happen on the first animation step. Force redraw otherwise |
2758 // the animation would stop because of no new frames. | 2753 // the animation would stop because of no new frames. |
2759 SetNeedsRedraw(); | 2754 SetNeedsRedraw(); |
2760 } else { | 2755 } else { |
2761 ScrollViewportBy(gfx::ScaleVector2d( | 2756 ScrollViewportBy(gfx::ScaleVector2d( |
2762 scroll, 1.f / active_tree_->total_page_scale_factor())); | 2757 scroll, 1.f / active_tree_->total_page_scale_factor())); |
2763 } | 2758 } |
2764 } | 2759 } |
2765 | 2760 |
2766 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2761 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
2767 if (!settings_.accelerated_animation_enabled || | 2762 if (!settings_.accelerated_animation_enabled || |
2768 !needs_animate_layers() || | 2763 !needs_animate_layers() || |
2769 !active_tree_->root_layer()) | 2764 !active_tree_->root_layer()) |
2770 return; | 2765 return; |
2771 | 2766 |
2772 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2767 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
2773 | |
2774 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2775 // time. | |
2776 double monotonic_time_for_cc_animations = | |
2777 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2778 AnimationRegistrar::AnimationControllerMap copy = | 2768 AnimationRegistrar::AnimationControllerMap copy = |
2779 animation_registrar_->active_animation_controllers(); | 2769 animation_registrar_->active_animation_controllers(); |
2780 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2770 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
2781 iter != copy.end(); | 2771 iter != copy.end(); |
2782 ++iter) | 2772 ++iter) |
2783 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2773 (*iter).second->Animate(monotonic_time); |
2784 | 2774 |
2785 SetNeedsRedraw(); | 2775 SetNeedsRedraw(); |
2786 } | 2776 } |
2787 | 2777 |
2788 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2778 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
2789 if (!settings_.accelerated_animation_enabled || | 2779 if (!settings_.accelerated_animation_enabled || |
2790 !needs_animate_layers() || | 2780 !needs_animate_layers() || |
2791 !active_tree_->root_layer()) | 2781 !active_tree_->root_layer()) |
2792 return; | 2782 return; |
2793 | 2783 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3102 swap_promise_monitor_.erase(monitor); | 3092 swap_promise_monitor_.erase(monitor); |
3103 } | 3093 } |
3104 | 3094 |
3105 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3095 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3106 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3096 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3107 for (; it != swap_promise_monitor_.end(); it++) | 3097 for (; it != swap_promise_monitor_.end(); it++) |
3108 (*it)->OnSetNeedsRedrawOnImpl(); | 3098 (*it)->OnSetNeedsRedrawOnImpl(); |
3109 } | 3099 } |
3110 | 3100 |
3111 } // namespace cc | 3101 } // namespace cc |
OLD | NEW |