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

Unified Diff: cc/scheduler/scheduler.cc

Issue 554973002: Disable scheduler deadline task on battery power in Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After rebase Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler.cc
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 65f63fc8b641040ad3e26a8e572ae97fd9c6943f..032a7d3578a270a44faa2771ce915b0ee8f2e896 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -9,6 +9,7 @@
#include "base/debug/trace_event.h"
#include "base/debug/trace_event_argument.h"
#include "base/logging.h"
+#include "base/power_monitor/power_monitor.h"
#include "base/single_thread_task_runner.h"
#include "cc/debug/devtools_instrumentation.h"
#include "cc/debug/traced_value.h"
@@ -113,12 +114,20 @@ Scheduler::Scheduler(
advance_commit_state_closure_ = base::Bind(
&Scheduler::PollToAdvanceCommitState, weak_factory_.GetWeakPtr());
+ if (settings_.high_latency_mode_on_battery) {
+ SetupPowerMonitoring();
+ }
+
if (!settings_.begin_frame_scheduling_enabled) {
SetupSyntheticBeginFrames();
}
}
Scheduler::~Scheduler() {
+ if (settings_.high_latency_mode_on_battery) {
+ TeardownPowerMonitoring();
+ }
+
if (synthetic_begin_frame_source_) {
synthetic_begin_frame_source_->SetNeedsBeginFrame(false,
&begin_retro_frame_args_);
@@ -131,6 +140,22 @@ void Scheduler::SetupSyntheticBeginFrames() {
new SyntheticBeginFrameSource(this, task_runner_.get()));
}
+void Scheduler::SetupPowerMonitoring() {
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ DCHECK(power_monitor != NULL);
+ power_monitor->AddObserver(this);
+}
+
+void Scheduler::TeardownPowerMonitoring() {
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ DCHECK(power_monitor != NULL);
+ power_monitor->RemoveObserver(this);
+}
+
+void Scheduler::OnPowerStateChange(bool on_battery_power) {
+ on_battery_power_ = on_battery_power;
+}
+
void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) {
// TODO(brianderson): We should not be receiving 0 intervals.
@@ -497,6 +522,25 @@ void Scheduler::PostBeginRetroFrameIfNeeded() {
task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_);
}
+bool Scheduler::ShouldPostBeginImplFrameDeadline() {
+ // The synchronous renderer compositor has to make its GL calls
+ // within this call.
brianderson 2014/09/09 17:59:05 this call -> within the BeginFrame call stack.
+ // TODO(brianderson): Have the OutputSurface initiate the deadline tasks
+ // so the sychronous renderer compositor can take advantage of splitting
+ // up the BeginImplFrame and deadline as well.
+ if (settings_.using_synchronous_renderer_compositor)
+ return false;
+
+ if (settings_.high_latency_mode_on_battery && on_battery_power_)
+ return false;
+
+ // We are ready to draw a new active tree immediately.
+ if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly())
+ return false;
+
+ return true;
+}
+
// BeginImplFrame starts a compositor frame that will wait up until a deadline
// for a BeginMainFrame+activation to complete before it times out and draws
// any asynchronous animation and scroll/pinch updates.
@@ -505,6 +549,7 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
DCHECK_EQ(state_machine_.begin_impl_frame_state(),
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
DCHECK(state_machine_.HasInitializedOutputSurface());
+ DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
advance_commit_state_task_.Cancel();
@@ -525,20 +570,19 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
ProcessScheduledActions();
state_machine_.OnBeginImplFrameDeadlinePending();
- ScheduleBeginImplFrameDeadline(
- AdjustedBeginImplFrameDeadline(args, draw_duration_estimate));
+
+ if (ShouldPostBeginImplFrameDeadline()) {
+ ScheduleBeginImplFrameDeadline(
+ AdjustedBeginImplFrameDeadline(args, draw_duration_estimate));
+ } else {
+ OnBeginImplFrameDeadline();
+ }
}
base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline(
const BeginFrameArgs& args,
base::TimeDelta draw_duration_estimate) const {
- if (settings_.using_synchronous_renderer_compositor) {
- // The synchronous compositor needs to draw right away.
- return base::TimeTicks();
- } else if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) {
- // We are ready to draw a new active tree immediately.
- return base::TimeTicks();
- } else if (state_machine_.needs_redraw()) {
+ if (state_machine_.needs_redraw()) {
brianderson 2014/09/09 17:59:05 AdjustedBeginImplFrameDeadline is used in more tha
// We have an animation or fast input path on the impl thread that wants
// to draw, so don't wait too long for a new active tree.
return args.deadline - draw_duration_estimate;
@@ -555,15 +599,6 @@ base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline(
}
void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
- if (settings_.using_synchronous_renderer_compositor) {
- // The synchronous renderer compositor has to make its GL calls
- // within this call.
- // TODO(brianderson): Have the OutputSurface initiate the deadline tasks
- // so the sychronous renderer compositor can take advantage of splitting
- // up the BeginImplFrame and deadline as well.
- OnBeginImplFrameDeadline();
- return;
- }
begin_impl_frame_deadline_task_.Cancel();
begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_);

Powered by Google App Engine
This is Rietveld 408576698