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 2641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2652 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); | 2652 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); |
2653 | 2653 |
2654 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) | 2654 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) |
2655 InnerViewportScrollLayer()->ScrollBy(unused_delta); | 2655 InnerViewportScrollLayer()->ScrollBy(unused_delta); |
2656 } | 2656 } |
2657 | 2657 |
2658 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 2658 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
2659 if (!page_scale_animation_) | 2659 if (!page_scale_animation_) |
2660 return; | 2660 return; |
2661 | 2661 |
2662 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2663 // time. | |
2664 double monotonic_time_for_cc_animations = | |
2665 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2666 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); | 2662 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); |
2667 | 2663 |
2668 if (!page_scale_animation_->IsAnimationStarted()) | 2664 if (!page_scale_animation_->IsAnimationStarted()) |
2669 page_scale_animation_->StartAnimation(monotonic_time_for_cc_animations); | 2665 page_scale_animation_->StartAnimation(monotonic_time); |
2670 | 2666 |
2671 active_tree_->SetPageScaleDelta(page_scale_animation_->PageScaleFactorAtTime( | 2667 active_tree_->SetPageScaleDelta( |
2672 monotonic_time_for_cc_animations) / | 2668 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
2673 active_tree_->page_scale_factor()); | 2669 active_tree_->page_scale_factor()); |
2674 gfx::Vector2dF next_scroll = page_scale_animation_->ScrollOffsetAtTime( | 2670 gfx::Vector2dF next_scroll = |
2675 monotonic_time_for_cc_animations); | 2671 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
2676 | 2672 |
2677 ScrollViewportBy(next_scroll - scroll_total); | 2673 ScrollViewportBy(next_scroll - scroll_total); |
2678 SetNeedsRedraw(); | 2674 SetNeedsRedraw(); |
2679 | 2675 |
2680 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2676 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
2681 monotonic_time_for_cc_animations)) { | |
2682 page_scale_animation_.reset(); | 2677 page_scale_animation_.reset(); |
2683 client_->SetNeedsCommitOnImplThread(); | 2678 client_->SetNeedsCommitOnImplThread(); |
2684 client_->RenewTreePriority(); | 2679 client_->RenewTreePriority(); |
2685 } | 2680 } |
2686 } | 2681 } |
2687 | 2682 |
2688 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2683 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
2689 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2684 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
2690 return; | 2685 return; |
2691 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2686 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
(...skipping 10 matching lines...) Expand all Loading... |
2702 } | 2697 } |
2703 | 2698 |
2704 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2699 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
2705 if (!settings_.accelerated_animation_enabled || | 2700 if (!settings_.accelerated_animation_enabled || |
2706 !needs_animate_layers() || | 2701 !needs_animate_layers() || |
2707 !active_tree_->root_layer()) | 2702 !active_tree_->root_layer()) |
2708 return; | 2703 return; |
2709 | 2704 |
2710 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2705 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
2711 | 2706 |
2712 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | |
2713 // time. | |
2714 double monotonic_time_for_cc_animations = | |
2715 (monotonic_time - base::TimeTicks()).InSecondsF(); | |
2716 AnimationRegistrar::AnimationControllerMap copy = | 2707 AnimationRegistrar::AnimationControllerMap copy = |
2717 animation_registrar_->active_animation_controllers(); | 2708 animation_registrar_->active_animation_controllers(); |
2718 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2709 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
2719 iter != copy.end(); | 2710 iter != copy.end(); |
2720 ++iter) | 2711 ++iter) |
2721 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2712 (*iter).second->Animate(monotonic_time); |
2722 | 2713 |
2723 SetNeedsRedraw(); | 2714 SetNeedsRedraw(); |
2724 } | 2715 } |
2725 | 2716 |
2726 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2717 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
2727 if (!settings_.accelerated_animation_enabled || | 2718 if (!settings_.accelerated_animation_enabled || |
2728 !needs_animate_layers() || | 2719 !needs_animate_layers() || |
2729 !active_tree_->root_layer()) | 2720 !active_tree_->root_layer()) |
2730 return; | 2721 return; |
2731 | 2722 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 swap_promise_monitor_.erase(monitor); | 3031 swap_promise_monitor_.erase(monitor); |
3041 } | 3032 } |
3042 | 3033 |
3043 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3034 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3044 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3035 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3045 for (; it != swap_promise_monitor_.end(); it++) | 3036 for (; it != swap_promise_monitor_.end(); it++) |
3046 (*it)->OnSetNeedsRedrawOnImpl(); | 3037 (*it)->OnSetNeedsRedrawOnImpl(); |
3047 } | 3038 } |
3048 | 3039 |
3049 } // namespace cc | 3040 } // namespace cc |
OLD | NEW |