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