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

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

Issue 254883004: Revert 266624 "cc: Split animating and drawing into separate act..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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
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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 // draw or timer tick. 1725 // draw or timer tick.
1722 if (!visible_) 1726 if (!visible_)
1723 ManageTiles(); 1727 ManageTiles();
1724 1728
1725 if (!renderer_) 1729 if (!renderer_)
1726 return; 1730 return;
1727 1731
1728 renderer_->SetVisible(visible); 1732 renderer_->SetVisible(visible);
1729 } 1733 }
1730 1734
1731 void LayerTreeHostImpl::SetNeedsAnimate() {
1732 NotifySwapPromiseMonitorsOfSetNeedsRedraw();
1733 client_->SetNeedsAnimateOnImplThread();
1734 }
1735
1736 void LayerTreeHostImpl::SetNeedsRedraw() { 1735 void LayerTreeHostImpl::SetNeedsRedraw() {
1737 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); 1736 NotifySwapPromiseMonitorsOfSetNeedsRedraw();
1738 client_->SetNeedsRedrawOnImplThread(); 1737 client_->SetNeedsRedrawOnImplThread();
1739 } 1738 }
1740 1739
1741 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { 1740 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const {
1742 ManagedMemoryPolicy actual = cached_managed_memory_policy_; 1741 ManagedMemoryPolicy actual = cached_managed_memory_policy_;
1743 // TODO(ernstm): The second condition disables pre-painting for all layers 1742 // TODO(ernstm): The second condition disables pre-painting for all layers
1744 // when GPU rasterization is enabled. Once we selectively enable GPU 1743 // when GPU rasterization is enabled. Once we selectively enable GPU
1745 // rasterization per layer, we also need to disable pre-painting selectively: 1744 // rasterization per layer, we also need to disable pre-painting selectively:
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 monotonic_time_for_cc_animations); 2720 monotonic_time_for_cc_animations);
2722 2721
2723 ScrollViewportBy(next_scroll - scroll_total); 2722 ScrollViewportBy(next_scroll - scroll_total);
2724 SetNeedsRedraw(); 2723 SetNeedsRedraw();
2725 2724
2726 if (page_scale_animation_->IsAnimationCompleteAtTime( 2725 if (page_scale_animation_->IsAnimationCompleteAtTime(
2727 monotonic_time_for_cc_animations)) { 2726 monotonic_time_for_cc_animations)) {
2728 page_scale_animation_.reset(); 2727 page_scale_animation_.reset();
2729 client_->SetNeedsCommitOnImplThread(); 2728 client_->SetNeedsCommitOnImplThread();
2730 client_->RenewTreePriority(); 2729 client_->RenewTreePriority();
2731 } else {
2732 SetNeedsAnimate();
2733 } 2730 }
2734 } 2731 }
2735 2732
2736 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 2733 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
2737 if (!top_controls_manager_ || !top_controls_manager_->animation()) 2734 if (!top_controls_manager_ || !top_controls_manager_->animation())
2738 return; 2735 return;
2739 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 2736 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
2740 if (active_tree_->TotalScrollOffset().y() == 0.f) 2737 if (active_tree_->TotalScrollOffset().y() == 0.f)
2741 return; 2738 return;
2742 if (!scroll.IsZero()) { 2739 if (scroll.IsZero()) {
2740 // This may happen on the first animation step. Force redraw otherwise
2741 // the animation would stop because of no new frames.
2742 SetNeedsRedraw();
2743 } else {
2743 ScrollViewportBy(gfx::ScaleVector2d( 2744 ScrollViewportBy(gfx::ScaleVector2d(
2744 scroll, 1.f / active_tree_->total_page_scale_factor())); 2745 scroll, 1.f / active_tree_->total_page_scale_factor()));
2745 SetNeedsRedraw();
2746 } 2746 }
2747 SetNeedsAnimate();
2748 } 2747 }
2749 2748
2750 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { 2749 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
2751 if (!settings_.accelerated_animation_enabled || 2750 if (!settings_.accelerated_animation_enabled ||
2752 !needs_animate_layers() || 2751 !needs_animate_layers() ||
2753 !active_tree_->root_layer()) 2752 !active_tree_->root_layer())
2754 return; 2753 return;
2755 2754
2756 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); 2755 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers");
2757 2756
2758 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic 2757 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic
2759 // time. 2758 // time.
2760 double monotonic_time_for_cc_animations = 2759 double monotonic_time_for_cc_animations =
2761 (monotonic_time - base::TimeTicks()).InSecondsF(); 2760 (monotonic_time - base::TimeTicks()).InSecondsF();
2762 AnimationRegistrar::AnimationControllerMap copy = 2761 AnimationRegistrar::AnimationControllerMap copy =
2763 animation_registrar_->active_animation_controllers(); 2762 animation_registrar_->active_animation_controllers();
2764 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2763 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2765 iter != copy.end(); 2764 iter != copy.end();
2766 ++iter) 2765 ++iter)
2767 (*iter).second->Animate(monotonic_time_for_cc_animations); 2766 (*iter).second->Animate(monotonic_time_for_cc_animations);
2768 2767
2769 SetNeedsAnimate(); 2768 SetNeedsRedraw();
2770 } 2769 }
2771 2770
2772 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { 2771 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
2773 if (!settings_.accelerated_animation_enabled || 2772 if (!settings_.accelerated_animation_enabled ||
2774 !needs_animate_layers() || 2773 !needs_animate_layers() ||
2775 !active_tree_->root_layer()) 2774 !active_tree_->root_layer())
2776 return; 2775 return;
2777 2776
2778 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); 2777 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState");
2779 scoped_ptr<AnimationEventsVector> events = 2778 scoped_ptr<AnimationEventsVector> events =
2780 make_scoped_ptr(new AnimationEventsVector); 2779 make_scoped_ptr(new AnimationEventsVector);
2781 AnimationRegistrar::AnimationControllerMap copy = 2780 AnimationRegistrar::AnimationControllerMap copy =
2782 animation_registrar_->active_animation_controllers(); 2781 animation_registrar_->active_animation_controllers();
2783 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2782 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2784 iter != copy.end(); 2783 iter != copy.end();
2785 ++iter) 2784 ++iter)
2786 (*iter).second->UpdateState(start_ready_animations, events.get()); 2785 (*iter).second->UpdateState(start_ready_animations, events.get());
2787 2786
2788 if (!events->empty()) { 2787 if (!events->empty()) {
2789 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); 2788 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass());
2790 } 2789 }
2791
2792 SetNeedsAnimate();
2793 } 2790 }
2794 2791
2795 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { 2792 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const {
2796 return base::TimeDelta::FromSeconds(1); 2793 return base::TimeDelta::FromSeconds(1);
2797 } 2794 }
2798 2795
2799 void LayerTreeHostImpl::SendReleaseResourcesRecursive(LayerImpl* current) { 2796 void LayerTreeHostImpl::SendReleaseResourcesRecursive(LayerImpl* current) {
2800 DCHECK(current); 2797 DCHECK(current);
2801 current->ReleaseResources(); 2798 current->ReleaseResources();
2802 if (current->mask_layer()) 2799 if (current->mask_layer())
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 2853
2857 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, 2854 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer,
2858 base::TimeTicks time) { 2855 base::TimeTicks time) {
2859 if (!layer) 2856 if (!layer)
2860 return; 2857 return;
2861 2858
2862 ScrollbarAnimationController* scrollbar_controller = 2859 ScrollbarAnimationController* scrollbar_controller =
2863 layer->scrollbar_animation_controller(); 2860 layer->scrollbar_animation_controller();
2864 if (scrollbar_controller && scrollbar_controller->Animate(time)) { 2861 if (scrollbar_controller && scrollbar_controller->Animate(time)) {
2865 TRACE_EVENT_INSTANT0( 2862 TRACE_EVENT_INSTANT0(
2866 "cc", 2863 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars",
2867 "LayerTreeHostImpl::SetNeedsAnimate due to AnimateScrollbars",
2868 TRACE_EVENT_SCOPE_THREAD); 2864 TRACE_EVENT_SCOPE_THREAD);
2869 SetNeedsAnimate(); 2865 SetNeedsRedraw();
2870 } 2866 }
2871 2867
2872 for (size_t i = 0; i < layer->children().size(); ++i) 2868 for (size_t i = 0; i < layer->children().size(); ++i)
2873 AnimateScrollbarsRecursive(layer->children()[i], time); 2869 AnimateScrollbarsRecursive(layer->children()[i], time);
2874 } 2870 }
2875 2871
2876 void LayerTreeHostImpl::StartScrollbarAnimation() { 2872 void LayerTreeHostImpl::StartScrollbarAnimation() {
2877 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); 2873 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation");
2878 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); 2874 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks());
2879 } 2875 }
2880 2876
2881 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, 2877 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer,
2882 base::TimeTicks time) { 2878 base::TimeTicks time) {
2883 if (!layer) 2879 if (!layer)
2884 return; 2880 return;
2885 2881
2886 ScrollbarAnimationController* scrollbar_controller = 2882 ScrollbarAnimationController* scrollbar_controller =
2887 layer->scrollbar_animation_controller(); 2883 layer->scrollbar_animation_controller();
2888 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { 2884 if (scrollbar_controller && scrollbar_controller->IsAnimating()) {
2889 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time); 2885 base::TimeDelta delay = scrollbar_controller->DelayBeforeStart(time);
2890 if (delay > base::TimeDelta()) { 2886 if (delay > base::TimeDelta())
2891 client_->RequestScrollbarAnimationOnImplThread(delay); 2887 client_->RequestScrollbarAnimationOnImplThread(delay);
2892 } else if (scrollbar_controller->Animate(time)) { 2888 else if (scrollbar_controller->Animate(time))
2893 SetNeedsAnimate(); 2889 SetNeedsRedraw();
2894 }
2895 } 2890 }
2896 2891
2897 for (size_t i = 0; i < layer->children().size(); ++i) 2892 for (size_t i = 0; i < layer->children().size(); ++i)
2898 StartScrollbarAnimationRecursive(layer->children()[i], time); 2893 StartScrollbarAnimationRecursive(layer->children()[i], time);
2899 } 2894 }
2900 2895
2901 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { 2896 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) {
2902 if (!tile_manager_) 2897 if (!tile_manager_)
2903 return; 2898 return;
2904 2899
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 swap_promise_monitor_.erase(monitor); 3070 swap_promise_monitor_.erase(monitor);
3076 } 3071 }
3077 3072
3078 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3073 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3079 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3074 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3080 for (; it != swap_promise_monitor_.end(); it++) 3075 for (; it != swap_promise_monitor_.end(); it++)
3081 (*it)->OnSetNeedsRedrawOnImpl(); 3076 (*it)->OnSetNeedsRedrawOnImpl();
3082 } 3077 }
3083 3078
3084 } // namespace cc 3079 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host_impl.h ('k') | trunk/src/cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698