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

Side by Side Diff: content/renderer/render_widget.cc

Issue 9233018: Convert use of int ms to TimeDelta in files owned by brettw. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. Created 8 years, 11 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 | « content/renderer/load_progress_tracker.cc ('k') | dbus/test_service.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 25); 669 25);
670 } 670 }
671 DoDeferredUpdateAndSendInputAck(); 671 DoDeferredUpdateAndSendInputAck();
672 } 672 }
673 673
674 void RenderWidget::AnimateIfNeeded() { 674 void RenderWidget::AnimateIfNeeded() {
675 if (!animation_update_pending_) 675 if (!animation_update_pending_)
676 return; 676 return;
677 677
678 // Target 60FPS if vsync is on. Go as fast as we can if vsync is off. 678 // Target 60FPS if vsync is on. Go as fast as we can if vsync is off.
679 int animationInterval = IsRenderingVSynced() ? 16 : 0; 679 base::TimeDelta animationInterval = IsRenderingVSynced() ?
680 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta();
680 681
681 base::Time now = base::Time::Now(); 682 base::Time now = base::Time::Now();
682 if (now >= animation_floor_time_ || is_accelerated_compositing_active_) { 683 if (now >= animation_floor_time_ || is_accelerated_compositing_active_) {
683 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") 684 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
684 animation_floor_time_ = now + 685 animation_floor_time_ = now + animationInterval;
685 base::TimeDelta::FromMilliseconds(animationInterval);
686 // Set a timer to call us back after animationInterval before 686 // Set a timer to call us back after animationInterval before
687 // running animation callbacks so that if a callback requests another 687 // running animation callbacks so that if a callback requests another
688 // we'll be sure to run it at the proper time. 688 // we'll be sure to run it at the proper time.
689 MessageLoop::current()->PostDelayedTask( 689 MessageLoop::current()->PostDelayedTask(
690 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this), 690 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this),
691 animationInterval); 691 animationInterval);
692 animation_task_posted_ = true; 692 animation_task_posted_ = true;
693 animation_update_pending_ = false; 693 animation_update_pending_ = false;
694 webwidget_->animate(0.0); 694 webwidget_->animate(0.0);
695 return; 695 return;
696 } 696 }
697 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); 697 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently");
698 if (animation_task_posted_) 698 if (animation_task_posted_)
699 return; 699 return;
700 // This code uses base::Time::Now() to calculate the floor and next fire 700 // This code uses base::Time::Now() to calculate the floor and next fire
701 // time because javascript's Date object uses base::Time::Now(). The 701 // time because javascript's Date object uses base::Time::Now(). The
702 // message loop uses base::TimeTicks, which on windows can have a 702 // message loop uses base::TimeTicks, which on windows can have a
703 // different granularity than base::Time. 703 // different granularity than base::Time.
704 // The upshot of all this is that this function might be called before 704 // The upshot of all this is that this function might be called before
705 // base::Time::Now() has advanced past the animation_floor_time_. To 705 // base::Time::Now() has advanced past the animation_floor_time_. To
706 // avoid exposing this delay to javascript, we keep posting delayed 706 // avoid exposing this delay to javascript, we keep posting delayed
707 // tasks until base::Time::Now() has advanced far enough. 707 // tasks until base::Time::Now() has advanced far enough.
708 int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp(); 708 base::TimeDelta delay = animation_floor_time_ - now;
709 animation_task_posted_ = true; 709 animation_task_posted_ = true;
710 MessageLoop::current()->PostDelayedTask( 710 MessageLoop::current()->PostDelayedTask(
711 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this), delay); 711 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this), delay);
712 } 712 }
713 713
714 bool RenderWidget::IsRenderingVSynced() { 714 bool RenderWidget::IsRenderingVSynced() {
715 // TODO(nduca): Forcing a driver to disable vsync (e.g. in a control panel) is 715 // TODO(nduca): Forcing a driver to disable vsync (e.g. in a control panel) is
716 // not caught by this check. This will lead to artificially low frame rates 716 // not caught by this check. This will lead to artificially low frame rates
717 // for people who force vsync off at a driver level and expect Chrome to speed 717 // for people who force vsync off at a driver level and expect Chrome to speed
718 // up. 718 // up.
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 } 1559 }
1560 } 1560 }
1561 1561
1562 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { 1562 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1563 return false; 1563 return false;
1564 } 1564 }
1565 1565
1566 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1566 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1567 return false; 1567 return false;
1568 } 1568 }
OLDNEW
« no previous file with comments | « content/renderer/load_progress_tracker.cc ('k') | dbus/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698