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