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

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

Issue 178103004: Removing the use of base::Time inside the LayerTreeHost system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating for code which has been split out. Created 6 years, 9 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
« 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); 161 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
162 } 162 }
163 163
164 // TODO(enne): This should probably happen post-animate. 164 // TODO(enne): This should probably happen post-animate.
165 if (layer_tree_host_impl_->pending_tree()) { 165 if (layer_tree_host_impl_->pending_tree()) {
166 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); 166 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
167 layer_tree_host_impl_->ManageTiles(); 167 layer_tree_host_impl_->ManageTiles();
168 } 168 }
169 169
170 layer_tree_host_impl_->Animate( 170 layer_tree_host_impl_->Animate(
171 layer_tree_host_impl_->CurrentFrameTimeTicks(), 171 layer_tree_host_impl_->CurrentFrameTimeTicks());
172 layer_tree_host_impl_->CurrentFrameTime());
173 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); 172 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
174 bool start_ready_animations = true; 173 bool start_ready_animations = true;
175 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 174 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
176 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 175 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
177 } 176 }
178 177
179 void SetActive(bool active) { 178 void SetActive(bool active) {
180 if (active != time_source_->Active()) 179 if (active != time_source_->Active())
181 time_source_->SetActive(active); 180 time_source_->SetActive(active);
182 } 181 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 389 }
391 if (EvictedUIResourcesExist()) { 390 if (EvictedUIResourcesExist()) {
392 TRACE_EVENT_INSTANT0( 391 TRACE_EVENT_INSTANT0(
393 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", 392 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
394 TRACE_EVENT_SCOPE_THREAD); 393 TRACE_EVENT_SCOPE_THREAD);
395 return false; 394 return false;
396 } 395 }
397 return true; 396 return true;
398 } 397 }
399 398
400 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, 399 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
401 base::Time wall_clock_time) {
402 if (input_handler_client_) 400 if (input_handler_client_)
403 input_handler_client_->Animate(monotonic_time); 401 input_handler_client_->Animate(monotonic_time);
404 AnimatePageScale(monotonic_time); 402 AnimatePageScale(monotonic_time);
405 AnimateLayers(monotonic_time, wall_clock_time); 403 AnimateLayers(monotonic_time);
406 AnimateScrollbars(monotonic_time); 404 AnimateScrollbars(monotonic_time);
407 AnimateTopControls(monotonic_time); 405 AnimateTopControls(monotonic_time);
408 } 406 }
409 407
410 void LayerTreeHostImpl::ManageTiles() { 408 void LayerTreeHostImpl::ManageTiles() {
411 if (!tile_manager_) 409 if (!tile_manager_)
412 return; 410 return;
413 if (!tile_priorities_dirty_) 411 if (!tile_priorities_dirty_)
414 return; 412 return;
415 413
(...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 LayerImpl* scroll_layer = OuterViewportScrollLayer() 2637 LayerImpl* scroll_layer = OuterViewportScrollLayer()
2640 ? OuterViewportScrollLayer() 2638 ? OuterViewportScrollLayer()
2641 : InnerViewportScrollLayer(); 2639 : InnerViewportScrollLayer();
2642 2640
2643 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); 2641 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta);
2644 2642
2645 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) 2643 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer()))
2646 InnerViewportScrollLayer()->ScrollBy(unused_delta); 2644 InnerViewportScrollLayer()->ScrollBy(unused_delta);
2647 } 2645 }
2648 2646
2649 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { 2647 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
2650 if (!page_scale_animation_) 2648 if (!page_scale_animation_)
2651 return; 2649 return;
2652 2650
2653 double monotonic_time = (time - base::TimeTicks()).InSecondsF(); 2651 double blink_monotonic_time =
ajuma 2014/03/11 13:29:18 This time isn't actually sent to Blink (it's sent
mithro-old 2014/03/11 13:31:20 Why does cc::PageScaleAnimation use a double? Is
ajuma 2014/03/11 13:37:05 Yes to both: it's leftover from the move, and shou
2652 (monotonic_time - base::TimeTicks()).InSecondsF();
2654 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); 2653 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset();
2655 2654
2656 if (!page_scale_animation_->IsAnimationStarted()) 2655 if (!page_scale_animation_->IsAnimationStarted())
2657 page_scale_animation_->StartAnimation(monotonic_time); 2656 page_scale_animation_->StartAnimation(blink_monotonic_time);
2658 2657
2659 active_tree_->SetPageScaleDelta( 2658 active_tree_->SetPageScaleDelta(
2660 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / 2659 page_scale_animation_->PageScaleFactorAtTime(blink_monotonic_time) /
2661 active_tree_->page_scale_factor()); 2660 active_tree_->page_scale_factor());
2662 gfx::Vector2dF next_scroll = 2661 gfx::Vector2dF next_scroll =
2663 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); 2662 page_scale_animation_->ScrollOffsetAtTime(blink_monotonic_time);
2664 2663
2665 ScrollViewportBy(next_scroll - scroll_total); 2664 ScrollViewportBy(next_scroll - scroll_total);
2666 SetNeedsRedraw(); 2665 SetNeedsRedraw();
2667 2666
2668 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { 2667 if (page_scale_animation_->IsAnimationCompleteAtTime(blink_monotonic_time)) {
2669 page_scale_animation_.reset(); 2668 page_scale_animation_.reset();
2670 client_->SetNeedsCommitOnImplThread(); 2669 client_->SetNeedsCommitOnImplThread();
2671 client_->RenewTreePriority(); 2670 client_->RenewTreePriority();
2672 } 2671 }
2673 } 2672 }
2674 2673
2675 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 2674 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
2676 if (!top_controls_manager_ || !top_controls_manager_->animation()) 2675 if (!top_controls_manager_ || !top_controls_manager_->animation())
2677 return; 2676 return;
2678 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 2677 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
2679 if (active_tree_->TotalScrollOffset().y() == 0.f) 2678 if (active_tree_->TotalScrollOffset().y() == 0.f)
2680 return; 2679 return;
2681 if (scroll.IsZero()) { 2680 if (scroll.IsZero()) {
2682 // This may happen on the first animation step. Force redraw otherwise 2681 // This may happen on the first animation step. Force redraw otherwise
2683 // the animation would stop because of no new frames. 2682 // the animation would stop because of no new frames.
2684 SetNeedsRedraw(); 2683 SetNeedsRedraw();
2685 } else { 2684 } else {
2686 ScrollViewportBy(gfx::ScaleVector2d( 2685 ScrollViewportBy(gfx::ScaleVector2d(
2687 scroll, 1.f / active_tree_->total_page_scale_factor())); 2686 scroll, 1.f / active_tree_->total_page_scale_factor()));
2688 } 2687 }
2689 } 2688 }
2690 2689
2691 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time, 2690 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
2692 base::Time wall_clock_time) {
2693 if (!settings_.accelerated_animation_enabled || 2691 if (!settings_.accelerated_animation_enabled ||
2694 animation_registrar_->active_animation_controllers().empty() || 2692 animation_registrar_->active_animation_controllers().empty() ||
2695 !active_tree_->root_layer()) 2693 !active_tree_->root_layer())
2696 return; 2694 return;
2697 2695
2698 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); 2696 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers");
2699 2697
2700 double monotonic_seconds = (monotonic_time - base::TimeTicks()).InSecondsF(); 2698 double blink_monotonic_time =
ajuma 2014/03/11 13:29:18 Same naming comment as before. While this time is
2701 2699 (monotonic_time - base::TimeTicks()).InSecondsF();
2702 AnimationRegistrar::AnimationControllerMap copy = 2700 AnimationRegistrar::AnimationControllerMap copy =
2703 animation_registrar_->active_animation_controllers(); 2701 animation_registrar_->active_animation_controllers();
2704 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2702 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2705 iter != copy.end(); 2703 iter != copy.end();
2706 ++iter) 2704 ++iter)
2707 (*iter).second->Animate(monotonic_seconds); 2705 (*iter).second->Animate(blink_monotonic_time);
2708 2706
2709 SetNeedsRedraw(); 2707 SetNeedsRedraw();
2710 } 2708 }
2711 2709
2712 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { 2710 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
2713 if (!settings_.accelerated_animation_enabled || 2711 if (!settings_.accelerated_animation_enabled ||
2714 animation_registrar_->active_animation_controllers().empty() || 2712 animation_registrar_->active_animation_controllers().empty() ||
2715 !active_tree_->root_layer()) 2713 !active_tree_->root_layer())
2716 return; 2714 return;
2717 2715
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2854 return; 2852 return;
2855 2853
2856 if (global_tile_state_.tree_priority == priority) 2854 if (global_tile_state_.tree_priority == priority)
2857 return; 2855 return;
2858 global_tile_state_.tree_priority = priority; 2856 global_tile_state_.tree_priority = priority;
2859 DidModifyTilePriorities(); 2857 DidModifyTilePriorities();
2860 } 2858 }
2861 2859
2862 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { 2860 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() {
2863 current_frame_timeticks_ = base::TimeTicks(); 2861 current_frame_timeticks_ = base::TimeTicks();
2864 current_frame_time_ = base::Time();
2865 } 2862 }
2866 2863
2867 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks, 2864 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks) const {
2868 base::Time* now) const {
2869 if (ticks->is_null()) { 2865 if (ticks->is_null()) {
2870 DCHECK(now->is_null());
2871 *ticks = CurrentPhysicalTimeTicks(); 2866 *ticks = CurrentPhysicalTimeTicks();
2872 *now = base::Time::Now();
2873 } 2867 }
2874 } 2868 }
2875 2869
2876 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { 2870 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() {
2877 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_); 2871 UpdateCurrentFrameTime(&current_frame_timeticks_);
2878 return current_frame_timeticks_; 2872 return current_frame_timeticks_;
2879 } 2873 }
2880 2874
2881 base::Time LayerTreeHostImpl::CurrentFrameTime() {
2882 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_);
2883 return current_frame_time_;
2884 }
2885
2886 base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const { 2875 base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const {
2887 return gfx::FrameTime::Now(); 2876 return gfx::FrameTime::Now();
2888 } 2877 }
2889 2878
2890 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( 2879 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame(
2891 FrameData* frame) const { 2880 FrameData* frame) const {
2892 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 2881 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
2893 if (this->pending_tree_) 2882 if (this->pending_tree_)
2894 state->Set("activation_state", ActivationStateAsValue().release()); 2883 state->Set("activation_state", ActivationStateAsValue().release());
2895 state->Set("device_viewport_size", 2884 state->Set("device_viewport_size",
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 swap_promise_monitor_.erase(monitor); 3025 swap_promise_monitor_.erase(monitor);
3037 } 3026 }
3038 3027
3039 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3028 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3040 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3029 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3041 for (; it != swap_promise_monitor_.end(); it++) 3030 for (; it != swap_promise_monitor_.end(); it++)
3042 (*it)->OnSetNeedsRedrawOnImpl(); 3031 (*it)->OnSetNeedsRedrawOnImpl();
3043 } 3032 }
3044 3033
3045 } // namespace cc 3034 } // 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