summaryrefslogtreecommitdiffstats
path: root/cc/scheduler/scheduler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc/scheduler/scheduler.cc')
-rw-r--r--cc/scheduler/scheduler.cc106
1 files changed, 26 insertions, 80 deletions
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index a84c1ba..ca36c1e 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -31,19 +31,11 @@ scoped_ptr<Scheduler> Scheduler::Create(
const SchedulerSettings& settings,
int layer_tree_host_id,
base::SingleThreadTaskRunner* task_runner,
- BeginFrameSource* external_frame_source,
+ BeginFrameSource* begin_frame_source,
scoped_ptr<CompositorTimingHistory> compositor_timing_history) {
- scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source;
- if (!settings.use_external_begin_frame_source) {
- synthetic_frame_source = SyntheticBeginFrameSource::Create(
- task_runner, BeginFrameArgs::DefaultInterval());
- }
- scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source =
- BackToBackBeginFrameSource::Create(task_runner);
- return make_scoped_ptr(new Scheduler(
- client, settings, layer_tree_host_id, task_runner, external_frame_source,
- std::move(synthetic_frame_source), std::move(unthrottled_frame_source),
- std::move(compositor_timing_history)));
+ return make_scoped_ptr(new Scheduler(client, settings, layer_tree_host_id,
+ task_runner, begin_frame_source,
+ std::move(compositor_timing_history)));
}
Scheduler::Scheduler(
@@ -51,19 +43,14 @@ Scheduler::Scheduler(
const SchedulerSettings& settings,
int layer_tree_host_id,
base::SingleThreadTaskRunner* task_runner,
- BeginFrameSource* external_frame_source,
- scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source,
- scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source,
+ BeginFrameSource* begin_frame_source,
scoped_ptr<CompositorTimingHistory> compositor_timing_history)
: settings_(settings),
client_(client),
layer_tree_host_id_(layer_tree_host_id),
task_runner_(task_runner),
- external_frame_source_(external_frame_source),
- synthetic_frame_source_(std::move(synthetic_frame_source)),
- unthrottled_frame_source_(std::move(unthrottled_frame_source)),
- frame_source_(BeginFrameSourceMultiplexer::Create()),
- observing_frame_source_(false),
+ begin_frame_source_(begin_frame_source),
+ observing_begin_frame_source_(false),
compositor_timing_history_(std::move(compositor_timing_history)),
begin_impl_frame_deadline_mode_(
SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE),
@@ -75,33 +62,19 @@ Scheduler::Scheduler(
TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue());
DCHECK(client_);
DCHECK(!state_machine_.BeginFrameNeeded());
- DCHECK(!settings_.use_external_begin_frame_source || external_frame_source_);
- DCHECK(settings_.use_external_begin_frame_source || synthetic_frame_source_);
- DCHECK(unthrottled_frame_source_);
begin_retro_frame_closure_ =
base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr());
begin_impl_frame_deadline_closure_ = base::Bind(
&Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr());
- frame_source_->AddSource(primary_frame_source());
- primary_frame_source()->SetClientReady();
-
- frame_source_->AddSource(unthrottled_frame_source_.get());
- unthrottled_frame_source_->SetClientReady();
-
- if (settings_.throttle_frame_production) {
- frame_source_->SetActiveSource(primary_frame_source());
- } else {
- frame_source_->SetActiveSource(unthrottled_frame_source_.get());
- }
+ begin_frame_source_->SetClientReady();
ProcessScheduledActions();
}
Scheduler::~Scheduler() {
- if (observing_frame_source_)
- frame_source_->RemoveObserver(this);
- frame_source_->SetActiveSource(nullptr);
+ if (observing_begin_frame_source_)
+ begin_frame_source_->RemoveObserver(this);
}
base::TimeTicks Scheduler::Now() const {
@@ -113,21 +86,6 @@ base::TimeTicks Scheduler::Now() const {
return now;
}
-void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
- base::TimeDelta interval) {
- if (authoritative_vsync_interval_ != base::TimeDelta()) {
- interval = authoritative_vsync_interval_;
- } else if (interval == base::TimeDelta()) {
- // TODO(brianderson): We should not be receiving 0 intervals.
- interval = BeginFrameArgs::DefaultInterval();
- }
-
- last_vsync_timebase_ = timebase;
-
- if (synthetic_frame_source_)
- synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval);
-}
-
void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
DCHECK_GE(draw_time.ToInternalValue(), 0);
estimated_parent_draw_time_ = draw_time;
@@ -241,7 +199,7 @@ void Scheduler::DidLoseOutputSurface() {
void Scheduler::DidCreateAndInitializeOutputSurface() {
TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
- DCHECK(!observing_frame_source_);
+ DCHECK(!observing_begin_frame_source_);
DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
state_machine_.DidCreateAndInitializeOutputSurface();
compositor_timing_history_->DidCreateAndInitializeOutputSurface();
@@ -272,18 +230,18 @@ void Scheduler::BeginImplFrameNotExpectedSoon() {
void Scheduler::SetupNextBeginFrameIfNeeded() {
// Never call SetNeedsBeginFrames if the frame source already has the right
// value.
- if (observing_frame_source_ != state_machine_.BeginFrameNeeded()) {
+ if (observing_begin_frame_source_ != state_machine_.BeginFrameNeeded()) {
if (state_machine_.BeginFrameNeeded()) {
// Call AddObserver as soon as possible.
- observing_frame_source_ = true;
- frame_source_->AddObserver(this);
+ observing_begin_frame_source_ = true;
+ begin_frame_source_->AddObserver(this);
devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_,
true);
} else if (state_machine_.begin_impl_frame_state() ==
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) {
// Call RemoveObserver in between frames only.
- observing_frame_source_ = false;
- frame_source_->RemoveObserver(this);
+ observing_begin_frame_source_ = false;
+ begin_frame_source_->RemoveObserver(this);
BeginImplFrameNotExpectedSoon();
devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_,
false);
@@ -340,7 +298,8 @@ bool Scheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) {
bool should_defer_begin_frame =
!begin_retro_frame_args_.empty() ||
- !begin_retro_frame_task_.IsCancelled() || !observing_frame_source_ ||
+ !begin_retro_frame_task_.IsCancelled() ||
+ !observing_begin_frame_source_ ||
(state_machine_.begin_impl_frame_state() !=
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
@@ -360,14 +319,6 @@ void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) {
ProcessScheduledActions();
}
-void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) {
- authoritative_vsync_interval_ = interval;
- if (synthetic_frame_source_) {
- synthetic_frame_source_->OnUpdateVSyncParameters(last_vsync_timebase_,
- interval);
- }
-}
-
void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) {
state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames);
ProcessScheduledActions();
@@ -419,7 +370,7 @@ void Scheduler::BeginRetroFrame() {
"expiration_time - now", (expiration_time - now).InMillisecondsF(),
"BeginFrameArgs", begin_retro_frame_args_.front().AsValue());
begin_retro_frame_args_.pop_front();
- frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
+ begin_frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
}
if (begin_retro_frame_args_.empty()) {
@@ -442,7 +393,7 @@ void Scheduler::PostBeginRetroFrameIfNeeded() {
"Scheduler::PostBeginRetroFrameIfNeeded",
"state",
AsValue());
- if (!observing_frame_source_)
+ if (!observing_begin_frame_source_)
return;
if (begin_retro_frame_args_.empty() || !begin_retro_frame_task_.IsCancelled())
@@ -512,7 +463,7 @@ void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) {
can_activate_before_deadline)) {
TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency",
TRACE_EVENT_SCOPE_THREAD);
- frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
+ begin_frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
return;
}
@@ -544,7 +495,7 @@ void Scheduler::FinishImplFrame() {
ProcessScheduledActions();
client_->DidFinishImplFrame();
- frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
+ begin_frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
begin_impl_frame_tracker_.Finish();
}
@@ -795,23 +746,18 @@ void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const {
TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
&frame_tracing_enabled);
if (frame_tracing_enabled) {
- state->BeginDictionary("frame_source_");
- frame_source_->AsValueInto(state);
+ state->BeginDictionary("begin_frame_source_");
+ begin_frame_source_->AsValueInto(state);
state->EndDictionary();
}
state->BeginDictionary("scheduler_state");
- state->SetBoolean("external_frame_source_", !!external_frame_source_);
state->SetBoolean("throttle_frame_production_",
settings_.throttle_frame_production);
- state->SetDouble("authoritative_vsync_interval_ms",
- authoritative_vsync_interval_.InMillisecondsF());
- state->SetDouble(
- "last_vsync_timebase_ms",
- (last_vsync_timebase_ - base::TimeTicks()).InMillisecondsF());
state->SetDouble("estimated_parent_draw_time_ms",
estimated_parent_draw_time_.InMillisecondsF());
- state->SetBoolean("observing_frame_source", observing_frame_source_);
+ state->SetBoolean("observing_begin_frame_source",
+ observing_begin_frame_source_);
state->SetInteger("begin_retro_frame_args",
static_cast<int>(begin_retro_frame_args_.size()));
state->SetBoolean("begin_retro_frame_task",