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