OLD | NEW |
---|---|
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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 background_frame_source_(NULL), | 84 background_frame_source_(NULL), |
85 primary_frame_source_internal_(external_begin_frame_source.Pass()), | 85 primary_frame_source_internal_(external_begin_frame_source.Pass()), |
86 background_frame_source_internal_(), | 86 background_frame_source_internal_(), |
87 vsync_observer_(NULL), | 87 vsync_observer_(NULL), |
88 settings_(scheduler_settings), | 88 settings_(scheduler_settings), |
89 client_(client), | 89 client_(client), |
90 layer_tree_host_id_(layer_tree_host_id), | 90 layer_tree_host_id_(layer_tree_host_id), |
91 task_runner_(task_runner), | 91 task_runner_(task_runner), |
92 power_monitor_(power_monitor), | 92 power_monitor_(power_monitor), |
93 begin_retro_frame_posted_(false), | 93 begin_retro_frame_posted_(false), |
94 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | |
94 state_machine_(scheduler_settings), | 95 state_machine_(scheduler_settings), |
95 inside_process_scheduled_actions_(false), | 96 inside_process_scheduled_actions_(false), |
96 inside_action_(SchedulerStateMachine::ACTION_NONE), | 97 inside_action_(SchedulerStateMachine::ACTION_NONE), |
97 weak_factory_(this) { | 98 weak_factory_(this) { |
98 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 99 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
99 "Scheduler::Scheduler", | 100 "Scheduler::Scheduler", |
100 "settings", | 101 "settings", |
101 settings_.AsValue()); | 102 settings_.AsValue()); |
102 DCHECK(client_); | 103 DCHECK(client_); |
103 DCHECK(!state_machine_.BeginFrameNeeded()); | 104 DCHECK(!state_machine_.BeginFrameNeeded()); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 ProcessScheduledActions(); | 289 ProcessScheduledActions(); |
289 } | 290 } |
290 | 291 |
291 void Scheduler::NotifyBeginMainFrameStarted() { | 292 void Scheduler::NotifyBeginMainFrameStarted() { |
292 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); | 293 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); |
293 state_machine_.NotifyBeginMainFrameStarted(); | 294 state_machine_.NotifyBeginMainFrameStarted(); |
294 } | 295 } |
295 | 296 |
296 base::TimeTicks Scheduler::AnticipatedDrawTime() const { | 297 base::TimeTicks Scheduler::AnticipatedDrawTime() const { |
297 if (!frame_source_->NeedsBeginFrames() || | 298 if (!frame_source_->NeedsBeginFrames() || |
298 begin_impl_frame_args_.interval <= base::TimeDelta()) | 299 begin_impl_frame_tracker_.HasFinished()) |
brianderson
2014/12/19 01:18:25
Just a note:
This might adversely affect the old
mithro-old
2014/12/19 03:40:55
Acknowledged.
| |
299 return base::TimeTicks(); | 300 return base::TimeTicks(); |
300 | 301 |
301 base::TimeTicks now = Now(); | 302 base::TimeTicks now = Now(); |
302 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time, | 303 BeginFrameArgs args = begin_impl_frame_tracker_.Get(); |
303 begin_impl_frame_args_.deadline); | 304 base::TimeTicks timebase = std::max(args.frame_time, args.deadline); |
304 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); | 305 int64 intervals = |
305 return timebase + (begin_impl_frame_args_.interval * intervals); | 306 1 + ((now - timebase) / begin_impl_frame_tracker_.Interval()); |
307 return timebase + (begin_impl_frame_tracker_.Interval() * intervals); | |
306 } | 308 } |
307 | 309 |
308 base::TimeTicks Scheduler::LastBeginImplFrameTime() { | 310 base::TimeTicks Scheduler::LastBeginImplFrameTime() { |
309 return begin_impl_frame_args_.frame_time; | 311 return begin_impl_frame_tracker_.Get().frame_time; |
310 } | 312 } |
311 | 313 |
312 void Scheduler::SetupNextBeginFrameIfNeeded() { | 314 void Scheduler::SetupNextBeginFrameIfNeeded() { |
313 if (!task_runner_.get()) | 315 if (!task_runner_.get()) |
314 return; | 316 return; |
315 | 317 |
316 bool needs_begin_frame = state_machine_.BeginFrameNeeded(); | 318 bool needs_begin_frame = state_machine_.BeginFrameNeeded(); |
317 | 319 |
318 bool at_end_of_deadline = | 320 bool at_end_of_deadline = |
319 (state_machine_.begin_impl_frame_state() == | 321 (state_machine_.begin_impl_frame_state() == |
(...skipping 23 matching lines...) Expand all Loading... | |
343 void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) { | 345 void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) { |
344 bool needs_advance_commit_state_timer = false; | 346 bool needs_advance_commit_state_timer = false; |
345 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but | 347 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but |
346 // aren't expecting any more BeginFrames. This should only be needed by | 348 // aren't expecting any more BeginFrames. This should only be needed by |
347 // the synchronous compositor when BeginFrameNeeded is false. | 349 // the synchronous compositor when BeginFrameNeeded is false. |
348 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { | 350 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { |
349 DCHECK(!state_machine_.SupportsProactiveBeginFrame()); | 351 DCHECK(!state_machine_.SupportsProactiveBeginFrame()); |
350 DCHECK(!needs_begin_frame); | 352 DCHECK(!needs_begin_frame); |
351 if (poll_for_draw_triggers_task_.IsCancelled()) { | 353 if (poll_for_draw_triggers_task_.IsCancelled()) { |
352 poll_for_draw_triggers_task_.Reset(poll_for_draw_triggers_closure_); | 354 poll_for_draw_triggers_task_.Reset(poll_for_draw_triggers_closure_); |
353 base::TimeDelta delay = begin_impl_frame_args_.IsValid() | 355 base::TimeDelta delay = begin_impl_frame_tracker_.Interval(); |
354 ? begin_impl_frame_args_.interval | |
355 : BeginFrameArgs::DefaultInterval(); | |
356 task_runner_->PostDelayedTask( | 356 task_runner_->PostDelayedTask( |
357 FROM_HERE, poll_for_draw_triggers_task_.callback(), delay); | 357 FROM_HERE, poll_for_draw_triggers_task_.callback(), delay); |
358 } | 358 } |
359 } else { | 359 } else { |
360 poll_for_draw_triggers_task_.Cancel(); | 360 poll_for_draw_triggers_task_.Cancel(); |
361 | 361 |
362 // At this point we'd prefer to advance through the commit flow by | 362 // At this point we'd prefer to advance through the commit flow by |
363 // drawing a frame, however it's possible that the frame rate controller | 363 // drawing a frame, however it's possible that the frame rate controller |
364 // will not give us a BeginFrame until the commit completes. See | 364 // will not give us a BeginFrame until the commit completes. See |
365 // crbug.com/317430 for an example of a swap ack being held on commit. Thus | 365 // crbug.com/317430 for an example of a swap ack being held on commit. Thus |
366 // we set a repeating timer to poll on ProcessScheduledActions until we | 366 // we set a repeating timer to poll on ProcessScheduledActions until we |
367 // successfully reach BeginFrame. Synchronous compositor does not use | 367 // successfully reach BeginFrame. Synchronous compositor does not use |
368 // frame rate controller or have the circular wait in the bug. | 368 // frame rate controller or have the circular wait in the bug. |
369 if (IsBeginMainFrameSentOrStarted() && | 369 if (IsBeginMainFrameSentOrStarted() && |
370 !settings_.using_synchronous_renderer_compositor) { | 370 !settings_.using_synchronous_renderer_compositor) { |
371 needs_advance_commit_state_timer = true; | 371 needs_advance_commit_state_timer = true; |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 if (needs_advance_commit_state_timer) { | 375 if (needs_advance_commit_state_timer) { |
376 if (advance_commit_state_task_.IsCancelled() && | 376 if (advance_commit_state_task_.IsCancelled()) { |
377 begin_impl_frame_args_.IsValid()) { | |
378 // Since we'd rather get a BeginImplFrame by the normal mechanism, we | 377 // Since we'd rather get a BeginImplFrame by the normal mechanism, we |
379 // set the interval to twice the interval from the previous frame. | 378 // set the interval to twice the interval from the previous frame. |
380 advance_commit_state_task_.Reset(advance_commit_state_closure_); | 379 advance_commit_state_task_.Reset(advance_commit_state_closure_); |
381 task_runner_->PostDelayedTask(FROM_HERE, | 380 task_runner_->PostDelayedTask(FROM_HERE, |
382 advance_commit_state_task_.callback(), | 381 advance_commit_state_task_.callback(), |
383 begin_impl_frame_args_.interval * 2); | 382 begin_impl_frame_tracker_.Interval() * 2); |
384 } | 383 } |
385 } else { | 384 } else { |
386 advance_commit_state_task_.Cancel(); | 385 advance_commit_state_task_.Cancel(); |
387 } | 386 } |
388 } | 387 } |
389 | 388 |
390 // BeginFrame is the mechanism that tells us that now is a good time to start | 389 // BeginFrame is the mechanism that tells us that now is a good time to start |
391 // making a frame. Usually this means that user input for the frame is complete. | 390 // making a frame. Usually this means that user input for the frame is complete. |
392 // If the scheduler is busy, we queue the BeginFrame to be handled later as | 391 // If the scheduler is busy, we queue the BeginFrame to be handled later as |
393 // a BeginRetroFrame. | 392 // a BeginRetroFrame. |
394 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { | 393 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { |
395 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); | 394 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); |
396 | 395 |
396 // Trace this begin frame time through the Chrome stack | |
397 TRACE_EVENT_FLOW_BEGIN0( | |
398 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", | |
399 args.frame_time.ToInternalValue()); | |
400 | |
397 // Deliver BeginFrames to children. | 401 // Deliver BeginFrames to children. |
398 if (settings_.forward_begin_frames_to_children && | 402 if (settings_.forward_begin_frames_to_children && |
399 state_machine_.children_need_begin_frames()) { | 403 state_machine_.children_need_begin_frames()) { |
400 BeginFrameArgs adjusted_args_for_children(args); | 404 BeginFrameArgs adjusted_args_for_children(args); |
401 // Adjust a deadline for child schedulers. | 405 // Adjust a deadline for child schedulers. |
402 // TODO(simonhong): Once we have commitless update, we can get rid of | 406 // TODO(simonhong): Once we have commitless update, we can get rid of |
403 // BeginMainFrameToCommitDurationEstimate() + | 407 // BeginMainFrameToCommitDurationEstimate() + |
404 // CommitToActivateDurationEstimate(). | 408 // CommitToActivateDurationEstimate(). |
405 adjusted_args_for_children.deadline -= | 409 adjusted_args_for_children.deadline -= |
406 (client_->BeginMainFrameToCommitDurationEstimate() + | 410 (client_->BeginMainFrameToCommitDurationEstimate() + |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 main_thread_is_in_high_latency_mode); | 541 main_thread_is_in_high_latency_mode); |
538 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 542 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
539 "MainThreadLatency", | 543 "MainThreadLatency", |
540 main_thread_is_in_high_latency_mode); | 544 main_thread_is_in_high_latency_mode); |
541 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 545 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
542 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 546 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
543 DCHECK(state_machine_.HasInitializedOutputSurface()); | 547 DCHECK(state_machine_.HasInitializedOutputSurface()); |
544 | 548 |
545 advance_commit_state_task_.Cancel(); | 549 advance_commit_state_task_.Cancel(); |
546 | 550 |
547 begin_impl_frame_args_ = args; | 551 BeginFrameArgs adjusted_args = args; |
548 begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); | 552 adjusted_args.deadline -= client_->DrawDurationEstimate(); |
549 | 553 |
550 if (!state_machine_.impl_latency_takes_priority() && | 554 if (!state_machine_.impl_latency_takes_priority() && |
551 main_thread_is_in_high_latency_mode && | 555 main_thread_is_in_high_latency_mode && |
552 CanCommitAndActivateBeforeDeadline()) { | 556 CanCommitAndActivateBeforeDeadline()) { |
553 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); | 557 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); |
554 } | 558 } |
555 | 559 |
556 client_->WillBeginImplFrame(begin_impl_frame_args_); | 560 begin_impl_frame_tracker_.Start(adjusted_args); |
557 state_machine_.OnBeginImplFrame(begin_impl_frame_args_); | 561 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Get()); |
562 state_machine_.OnBeginImplFrame(begin_impl_frame_tracker_.Get()); | |
558 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); | 563 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); |
559 | 564 |
560 ProcessScheduledActions(); | 565 ProcessScheduledActions(); |
561 | 566 |
562 state_machine_.OnBeginImplFrameDeadlinePending(); | 567 state_machine_.OnBeginImplFrameDeadlinePending(); |
563 | 568 |
564 if (settings_.using_synchronous_renderer_compositor) { | 569 if (settings_.using_synchronous_renderer_compositor) { |
565 // The synchronous renderer compositor has to make its GL calls | 570 // The synchronous renderer compositor has to make its GL calls |
566 // within this call. | 571 // within this call. |
567 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks | 572 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks |
(...skipping 17 matching lines...) Expand all Loading... | |
585 | 590 |
586 base::TimeTicks deadline; | 591 base::TimeTicks deadline; |
587 switch (begin_impl_frame_deadline_mode_) { | 592 switch (begin_impl_frame_deadline_mode_) { |
588 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: | 593 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: |
589 // We are ready to draw a new active tree immediately. | 594 // We are ready to draw a new active tree immediately. |
590 // We don't use Now() here because it's somewhat expensive to call. | 595 // We don't use Now() here because it's somewhat expensive to call. |
591 deadline = base::TimeTicks(); | 596 deadline = base::TimeTicks(); |
592 break; | 597 break; |
593 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: | 598 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: |
594 // We are animating on the impl thread but we can wait for some time. | 599 // We are animating on the impl thread but we can wait for some time. |
595 deadline = begin_impl_frame_args_.deadline; | 600 deadline = begin_impl_frame_tracker_.Get().deadline; |
596 break; | 601 break; |
597 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: | 602 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: |
598 // We are blocked for one reason or another and we should wait. | 603 // We are blocked for one reason or another and we should wait. |
599 // TODO(brianderson): Handle long deadlines (that are past the next | 604 // TODO(brianderson): Handle long deadlines (that are past the next |
600 // frame's frame time) properly instead of using this hack. | 605 // frame's frame time) properly instead of using this hack. |
601 deadline = | 606 deadline = begin_impl_frame_tracker_.Get().frame_time + |
602 begin_impl_frame_args_.frame_time + begin_impl_frame_args_.interval; | 607 begin_impl_frame_tracker_.Get().interval; |
603 break; | 608 break; |
604 } | 609 } |
605 | 610 |
606 TRACE_EVENT1( | 611 TRACE_EVENT1( |
607 "cc", "Scheduler::ScheduleBeginImplFrameDeadline", "deadline", deadline); | 612 "cc", "Scheduler::ScheduleBeginImplFrameDeadline", "deadline", deadline); |
608 | 613 |
609 base::TimeDelta delta = deadline - Now(); | 614 base::TimeDelta delta = deadline - Now(); |
610 if (delta <= base::TimeDelta()) | 615 if (delta <= base::TimeDelta()) |
611 delta = base::TimeDelta(); | 616 delta = base::TimeDelta(); |
612 task_runner_->PostDelayedTask( | 617 task_runner_->PostDelayedTask( |
(...skipping 21 matching lines...) Expand all Loading... | |
634 // the deadline separately. For example: | 639 // the deadline separately. For example: |
635 // * Sending the BeginMainFrame will not occur after the deadline in | 640 // * Sending the BeginMainFrame will not occur after the deadline in |
636 // order to wait for more user-input before starting the next commit. | 641 // order to wait for more user-input before starting the next commit. |
637 // * Creating a new OuputSurface will not occur during the deadline in | 642 // * Creating a new OuputSurface will not occur during the deadline in |
638 // order to allow the state machine to "settle" first. | 643 // order to allow the state machine to "settle" first. |
639 state_machine_.OnBeginImplFrameDeadline(); | 644 state_machine_.OnBeginImplFrameDeadline(); |
640 ProcessScheduledActions(); | 645 ProcessScheduledActions(); |
641 state_machine_.OnBeginImplFrameIdle(); | 646 state_machine_.OnBeginImplFrameIdle(); |
642 ProcessScheduledActions(); | 647 ProcessScheduledActions(); |
643 | 648 |
649 begin_impl_frame_tracker_.Finish(); | |
644 client_->DidBeginImplFrameDeadline(); | 650 client_->DidBeginImplFrameDeadline(); |
645 } | 651 } |
646 | 652 |
647 void Scheduler::PollForAnticipatedDrawTriggers() { | 653 void Scheduler::PollForAnticipatedDrawTriggers() { |
648 TRACE_EVENT0("cc", "Scheduler::PollForAnticipatedDrawTriggers"); | 654 TRACE_EVENT0("cc", "Scheduler::PollForAnticipatedDrawTriggers"); |
649 poll_for_draw_triggers_task_.Cancel(); | 655 poll_for_draw_triggers_task_.Cancel(); |
650 state_machine_.DidEnterPollForAnticipatedDrawTriggers(); | 656 state_machine_.DidEnterPollForAnticipatedDrawTriggers(); |
651 ProcessScheduledActions(); | 657 ProcessScheduledActions(); |
652 state_machine_.DidLeavePollForAnticipatedDrawTriggers(); | 658 state_machine_.DidLeavePollForAnticipatedDrawTriggers(); |
653 } | 659 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 frame_source_->NeedsBeginFrames()); | 763 frame_source_->NeedsBeginFrames()); |
758 state->SetBoolean("begin_retro_frame_posted_", begin_retro_frame_posted_); | 764 state->SetBoolean("begin_retro_frame_posted_", begin_retro_frame_posted_); |
759 state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size()); | 765 state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size()); |
760 state->SetBoolean("begin_impl_frame_deadline_task_", | 766 state->SetBoolean("begin_impl_frame_deadline_task_", |
761 !begin_impl_frame_deadline_task_.IsCancelled()); | 767 !begin_impl_frame_deadline_task_.IsCancelled()); |
762 state->SetBoolean("poll_for_draw_triggers_task_", | 768 state->SetBoolean("poll_for_draw_triggers_task_", |
763 !poll_for_draw_triggers_task_.IsCancelled()); | 769 !poll_for_draw_triggers_task_.IsCancelled()); |
764 state->SetBoolean("advance_commit_state_task_", | 770 state->SetBoolean("advance_commit_state_task_", |
765 !advance_commit_state_task_.IsCancelled()); | 771 !advance_commit_state_task_.IsCancelled()); |
766 state->BeginDictionary("begin_impl_frame_args"); | 772 state->BeginDictionary("begin_impl_frame_args"); |
767 begin_impl_frame_args_.AsValueInto(state); | 773 begin_impl_frame_tracker_.AsValueInto(state); |
768 state->EndDictionary(); | 774 state->EndDictionary(); |
769 | 775 |
770 state->EndDictionary(); | 776 state->EndDictionary(); |
771 | 777 |
772 state->BeginDictionary("client_state"); | 778 state->BeginDictionary("client_state"); |
773 state->SetDouble("draw_duration_estimate_ms", | 779 state->SetDouble("draw_duration_estimate_ms", |
774 client_->DrawDurationEstimate().InMillisecondsF()); | 780 client_->DrawDurationEstimate().InMillisecondsF()); |
775 state->SetDouble( | 781 state->SetDouble( |
776 "begin_main_frame_to_commit_duration_estimate_ms", | 782 "begin_main_frame_to_commit_duration_estimate_ms", |
777 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); | 783 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); |
778 state->SetDouble( | 784 state->SetDouble( |
779 "commit_to_activate_duration_estimate_ms", | 785 "commit_to_activate_duration_estimate_ms", |
780 client_->CommitToActivateDurationEstimate().InMillisecondsF()); | 786 client_->CommitToActivateDurationEstimate().InMillisecondsF()); |
781 state->EndDictionary(); | 787 state->EndDictionary(); |
782 } | 788 } |
783 | 789 |
784 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { | 790 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { |
791 BeginFrameArgs args; | |
792 if (!begin_impl_frame_tracker_.HasFinished()) | |
793 args = begin_impl_frame_tracker_.Get(); | |
794 else | |
795 args = begin_impl_frame_tracker_.Last(); | |
796 | |
785 // Check if the main thread computation and commit can be finished before the | 797 // Check if the main thread computation and commit can be finished before the |
786 // impl thread's deadline. | 798 // impl thread's deadline. |
787 base::TimeTicks estimated_draw_time = | 799 base::TimeTicks estimated_draw_time = |
788 begin_impl_frame_args_.frame_time + | 800 args.frame_time + client_->BeginMainFrameToCommitDurationEstimate() + |
789 client_->BeginMainFrameToCommitDurationEstimate() + | |
790 client_->CommitToActivateDurationEstimate(); | 801 client_->CommitToActivateDurationEstimate(); |
791 | 802 |
792 TRACE_EVENT2( | 803 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
793 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 804 "CanCommitAndActivateBeforeDeadline", |
794 "CanCommitAndActivateBeforeDeadline", | 805 "time_left_after_drawing_ms", |
795 "time_left_after_drawing_ms", | 806 (args.deadline - estimated_draw_time).InMillisecondsF(), "state", |
796 (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), | 807 AsValue()); |
797 "state", | |
798 AsValue()); | |
799 | 808 |
800 return estimated_draw_time < begin_impl_frame_args_.deadline; | 809 return estimated_draw_time < args.deadline; |
801 } | 810 } |
802 | 811 |
803 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 812 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
804 return (state_machine_.commit_state() == | 813 return (state_machine_.commit_state() == |
805 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 814 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
806 state_machine_.commit_state() == | 815 state_machine_.commit_state() == |
807 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 816 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
808 } | 817 } |
809 | 818 |
810 } // namespace cc | 819 } // namespace cc |
OLD | NEW |