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 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2684 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
2685 | 2685 |
2686 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2686 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
2687 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2687 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
2688 } | 2688 } |
2689 | 2689 |
2690 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 2690 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
2691 if (!page_scale_animation_) | 2691 if (!page_scale_animation_) |
2692 return; | 2692 return; |
2693 | 2693 |
2694 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2695 // time. | |
2696 double monotonic_time_for_cc_animations = | |
2697 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2698 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); | 2694 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); |
2699 | 2695 |
2700 if (!page_scale_animation_->IsAnimationStarted()) | 2696 if (!page_scale_animation_->IsAnimationStarted()) |
2701 page_scale_animation_->StartAnimation(monotonic_time_for_cc_animations); | 2697 page_scale_animation_->StartAnimation(monotonic_time); |
2702 | 2698 |
2703 active_tree_->SetPageScaleDelta(page_scale_animation_->PageScaleFactorAtTime( | 2699 active_tree_->SetPageScaleDelta( |
2704 monotonic_time_for_cc_animations) / | 2700 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
2705 active_tree_->page_scale_factor()); | 2701 active_tree_->page_scale_factor()); |
2706 gfx::Vector2dF next_scroll = page_scale_animation_->ScrollOffsetAtTime( | 2702 gfx::Vector2dF next_scroll = |
2707 monotonic_time_for_cc_animations); | 2703 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
2708 | 2704 |
2709 ScrollViewportBy(next_scroll - scroll_total); | 2705 ScrollViewportBy(next_scroll - scroll_total); |
2710 SetNeedsRedraw(); | 2706 SetNeedsRedraw(); |
2711 | 2707 |
2712 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2708 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
2713 monotonic_time_for_cc_animations)) { | |
2714 page_scale_animation_.reset(); | 2709 page_scale_animation_.reset(); |
2715 client_->SetNeedsCommitOnImplThread(); | 2710 client_->SetNeedsCommitOnImplThread(); |
2716 client_->RenewTreePriority(); | 2711 client_->RenewTreePriority(); |
2717 } | 2712 } |
2718 } | 2713 } |
2719 | 2714 |
2720 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2715 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
2721 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2716 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
2722 return; | 2717 return; |
2723 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2718 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
(...skipping 10 matching lines...) Expand all Loading... |
2734 } | 2729 } |
2735 | 2730 |
2736 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2731 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
2737 if (!settings_.accelerated_animation_enabled || | 2732 if (!settings_.accelerated_animation_enabled || |
2738 !needs_animate_layers() || | 2733 !needs_animate_layers() || |
2739 !active_tree_->root_layer()) | 2734 !active_tree_->root_layer()) |
2740 return; | 2735 return; |
2741 | 2736 |
2742 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2737 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
2743 | 2738 |
2744 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2745 // time. | |
2746 double monotonic_time_for_cc_animations = | |
2747 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2748 AnimationRegistrar::AnimationControllerMap copy = | 2739 AnimationRegistrar::AnimationControllerMap copy = |
2749 animation_registrar_->active_animation_controllers(); | 2740 animation_registrar_->active_animation_controllers(); |
2750 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2741 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
2751 iter != copy.end(); | 2742 iter != copy.end(); |
2752 ++iter) | 2743 ++iter) |
2753 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2744 (*iter).second->Animate(monotonic_time); |
2754 | 2745 |
2755 SetNeedsRedraw(); | 2746 SetNeedsRedraw(); |
2756 } | 2747 } |
2757 | 2748 |
2758 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2749 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
2759 if (!settings_.accelerated_animation_enabled || | 2750 if (!settings_.accelerated_animation_enabled || |
2760 !needs_animate_layers() || | 2751 !needs_animate_layers() || |
2761 !active_tree_->root_layer()) | 2752 !active_tree_->root_layer()) |
2762 return; | 2753 return; |
2763 | 2754 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3072 swap_promise_monitor_.erase(monitor); | 3063 swap_promise_monitor_.erase(monitor); |
3073 } | 3064 } |
3074 | 3065 |
3075 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3066 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3076 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3067 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3077 for (; it != swap_promise_monitor_.end(); it++) | 3068 for (; it != swap_promise_monitor_.end(); it++) |
3078 (*it)->OnSetNeedsRedrawOnImpl(); | 3069 (*it)->OnSetNeedsRedrawOnImpl(); |
3079 } | 3070 } |
3080 | 3071 |
3081 } // namespace cc | 3072 } // namespace cc |
OLD | NEW |