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

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: Changing to a common ToWebKitTime function. 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); 160 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
161 } 161 }
162 162
163 // TODO(enne): This should probably happen post-animate. 163 // TODO(enne): This should probably happen post-animate.
164 if (layer_tree_host_impl_->pending_tree()) { 164 if (layer_tree_host_impl_->pending_tree()) {
165 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); 165 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
166 layer_tree_host_impl_->ManageTiles(); 166 layer_tree_host_impl_->ManageTiles();
167 } 167 }
168 168
169 layer_tree_host_impl_->Animate( 169 layer_tree_host_impl_->Animate(
170 layer_tree_host_impl_->CurrentFrameTimeTicks(), 170 layer_tree_host_impl_->CurrentFrameTimeTicks());
171 layer_tree_host_impl_->CurrentFrameTime());
172 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); 171 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
173 bool start_ready_animations = true; 172 bool start_ready_animations = true;
174 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 173 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
175 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 174 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
176 } 175 }
177 176
178 void SetActive(bool active) { 177 void SetActive(bool active) {
179 if (active != time_source_->Active()) 178 if (active != time_source_->Active())
180 time_source_->SetActive(active); 179 time_source_->SetActive(active);
181 } 180 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 388 }
390 if (EvictedUIResourcesExist()) { 389 if (EvictedUIResourcesExist()) {
391 TRACE_EVENT_INSTANT0( 390 TRACE_EVENT_INSTANT0(
392 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", 391 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
393 TRACE_EVENT_SCOPE_THREAD); 392 TRACE_EVENT_SCOPE_THREAD);
394 return false; 393 return false;
395 } 394 }
396 return true; 395 return true;
397 } 396 }
398 397
399 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, 398 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
400 base::Time wall_clock_time) {
401 if (input_handler_client_) 399 if (input_handler_client_)
402 input_handler_client_->Animate(monotonic_time); 400 input_handler_client_->Animate(monotonic_time);
403 AnimatePageScale(monotonic_time); 401 AnimatePageScale(monotonic_time);
404 AnimateLayers(monotonic_time, wall_clock_time); 402 AnimateLayers(monotonic_time);
405 AnimateScrollbars(monotonic_time); 403 AnimateScrollbars(monotonic_time);
406 AnimateTopControls(monotonic_time); 404 AnimateTopControls(monotonic_time);
407 } 405 }
408 406
409 void LayerTreeHostImpl::ManageTiles() { 407 void LayerTreeHostImpl::ManageTiles() {
410 if (!tile_manager_) 408 if (!tile_manager_)
411 return; 409 return;
412 if (!tile_priorities_dirty_) 410 if (!tile_priorities_dirty_)
413 return; 411 return;
414 if (!device_viewport_valid_for_tile_management_) 412 if (!device_viewport_valid_for_tile_management_)
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); 2601 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta);
2604 2602
2605 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) 2603 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer()))
2606 InnerViewportScrollLayer()->ScrollBy(unused_delta); 2604 InnerViewportScrollLayer()->ScrollBy(unused_delta);
2607 } 2605 }
2608 2606
2609 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { 2607 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) {
2610 if (!page_scale_animation_) 2608 if (!page_scale_animation_)
2611 return; 2609 return;
2612 2610
2613 double monotonic_time = (time - base::TimeTicks()).InSecondsF(); 2611 double webkit_time = time.ToWebKit();
2614 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); 2612 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset();
2615 2613
2616 if (!page_scale_animation_->IsAnimationStarted()) 2614 if (!page_scale_animation_->IsAnimationStarted())
2617 page_scale_animation_->StartAnimation(monotonic_time); 2615 page_scale_animation_->StartAnimation(webkit_time);
2618 2616
2619 active_tree_->SetPageScaleDelta( 2617 active_tree_->SetPageScaleDelta(
2620 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / 2618 page_scale_animation_->PageScaleFactorAtTime(webkit_time) /
2621 active_tree_->page_scale_factor()); 2619 active_tree_->page_scale_factor());
2622 gfx::Vector2dF next_scroll = 2620 gfx::Vector2dF next_scroll =
2623 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); 2621 page_scale_animation_->ScrollOffsetAtTime(webkit_time);
2624 2622
2625 ScrollViewportBy(next_scroll - scroll_total); 2623 ScrollViewportBy(next_scroll - scroll_total);
2626 SetNeedsRedraw(); 2624 SetNeedsRedraw();
2627 2625
2628 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { 2626 if (page_scale_animation_->IsAnimationCompleteAtTime(webkit_time)) {
2629 page_scale_animation_.reset(); 2627 page_scale_animation_.reset();
2630 client_->SetNeedsCommitOnImplThread(); 2628 client_->SetNeedsCommitOnImplThread();
2631 client_->RenewTreePriority(); 2629 client_->RenewTreePriority();
2632 } 2630 }
2633 } 2631 }
2634 2632
2635 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 2633 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
2636 if (!top_controls_manager_) 2634 if (!top_controls_manager_)
2637 return; 2635 return;
2638 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 2636 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
2639 if (active_tree_->TotalScrollOffset().y() == 0.f) 2637 if (active_tree_->TotalScrollOffset().y() == 0.f)
2640 return; 2638 return;
2641 if (scroll.IsZero()) { 2639 if (scroll.IsZero()) {
2642 // This may happen on the first animation step. Force redraw otherwise 2640 // This may happen on the first animation step. Force redraw otherwise
2643 // the animation would stop because of no new frames. 2641 // the animation would stop because of no new frames.
2644 SetNeedsRedraw(); 2642 SetNeedsRedraw();
2645 } else { 2643 } else {
2646 ScrollViewportBy(gfx::ScaleVector2d( 2644 ScrollViewportBy(gfx::ScaleVector2d(
2647 scroll, 1.f / active_tree_->total_page_scale_factor())); 2645 scroll, 1.f / active_tree_->total_page_scale_factor()));
2648 } 2646 }
2649 } 2647 }
2650 2648
2651 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time, 2649 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
2652 base::Time wall_clock_time) {
2653 if (!settings_.accelerated_animation_enabled || 2650 if (!settings_.accelerated_animation_enabled ||
2654 animation_registrar_->active_animation_controllers().empty() || 2651 animation_registrar_->active_animation_controllers().empty() ||
2655 !active_tree_->root_layer()) 2652 !active_tree_->root_layer())
2656 return; 2653 return;
2657 2654
2658 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); 2655 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers");
2659 2656
2660 last_animation_time_ = wall_clock_time;
2661 double monotonic_seconds = (monotonic_time - base::TimeTicks()).InSecondsF();
2662
2663 AnimationRegistrar::AnimationControllerMap copy = 2657 AnimationRegistrar::AnimationControllerMap copy =
2664 animation_registrar_->active_animation_controllers(); 2658 animation_registrar_->active_animation_controllers();
2665 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2659 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2666 iter != copy.end(); 2660 iter != copy.end();
2667 ++iter) 2661 ++iter)
2668 (*iter).second->Animate(monotonic_seconds); 2662 (*iter).second->Animate(monotonic_time.ToWebKit());
2669 2663
2670 SetNeedsRedraw(); 2664 SetNeedsRedraw();
2671 } 2665 }
2672 2666
2673 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { 2667 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
2674 if (!settings_.accelerated_animation_enabled || 2668 if (!settings_.accelerated_animation_enabled ||
2675 animation_registrar_->active_animation_controllers().empty() || 2669 animation_registrar_->active_animation_controllers().empty() ||
2676 !active_tree_->root_layer()) 2670 !active_tree_->root_layer())
2677 return; 2671 return;
2678 2672
2679 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); 2673 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState");
2680 scoped_ptr<AnimationEventsVector> events = 2674 scoped_ptr<AnimationEventsVector> events =
2681 make_scoped_ptr(new AnimationEventsVector); 2675 make_scoped_ptr(new AnimationEventsVector);
2682 AnimationRegistrar::AnimationControllerMap copy = 2676 AnimationRegistrar::AnimationControllerMap copy =
2683 animation_registrar_->active_animation_controllers(); 2677 animation_registrar_->active_animation_controllers();
2684 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 2678 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
2685 iter != copy.end(); 2679 iter != copy.end();
2686 ++iter) 2680 ++iter)
2687 (*iter).second->UpdateState(start_ready_animations, events.get()); 2681 (*iter).second->UpdateState(start_ready_animations, events.get());
2688 2682
2689 if (!events->empty()) { 2683 if (!events->empty()) {
2690 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass(), 2684 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass(),
2691 last_animation_time_); 2685 last_animation_time_);
ajuma 2014/02/28 02:32:03 Since last_animation_time_ is no longer being set,
2692 } 2686 }
2693 } 2687 }
2694 2688
2695 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { 2689 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const {
2696 return base::TimeDelta::FromSeconds(1); 2690 return base::TimeDelta::FromSeconds(1);
2697 } 2691 }
2698 2692
2699 void LayerTreeHostImpl::SendReleaseResourcesRecursive(LayerImpl* current) { 2693 void LayerTreeHostImpl::SendReleaseResourcesRecursive(LayerImpl* current) {
2700 DCHECK(current); 2694 DCHECK(current);
2701 current->ReleaseResources(); 2695 current->ReleaseResources();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 return; 2810 return;
2817 2811
2818 if (global_tile_state_.tree_priority == priority) 2812 if (global_tile_state_.tree_priority == priority)
2819 return; 2813 return;
2820 global_tile_state_.tree_priority = priority; 2814 global_tile_state_.tree_priority = priority;
2821 DidModifyTilePriorities(); 2815 DidModifyTilePriorities();
2822 } 2816 }
2823 2817
2824 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { 2818 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() {
2825 current_frame_timeticks_ = base::TimeTicks(); 2819 current_frame_timeticks_ = base::TimeTicks();
2826 current_frame_time_ = base::Time();
2827 } 2820 }
2828 2821
2829 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks, 2822 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks) const {
2830 base::Time* now) const {
2831 if (ticks->is_null()) { 2823 if (ticks->is_null()) {
2832 DCHECK(now->is_null());
2833 *ticks = CurrentPhysicalTimeTicks(); 2824 *ticks = CurrentPhysicalTimeTicks();
2834 *now = base::Time::Now();
2835 } 2825 }
2836 } 2826 }
2837 2827
2838 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { 2828 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() {
2839 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_); 2829 UpdateCurrentFrameTime(&current_frame_timeticks_);
2840 return current_frame_timeticks_; 2830 return current_frame_timeticks_;
2841 } 2831 }
2842 2832
2843 base::Time LayerTreeHostImpl::CurrentFrameTime() {
2844 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_);
2845 return current_frame_time_;
2846 }
2847
2848 base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const { 2833 base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const {
2849 return gfx::FrameTime::Now(); 2834 return gfx::FrameTime::Now();
2850 } 2835 }
2851 2836
2852 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( 2837 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame(
2853 FrameData* frame) const { 2838 FrameData* frame) const {
2854 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 2839 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
2855 if (this->pending_tree_) 2840 if (this->pending_tree_)
2856 state->Set("activation_state", ActivationStateAsValue().release()); 2841 state->Set("activation_state", ActivationStateAsValue().release());
2857 state->Set("device_viewport_size", 2842 state->Set("device_viewport_size",
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2998 swap_promise_monitor_.erase(monitor); 2983 swap_promise_monitor_.erase(monitor);
2999 } 2984 }
3000 2985
3001 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 2986 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3002 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 2987 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3003 for (; it != swap_promise_monitor_.end(); it++) 2988 for (; it != swap_promise_monitor_.end(); it++)
3004 (*it)->OnSetNeedsRedrawOnImpl(); 2989 (*it)->OnSetNeedsRedrawOnImpl();
3005 } 2990 }
3006 2991
3007 } // namespace cc 2992 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698