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