Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 260383003: Revert of cc: Split animating and drawing into separate actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 page_scale_animation_->ZoomWithAnchor(anchor, 463 page_scale_animation_->ZoomWithAnchor(anchor,
464 page_scale, 464 page_scale,
465 duration.InSecondsF()); 465 duration.InSecondsF());
466 } else { 466 } else {
467 gfx::Vector2dF scaled_target_offset = target_offset; 467 gfx::Vector2dF scaled_target_offset = target_offset;
468 page_scale_animation_->ZoomTo(scaled_target_offset, 468 page_scale_animation_->ZoomTo(scaled_target_offset,
469 page_scale, 469 page_scale,
470 duration.InSecondsF()); 470 duration.InSecondsF());
471 } 471 }
472 472
473 SetNeedsAnimate(); 473 SetNeedsRedraw();
474 client_->SetNeedsCommitOnImplThread(); 474 client_->SetNeedsCommitOnImplThread();
475 client_->RenewTreePriority(); 475 client_->RenewTreePriority();
476 } 476 }
477 477
478 void LayerTreeHostImpl::ScheduleAnimation() {
479 SetNeedsRedraw();
480 }
481
478 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( 482 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(
479 const gfx::Point& viewport_point) { 483 const gfx::Point& viewport_point) {
480 if (!settings_.touch_hit_testing) 484 if (!settings_.touch_hit_testing)
481 return true; 485 return true;
482 if (!EnsureRenderSurfaceLayerList()) 486 if (!EnsureRenderSurfaceLayerList())
483 return false; 487 return false;
484 488
485 gfx::PointF device_viewport_point = 489 gfx::PointF device_viewport_point =
486 gfx::ScalePoint(viewport_point, device_scale_factor_); 490 gfx::ScalePoint(viewport_point, device_scale_factor_);
487 491
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 // draw or timer tick. 1711 // draw or timer tick.
1708 if (!visible_) 1712 if (!visible_)
1709 ManageTiles(); 1713 ManageTiles();
1710 1714
1711 if (!renderer_) 1715 if (!renderer_)
1712 return; 1716 return;
1713 1717
1714 renderer_->SetVisible(visible); 1718 renderer_->SetVisible(visible);
1715 } 1719 }
1716 1720
1717 void LayerTreeHostImpl::SetNeedsAnimate() {
1718 NotifySwapPromiseMonitorsOfSetNeedsRedraw();
1719 client_->SetNeedsAnimateOnImplThread();
1720 }
1721
1722 void LayerTreeHostImpl::SetNeedsRedraw() { 1721 void LayerTreeHostImpl::SetNeedsRedraw() {
1723 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); 1722 NotifySwapPromiseMonitorsOfSetNeedsRedraw();
1724 client_->SetNeedsRedrawOnImplThread(); 1723 client_->SetNeedsRedrawOnImplThread();
1725 } 1724 }
1726 1725
1727 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { 1726 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const {
1728 ManagedMemoryPolicy actual = cached_managed_memory_policy_; 1727 ManagedMemoryPolicy actual = cached_managed_memory_policy_;
1729 // TODO(ernstm): The second condition disables pre-painting for all layers 1728 // TODO(ernstm): The second condition disables pre-painting for all layers
1730 // when GPU rasterization is enabled. Once we selectively enable GPU 1729 // when GPU rasterization is enabled. Once we selectively enable GPU
1731 // rasterization per layer, we also need to disable pre-painting selectively: 1730 // rasterization per layer, we also need to disable pre-painting selectively:
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 monotonic_time_for_cc_animations); 2706 monotonic_time_for_cc_animations);
2708 2707
2709 ScrollViewportBy(next_scroll - scroll_total); 2708 ScrollViewportBy(next_scroll - scroll_total);
2710 SetNeedsRedraw(); 2709 SetNeedsRedraw();
2711 2710
2712 if (page_scale_animation_->IsAnimationCompleteAtTime( 2711 if (page_scale_animation_->IsAnimationCompleteAtTime(
2713 monotonic_time_for_cc_animations)) { 2712 monotonic_time_for_cc_animations)) {
2714 page_scale_animation_.reset(); 2713 page_scale_animation_.reset();
2715 client_->SetNeedsCommitOnImplThread(); 2714 client_->SetNeedsCommitOnImplThread();
2716 client_->RenewTreePriority(); 2715 client_->RenewTreePriority();
2717 } else {
2718 SetNeedsAnimate();
2719 } 2716 }
2720 } 2717 }
2721 2718
2722 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 2719 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
2723 if (!top_controls_manager_ || !top_controls_manager_->animation()) 2720 if (!top_controls_manager_ || !top_controls_manager_->animation())
2724 return; 2721 return;
2725 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 2722 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
2726 if (active_tree_->TotalScrollOffset().y() == 0.f) 2723 if (active_tree_->TotalScrollOffset().y() == 0.f)
2727 return; 2724 return;
2728 if (!scroll.IsZero()) { 2725 if (scroll.IsZero()) {
2726 // This may happen on the first animation step. Force redraw otherwise
2727 // the animation would stop because of no new frames.
2728 SetNeedsRedraw();
2729 } else {
2729 ScrollViewportBy(gfx::ScaleVector2d( 2730 ScrollViewportBy(gfx::ScaleVector2d(
2730 scroll, 1.f / active_tree_->total_page_scale_factor())); 2731 scroll, 1.f / active_tree_->total_page_scale_factor()));
2731 SetNeedsRedraw();
2732 } 2732 }
2733 SetNeedsAnimate();
2734 } 2733 }
2735 2734
2736 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { 2735 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
2737 if (!settings_.accelerated_animation_enabled || 2736 if (!settings_.accelerated_animation_enabled ||
2738 !needs_animate_layers() || 2737 !needs_animate_layers() ||
2739 !active_tree_->root_layer()) 2738 !active_tree_->root_layer())
2740 return; 2739 return;
2741 2740
2742 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); 2741 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers");
2743 2742
2744 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic 2743 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic
2745 // time. 2744 // time.
2746 double monotonic_time_for_cc_animations = 2745 double monotonic_time_for_cc_animations =
2747 (monotonic_time - base::TimeTicks()).InSecondsF(); 2746 (monotonic_time - base::TimeTicks()).InSecondsF();
2748 AnimationRegistrar::AnimationControllerMap copy = 2747 AnimationRegistrar::AnimationControllerMap copy =
2749 animation_registrar_->active_animation_controllers(); 2748 animation_registrar_->active_animation_controllers();
2750 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2749 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2751 iter != copy.end(); 2750 iter != copy.end();
2752 ++iter) 2751 ++iter)
2753 (*iter).second->Animate(monotonic_time_for_cc_animations); 2752 (*iter).second->Animate(monotonic_time_for_cc_animations);
2754 2753
2755 SetNeedsAnimate(); 2754 SetNeedsRedraw();
2756 } 2755 }
2757 2756
2758 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { 2757 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
2759 if (!settings_.accelerated_animation_enabled || 2758 if (!settings_.accelerated_animation_enabled ||
2760 !needs_animate_layers() || 2759 !needs_animate_layers() ||
2761 !active_tree_->root_layer()) 2760 !active_tree_->root_layer())
2762 return; 2761 return;
2763 2762
2764 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); 2763 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState");
2765 scoped_ptr<AnimationEventsVector> events = 2764 scoped_ptr<AnimationEventsVector> events =
2766 make_scoped_ptr(new AnimationEventsVector); 2765 make_scoped_ptr(new AnimationEventsVector);
2767 AnimationRegistrar::AnimationControllerMap copy = 2766 AnimationRegistrar::AnimationControllerMap copy =
2768 animation_registrar_->active_animation_controllers(); 2767 animation_registrar_->active_animation_controllers();
2769 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2768 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2770 iter != copy.end(); 2769 iter != copy.end();
2771 ++iter) 2770 ++iter)
2772 (*iter).second->UpdateState(start_ready_animations, events.get()); 2771 (*iter).second->UpdateState(start_ready_animations, events.get());
2773 2772
2774 if (!events->empty()) { 2773 if (!events->empty()) {
2775 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); 2774 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass());
2776 } 2775 }
2777
2778 SetNeedsAnimate();
2779 } 2776 }
2780 2777
2781 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { 2778 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const {
2782 return base::TimeDelta::FromSeconds(1); 2779 return base::TimeDelta::FromSeconds(1);
2783 } 2780 }
2784 2781
2785 void LayerTreeHostImpl::SendReleaseResourcesRecursive(LayerImpl* current) { 2782 void LayerTreeHostImpl::SendReleaseResourcesRecursive(LayerImpl* current) {
2786 DCHECK(current); 2783 DCHECK(current);
2787 current->ReleaseResources(); 2784 current->ReleaseResources();
2788 if (current->mask_layer()) 2785 if (current->mask_layer())
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 2839
2843 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, 2840 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer,
2844 base::TimeTicks time) { 2841 base::TimeTicks time) {
2845 if (!layer) 2842 if (!layer)
2846 return; 2843 return;
2847 2844
2848 ScrollbarAnimationController* scrollbar_controller = 2845 ScrollbarAnimationController* scrollbar_controller =
2849 layer->scrollbar_animation_controller(); 2846 layer->scrollbar_animation_controller();
2850 if (scrollbar_controller && scrollbar_controller->Animate(time)) { 2847 if (scrollbar_controller && scrollbar_controller->Animate(time)) {
2851 TRACE_EVENT_INSTANT0( 2848 TRACE_EVENT_INSTANT0(
2852 "cc", 2849 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars",
2853 "LayerTreeHostImpl::SetNeedsAnimate due to AnimateScrollbars",
2854 TRACE_EVENT_SCOPE_THREAD); 2850 TRACE_EVENT_SCOPE_THREAD);
2855 SetNeedsAnimate(); 2851 SetNeedsRedraw();
2856 } 2852 }
2857 2853
2858 for (size_t i = 0; i < layer->children().size(); ++i) 2854 for (size_t i = 0; i < layer->children().size(); ++i)
2859 AnimateScrollbarsRecursive(layer->children()[i], time); 2855 AnimateScrollbarsRecursive(layer->children()[i], time);
2860 } 2856 }
2861 2857
2862 void LayerTreeHostImpl::StartScrollbarAnimation() { 2858 void LayerTreeHostImpl::StartScrollbarAnimation() {
2863 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); 2859 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation");
2864 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); 2860 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks());
2865 } 2861 }
2866 2862
2867 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, 2863 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer,
2868 base::TimeTicks time) { 2864 base::TimeTicks time) {
2869 if (!layer) 2865 if (!layer)
2870 return; 2866 return;
2871 2867
2872 ScrollbarAnimationController* scrollbar_controller = 2868 ScrollbarAnimationController* scrollbar_controller =
2873 layer->scrollbar_animation_controller(); 2869 layer->scrollbar_animation_controller();
2874 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { 2870 if (scrollbar_controller && scrollbar_controller->IsAnimating()) {
2875 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); 2871 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time);
2876 if (delay > base::TimeDelta()) { 2872 if (delay > base::TimeDelta())
2877 client_->RequestScrollbarAnimationOnImplThread(delay); 2873 client_->RequestScrollbarAnimationOnImplThread(delay);
2878 } else if (scrollbar_controller->Animate(time)) { 2874 else if (scrollbar_controller->Animate(time))
2879 SetNeedsAnimate(); 2875 SetNeedsRedraw();
2880 }
2881 } 2876 }
2882 2877
2883 for (size_t i = 0; i < layer->children().size(); ++i) 2878 for (size_t i = 0; i < layer->children().size(); ++i)
2884 StartScrollbarAnimationRecursive(layer->children()[i], time); 2879 StartScrollbarAnimationRecursive(layer->children()[i], time);
2885 } 2880 }
2886 2881
2887 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { 2882 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) {
2888 if (!tile_manager_) 2883 if (!tile_manager_)
2889 return; 2884 return;
2890 2885
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3061 swap_promise_monitor_.erase(monitor); 3056 swap_promise_monitor_.erase(monitor);
3062 } 3057 }
3063 3058
3064 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3059 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3065 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3060 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3066 for (; it != swap_promise_monitor_.end(); it++) 3061 for (; it != swap_promise_monitor_.end(); it++)
3067 (*it)->OnSetNeedsRedrawOnImpl(); 3062 (*it)->OnSetNeedsRedrawOnImpl();
3068 } 3063 }
3069 3064
3070 } // namespace cc 3065 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698