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

Side by Side Diff: cc/scheduler/scheduler.cc

Issue 176973007: cc: Also trace the scheduler client state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 void Scheduler::DidCreateAndInitializeOutputSurface() { 117 void Scheduler::DidCreateAndInitializeOutputSurface() {
118 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); 118 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
119 DCHECK(!last_set_needs_begin_impl_frame_); 119 DCHECK(!last_set_needs_begin_impl_frame_);
120 DCHECK(begin_impl_frame_deadline_closure_.IsCancelled()); 120 DCHECK(begin_impl_frame_deadline_closure_.IsCancelled());
121 state_machine_.DidCreateAndInitializeOutputSurface(); 121 state_machine_.DidCreateAndInitializeOutputSurface();
122 ProcessScheduledActions(); 122 ProcessScheduledActions();
123 } 123 }
124 124
125 base::TimeTicks Scheduler::AnticipatedDrawTime() { 125 base::TimeTicks Scheduler::AnticipatedDrawTime() const {
126 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime");
127
128 if (!last_set_needs_begin_impl_frame_ || 126 if (!last_set_needs_begin_impl_frame_ ||
129 last_begin_impl_frame_args_.interval <= base::TimeDelta()) 127 last_begin_impl_frame_args_.interval <= base::TimeDelta())
130 return base::TimeTicks(); 128 return base::TimeTicks();
131 129
132 base::TimeTicks now = gfx::FrameTime::Now(); 130 base::TimeTicks now = gfx::FrameTime::Now();
133 base::TimeTicks timebase = std::max(last_begin_impl_frame_args_.frame_time, 131 base::TimeTicks timebase = std::max(last_begin_impl_frame_args_.frame_time,
134 last_begin_impl_frame_args_.deadline); 132 last_begin_impl_frame_args_.deadline);
135 int64 intervals = 133 int64 intervals =
136 1 + ((now - timebase) / last_begin_impl_frame_args_.interval); 134 1 + ((now - timebase) / last_begin_impl_frame_args_.interval);
137 return timebase + (last_begin_impl_frame_args_.interval * intervals); 135 return timebase + (last_begin_impl_frame_args_.interval * intervals);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 312
315 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); 313 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true);
316 314
317 SchedulerStateMachine::Action action; 315 SchedulerStateMachine::Action action;
318 do { 316 do {
319 state_machine_.CheckInvariants(); 317 state_machine_.CheckInvariants();
320 action = state_machine_.NextAction(); 318 action = state_machine_.NextAction();
321 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 319 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
322 "SchedulerStateMachine", 320 "SchedulerStateMachine",
323 "state", 321 "state",
324 TracedValue::FromValue(state_machine_.AsValue().release())); 322 TracedValue::FromValue(StateAsValue().release()));
325 state_machine_.UpdateState(action); 323 state_machine_.UpdateState(action);
326 base::AutoReset<SchedulerStateMachine::Action> 324 base::AutoReset<SchedulerStateMachine::Action>
327 mark_inside_action(&inside_action_, action); 325 mark_inside_action(&inside_action_, action);
328 switch (action) { 326 switch (action) {
329 case SchedulerStateMachine::ACTION_NONE: 327 case SchedulerStateMachine::ACTION_NONE:
330 break; 328 break;
331 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: 329 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME:
332 client_->ScheduledActionSendBeginMainFrame(); 330 client_->ScheduledActionSendBeginMainFrame();
333 break; 331 break;
334 case SchedulerStateMachine::ACTION_COMMIT: 332 case SchedulerStateMachine::ACTION_COMMIT:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); 367 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime());
370 368
371 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) 369 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly())
372 PostBeginImplFrameDeadline(base::TimeTicks()); 370 PostBeginImplFrameDeadline(base::TimeTicks());
373 } 371 }
374 372
375 bool Scheduler::WillDrawIfNeeded() const { 373 bool Scheduler::WillDrawIfNeeded() const {
376 return !state_machine_.PendingDrawsShouldBeAborted(); 374 return !state_machine_.PendingDrawsShouldBeAborted();
377 } 375 }
378 376
377 scoped_ptr<base::Value> Scheduler::StateAsValue() const {
378 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue);
379 state->Set("state_machine", state_machine_.AsValue().release());
380 state->SetDouble(
381 "time_until_anticipated_draw_time_ms",
382 (AnticipatedDrawTime() - base::TimeTicks::Now()).InMillisecondsF());
383
384 scoped_ptr<base::DictionaryValue> client_state(new base::DictionaryValue);
385 client_state->SetDouble("draw_duration_estimate_ms",
386 client_->DrawDurationEstimate().InMillisecondsF());
387 client_state->SetDouble(
388 "begin_main_frame_to_commit_duration_estimate_ms",
389 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF());
390 client_state->SetDouble(
391 "commit_to_activate_duration_estimate_ms",
392 client_->CommitToActivateDurationEstimate().InMillisecondsF());
393 state->Set("client_state", client_state.release());
394 return state.PassAs<base::Value>();
395 }
396
379 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { 397 bool Scheduler::CanCommitAndActivateBeforeDeadline() const {
380 // Check if the main thread computation and commit can be finished before the 398 // Check if the main thread computation and commit can be finished before the
381 // impl thread's deadline. 399 // impl thread's deadline.
382 base::TimeTicks estimated_draw_time = 400 base::TimeTicks estimated_draw_time =
383 last_begin_impl_frame_args_.frame_time + 401 last_begin_impl_frame_args_.frame_time +
384 client_->BeginMainFrameToCommitDurationEstimate() + 402 client_->BeginMainFrameToCommitDurationEstimate() +
385 client_->CommitToActivateDurationEstimate(); 403 client_->CommitToActivateDurationEstimate();
386 404
405 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
406 "CanCommitAndActivateBeforeDeadline",
407 "time_left_after_drawing_ms",
408 (last_begin_impl_frame_args_.deadline - estimated_draw_time)
409 .InMillisecondsF(),
410 "state",
411 TracedValue::FromValue(StateAsValue().release()));
412
387 return estimated_draw_time < last_begin_impl_frame_args_.deadline; 413 return estimated_draw_time < last_begin_impl_frame_args_.deadline;
388 } 414 }
389 415
390 } // namespace cc 416 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698