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_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 BeginMainFrameState state) { | 116 BeginMainFrameState state) { |
117 switch (state) { | 117 switch (state) { |
118 case BEGIN_MAIN_FRAME_STATE_IDLE: | 118 case BEGIN_MAIN_FRAME_STATE_IDLE: |
119 return "BEGIN_MAIN_FRAME_STATE_IDLE"; | 119 return "BEGIN_MAIN_FRAME_STATE_IDLE"; |
120 case BEGIN_MAIN_FRAME_STATE_SENT: | 120 case BEGIN_MAIN_FRAME_STATE_SENT: |
121 return "BEGIN_MAIN_FRAME_STATE_SENT"; | 121 return "BEGIN_MAIN_FRAME_STATE_SENT"; |
122 case BEGIN_MAIN_FRAME_STATE_STARTED: | 122 case BEGIN_MAIN_FRAME_STATE_STARTED: |
123 return "BEGIN_MAIN_FRAME_STATE_STARTED"; | 123 return "BEGIN_MAIN_FRAME_STATE_STARTED"; |
124 case BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT: | 124 case BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT: |
125 return "BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT"; | 125 return "BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT"; |
| 126 case BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION: |
| 127 return "BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION"; |
| 128 case BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW: |
| 129 return "BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW"; |
126 } | 130 } |
127 NOTREACHED(); | 131 NOTREACHED(); |
128 return "???"; | 132 return "???"; |
129 } | 133 } |
130 | 134 |
131 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( | 135 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( |
132 ForcedRedrawOnTimeoutState state) { | 136 ForcedRedrawOnTimeoutState state) { |
133 switch (state) { | 137 switch (state) { |
134 case FORCED_REDRAW_STATE_IDLE: | 138 case FORCED_REDRAW_STATE_IDLE: |
135 return "FORCED_REDRAW_STATE_IDLE"; | 139 return "FORCED_REDRAW_STATE_IDLE"; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 360 |
357 // Do not queue too many swaps. | 361 // Do not queue too many swaps. |
358 if (SwapThrottled()) | 362 if (SwapThrottled()) |
359 return false; | 363 return false; |
360 | 364 |
361 // Except for the cases above, do not draw outside of the BeginImplFrame | 365 // Except for the cases above, do not draw outside of the BeginImplFrame |
362 // deadline. | 366 // deadline. |
363 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 367 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
364 return false; | 368 return false; |
365 | 369 |
366 // Wait for active tree to be rasterized before drawing in browser compositor. | |
367 if (wait_for_ready_to_draw_) { | |
368 DCHECK(settings_.commit_to_active_tree); | |
369 return false; | |
370 } | |
371 | |
372 // Browser compositor commit steals any resources submitted in draw. Therefore | |
373 // drawing while a commit is pending is wasteful. | |
374 if (settings_.commit_to_active_tree && CommitPending()) | |
375 return false; | |
376 | |
377 // Only handle forced redraws due to timeouts on the regular deadline. | 370 // Only handle forced redraws due to timeouts on the regular deadline. |
378 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 371 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
379 return true; | 372 return true; |
380 | 373 |
381 return needs_redraw_; | 374 return needs_redraw_; |
382 } | 375 } |
383 | 376 |
384 bool SchedulerStateMachine::ShouldActivatePendingTree() const { | 377 bool SchedulerStateMachine::ShouldActivatePendingTree() const { |
385 // There is nothing to activate. | 378 // There is nothing to activate. |
386 if (!has_pending_tree_) | 379 if (!has_pending_tree_) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 if (send_begin_main_frame_funnel_) | 422 if (send_begin_main_frame_funnel_) |
430 return false; | 423 return false; |
431 | 424 |
432 // Only send BeginMainFrame when there isn't another commit pending already. | 425 // Only send BeginMainFrame when there isn't another commit pending already. |
433 // Other parts of the state machine indirectly defer the BeginMainFrame | 426 // Other parts of the state machine indirectly defer the BeginMainFrame |
434 // by transitioning to WAITING commit states rather than going | 427 // by transitioning to WAITING commit states rather than going |
435 // immediately to IDLE. | 428 // immediately to IDLE. |
436 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) | 429 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) |
437 return false; | 430 return false; |
438 | 431 |
439 // MFBA is disabled and we are waiting for previous activation. | |
440 if (!settings_.main_frame_before_activation_enabled && has_pending_tree_) | |
441 return false; | |
442 | |
443 // We are waiting for previous frame to be drawn, swapped and acked. | |
444 if (settings_.commit_to_active_tree && | |
445 (active_tree_needs_first_draw_ || SwapThrottled())) { | |
446 return false; | |
447 } | |
448 | |
449 // Don't send BeginMainFrame early if we are prioritizing the active tree | 432 // Don't send BeginMainFrame early if we are prioritizing the active tree |
450 // because of ImplLatencyTakesPriority. | 433 // because of ImplLatencyTakesPriority. |
451 if (ImplLatencyTakesPriority() && | 434 if (ImplLatencyTakesPriority() && |
452 (has_pending_tree_ || active_tree_needs_first_draw_)) { | 435 (has_pending_tree_ || active_tree_needs_first_draw_)) { |
453 return false; | 436 return false; |
454 } | 437 } |
455 | 438 |
456 // We should not send BeginMainFrame while we are in the idle state since we | 439 // We should not send BeginMainFrame while we are in the idle state since we |
457 // might have new user input arriving soon. It's okay to send BeginMainFrame | 440 // might have new user input arriving soon. It's okay to send BeginMainFrame |
458 // for the synchronous compositor because the main thread is always high | 441 // for the synchronous compositor because the main thread is always high |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 bool SchedulerStateMachine::ShouldCommit() const { | 477 bool SchedulerStateMachine::ShouldCommit() const { |
495 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) | 478 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) |
496 return false; | 479 return false; |
497 | 480 |
498 // We must not finish the commit until the pending tree is free. | 481 // We must not finish the commit until the pending tree is free. |
499 if (has_pending_tree_) { | 482 if (has_pending_tree_) { |
500 DCHECK(settings_.main_frame_before_activation_enabled); | 483 DCHECK(settings_.main_frame_before_activation_enabled); |
501 return false; | 484 return false; |
502 } | 485 } |
503 | 486 |
504 // If we only have an active tree, it is incorrect to replace it before we've | 487 // If we only have an active tree, it is incorrect to replace it |
505 // drawn it. | 488 // before we've drawn it. |
506 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); | 489 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); |
507 | 490 |
508 // In browser compositor commit reclaims any resources submitted during draw. | |
509 DCHECK(!settings_.commit_to_active_tree || !SwapThrottled()); | |
510 | |
511 return true; | 491 return true; |
512 } | 492 } |
513 | 493 |
514 bool SchedulerStateMachine::ShouldPrepareTiles() const { | 494 bool SchedulerStateMachine::ShouldPrepareTiles() const { |
515 // PrepareTiles only really needs to be called immediately after commit | 495 // PrepareTiles only really needs to be called immediately after commit |
516 // and then periodically after that. Use a funnel to make sure we average | 496 // and then periodically after that. Use a funnel to make sure we average |
517 // one PrepareTiles per BeginImplFrame in the long run. | 497 // one PrepareTiles per BeginImplFrame in the long run. |
518 if (prepare_tiles_funnel_ > 0) | 498 if (prepare_tiles_funnel_ > 0) |
519 return false; | 499 return false; |
520 | 500 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 send_begin_main_frame_funnel_ = true; | 559 send_begin_main_frame_funnel_ = true; |
580 last_frame_number_begin_main_frame_sent_ = current_frame_number_; | 560 last_frame_number_begin_main_frame_sent_ = current_frame_number_; |
581 } | 561 } |
582 | 562 |
583 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { | 563 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { |
584 DCHECK(!has_pending_tree_ || | 564 DCHECK(!has_pending_tree_ || |
585 (settings_.main_frame_before_activation_enabled && | 565 (settings_.main_frame_before_activation_enabled && |
586 commit_has_no_updates)); | 566 commit_has_no_updates)); |
587 commit_count_++; | 567 commit_count_++; |
588 last_commit_had_no_updates_ = commit_has_no_updates; | 568 last_commit_had_no_updates_ = commit_has_no_updates; |
589 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 569 |
| 570 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) { |
| 571 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
| 572 } else { |
| 573 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION; |
| 574 } |
590 | 575 |
591 if (!commit_has_no_updates) { | 576 if (!commit_has_no_updates) { |
592 // Pending tree only exists if commit had updates. | 577 // Pending tree only exists if commit had updates. |
593 has_pending_tree_ = true; | 578 has_pending_tree_ = true; |
594 pending_tree_is_ready_for_activation_ = false; | 579 pending_tree_is_ready_for_activation_ = false; |
595 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; | 580 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; |
596 } | 581 } |
597 | 582 |
598 // Update state related to forced draws. | 583 // Update state related to forced draws. |
599 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 584 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
600 forced_redraw_state_ = has_pending_tree_ | 585 forced_redraw_state_ = has_pending_tree_ |
601 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 586 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
602 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 587 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
603 } | 588 } |
604 | 589 |
605 // Update the output surface state. | 590 // Update the output surface state. |
606 if (compositor_frame_sink_state_ == | 591 if (compositor_frame_sink_state_ == |
607 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT) { | 592 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT) { |
608 compositor_frame_sink_state_ = | 593 compositor_frame_sink_state_ = |
609 has_pending_tree_ ? COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION | 594 has_pending_tree_ ? COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION |
610 : COMPOSITOR_FRAME_SINK_ACTIVE; | 595 : COMPOSITOR_FRAME_SINK_ACTIVE; |
611 } | 596 } |
612 } | 597 } |
613 | 598 |
614 void SchedulerStateMachine::WillActivate() { | 599 void SchedulerStateMachine::WillActivate() { |
| 600 if (begin_main_frame_state_ == |
| 601 BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) { |
| 602 begin_main_frame_state_ = settings_.commit_to_active_tree |
| 603 ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW |
| 604 : BEGIN_MAIN_FRAME_STATE_IDLE; |
| 605 } |
| 606 |
615 if (compositor_frame_sink_state_ == | 607 if (compositor_frame_sink_state_ == |
616 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) | 608 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) |
617 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; | 609 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; |
618 | 610 |
619 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) | 611 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) |
620 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 612 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
621 | 613 |
622 has_pending_tree_ = false; | 614 has_pending_tree_ = false; |
623 pending_tree_is_ready_for_activation_ = false; | 615 pending_tree_is_ready_for_activation_ = false; |
624 active_tree_needs_first_draw_ = true; | 616 active_tree_needs_first_draw_ = true; |
(...skipping 12 matching lines...) Expand all Loading... |
637 // draw itself might request another draw. | 629 // draw itself might request another draw. |
638 needs_redraw_ = false; | 630 needs_redraw_ = false; |
639 | 631 |
640 draw_funnel_ = true; | 632 draw_funnel_ = true; |
641 active_tree_needs_first_draw_ = false; | 633 active_tree_needs_first_draw_ = false; |
642 did_draw_in_last_frame_ = true; | 634 did_draw_in_last_frame_ = true; |
643 last_frame_number_draw_performed_ = current_frame_number_; | 635 last_frame_number_draw_performed_ = current_frame_number_; |
644 | 636 |
645 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 637 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
646 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 638 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 639 |
| 640 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW) |
| 641 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
647 } | 642 } |
648 | 643 |
649 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { | 644 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { |
650 switch (draw_result) { | 645 switch (draw_result) { |
651 case INVALID_RESULT: | 646 case INVALID_RESULT: |
652 case DRAW_ABORTED_CANT_DRAW: | 647 case DRAW_ABORTED_CANT_DRAW: |
653 case DRAW_ABORTED_CONTEXT_LOST: | 648 case DRAW_ABORTED_CONTEXT_LOST: |
654 NOTREACHED() << "Invalid return DrawResult:" << draw_result; | 649 NOTREACHED() << "Invalid return DrawResult:" << draw_result; |
655 break; | 650 break; |
656 case DRAW_ABORTED_DRAINING_PIPELINE: | 651 case DRAW_ABORTED_DRAINING_PIPELINE: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 last_frame_number_invalidate_compositor_frame_sink_performed_ = | 722 last_frame_number_invalidate_compositor_frame_sink_performed_ = |
728 current_frame_number_; | 723 current_frame_number_; |
729 | 724 |
730 // The synchronous compositor makes no guarantees about a draw coming in after | 725 // The synchronous compositor makes no guarantees about a draw coming in after |
731 // an invalidate so clear any flags that would cause the compositor's pipeline | 726 // an invalidate so clear any flags that would cause the compositor's pipeline |
732 // to stall. | 727 // to stall. |
733 active_tree_needs_first_draw_ = false; // blocks commit if true | 728 active_tree_needs_first_draw_ = false; // blocks commit if true |
734 } | 729 } |
735 | 730 |
736 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { | 731 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { |
737 TRACE_EVENT_INSTANT0("cc", "Scheduler: SkipNextBeginMainFrameToReduceLatency", | 732 TRACE_EVENT_INSTANT0("cc", |
| 733 "Scheduler: SkipNextBeginMainFrameToReduceLatency", |
738 TRACE_EVENT_SCOPE_THREAD); | 734 TRACE_EVENT_SCOPE_THREAD); |
739 skip_next_begin_main_frame_to_reduce_latency_ = true; | 735 skip_next_begin_main_frame_to_reduce_latency_ = true; |
740 } | 736 } |
741 | 737 |
742 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { | 738 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { |
743 return video_needs_begin_frames_; | 739 return video_needs_begin_frames_; |
744 } | 740 } |
745 | 741 |
746 bool SchedulerStateMachine::BeginFrameNeeded() const { | 742 bool SchedulerStateMachine::BeginFrameNeeded() const { |
747 // We can't handle BeginFrames when output surface isn't initialized. | 743 // We can't handle BeginFrames when output surface isn't initialized. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 // funnels so that we don't perform any actions that we shouldn't. | 865 // funnels so that we don't perform any actions that we shouldn't. |
870 if (!BeginFrameNeeded()) | 866 if (!BeginFrameNeeded()) |
871 send_begin_main_frame_funnel_ = true; | 867 send_begin_main_frame_funnel_ = true; |
872 } | 868 } |
873 | 869 |
874 SchedulerStateMachine::BeginImplFrameDeadlineMode | 870 SchedulerStateMachine::BeginImplFrameDeadlineMode |
875 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { | 871 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { |
876 if (settings_.using_synchronous_renderer_compositor) { | 872 if (settings_.using_synchronous_renderer_compositor) { |
877 // No deadline for synchronous compositor. | 873 // No deadline for synchronous compositor. |
878 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; | 874 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; |
879 } else if (wait_for_ready_to_draw_) { | |
880 // In browser compositor, wait for active tree to be rasterized. | |
881 DCHECK(settings_.commit_to_active_tree); | |
882 return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW; | |
883 } else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) { | 875 } else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) { |
884 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE; | 876 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE; |
| 877 } else if (wait_for_ready_to_draw_) { |
| 878 // When we are waiting for ready to draw signal, we do not wait to post a |
| 879 // deadline yet. |
| 880 return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW; |
885 } else if (needs_redraw_) { | 881 } else if (needs_redraw_) { |
886 // We have an animation or fast input path on the impl thread that wants | 882 // We have an animation or fast input path on the impl thread that wants |
887 // to draw, so don't wait too long for a new active tree. | 883 // to draw, so don't wait too long for a new active tree. |
888 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR; | 884 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR; |
889 } else { | 885 } else { |
890 // The impl thread doesn't have anything it wants to draw and we are just | 886 // The impl thread doesn't have anything it wants to draw and we are just |
891 // waiting for a new active tree. In short we are blocked. | 887 // waiting for a new active tree. In short we are blocked. |
892 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; | 888 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; |
893 } | 889 } |
894 } | 890 } |
895 | 891 |
896 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() | 892 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() |
897 const { | 893 const { |
898 // If we just forced activation, we should end the deadline right now. | 894 // If we just forced activation, we should end the deadline right now. |
899 if (PendingActivationsShouldBeForced() && !has_pending_tree_) | 895 if (PendingActivationsShouldBeForced() && !has_pending_tree_) |
900 return true; | 896 return true; |
901 | 897 |
| 898 // Do not trigger deadline immediately if we're waiting for READY_TO_DRAW |
| 899 // unless it's one of the forced cases. |
| 900 if (wait_for_ready_to_draw_) |
| 901 return false; |
| 902 |
902 // SwapAck throttle the deadline since we wont draw and swap anyway. | 903 // SwapAck throttle the deadline since we wont draw and swap anyway. |
903 if (SwapThrottled()) | 904 if (SwapThrottled()) |
904 return false; | 905 return false; |
905 | 906 |
906 if (active_tree_needs_first_draw_) | 907 if (active_tree_needs_first_draw_) |
907 return true; | 908 return true; |
908 | 909 |
909 if (!needs_redraw_) | 910 if (!needs_redraw_) |
910 return false; | 911 return false; |
911 | 912 |
912 // This is used to prioritize impl-thread draws when the main thread isn't | 913 // This is used to prioritize impl-thread draws when the main thread isn't |
913 // producing anything, e.g., after an aborted commit. We also check that we | 914 // producing anything, e.g., after an aborted commit. We also check that we |
914 // don't have a pending tree -- otherwise we should give it a chance to | 915 // don't have a pending tree -- otherwise we should give it a chance to |
915 // activate. | 916 // activate. |
916 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. | 917 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. |
917 if (!CommitPending() && !has_pending_tree_) | 918 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE && |
| 919 !has_pending_tree_) |
918 return true; | 920 return true; |
919 | 921 |
920 // Prioritize impl-thread draws in ImplLatencyTakesPriority mode. | 922 // Prioritize impl-thread draws in ImplLatencyTakesPriority mode. |
921 if (ImplLatencyTakesPriority()) | 923 if (ImplLatencyTakesPriority()) |
922 return true; | 924 return true; |
923 | 925 |
924 return false; | 926 return false; |
925 } | 927 } |
926 | 928 |
927 bool SchedulerStateMachine::SwapThrottled() const { | 929 bool SchedulerStateMachine::SwapThrottled() const { |
(...skipping 16 matching lines...) Expand all Loading... |
944 | 946 |
945 void SchedulerStateMachine::SetBeginFrameSourcePaused(bool paused) { | 947 void SchedulerStateMachine::SetBeginFrameSourcePaused(bool paused) { |
946 begin_frame_source_paused_ = paused; | 948 begin_frame_source_paused_ = paused; |
947 } | 949 } |
948 | 950 |
949 void SchedulerStateMachine::SetResourcelessSoftwareDraw( | 951 void SchedulerStateMachine::SetResourcelessSoftwareDraw( |
950 bool resourceless_draw) { | 952 bool resourceless_draw) { |
951 resourceless_draw_ = resourceless_draw; | 953 resourceless_draw_ = resourceless_draw; |
952 } | 954 } |
953 | 955 |
954 void SchedulerStateMachine::SetCanDraw(bool can_draw) { | 956 void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; } |
955 can_draw_ = can_draw; | |
956 } | |
957 | 957 |
958 void SchedulerStateMachine::SetNeedsRedraw() { | 958 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } |
959 needs_redraw_ = true; | |
960 } | |
961 | 959 |
962 bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const { | 960 bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const { |
963 bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_; | 961 bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_; |
964 bool main_updates_expected = | 962 bool main_updates_expected = |
965 needs_begin_main_frame_ || | 963 needs_begin_main_frame_ || |
966 begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE || | 964 begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE || |
967 has_pending_tree_; | 965 has_pending_tree_; |
968 return has_impl_updates && !main_updates_expected; | 966 return has_impl_updates && !main_updates_expected; |
969 } | 967 } |
970 | 968 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 } | 1022 } |
1025 | 1023 |
1026 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { | 1024 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { |
1027 needs_one_begin_impl_frame_ = true; | 1025 needs_one_begin_impl_frame_ = true; |
1028 } | 1026 } |
1029 | 1027 |
1030 void SchedulerStateMachine::NotifyReadyToCommit() { | 1028 void SchedulerStateMachine::NotifyReadyToCommit() { |
1031 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) | 1029 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) |
1032 << AsValue()->ToString(); | 1030 << AsValue()->ToString(); |
1033 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; | 1031 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; |
1034 // In commit_to_active_tree mode, commit should happen right after BeginFrame, | 1032 // In commit_to_active_tree mode, commit should happen right after |
1035 // meaning when this function is called, next action should be commit. | 1033 // BeginFrame, meaning when this function is called, next action should be |
| 1034 // commit. |
1036 if (settings_.commit_to_active_tree) | 1035 if (settings_.commit_to_active_tree) |
1037 DCHECK(ShouldCommit()); | 1036 DCHECK(ShouldCommit()); |
1038 } | 1037 } |
1039 | 1038 |
1040 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { | 1039 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { |
1041 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); | 1040 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); |
1042 | 1041 |
1043 // If the main thread aborted, it doesn't matter if the main thread missed | 1042 // If the main thread aborted, it doesn't matter if the main thread missed |
1044 // the last deadline since it didn't have an update anyway. | 1043 // the last deadline since it didn't have an update anyway. |
1045 main_thread_missed_last_deadline_ = false; | 1044 main_thread_missed_last_deadline_ = false; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 case COMPOSITOR_FRAME_SINK_ACTIVE: | 1110 case COMPOSITOR_FRAME_SINK_ACTIVE: |
1112 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: | 1111 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
1113 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: | 1112 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
1114 return true; | 1113 return true; |
1115 } | 1114 } |
1116 NOTREACHED(); | 1115 NOTREACHED(); |
1117 return false; | 1116 return false; |
1118 } | 1117 } |
1119 | 1118 |
1120 } // namespace cc | 1119 } // namespace cc |
OLD | NEW |