Index: cc/scheduler/scheduler.cc |
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc |
index 20559063f151076fc439af9ffaf72e5cfc79bb87..68d5d9420ec16e3d351a3807837ac5840818b97a 100644 |
--- a/cc/scheduler/scheduler.cc |
+++ b/cc/scheduler/scheduler.cc |
@@ -64,6 +64,7 @@ Scheduler::Scheduler( |
int layer_tree_host_id, |
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
scoped_ptr<BeginFrameSource> external_begin_frame_source, |
+ RenderingStatsInstrumentation* rendering_stats_instrumentation, |
sunnyps
2015/06/23 18:11:02
The Scheduler could take in a CompositorTimingHist
brianderson
2015/06/23 20:23:27
I kept this constructor and Scheduler::Create the
|
SchedulerFrameSourcesConstructor* frame_sources_constructor) |
: frame_source_(), |
primary_frame_source_(NULL), |
@@ -76,6 +77,7 @@ Scheduler::Scheduler( |
client_(client), |
layer_tree_host_id_(layer_tree_host_id), |
task_runner_(task_runner), |
+ compositor_timing_history_(rendering_stats_instrumentation), |
begin_impl_frame_deadline_mode_( |
SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), |
begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
@@ -129,6 +131,18 @@ base::TimeTicks Scheduler::Now() const { |
return now; |
} |
+base::TimeDelta Scheduler::DrawDurationEstimate() const { |
+ return compositor_timing_history_.DrawDurationEstimate(); |
+} |
+ |
+base::TimeDelta Scheduler::BeginMainFrameToCommitDurationEstimate() const { |
+ return compositor_timing_history_.BeginMainFrameToCommitDurationEstimate(); |
+} |
+ |
+base::TimeDelta Scheduler::CommitToActivateDurationEstimate() const { |
+ return compositor_timing_history_.CommitToActivateDurationEstimate(); |
+} |
+ |
void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, |
base::TimeDelta interval) { |
if (authoritative_vsync_interval_ != base::TimeDelta()) { |
@@ -495,7 +509,7 @@ void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { |
advance_commit_state_task_.Cancel(); |
BeginFrameArgs adjusted_args = args; |
- adjusted_args.deadline -= client_->DrawDurationEstimate(); |
+ adjusted_args.deadline -= DrawDurationEstimate(); |
if (!state_machine_.impl_latency_takes_priority() && |
main_thread_is_in_high_latency_mode && |
@@ -638,8 +652,16 @@ void Scheduler::PollToAdvanceCommitState() { |
} |
void Scheduler::DrawAndSwapIfPossible() { |
+ compositor_timing_history_.DidStartDrawing(); |
DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); |
state_machine_.DidDrawIfPossibleCompleted(result); |
+ compositor_timing_history_.DidFinishDrawing(); |
+} |
+ |
+void Scheduler::DrawAndSwapForced() { |
+ compositor_timing_history_.DidStartDrawing(); |
+ client_->ScheduledActionDrawAndSwapForced(); |
+ compositor_timing_history_.DidFinishDrawing(); |
} |
void Scheduler::SetDeferCommits(bool defer_commits) { |
@@ -678,6 +700,7 @@ void Scheduler::ProcessScheduledActions() { |
client_->ScheduledActionAnimate(); |
break; |
case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: |
+ compositor_timing_history_.WillBeginMainFrame(); |
client_->ScheduledActionSendBeginMainFrame(); |
break; |
case SchedulerStateMachine::ACTION_COMMIT: { |
@@ -687,10 +710,12 @@ void Scheduler::ProcessScheduledActions() { |
FROM_HERE_WITH_EXPLICIT_FUNCTION( |
"461509 Scheduler::ProcessScheduledActions4")); |
client_->ScheduledActionCommit(); |
+ compositor_timing_history_.DidCommit(); |
break; |
} |
case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: |
client_->ScheduledActionActivateSyncTree(); |
+ compositor_timing_history_.DidActivateSyncTree(); |
break; |
case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { |
// TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is |
@@ -702,7 +727,7 @@ void Scheduler::ProcessScheduledActions() { |
break; |
} |
case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: |
- client_->ScheduledActionDrawAndSwapForced(); |
+ DrawAndSwapForced(); |
break; |
case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: |
// No action is actually performed, but this allows the state machine to |
@@ -772,15 +797,13 @@ void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { |
state->EndDictionary(); |
state->EndDictionary(); |
- state->BeginDictionary("client_state"); |
+ state->BeginDictionary("compositor_timing_history"); |
state->SetDouble("draw_duration_estimate_ms", |
- client_->DrawDurationEstimate().InMillisecondsF()); |
- state->SetDouble( |
- "begin_main_frame_to_commit_duration_estimate_ms", |
- client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); |
- state->SetDouble( |
- "commit_to_activate_duration_estimate_ms", |
- client_->CommitToActivateDurationEstimate().InMillisecondsF()); |
+ DrawDurationEstimate().InMillisecondsF()); |
+ state->SetDouble("begin_main_frame_to_commit_duration_estimate_ms", |
+ BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); |
+ state->SetDouble("commit_to_activate_duration_estimate_ms", |
+ CommitToActivateDurationEstimate().InMillisecondsF()); |
state->EndDictionary(); |
} |
@@ -791,8 +814,8 @@ bool Scheduler::CanCommitAndActivateBeforeDeadline() const { |
// Check if the main thread computation and commit can be finished before the |
// impl thread's deadline. |
base::TimeTicks estimated_draw_time = |
- args.frame_time + client_->BeginMainFrameToCommitDurationEstimate() + |
- client_->CommitToActivateDurationEstimate(); |
+ args.frame_time + BeginMainFrameToCommitDurationEstimate() + |
+ CommitToActivateDurationEstimate(); |
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
"CanCommitAndActivateBeforeDeadline", |