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

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

Issue 787763006: cc: Adding BeginFrameTracker object and removing Now() from LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto master. Created 5 years, 7 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
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | 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 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 vsync_observer_(NULL), 71 vsync_observer_(NULL),
72 authoritative_vsync_interval_(base::TimeDelta()), 72 authoritative_vsync_interval_(base::TimeDelta()),
73 last_vsync_timebase_(base::TimeTicks()), 73 last_vsync_timebase_(base::TimeTicks()),
74 throttle_frame_production_(false), 74 throttle_frame_production_(false),
75 settings_(scheduler_settings), 75 settings_(scheduler_settings),
76 client_(client), 76 client_(client),
77 layer_tree_host_id_(layer_tree_host_id), 77 layer_tree_host_id_(layer_tree_host_id),
78 task_runner_(task_runner), 78 task_runner_(task_runner),
79 begin_impl_frame_deadline_mode_( 79 begin_impl_frame_deadline_mode_(
80 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), 80 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE),
81 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
81 state_machine_(scheduler_settings), 82 state_machine_(scheduler_settings),
82 inside_process_scheduled_actions_(false), 83 inside_process_scheduled_actions_(false),
83 inside_action_(SchedulerStateMachine::ACTION_NONE), 84 inside_action_(SchedulerStateMachine::ACTION_NONE),
84 weak_factory_(this) { 85 weak_factory_(this) {
85 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 86 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
86 "Scheduler::Scheduler", 87 "Scheduler::Scheduler",
87 "settings", 88 "settings",
88 settings_.AsValue()); 89 settings_.AsValue());
89 DCHECK(client_); 90 DCHECK(client_);
90 DCHECK(!state_machine_.BeginFrameNeeded()); 91 DCHECK(!state_machine_.BeginFrameNeeded());
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 ProcessScheduledActions(); 268 ProcessScheduledActions();
268 } 269 }
269 270
270 void Scheduler::NotifyBeginMainFrameStarted() { 271 void Scheduler::NotifyBeginMainFrameStarted() {
271 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); 272 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
272 state_machine_.NotifyBeginMainFrameStarted(); 273 state_machine_.NotifyBeginMainFrameStarted();
273 } 274 }
274 275
275 base::TimeTicks Scheduler::AnticipatedDrawTime() const { 276 base::TimeTicks Scheduler::AnticipatedDrawTime() const {
276 if (!frame_source_->NeedsBeginFrames() || 277 if (!frame_source_->NeedsBeginFrames() ||
277 begin_impl_frame_args_.interval <= base::TimeDelta()) 278 begin_impl_frame_tracker_.DangerousMethodHasFinished())
278 return base::TimeTicks(); 279 return base::TimeTicks();
279 280
280 base::TimeTicks now = Now(); 281 base::TimeTicks now = Now();
281 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time, 282 BeginFrameArgs args = begin_impl_frame_tracker_.Current();
282 begin_impl_frame_args_.deadline); 283 base::TimeTicks timebase = std::max(args.frame_time, args.deadline);
283 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); 284 int64 intervals =
284 return timebase + (begin_impl_frame_args_.interval * intervals); 285 1 + ((now - timebase) / begin_impl_frame_tracker_.Interval());
286 return timebase + (begin_impl_frame_tracker_.Interval() * intervals);
285 } 287 }
286 288
287 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 289 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
288 return begin_impl_frame_args_.frame_time; 290 return begin_impl_frame_tracker_.Current().frame_time;
289 } 291 }
290 292
291 void Scheduler::SetupNextBeginFrameIfNeeded() { 293 void Scheduler::SetupNextBeginFrameIfNeeded() {
292 // Never call SetNeedsBeginFrames if the frame source already has the right 294 // Never call SetNeedsBeginFrames if the frame source already has the right
293 // value. 295 // value.
294 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) { 296 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) {
295 if (state_machine_.BeginFrameNeeded()) { 297 if (state_machine_.BeginFrameNeeded()) {
296 // Call SetNeedsBeginFrames(true) as soon as possible. 298 // Call SetNeedsBeginFrames(true) as soon as possible.
297 frame_source_->SetNeedsBeginFrames(true); 299 frame_source_->SetNeedsBeginFrames(true);
298 } else if (state_machine_.begin_impl_frame_state() == 300 } else if (state_machine_.begin_impl_frame_state() ==
(...skipping 13 matching lines...) Expand all
312 // At this point we'd prefer to advance through the commit flow by 314 // At this point we'd prefer to advance through the commit flow by
313 // drawing a frame, however it's possible that the frame rate controller 315 // drawing a frame, however it's possible that the frame rate controller
314 // will not give us a BeginFrame until the commit completes. See 316 // will not give us a BeginFrame until the commit completes. See
315 // crbug.com/317430 for an example of a swap ack being held on commit. Thus 317 // crbug.com/317430 for an example of a swap ack being held on commit. Thus
316 // we set a repeating timer to poll on ProcessScheduledActions until we 318 // we set a repeating timer to poll on ProcessScheduledActions until we
317 // successfully reach BeginFrame. Synchronous compositor does not use 319 // successfully reach BeginFrame. Synchronous compositor does not use
318 // frame rate controller or have the circular wait in the bug. 320 // frame rate controller or have the circular wait in the bug.
319 if (IsBeginMainFrameSentOrStarted() && 321 if (IsBeginMainFrameSentOrStarted() &&
320 !settings_.using_synchronous_renderer_compositor) { 322 !settings_.using_synchronous_renderer_compositor) {
321 if (advance_commit_state_task_.IsCancelled() && 323 if (advance_commit_state_task_.IsCancelled() &&
322 begin_impl_frame_args_.IsValid()) { 324 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().IsValid()) {
323 // Since we'd rather get a BeginImplFrame by the normal mechanism, we 325 // Since we'd rather get a BeginImplFrame by the normal mechanism, we
324 // set the interval to twice the interval from the previous frame. 326 // set the interval to twice the interval from the previous frame.
325 advance_commit_state_task_.Reset(advance_commit_state_closure_); 327 advance_commit_state_task_.Reset(advance_commit_state_closure_);
326 task_runner_->PostDelayedTask(FROM_HERE, 328 task_runner_->PostDelayedTask(FROM_HERE,
327 advance_commit_state_task_.callback(), 329 advance_commit_state_task_.callback(),
328 begin_impl_frame_args_.interval * 2); 330 begin_impl_frame_tracker_.Interval() * 2);
329 } 331 }
330 } else { 332 } else {
331 advance_commit_state_task_.Cancel(); 333 advance_commit_state_task_.Cancel();
332 } 334 }
333 } 335 }
334 336
335 // BeginFrame is the mechanism that tells us that now is a good time to start 337 // BeginFrame is the mechanism that tells us that now is a good time to start
336 // making a frame. Usually this means that user input for the frame is complete. 338 // making a frame. Usually this means that user input for the frame is complete.
337 // If the scheduler is busy, we queue the BeginFrame to be handled later as 339 // If the scheduler is busy, we queue the BeginFrame to be handled later as
338 // a BeginRetroFrame. 340 // a BeginRetroFrame.
339 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { 341 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) {
340 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginFrame", "args", args.AsValue()); 342 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginFrame", "args", args.AsValue());
341 343
344 // Trace this begin frame time through the Chrome stack
345 TRACE_EVENT_FLOW_BEGIN0(
346 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs",
347 args.frame_time.ToInternalValue());
348
342 // TODO(brianderson): Adjust deadline in the DisplayScheduler. 349 // TODO(brianderson): Adjust deadline in the DisplayScheduler.
343 BeginFrameArgs adjusted_args(args); 350 BeginFrameArgs adjusted_args(args);
344 adjusted_args.deadline -= EstimatedParentDrawTime(); 351 adjusted_args.deadline -= EstimatedParentDrawTime();
345 352
346 // Deliver BeginFrames to children. 353 // Deliver BeginFrames to children.
347 // TODO(brianderson): Move this responsibility to the DisplayScheduler. 354 // TODO(brianderson): Move this responsibility to the DisplayScheduler.
348 if (state_machine_.children_need_begin_frames()) 355 if (state_machine_.children_need_begin_frames())
349 client_->SendBeginFramesToChildren(adjusted_args); 356 client_->SendBeginFramesToChildren(adjusted_args);
350 357
351 if (settings_.using_synchronous_renderer_compositor) { 358 if (settings_.using_synchronous_renderer_compositor) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 bool main_thread_is_in_high_latency_mode = 494 bool main_thread_is_in_high_latency_mode =
488 state_machine_.MainThreadIsInHighLatencyMode(); 495 state_machine_.MainThreadIsInHighLatencyMode();
489 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", 496 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args",
490 args.AsValue(), "main_thread_is_high_latency", 497 args.AsValue(), "main_thread_is_high_latency",
491 main_thread_is_in_high_latency_mode); 498 main_thread_is_in_high_latency_mode);
492 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 499 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
493 "MainThreadLatency", main_thread_is_in_high_latency_mode); 500 "MainThreadLatency", main_thread_is_in_high_latency_mode);
494 501
495 advance_commit_state_task_.Cancel(); 502 advance_commit_state_task_.Cancel();
496 503
497 begin_impl_frame_args_ = args; 504 BeginFrameArgs adjusted_args = args;
498 begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); 505 adjusted_args.deadline -= client_->DrawDurationEstimate();
499 506
500 if (!state_machine_.impl_latency_takes_priority() && 507 if (!state_machine_.impl_latency_takes_priority() &&
501 main_thread_is_in_high_latency_mode && 508 main_thread_is_in_high_latency_mode &&
502 CanCommitAndActivateBeforeDeadline()) { 509 CanCommitAndActivateBeforeDeadline()) {
503 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); 510 state_machine_.SetSkipNextBeginMainFrameToReduceLatency();
504 } 511 }
505 512
506 BeginImplFrame(); 513 BeginImplFrame(adjusted_args);
507 514
508 // The deadline will be scheduled in ProcessScheduledActions. 515 // The deadline will be scheduled in ProcessScheduledActions.
509 state_machine_.OnBeginImplFrameDeadlinePending(); 516 state_machine_.OnBeginImplFrameDeadlinePending();
510 ProcessScheduledActions(); 517 ProcessScheduledActions();
511 } 518 }
512 519
513 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) { 520 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) {
514 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args", 521 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args",
515 args.AsValue()); 522 args.AsValue());
516 begin_impl_frame_args_ = args; 523 BeginImplFrame(args);
517 BeginImplFrame();
518 FinishImplFrame(); 524 FinishImplFrame();
519 } 525 }
520 526
521 void Scheduler::FinishImplFrame() { 527 void Scheduler::FinishImplFrame() {
522 state_machine_.OnBeginImplFrameIdle(); 528 state_machine_.OnBeginImplFrameIdle();
523 ProcessScheduledActions(); 529 ProcessScheduledActions();
524 530
525 client_->DidFinishImplFrame(); 531 client_->DidFinishImplFrame();
526 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); 532 frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
533 begin_impl_frame_tracker_.Finish();
527 } 534 }
528 535
529 // BeginImplFrame starts a compositor frame that will wait up until a deadline 536 // BeginImplFrame starts a compositor frame that will wait up until a deadline
530 // for a BeginMainFrame+activation to complete before it times out and draws 537 // for a BeginMainFrame+activation to complete before it times out and draws
531 // any asynchronous animation and scroll/pinch updates. 538 // any asynchronous animation and scroll/pinch updates.
532 void Scheduler::BeginImplFrame() { 539 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
533 DCHECK_EQ(state_machine_.begin_impl_frame_state(), 540 DCHECK_EQ(state_machine_.begin_impl_frame_state(),
534 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 541 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
535 DCHECK(!BeginImplFrameDeadlinePending()); 542 DCHECK(!BeginImplFrameDeadlinePending());
536 DCHECK(state_machine_.HasInitializedOutputSurface()); 543 DCHECK(state_machine_.HasInitializedOutputSurface());
537 DCHECK(advance_commit_state_task_.IsCancelled()); 544 DCHECK(advance_commit_state_task_.IsCancelled());
538 545
546 begin_impl_frame_tracker_.Start(args);
539 state_machine_.OnBeginImplFrame(); 547 state_machine_.OnBeginImplFrame();
540 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); 548 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
541 client_->WillBeginImplFrame(begin_impl_frame_args_); 549 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current());
542 550
543 ProcessScheduledActions(); 551 ProcessScheduledActions();
544 } 552 }
545 553
546 void Scheduler::ScheduleBeginImplFrameDeadline() { 554 void Scheduler::ScheduleBeginImplFrameDeadline() {
547 // The synchronous compositor does not post a deadline task. 555 // The synchronous compositor does not post a deadline task.
548 DCHECK(!settings_.using_synchronous_renderer_compositor); 556 DCHECK(!settings_.using_synchronous_renderer_compositor);
549 557
550 begin_impl_frame_deadline_task_.Cancel(); 558 begin_impl_frame_deadline_task_.Cancel();
551 begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_); 559 begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_);
552 560
553 begin_impl_frame_deadline_mode_ = 561 begin_impl_frame_deadline_mode_ =
554 state_machine_.CurrentBeginImplFrameDeadlineMode(); 562 state_machine_.CurrentBeginImplFrameDeadlineMode();
555 563
556 base::TimeTicks deadline; 564 base::TimeTicks deadline;
557 switch (begin_impl_frame_deadline_mode_) { 565 switch (begin_impl_frame_deadline_mode_) {
558 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: 566 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE:
559 // No deadline. 567 // No deadline.
560 return; 568 return;
561 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: 569 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE:
562 // We are ready to draw a new active tree immediately. 570 // We are ready to draw a new active tree immediately.
563 // We don't use Now() here because it's somewhat expensive to call. 571 // We don't use Now() here because it's somewhat expensive to call.
564 deadline = base::TimeTicks(); 572 deadline = base::TimeTicks();
565 break; 573 break;
566 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: 574 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR:
567 // We are animating on the impl thread but we can wait for some time. 575 // We are animating on the impl thread but we can wait for some time.
568 deadline = begin_impl_frame_args_.deadline; 576 deadline = begin_impl_frame_tracker_.Current().deadline;
569 break; 577 break;
570 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: 578 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE:
571 // We are blocked for one reason or another and we should wait. 579 // We are blocked for one reason or another and we should wait.
572 // TODO(brianderson): Handle long deadlines (that are past the next 580 // TODO(brianderson): Handle long deadlines (that are past the next
573 // frame's frame time) properly instead of using this hack. 581 // frame's frame time) properly instead of using this hack.
574 deadline = 582 deadline = begin_impl_frame_tracker_.Current().frame_time +
575 begin_impl_frame_args_.frame_time + begin_impl_frame_args_.interval; 583 begin_impl_frame_tracker_.Current().interval;
576 break; 584 break;
577 case SchedulerStateMachine:: 585 case SchedulerStateMachine::
578 BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW: 586 BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW:
579 // We are blocked because we are waiting for ReadyToDraw signal. We would 587 // We are blocked because we are waiting for ReadyToDraw signal. We would
580 // post deadline after we received ReadyToDraw singal. 588 // post deadline after we received ReadyToDraw singal.
581 TRACE_EVENT1("cc", "Scheduler::ScheduleBeginImplFrameDeadline", 589 TRACE_EVENT1("cc", "Scheduler::ScheduleBeginImplFrameDeadline",
582 "deadline_mode", "blocked_on_ready_to_draw"); 590 "deadline_mode", "blocked_on_ready_to_draw");
583 return; 591 return;
584 } 592 }
585 593
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 state->SetBoolean("last_set_needs_begin_frame_", 769 state->SetBoolean("last_set_needs_begin_frame_",
762 frame_source_->NeedsBeginFrames()); 770 frame_source_->NeedsBeginFrames());
763 state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size()); 771 state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size());
764 state->SetBoolean("begin_retro_frame_task_", 772 state->SetBoolean("begin_retro_frame_task_",
765 !begin_retro_frame_task_.IsCancelled()); 773 !begin_retro_frame_task_.IsCancelled());
766 state->SetBoolean("begin_impl_frame_deadline_task_", 774 state->SetBoolean("begin_impl_frame_deadline_task_",
767 !begin_impl_frame_deadline_task_.IsCancelled()); 775 !begin_impl_frame_deadline_task_.IsCancelled());
768 state->SetBoolean("advance_commit_state_task_", 776 state->SetBoolean("advance_commit_state_task_",
769 !advance_commit_state_task_.IsCancelled()); 777 !advance_commit_state_task_.IsCancelled());
770 state->BeginDictionary("begin_impl_frame_args"); 778 state->BeginDictionary("begin_impl_frame_args");
771 begin_impl_frame_args_.AsValueInto(state); 779 begin_impl_frame_tracker_.AsValueInto(Now(), state);
772 state->EndDictionary(); 780 state->EndDictionary();
773
774 base::TimeTicks now = Now();
775 base::TimeTicks frame_time = begin_impl_frame_args_.frame_time;
776 base::TimeTicks deadline = begin_impl_frame_args_.deadline;
777 base::TimeDelta interval = begin_impl_frame_args_.interval;
778 state->BeginDictionary("major_timestamps_in_ms");
779 state->SetDouble("0_interval", interval.InMillisecondsF());
780 state->SetDouble("1_now_to_deadline", (deadline - now).InMillisecondsF());
781 state->SetDouble("2_frame_time_to_now", (now - frame_time).InMillisecondsF());
782 state->SetDouble("3_frame_time_to_deadline",
783 (deadline - frame_time).InMillisecondsF());
784 state->SetDouble("4_now", (now - base::TimeTicks()).InMillisecondsF());
785 state->SetDouble("5_frame_time",
786 (frame_time - base::TimeTicks()).InMillisecondsF());
787 state->SetDouble("6_deadline",
788 (deadline - base::TimeTicks()).InMillisecondsF());
789 state->EndDictionary();
790
791 state->EndDictionary(); 781 state->EndDictionary();
792 782
793 state->BeginDictionary("client_state"); 783 state->BeginDictionary("client_state");
794 state->SetDouble("draw_duration_estimate_ms", 784 state->SetDouble("draw_duration_estimate_ms",
795 client_->DrawDurationEstimate().InMillisecondsF()); 785 client_->DrawDurationEstimate().InMillisecondsF());
796 state->SetDouble( 786 state->SetDouble(
797 "begin_main_frame_to_commit_duration_estimate_ms", 787 "begin_main_frame_to_commit_duration_estimate_ms",
798 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); 788 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF());
799 state->SetDouble( 789 state->SetDouble(
800 "commit_to_activate_duration_estimate_ms", 790 "commit_to_activate_duration_estimate_ms",
801 client_->CommitToActivateDurationEstimate().InMillisecondsF()); 791 client_->CommitToActivateDurationEstimate().InMillisecondsF());
802 state->EndDictionary(); 792 state->EndDictionary();
803 } 793 }
804 794
805 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { 795 bool Scheduler::CanCommitAndActivateBeforeDeadline() const {
796 BeginFrameArgs args =
797 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast();
798
806 // Check if the main thread computation and commit can be finished before the 799 // Check if the main thread computation and commit can be finished before the
807 // impl thread's deadline. 800 // impl thread's deadline.
808 base::TimeTicks estimated_draw_time = 801 base::TimeTicks estimated_draw_time =
809 begin_impl_frame_args_.frame_time + 802 args.frame_time + client_->BeginMainFrameToCommitDurationEstimate() +
810 client_->BeginMainFrameToCommitDurationEstimate() +
811 client_->CommitToActivateDurationEstimate(); 803 client_->CommitToActivateDurationEstimate();
812 804
813 TRACE_EVENT2( 805 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
814 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 806 "CanCommitAndActivateBeforeDeadline",
815 "CanCommitAndActivateBeforeDeadline", 807 "time_left_after_drawing_ms",
816 "time_left_after_drawing_ms", 808 (args.deadline - estimated_draw_time).InMillisecondsF(), "state",
817 (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), 809 AsValue());
818 "state",
819 AsValue());
820 810
821 return estimated_draw_time < begin_impl_frame_args_.deadline; 811 return estimated_draw_time < args.deadline;
822 } 812 }
823 813
824 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 814 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
825 return (state_machine_.commit_state() == 815 return (state_machine_.commit_state() ==
826 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 816 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
827 state_machine_.commit_state() == 817 state_machine_.commit_state() ==
828 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 818 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
829 } 819 }
830 820
831 } // namespace cc 821 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698