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