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

Unified Diff: cc/scheduler/scheduler.cc

Issue 811523002: Added ability to dynamically toggle frame throttling in the scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 143c3ff54489573b1e22bf3a2a35ee17fecb1d95..57366e04a1254c123cb7f12dc66053f34e88b8aa 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -71,6 +71,17 @@ SchedulerFrameSourcesConstructor::ConstructBackgroundFrameSource(
return scheduler->background_frame_source_internal_.get();
}
+BeginFrameSource*
+SchedulerFrameSourcesConstructor::ConstructUnthrottledFrameSource(
+ Scheduler* scheduler) {
+ TRACE_EVENT1("cc", "Scheduler::Scheduler()", "PrimaryFrameSource",
+ "BackToBackBeginFrameSource");
+ DCHECK(!scheduler->unthrottled_frame_source_internal_);
+ scheduler->unthrottled_frame_source_internal_ =
+ BackToBackBeginFrameSource::Create(scheduler->task_runner_.get());
+ return scheduler->unthrottled_frame_source_internal_.get();
+}
+
Scheduler::Scheduler(
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
@@ -85,6 +96,7 @@ Scheduler::Scheduler(
primary_frame_source_internal_(external_begin_frame_source.Pass()),
background_frame_source_internal_(),
vsync_observer_(NULL),
+ throttle_frame_production_(scheduler_settings.throttle_frame_production),
settings_(scheduler_settings),
client_(client),
layer_tree_host_id_(layer_tree_host_id),
@@ -125,6 +137,11 @@ Scheduler::Scheduler(
frame_sources_constructor->ConstructBackgroundFrameSource(this);
frame_source_->AddSource(background_frame_source_);
+ // Unthrottled frame source
+ unthrottled_frame_source_ =
+ frame_sources_constructor->ConstructUnthrottledFrameSource(this);
+ frame_source_->AddSource(unthrottled_frame_source_);
+
SetupPowerMonitoring();
}
@@ -184,16 +201,24 @@ void Scheduler::SetCanStart() {
ProcessScheduledActions();
}
-void Scheduler::SetVisible(bool visible) {
- state_machine_.SetVisible(visible);
- if (visible) {
- frame_source_->SetActiveSource(primary_frame_source_);
+void Scheduler::UpdateActiveFrameSource() {
+ if (state_machine_.visible()) {
+ if (throttle_frame_production_) {
+ frame_source_->SetActiveSource(primary_frame_source_);
+ } else {
+ frame_source_->SetActiveSource(unthrottled_frame_source_);
+ }
} else {
frame_source_->SetActiveSource(background_frame_source_);
}
ProcessScheduledActions();
}
+void Scheduler::SetVisible(bool visible) {
+ state_machine_.SetVisible(visible);
+ UpdateActiveFrameSource();
+}
+
void Scheduler::SetCanDraw(bool can_draw) {
state_machine_.SetCanDraw(can_draw);
ProcessScheduledActions();
@@ -209,6 +234,11 @@ void Scheduler::NotifyReadyToDraw() {
// crbugs 352894, 383157, 421923.
}
+void Scheduler::SetThrottleFrameProduction(bool throttle) {
+ throttle_frame_production_ = settings_.throttle_frame_production && throttle;
enne (OOO) 2014/12/15 23:21:07 It's a little odd to my eyes to have both a schedu
brianderson 2014/12/16 22:36:42 Can we make the command line flag only set the ini
+ UpdateActiveFrameSource();
+}
+
void Scheduler::SetNeedsCommit() {
state_machine_.SetNeedsCommit();
ProcessScheduledActions();

Powered by Google App Engine
This is Rietveld 408576698