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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 page_scale_animation_->ZoomWithAnchor(anchor, | 454 page_scale_animation_->ZoomWithAnchor(anchor, |
455 page_scale, | 455 page_scale, |
456 duration.InSecondsF()); | 456 duration.InSecondsF()); |
457 } else { | 457 } else { |
458 gfx::Vector2dF scaled_target_offset = target_offset; | 458 gfx::Vector2dF scaled_target_offset = target_offset; |
459 page_scale_animation_->ZoomTo(scaled_target_offset, | 459 page_scale_animation_->ZoomTo(scaled_target_offset, |
460 page_scale, | 460 page_scale, |
461 duration.InSecondsF()); | 461 duration.InSecondsF()); |
462 } | 462 } |
463 | 463 |
464 SetNeedsRedraw(); | 464 SetNeedsAnimate(); |
465 client_->SetNeedsCommitOnImplThread(); | 465 client_->SetNeedsCommitOnImplThread(); |
466 client_->RenewTreePriority(); | 466 client_->RenewTreePriority(); |
467 } | 467 } |
468 | 468 |
469 void LayerTreeHostImpl::ScheduleAnimation() { | 469 void LayerTreeHostImpl::ScheduleAnimation() { SetNeedsAnimate(); } |
brianderson
2014/04/01 16:05:11
Can we get rid of ScheduleAnimation?
Sami
2014/04/17 15:16:33
Looks like we can, done.
| |
470 SetNeedsRedraw(); | |
471 } | |
472 | 470 |
473 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( | 471 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( |
474 const gfx::Point& viewport_point) { | 472 const gfx::Point& viewport_point) { |
475 if (!settings_.touch_hit_testing) | 473 if (!settings_.touch_hit_testing) |
476 return true; | 474 return true; |
477 if (!EnsureRenderSurfaceLayerList()) | 475 if (!EnsureRenderSurfaceLayerList()) |
478 return false; | 476 return false; |
479 | 477 |
480 gfx::PointF device_viewport_point = | 478 gfx::PointF device_viewport_point = |
481 gfx::ScalePoint(viewport_point, device_scale_factor_); | 479 gfx::ScalePoint(viewport_point, device_scale_factor_); |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1672 // draw or timer tick. | 1670 // draw or timer tick. |
1673 if (!visible_) | 1671 if (!visible_) |
1674 ManageTiles(); | 1672 ManageTiles(); |
1675 | 1673 |
1676 if (!renderer_) | 1674 if (!renderer_) |
1677 return; | 1675 return; |
1678 | 1676 |
1679 renderer_->SetVisible(visible); | 1677 renderer_->SetVisible(visible); |
1680 } | 1678 } |
1681 | 1679 |
1680 void LayerTreeHostImpl::SetNeedsAnimate() { | |
1681 client_->SetNeedsAnimateOnImplThread(); | |
1682 } | |
1683 | |
1682 void LayerTreeHostImpl::SetNeedsRedraw() { | 1684 void LayerTreeHostImpl::SetNeedsRedraw() { |
1683 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1685 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
brianderson
2014/04/01 16:05:11
What does NotifySwapPromiseMonitorsOfSetNeedsRedra
Sami
2014/04/17 15:16:33
As far as I understand it, that call tells the lat
danakj
2014/04/17 15:18:09
It is meant to tell the monitor that we might draw
| |
1684 client_->SetNeedsRedrawOnImplThread(); | 1686 client_->SetNeedsRedrawOnImplThread(); |
1685 } | 1687 } |
1686 | 1688 |
1687 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { | 1689 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { |
1688 ManagedMemoryPolicy actual = cached_managed_memory_policy_; | 1690 ManagedMemoryPolicy actual = cached_managed_memory_policy_; |
1689 // TODO(ernstm): The second condition disables pre-painting for all layers | 1691 // TODO(ernstm): The second condition disables pre-painting for all layers |
1690 // when GPU rasterization is enabled. Once we selectively enable GPU | 1692 // when GPU rasterization is enabled. Once we selectively enable GPU |
1691 // rasterization per layer, we also need to disable pre-painting selectively: | 1693 // rasterization per layer, we also need to disable pre-painting selectively: |
1692 // crbug.com/335387 | 1694 // crbug.com/335387 |
1693 if (debug_state_.rasterize_only_visible_content || | 1695 if (debug_state_.rasterize_only_visible_content || |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2654 monotonic_time_for_cc_animations); | 2656 monotonic_time_for_cc_animations); |
2655 | 2657 |
2656 ScrollViewportBy(next_scroll - scroll_total); | 2658 ScrollViewportBy(next_scroll - scroll_total); |
2657 SetNeedsRedraw(); | 2659 SetNeedsRedraw(); |
2658 | 2660 |
2659 if (page_scale_animation_->IsAnimationCompleteAtTime( | 2661 if (page_scale_animation_->IsAnimationCompleteAtTime( |
2660 monotonic_time_for_cc_animations)) { | 2662 monotonic_time_for_cc_animations)) { |
2661 page_scale_animation_.reset(); | 2663 page_scale_animation_.reset(); |
2662 client_->SetNeedsCommitOnImplThread(); | 2664 client_->SetNeedsCommitOnImplThread(); |
2663 client_->RenewTreePriority(); | 2665 client_->RenewTreePriority(); |
2666 } else { | |
2667 SetNeedsAnimate(); | |
brianderson
2014/04/01 16:05:11
Can you get rid of the SetNeedsRedraw above?
In t
Sami
2014/04/17 15:16:33
I think we still need the SetNeedsRedraw here beca
| |
2664 } | 2668 } |
2665 } | 2669 } |
2666 | 2670 |
2667 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 2671 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { |
2668 if (!top_controls_manager_ || !top_controls_manager_->animation()) | 2672 if (!top_controls_manager_ || !top_controls_manager_->animation()) |
2669 return; | 2673 return; |
2670 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 2674 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); |
2671 if (active_tree_->TotalScrollOffset().y() == 0.f) | 2675 if (active_tree_->TotalScrollOffset().y() == 0.f) |
2672 return; | 2676 return; |
2673 if (scroll.IsZero()) { | 2677 if (scroll.IsZero()) { |
2674 // This may happen on the first animation step. Force redraw otherwise | 2678 // This may happen on the first animation step. Force animate otherwise |
2675 // the animation would stop because of no new frames. | 2679 // the animation would stop because of no new frames. |
2676 SetNeedsRedraw(); | 2680 SetNeedsAnimate(); |
brianderson
2014/04/01 16:05:11
I guess this is the way it already is, but I wonde
Sami
2014/04/17 15:16:33
Good question. I think we should call SetNeedsAnim
| |
2677 } else { | 2681 } else { |
2678 ScrollViewportBy(gfx::ScaleVector2d( | 2682 ScrollViewportBy(gfx::ScaleVector2d( |
2679 scroll, 1.f / active_tree_->total_page_scale_factor())); | 2683 scroll, 1.f / active_tree_->total_page_scale_factor())); |
2680 } | 2684 } |
2681 } | 2685 } |
2682 | 2686 |
2683 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 2687 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
2684 if (!settings_.accelerated_animation_enabled || | 2688 if (!settings_.accelerated_animation_enabled || |
2685 !needs_animate_layers() || | 2689 !needs_animate_layers() || |
2686 !active_tree_->root_layer()) | 2690 !active_tree_->root_layer()) |
2687 return; | 2691 return; |
2688 | 2692 |
2689 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); | 2693 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); |
2690 | 2694 |
2691 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic | 2695 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic |
2692 // time. | 2696 // time. |
2693 double monotonic_time_for_cc_animations = | 2697 double monotonic_time_for_cc_animations = |
2694 (monotonic_time - base::TimeTicks()).InSecondsF(); | 2698 (monotonic_time - base::TimeTicks()).InSecondsF(); |
2695 AnimationRegistrar::AnimationControllerMap copy = | 2699 AnimationRegistrar::AnimationControllerMap copy = |
2696 animation_registrar_->active_animation_controllers(); | 2700 animation_registrar_->active_animation_controllers(); |
2697 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 2701 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
2698 iter != copy.end(); | 2702 iter != copy.end(); |
2699 ++iter) | 2703 ++iter) |
2700 (*iter).second->Animate(monotonic_time_for_cc_animations); | 2704 (*iter).second->Animate(monotonic_time_for_cc_animations); |
2701 | 2705 |
2702 SetNeedsRedraw(); | 2706 SetNeedsAnimate(); |
2703 } | 2707 } |
2704 | 2708 |
2705 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 2709 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
2706 if (!settings_.accelerated_animation_enabled || | 2710 if (!settings_.accelerated_animation_enabled || |
2707 !needs_animate_layers() || | 2711 !needs_animate_layers() || |
2708 !active_tree_->root_layer()) | 2712 !active_tree_->root_layer()) |
2709 return; | 2713 return; |
2710 | 2714 |
2711 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); | 2715 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); |
2712 scoped_ptr<AnimationEventsVector> events = | 2716 scoped_ptr<AnimationEventsVector> events = |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2802 | 2806 |
2803 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, | 2807 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, |
2804 base::TimeTicks time) { | 2808 base::TimeTicks time) { |
2805 if (!layer) | 2809 if (!layer) |
2806 return; | 2810 return; |
2807 | 2811 |
2808 ScrollbarAnimationController* scrollbar_controller = | 2812 ScrollbarAnimationController* scrollbar_controller = |
2809 layer->scrollbar_animation_controller(); | 2813 layer->scrollbar_animation_controller(); |
2810 if (scrollbar_controller && scrollbar_controller->Animate(time)) { | 2814 if (scrollbar_controller && scrollbar_controller->Animate(time)) { |
2811 TRACE_EVENT_INSTANT0( | 2815 TRACE_EVENT_INSTANT0( |
2812 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars", | 2816 "cc", |
2817 "LayerTreeHostImpl::SetNeedsAnimate due to AnimateScrollbars", | |
2813 TRACE_EVENT_SCOPE_THREAD); | 2818 TRACE_EVENT_SCOPE_THREAD); |
2814 SetNeedsRedraw(); | 2819 SetNeedsAnimate(); |
2815 } | 2820 } |
2816 | 2821 |
2817 for (size_t i = 0; i < layer->children().size(); ++i) | 2822 for (size_t i = 0; i < layer->children().size(); ++i) |
2818 AnimateScrollbarsRecursive(layer->children()[i], time); | 2823 AnimateScrollbarsRecursive(layer->children()[i], time); |
2819 } | 2824 } |
2820 | 2825 |
2821 void LayerTreeHostImpl::StartScrollbarAnimation() { | 2826 void LayerTreeHostImpl::StartScrollbarAnimation() { |
2822 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); | 2827 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); |
2823 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); | 2828 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); |
2824 } | 2829 } |
2825 | 2830 |
2826 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, | 2831 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, |
2827 base::TimeTicks time) { | 2832 base::TimeTicks time) { |
2828 if (!layer) | 2833 if (!layer) |
2829 return; | 2834 return; |
2830 | 2835 |
2831 ScrollbarAnimationController* scrollbar_controller = | 2836 ScrollbarAnimationController* scrollbar_controller = |
2832 layer->scrollbar_animation_controller(); | 2837 layer->scrollbar_animation_controller(); |
2833 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { | 2838 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { |
2834 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); | 2839 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); |
2835 if (delay > base::TimeDelta()) | 2840 if (delay > base::TimeDelta()) { |
2836 client_->RequestScrollbarAnimationOnImplThread(delay); | 2841 client_->RequestScrollbarAnimationOnImplThread(delay); |
2837 else if (scrollbar_controller->Animate(time)) | 2842 } else if (scrollbar_controller->Animate(time)) { |
2838 SetNeedsRedraw(); | 2843 SetNeedsAnimate(); |
2844 } | |
2839 } | 2845 } |
2840 | 2846 |
2841 for (size_t i = 0; i < layer->children().size(); ++i) | 2847 for (size_t i = 0; i < layer->children().size(); ++i) |
2842 StartScrollbarAnimationRecursive(layer->children()[i], time); | 2848 StartScrollbarAnimationRecursive(layer->children()[i], time); |
2843 } | 2849 } |
2844 | 2850 |
2845 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 2851 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
2846 if (!tile_manager_) | 2852 if (!tile_manager_) |
2847 return; | 2853 return; |
2848 | 2854 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3019 swap_promise_monitor_.erase(monitor); | 3025 swap_promise_monitor_.erase(monitor); |
3020 } | 3026 } |
3021 | 3027 |
3022 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3028 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3023 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3029 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3024 for (; it != swap_promise_monitor_.end(); it++) | 3030 for (; it != swap_promise_monitor_.end(); it++) |
3025 (*it)->OnSetNeedsRedrawOnImpl(); | 3031 (*it)->OnSetNeedsRedrawOnImpl(); |
3026 } | 3032 } |
3027 | 3033 |
3028 } // namespace cc | 3034 } // namespace cc |
OLD | NEW |