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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 "Scheduler::Scheduler", | 99 "Scheduler::Scheduler", |
| 100 "settings", | 100 "settings", |
| 101 settings_.AsValue()); | 101 settings_.AsValue()); |
| 102 DCHECK(client_); | 102 DCHECK(client_); |
| 103 DCHECK(!state_machine_.BeginFrameNeeded()); | 103 DCHECK(!state_machine_.BeginFrameNeeded()); |
| 104 | 104 |
| 105 begin_retro_frame_closure_ = | 105 begin_retro_frame_closure_ = |
| 106 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()); | 106 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()); |
| 107 begin_impl_frame_deadline_closure_ = base::Bind( | 107 begin_impl_frame_deadline_closure_ = base::Bind( |
| 108 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); | 108 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); |
| 109 poll_for_draw_triggers_closure_ = base::Bind( | |
| 110 &Scheduler::PollForAnticipatedDrawTriggers, weak_factory_.GetWeakPtr()); | |
| 111 advance_commit_state_closure_ = base::Bind( | 109 advance_commit_state_closure_ = base::Bind( |
| 112 &Scheduler::PollToAdvanceCommitState, weak_factory_.GetWeakPtr()); | 110 &Scheduler::PollToAdvanceCommitState, weak_factory_.GetWeakPtr()); |
| 113 | 111 |
| 114 frame_source_ = BeginFrameSourceMultiplexer::Create(); | 112 frame_source_ = BeginFrameSourceMultiplexer::Create(); |
| 115 frame_source_->AddObserver(this); | 113 frame_source_->AddObserver(this); |
| 116 | 114 |
| 117 // Primary frame source | 115 // Primary frame source |
| 118 primary_frame_source_ = | 116 primary_frame_source_ = |
| 119 frame_sources_constructor->ConstructPrimaryFrameSource(this); | 117 frame_sources_constructor->ConstructPrimaryFrameSource(this); |
| 120 frame_source_->AddSource(primary_frame_source_); | 118 frame_source_->AddSource(primary_frame_source_); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 void Scheduler::SetNeedsCommit() { | 210 void Scheduler::SetNeedsCommit() { |
| 213 state_machine_.SetNeedsCommit(); | 211 state_machine_.SetNeedsCommit(); |
| 214 ProcessScheduledActions(); | 212 ProcessScheduledActions(); |
| 215 } | 213 } |
| 216 | 214 |
| 217 void Scheduler::SetNeedsRedraw() { | 215 void Scheduler::SetNeedsRedraw() { |
| 218 state_machine_.SetNeedsRedraw(); | 216 state_machine_.SetNeedsRedraw(); |
| 219 ProcessScheduledActions(); | 217 ProcessScheduledActions(); |
| 220 } | 218 } |
| 221 | 219 |
| 220 void Scheduler::OutputSurfaceDidRequestDraw() { | |
| 221 state_machine_.OutputSurfaceDidRequestDraw(); | |
| 222 ProcessScheduledActions(); | |
| 223 } | |
| 224 | |
| 222 void Scheduler::SetNeedsAnimate() { | 225 void Scheduler::SetNeedsAnimate() { |
| 223 state_machine_.SetNeedsAnimate(); | 226 state_machine_.SetNeedsAnimate(); |
| 224 ProcessScheduledActions(); | 227 ProcessScheduledActions(); |
| 225 } | 228 } |
| 226 | 229 |
| 227 void Scheduler::SetNeedsPrepareTiles() { | 230 void Scheduler::SetNeedsPrepareTiles() { |
| 228 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_PREPARE_TILES)); | 231 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_PREPARE_TILES)); |
| 229 state_machine_.SetNeedsPrepareTiles(); | 232 state_machine_.SetNeedsPrepareTiles(); |
| 230 ProcessScheduledActions(); | 233 ProcessScheduledActions(); |
| 231 } | 234 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); | 336 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); |
| 334 } | 337 } |
| 335 | 338 |
| 336 PostBeginRetroFrameIfNeeded(); | 339 PostBeginRetroFrameIfNeeded(); |
| 337 SetupPollingMechanisms(needs_begin_frame); | 340 SetupPollingMechanisms(needs_begin_frame); |
| 338 } | 341 } |
| 339 | 342 |
| 340 // We may need to poll when we can't rely on BeginFrame to advance certain | 343 // We may need to poll when we can't rely on BeginFrame to advance certain |
| 341 // state or to avoid deadlock. | 344 // state or to avoid deadlock. |
| 342 void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) { | 345 void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) { |
| 343 bool needs_advance_commit_state_timer = false; | 346 // At this point we'd prefer to advance through the commit flow by |
| 344 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but | 347 // drawing a frame, however it's possible that the frame rate controller |
|
brianderson
2014/12/20 00:34:13
frame rate controller doesn't exist anymore. Since
sunnyps
2014/12/20 00:39:30
Acknowledged.
| |
| 345 // aren't expecting any more BeginFrames. This should only be needed by | 348 // will not give us a BeginFrame until the commit completes. See |
| 346 // the synchronous compositor when BeginFrameNeeded is false. | 349 // crbug.com/317430 for an example of a swap ack being held on commit. Thus |
| 347 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { | 350 // we set a repeating timer to poll on ProcessScheduledActions until we |
| 348 DCHECK(!state_machine_.SupportsProactiveBeginFrame()); | 351 // successfully reach BeginFrame. Synchronous compositor does not use |
| 349 DCHECK(!needs_begin_frame); | 352 // frame rate controller or have the circular wait in the bug. |
| 350 if (poll_for_draw_triggers_task_.IsCancelled()) { | 353 if (IsBeginMainFrameSentOrStarted() && |
| 351 poll_for_draw_triggers_task_.Reset(poll_for_draw_triggers_closure_); | 354 !settings_.using_synchronous_renderer_compositor) { |
| 352 base::TimeDelta delay = begin_impl_frame_args_.IsValid() | |
| 353 ? begin_impl_frame_args_.interval | |
| 354 : BeginFrameArgs::DefaultInterval(); | |
| 355 task_runner_->PostDelayedTask( | |
| 356 FROM_HERE, poll_for_draw_triggers_task_.callback(), delay); | |
| 357 } | |
| 358 } else { | |
| 359 poll_for_draw_triggers_task_.Cancel(); | |
| 360 | |
| 361 // 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 | |
| 363 // 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 | |
| 365 // we set a repeating timer to poll on ProcessScheduledActions until we | |
| 366 // successfully reach BeginFrame. Synchronous compositor does not use | |
| 367 // frame rate controller or have the circular wait in the bug. | |
| 368 if (IsBeginMainFrameSentOrStarted() && | |
| 369 !settings_.using_synchronous_renderer_compositor) { | |
| 370 needs_advance_commit_state_timer = true; | |
| 371 } | |
| 372 } | |
| 373 | |
| 374 if (needs_advance_commit_state_timer) { | |
| 375 if (advance_commit_state_task_.IsCancelled() && | 355 if (advance_commit_state_task_.IsCancelled() && |
| 376 begin_impl_frame_args_.IsValid()) { | 356 begin_impl_frame_args_.IsValid()) { |
| 377 // Since we'd rather get a BeginImplFrame by the normal mechanism, we | 357 // Since we'd rather get a BeginImplFrame by the normal mechanism, we |
| 378 // set the interval to twice the interval from the previous frame. | 358 // set the interval to twice the interval from the previous frame. |
| 379 advance_commit_state_task_.Reset(advance_commit_state_closure_); | 359 advance_commit_state_task_.Reset(advance_commit_state_closure_); |
| 380 task_runner_->PostDelayedTask(FROM_HERE, | 360 task_runner_->PostDelayedTask(FROM_HERE, |
| 381 advance_commit_state_task_.callback(), | 361 advance_commit_state_task_.callback(), |
| 382 begin_impl_frame_args_.interval * 2); | 362 begin_impl_frame_args_.interval * 2); |
| 383 } | 363 } |
| 384 } else { | 364 } else { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 } | 533 } |
| 554 | 534 |
| 555 client_->WillBeginImplFrame(begin_impl_frame_args_); | 535 client_->WillBeginImplFrame(begin_impl_frame_args_); |
| 556 state_machine_.OnBeginImplFrame(begin_impl_frame_args_); | 536 state_machine_.OnBeginImplFrame(begin_impl_frame_args_); |
| 557 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); | 537 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); |
| 558 | 538 |
| 559 ProcessScheduledActions(); | 539 ProcessScheduledActions(); |
| 560 | 540 |
| 561 state_machine_.OnBeginImplFrameDeadlinePending(); | 541 state_machine_.OnBeginImplFrameDeadlinePending(); |
| 562 | 542 |
| 563 if (settings_.using_synchronous_renderer_compositor) { | 543 ProcessScheduledActions(); |
|
brianderson
2014/12/20 00:34:13
Nice.
| |
| 564 // The synchronous renderer compositor has to make its GL calls | |
| 565 // within this call. | |
| 566 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks | |
| 567 // so the synchronous renderer compositor can take advantage of splitting | |
| 568 // up the BeginImplFrame and deadline as well. | |
| 569 OnBeginImplFrameDeadline(); | |
| 570 } else { | |
| 571 ScheduleBeginImplFrameDeadline(); | |
| 572 } | |
| 573 } | 544 } |
| 574 | 545 |
| 575 void Scheduler::ScheduleBeginImplFrameDeadline() { | 546 void Scheduler::ScheduleBeginImplFrameDeadline() { |
| 576 // The synchronous compositor does not post a deadline task. | |
| 577 DCHECK(!settings_.using_synchronous_renderer_compositor); | |
| 578 | |
| 579 begin_impl_frame_deadline_task_.Cancel(); | 547 begin_impl_frame_deadline_task_.Cancel(); |
| 580 begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_); | 548 begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_); |
| 581 | 549 |
| 582 begin_impl_frame_deadline_mode_ = | 550 begin_impl_frame_deadline_mode_ = |
| 583 state_machine_.CurrentBeginImplFrameDeadlineMode(); | 551 state_machine_.CurrentBeginImplFrameDeadlineMode(); |
| 584 | 552 |
| 585 base::TimeTicks deadline; | 553 base::TimeTicks deadline; |
| 586 switch (begin_impl_frame_deadline_mode_) { | 554 switch (begin_impl_frame_deadline_mode_) { |
| 587 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: | 555 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE_SYNCHRO NOUS: |
| 556 // The synchronous renderer compositor has to make its GL calls | |
| 557 // within this call. | |
| 558 OnBeginImplFrameDeadline(); | |
| 559 return; | |
| 560 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE_ASYNCHR ONOUS: | |
| 588 // We are ready to draw a new active tree immediately. | 561 // We are ready to draw a new active tree immediately. |
| 589 // We don't use Now() here because it's somewhat expensive to call. | 562 // We don't use Now() here because it's somewhat expensive to call. |
| 590 deadline = base::TimeTicks(); | 563 deadline = base::TimeTicks(); |
| 591 break; | 564 break; |
| 592 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: | 565 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: |
| 593 // We are animating on the impl thread but we can wait for some time. | 566 // We are animating on the impl thread but we can wait for some time. |
| 594 deadline = begin_impl_frame_args_.deadline; | 567 deadline = begin_impl_frame_args_.deadline; |
| 595 break; | 568 break; |
| 596 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: | 569 case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: |
| 597 // We are blocked for one reason or another and we should wait. | 570 // We are blocked for one reason or another and we should wait. |
| 598 // TODO(brianderson): Handle long deadlines (that are past the next | 571 // TODO(brianderson): Handle long deadlines (that are past the next |
| 599 // frame's frame time) properly instead of using this hack. | 572 // frame's frame time) properly instead of using this hack. |
| 600 deadline = | 573 deadline = |
| 601 begin_impl_frame_args_.frame_time + begin_impl_frame_args_.interval; | 574 begin_impl_frame_args_.frame_time + begin_impl_frame_args_.interval; |
| 602 break; | 575 break; |
| 603 } | 576 } |
| 604 | 577 |
| 605 TRACE_EVENT1( | 578 TRACE_EVENT2( |
| 606 "cc", "Scheduler::ScheduleBeginImplFrameDeadline", "deadline", deadline); | 579 "cc", |
| 580 "Scheduler::ScheduleBeginImplFrameDeadline", | |
| 581 "mode", | |
| 582 SchedulerStateMachine::BeginImplFrameDeadlineModeToString( | |
| 583 begin_impl_frame_deadline_mode_), | |
| 584 "deadline", | |
| 585 deadline); | |
| 607 | 586 |
| 608 base::TimeDelta delta = deadline - Now(); | 587 base::TimeDelta delta = std::max(deadline - Now(), base::TimeDelta()); |
| 609 if (delta <= base::TimeDelta()) | |
| 610 delta = base::TimeDelta(); | |
| 611 task_runner_->PostDelayedTask( | 588 task_runner_->PostDelayedTask( |
| 612 FROM_HERE, begin_impl_frame_deadline_task_.callback(), delta); | 589 FROM_HERE, begin_impl_frame_deadline_task_.callback(), delta); |
| 613 } | 590 } |
| 614 | 591 |
| 615 void Scheduler::RescheduleBeginImplFrameDeadlineIfNeeded() { | 592 void Scheduler::ScheduleBeginImplFrameDeadlineIfNeeded() { |
| 616 if (settings_.using_synchronous_renderer_compositor) | |
| 617 return; | |
| 618 | |
| 619 if (state_machine_.begin_impl_frame_state() != | 593 if (state_machine_.begin_impl_frame_state() != |
| 620 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) | 594 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) |
| 621 return; | 595 return; |
| 622 | 596 |
| 623 if (begin_impl_frame_deadline_mode_ != | 597 if (begin_impl_frame_deadline_mode_ == state_machine_.CurrentBeginImplFrameDea dlineMode() && |
| 624 state_machine_.CurrentBeginImplFrameDeadlineMode()) | 598 BeginImplFrameDeadlinePending()) |
| 625 ScheduleBeginImplFrameDeadline(); | 599 return; |
| 600 | |
| 601 ScheduleBeginImplFrameDeadline(); | |
| 626 } | 602 } |
| 627 | 603 |
| 628 void Scheduler::OnBeginImplFrameDeadline() { | 604 void Scheduler::OnBeginImplFrameDeadline() { |
| 629 TRACE_EVENT0("cc", "Scheduler::OnBeginImplFrameDeadline"); | 605 TRACE_EVENT0("cc", "Scheduler::OnBeginImplFrameDeadline"); |
| 630 begin_impl_frame_deadline_task_.Cancel(); | 606 begin_impl_frame_deadline_task_.Cancel(); |
| 631 // We split the deadline actions up into two phases so the state machine | 607 // We split the deadline actions up into two phases so the state machine |
| 632 // has a chance to trigger actions that should occur durring and after | 608 // has a chance to trigger actions that should occur durring and after |
| 633 // the deadline separately. For example: | 609 // the deadline separately. For example: |
| 634 // * Sending the BeginMainFrame will not occur after the deadline in | 610 // * Sending the BeginMainFrame will not occur after the deadline in |
| 635 // order to wait for more user-input before starting the next commit. | 611 // order to wait for more user-input before starting the next commit. |
| 636 // * Creating a new OuputSurface will not occur during the deadline in | 612 // * Creating a new OuputSurface will not occur during the deadline in |
| 637 // order to allow the state machine to "settle" first. | 613 // order to allow the state machine to "settle" first. |
| 638 state_machine_.OnBeginImplFrameDeadline(); | 614 state_machine_.OnBeginImplFrameDeadline(); |
| 639 ProcessScheduledActions(); | 615 ProcessScheduledActions(); |
| 640 state_machine_.OnBeginImplFrameIdle(); | 616 state_machine_.OnBeginImplFrameIdle(); |
| 641 ProcessScheduledActions(); | 617 ProcessScheduledActions(); |
| 642 | 618 |
| 643 client_->DidBeginImplFrameDeadline(); | 619 client_->DidBeginImplFrameDeadline(); |
| 644 } | 620 } |
| 645 | 621 |
| 646 void Scheduler::PollForAnticipatedDrawTriggers() { | |
| 647 TRACE_EVENT0("cc", "Scheduler::PollForAnticipatedDrawTriggers"); | |
| 648 poll_for_draw_triggers_task_.Cancel(); | |
| 649 state_machine_.DidEnterPollForAnticipatedDrawTriggers(); | |
| 650 ProcessScheduledActions(); | |
| 651 state_machine_.DidLeavePollForAnticipatedDrawTriggers(); | |
| 652 } | |
| 653 | 622 |
| 654 void Scheduler::PollToAdvanceCommitState() { | 623 void Scheduler::PollToAdvanceCommitState() { |
| 655 TRACE_EVENT0("cc", "Scheduler::PollToAdvanceCommitState"); | 624 TRACE_EVENT0("cc", "Scheduler::PollToAdvanceCommitState"); |
| 656 advance_commit_state_task_.Cancel(); | 625 advance_commit_state_task_.Cancel(); |
| 657 ProcessScheduledActions(); | 626 ProcessScheduledActions(); |
| 658 } | 627 } |
| 659 | 628 |
| 660 void Scheduler::DrawAndSwapIfPossible() { | 629 void Scheduler::DrawAndSwapIfPossible() { |
| 661 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); | 630 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); |
| 662 state_machine_.DidDrawIfPossibleCompleted(result); | 631 state_machine_.DidDrawIfPossibleCompleted(result); |
| 663 } | 632 } |
| 664 | 633 |
| 665 void Scheduler::ProcessScheduledActions() { | 634 void Scheduler::ProcessScheduledActions() { |
| 666 // We do not allow ProcessScheduledActions to be recursive. | 635 // We do not allow ProcessScheduledActions to be recursive. |
| 667 // The top-level call will iteratively execute the next action for us anyway. | 636 // The top-level call will iteratively execute the next action for us anyway. |
| 668 if (inside_process_scheduled_actions_) | 637 if (inside_process_scheduled_actions_) |
| 669 return; | 638 return; |
| 639 { | |
| 640 // Separate scope for mark_inside. | |
|
brianderson
2014/12/20 00:34:13
Do you only need this to allow re-entrancy when Sc
| |
| 641 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | |
| 670 | 642 |
| 671 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | 643 SchedulerStateMachine::Action action; |
| 672 | 644 do { |
| 673 SchedulerStateMachine::Action action; | 645 action = state_machine_.NextAction(); |
| 674 do { | 646 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 675 action = state_machine_.NextAction(); | 647 "SchedulerStateMachine", |
| 676 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 648 "state", |
| 677 "SchedulerStateMachine", | 649 AsValue()); |
| 678 "state", | 650 VLOG(2) << "Scheduler::ProcessScheduledActions: " |
| 679 AsValue()); | 651 << SchedulerStateMachine::ActionToString(action) << " " |
| 680 VLOG(2) << "Scheduler::ProcessScheduledActions: " | 652 << state_machine_.GetStatesForDebugging(); |
| 681 << SchedulerStateMachine::ActionToString(action) << " " | 653 state_machine_.UpdateState(action); |
| 682 << state_machine_.GetStatesForDebugging(); | 654 base::AutoReset<SchedulerStateMachine::Action> |
| 683 state_machine_.UpdateState(action); | 655 mark_inside_action(&inside_action_, action); |
| 684 base::AutoReset<SchedulerStateMachine::Action> | 656 switch (action) { |
| 685 mark_inside_action(&inside_action_, action); | 657 case SchedulerStateMachine::ACTION_NONE: |
| 686 switch (action) { | 658 break; |
| 687 case SchedulerStateMachine::ACTION_NONE: | 659 case SchedulerStateMachine::ACTION_ANIMATE: |
| 688 break; | 660 client_->ScheduledActionAnimate(); |
| 689 case SchedulerStateMachine::ACTION_ANIMATE: | 661 break; |
| 690 client_->ScheduledActionAnimate(); | 662 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: |
| 691 break; | 663 client_->ScheduledActionSendBeginMainFrame(); |
| 692 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: | 664 break; |
| 693 client_->ScheduledActionSendBeginMainFrame(); | 665 case SchedulerStateMachine::ACTION_COMMIT: |
| 694 break; | 666 client_->ScheduledActionCommit(); |
| 695 case SchedulerStateMachine::ACTION_COMMIT: | 667 break; |
| 696 client_->ScheduledActionCommit(); | 668 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: |
| 697 break; | 669 client_->ScheduledActionActivateSyncTree(); |
| 698 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: | 670 break; |
| 699 client_->ScheduledActionActivateSyncTree(); | 671 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: |
| 700 break; | 672 DrawAndSwapIfPossible(); |
| 701 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: | 673 break; |
| 702 DrawAndSwapIfPossible(); | 674 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: |
| 703 break; | 675 client_->ScheduledActionDrawAndSwapForced(); |
| 704 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: | 676 break; |
| 705 client_->ScheduledActionDrawAndSwapForced(); | 677 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: |
| 706 break; | 678 // No action is actually performed, but this allows the state machine |
| 707 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: | 679 // to advance out of it's waiting to draw state without actually |
|
brianderson
2014/12/20 00:34:13
it's -> its
sunnyps
2014/12/20 00:39:30
Acknowledged.
| |
| 708 // No action is actually performed, but this allows the state machine to | 680 // drawing. |
| 709 // advance out of its waiting to draw state without actually drawing. | 681 break; |
| 710 break; | 682 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
| 711 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 683 client_->ScheduledActionBeginOutputSurfaceCreation(); |
| 712 client_->ScheduledActionBeginOutputSurfaceCreation(); | 684 break; |
| 713 break; | 685 case SchedulerStateMachine::ACTION_PREPARE_TILES: |
| 714 case SchedulerStateMachine::ACTION_PREPARE_TILES: | 686 client_->ScheduledActionPrepareTiles(); |
| 715 client_->ScheduledActionPrepareTiles(); | 687 break; |
| 716 break; | 688 case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: |
| 717 } | 689 client_->ScheduledActionInvalidateOutputSurface(); |
| 718 } while (action != SchedulerStateMachine::ACTION_NONE); | 690 break; |
| 691 } | |
| 692 } while (action != SchedulerStateMachine::ACTION_NONE); | |
| 693 } | |
| 719 | 694 |
| 720 SetupNextBeginFrameIfNeeded(); | 695 SetupNextBeginFrameIfNeeded(); |
| 721 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); | 696 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); |
| 722 | 697 |
| 723 RescheduleBeginImplFrameDeadlineIfNeeded(); | 698 ScheduleBeginImplFrameDeadlineIfNeeded(); |
| 724 } | 699 } |
| 725 | 700 |
| 726 bool Scheduler::WillDrawIfNeeded() const { | 701 bool Scheduler::WillDrawIfNeeded() const { |
| 727 return !state_machine_.PendingDrawsShouldBeAborted(); | 702 return !state_machine_.PendingDrawsShouldBeAborted(); |
| 728 } | 703 } |
| 729 | 704 |
| 730 scoped_refptr<base::debug::ConvertableToTraceFormat> Scheduler::AsValue() | 705 scoped_refptr<base::debug::ConvertableToTraceFormat> Scheduler::AsValue() |
| 731 const { | 706 const { |
| 732 scoped_refptr<base::debug::TracedValue> state = | 707 scoped_refptr<base::debug::TracedValue> state = |
| 733 new base::debug::TracedValue(); | 708 new base::debug::TracedValue(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 755 state->SetDouble("time_until_anticipated_draw_time_ms", | 730 state->SetDouble("time_until_anticipated_draw_time_ms", |
| 756 (AnticipatedDrawTime() - Now()).InMillisecondsF()); | 731 (AnticipatedDrawTime() - Now()).InMillisecondsF()); |
| 757 state->SetDouble("estimated_parent_draw_time_ms", | 732 state->SetDouble("estimated_parent_draw_time_ms", |
| 758 estimated_parent_draw_time_.InMillisecondsF()); | 733 estimated_parent_draw_time_.InMillisecondsF()); |
| 759 state->SetBoolean("last_set_needs_begin_frame_", | 734 state->SetBoolean("last_set_needs_begin_frame_", |
| 760 frame_source_->NeedsBeginFrames()); | 735 frame_source_->NeedsBeginFrames()); |
| 761 state->SetBoolean("begin_retro_frame_posted_", begin_retro_frame_posted_); | 736 state->SetBoolean("begin_retro_frame_posted_", begin_retro_frame_posted_); |
| 762 state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size()); | 737 state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size()); |
| 763 state->SetBoolean("begin_impl_frame_deadline_task_", | 738 state->SetBoolean("begin_impl_frame_deadline_task_", |
| 764 !begin_impl_frame_deadline_task_.IsCancelled()); | 739 !begin_impl_frame_deadline_task_.IsCancelled()); |
| 765 state->SetBoolean("poll_for_draw_triggers_task_", | |
| 766 !poll_for_draw_triggers_task_.IsCancelled()); | |
| 767 state->SetBoolean("advance_commit_state_task_", | 740 state->SetBoolean("advance_commit_state_task_", |
| 768 !advance_commit_state_task_.IsCancelled()); | 741 !advance_commit_state_task_.IsCancelled()); |
| 769 state->BeginDictionary("begin_impl_frame_args"); | 742 state->BeginDictionary("begin_impl_frame_args"); |
| 770 begin_impl_frame_args_.AsValueInto(state); | 743 begin_impl_frame_args_.AsValueInto(state); |
| 771 state->EndDictionary(); | 744 state->EndDictionary(); |
| 772 | 745 |
| 773 state->EndDictionary(); | 746 state->EndDictionary(); |
| 774 | 747 |
| 775 state->BeginDictionary("client_state"); | 748 state->BeginDictionary("client_state"); |
| 776 state->SetDouble("draw_duration_estimate_ms", | 749 state->SetDouble("draw_duration_estimate_ms", |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 804 } | 777 } |
| 805 | 778 |
| 806 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 779 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 807 return (state_machine_.commit_state() == | 780 return (state_machine_.commit_state() == |
| 808 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 781 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 809 state_machine_.commit_state() == | 782 state_machine_.commit_state() == |
| 810 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 783 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 811 } | 784 } |
| 812 | 785 |
| 813 } // namespace cc | 786 } // namespace cc |
| OLD | NEW |