| 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" |
| 11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "cc/output/begin_frame_args.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 // Surfaces and CompositorTimingHistory don't support more than 1 pending swap. | 18 // Surfaces and CompositorTimingHistory don't support more than 1 pending swap. |
| 18 const int kMaxPendingSubmitFrames = 1; | 19 const int kMaxPendingSubmitFrames = 1; |
| 19 } // namespace | 20 } // namespace |
| 20 | 21 |
| 21 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) | 22 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
| 22 : settings_(settings), | 23 : settings_(settings), |
| 23 compositor_frame_sink_state_(COMPOSITOR_FRAME_SINK_NONE), | 24 compositor_frame_sink_state_(COMPOSITOR_FRAME_SINK_NONE), |
| 24 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), | 25 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), |
| 25 begin_main_frame_state_(BEGIN_MAIN_FRAME_STATE_IDLE), | 26 begin_main_frame_state_(BEGIN_MAIN_FRAME_STATE_IDLE), |
| 26 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), | 27 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), |
| 28 begin_frame_source_id_(0), |
| 29 begin_frame_sequence_number_(BeginFrameArgs::kInvalidFrameNumber), |
| 30 last_begin_frame_sequence_number_begin_main_frame_sent_( |
| 31 BeginFrameArgs::kInvalidFrameNumber), |
| 32 last_begin_frame_sequence_number_pending_tree_was_fresh_( |
| 33 BeginFrameArgs::kInvalidFrameNumber), |
| 34 last_begin_frame_sequence_number_active_tree_was_fresh_( |
| 35 BeginFrameArgs::kInvalidFrameNumber), |
| 36 last_begin_frame_sequence_number_compositor_frame_was_fresh_( |
| 37 BeginFrameArgs::kInvalidFrameNumber), |
| 27 commit_count_(0), | 38 commit_count_(0), |
| 28 current_frame_number_(0), | 39 current_frame_number_(0), |
| 29 last_frame_number_submit_performed_(-1), | 40 last_frame_number_submit_performed_(-1), |
| 30 last_frame_number_draw_performed_(-1), | 41 last_frame_number_draw_performed_(-1), |
| 31 last_frame_number_begin_main_frame_sent_(-1), | 42 last_frame_number_begin_main_frame_sent_(-1), |
| 32 last_frame_number_invalidate_compositor_frame_sink_performed_(-1), | 43 last_frame_number_invalidate_compositor_frame_sink_performed_(-1), |
| 33 draw_funnel_(false), | 44 draw_funnel_(false), |
| 34 send_begin_main_frame_funnel_(true), | 45 send_begin_main_frame_funnel_(true), |
| 35 invalidate_compositor_frame_sink_funnel_(false), | 46 invalidate_compositor_frame_sink_funnel_(false), |
| 36 impl_side_invalidation_funnel_(false), | 47 impl_side_invalidation_funnel_(false), |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 224 |
| 214 state->BeginDictionary("minor_state"); | 225 state->BeginDictionary("minor_state"); |
| 215 state->SetInteger("commit_count", commit_count_); | 226 state->SetInteger("commit_count", commit_count_); |
| 216 state->SetInteger("current_frame_number", current_frame_number_); | 227 state->SetInteger("current_frame_number", current_frame_number_); |
| 217 state->SetInteger("last_frame_number_submit_performed", | 228 state->SetInteger("last_frame_number_submit_performed", |
| 218 last_frame_number_submit_performed_); | 229 last_frame_number_submit_performed_); |
| 219 state->SetInteger("last_frame_number_draw_performed", | 230 state->SetInteger("last_frame_number_draw_performed", |
| 220 last_frame_number_draw_performed_); | 231 last_frame_number_draw_performed_); |
| 221 state->SetInteger("last_frame_number_begin_main_frame_sent", | 232 state->SetInteger("last_frame_number_begin_main_frame_sent", |
| 222 last_frame_number_begin_main_frame_sent_); | 233 last_frame_number_begin_main_frame_sent_); |
| 234 state->SetInteger("begin_frame_source_id", begin_frame_source_id_); |
| 235 state->SetInteger("begin_frame_sequence_number", |
| 236 begin_frame_sequence_number_); |
| 237 state->SetInteger("last_begin_frame_sequence_number_begin_main_frame_sent", |
| 238 last_begin_frame_sequence_number_begin_main_frame_sent_); |
| 239 state->SetInteger("last_begin_frame_sequence_number_pending_tree_was_fresh", |
| 240 last_begin_frame_sequence_number_pending_tree_was_fresh_); |
| 241 state->SetInteger("last_begin_frame_sequence_number_active_tree_was_fresh", |
| 242 last_begin_frame_sequence_number_active_tree_was_fresh_); |
| 243 state->SetInteger( |
| 244 "last_begin_frame_sequence_number_compositor_frame_was_fresh", |
| 245 last_begin_frame_sequence_number_compositor_frame_was_fresh_); |
| 223 state->SetBoolean("funnel: draw_funnel", draw_funnel_); | 246 state->SetBoolean("funnel: draw_funnel", draw_funnel_); |
| 224 state->SetBoolean("funnel: send_begin_main_frame_funnel", | 247 state->SetBoolean("funnel: send_begin_main_frame_funnel", |
| 225 send_begin_main_frame_funnel_); | 248 send_begin_main_frame_funnel_); |
| 226 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); | 249 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); |
| 227 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", | 250 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", |
| 228 invalidate_compositor_frame_sink_funnel_); | 251 invalidate_compositor_frame_sink_funnel_); |
| 229 state->SetBoolean("funnel: impl_side_invalidation_funnel", | 252 state->SetBoolean("funnel: impl_side_invalidation_funnel", |
| 230 impl_side_invalidation_funnel_); | 253 impl_side_invalidation_funnel_); |
| 231 state->SetInteger("consecutive_checkerboard_animations", | 254 state->SetInteger("consecutive_checkerboard_animations", |
| 232 consecutive_checkerboard_animations_); | 255 consecutive_checkerboard_animations_); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 WillPerformImplSideInvalidationInternal(); | 646 WillPerformImplSideInvalidationInternal(); |
| 624 } | 647 } |
| 625 | 648 |
| 626 void SchedulerStateMachine::WillPerformImplSideInvalidationInternal() { | 649 void SchedulerStateMachine::WillPerformImplSideInvalidationInternal() { |
| 627 DCHECK(needs_impl_side_invalidation_); | 650 DCHECK(needs_impl_side_invalidation_); |
| 628 DCHECK(!has_pending_tree_); | 651 DCHECK(!has_pending_tree_); |
| 629 | 652 |
| 630 needs_impl_side_invalidation_ = false; | 653 needs_impl_side_invalidation_ = false; |
| 631 has_pending_tree_ = true; | 654 has_pending_tree_ = true; |
| 632 impl_side_invalidation_funnel_ = true; | 655 impl_side_invalidation_funnel_ = true; |
| 656 // TODO(eseckler): Track impl-side invalidations for pending/active tree and |
| 657 // CompositorFrame freshness computation. |
| 633 } | 658 } |
| 634 | 659 |
| 635 bool SchedulerStateMachine::CouldCreatePendingTree() const { | 660 bool SchedulerStateMachine::CouldCreatePendingTree() const { |
| 636 // Can't create a new pending tree till the current one is activated. | 661 // Can't create a new pending tree till the current one is activated. |
| 637 if (has_pending_tree_) | 662 if (has_pending_tree_) |
| 638 return false; | 663 return false; |
| 639 | 664 |
| 640 // Can't make frames while we're invisible. | 665 // Can't make frames while we're invisible. |
| 641 if (!visible_) | 666 if (!visible_) |
| 642 return false; | 667 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 655 | 680 |
| 656 void SchedulerStateMachine::WillSendBeginMainFrame() { | 681 void SchedulerStateMachine::WillSendBeginMainFrame() { |
| 657 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); | 682 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); |
| 658 DCHECK(visible_); | 683 DCHECK(visible_); |
| 659 DCHECK(!begin_frame_source_paused_); | 684 DCHECK(!begin_frame_source_paused_); |
| 660 DCHECK(!send_begin_main_frame_funnel_); | 685 DCHECK(!send_begin_main_frame_funnel_); |
| 661 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; | 686 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; |
| 662 needs_begin_main_frame_ = false; | 687 needs_begin_main_frame_ = false; |
| 663 send_begin_main_frame_funnel_ = true; | 688 send_begin_main_frame_funnel_ = true; |
| 664 last_frame_number_begin_main_frame_sent_ = current_frame_number_; | 689 last_frame_number_begin_main_frame_sent_ = current_frame_number_; |
| 690 last_begin_frame_sequence_number_begin_main_frame_sent_ = |
| 691 begin_frame_sequence_number_; |
| 665 } | 692 } |
| 666 | 693 |
| 667 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { | 694 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { |
| 668 DCHECK(!has_pending_tree_ || | 695 DCHECK(!has_pending_tree_ || |
| 669 (settings_.main_frame_before_activation_enabled && | 696 (settings_.main_frame_before_activation_enabled && |
| 670 commit_has_no_updates)); | 697 commit_has_no_updates)); |
| 671 commit_count_++; | 698 commit_count_++; |
| 672 last_commit_had_no_updates_ = commit_has_no_updates; | 699 last_commit_had_no_updates_ = commit_has_no_updates; |
| 673 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 700 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
| 674 | 701 |
| 675 if (!commit_has_no_updates) { | 702 if (commit_has_no_updates) { |
| 703 // Pending tree might still exist from prior commit. |
| 704 if (has_pending_tree_) { |
| 705 DCHECK(settings_.main_frame_before_activation_enabled); |
| 706 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 707 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 708 } else { |
| 709 if (last_begin_frame_sequence_number_compositor_frame_was_fresh_ == |
| 710 last_begin_frame_sequence_number_active_tree_was_fresh_) { |
| 711 // Assuming that SetNeedsRedraw() is only called at the beginning of |
| 712 // a BeginFrame, we can update the compositor frame freshness. |
| 713 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 714 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 715 } |
| 716 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 717 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 718 } |
| 719 } else { |
| 676 // If there was a commit, the impl-side invalidations will be merged with | 720 // If there was a commit, the impl-side invalidations will be merged with |
| 677 // it. We always fill the impl-side invalidation funnel here, even if no | 721 // it. We always fill the impl-side invalidation funnel here, even if no |
| 678 // request was currently pending, to defer creating another pending tree and | 722 // request was currently pending, to defer creating another pending tree and |
| 679 // performing PrepareTiles until the next frame, in case the invalidation | 723 // performing PrepareTiles until the next frame, in case the invalidation |
| 680 // request is received after the commit. | 724 // request is received after the commit. |
| 681 if (needs_impl_side_invalidation_) | 725 if (needs_impl_side_invalidation_) |
| 682 WillPerformImplSideInvalidationInternal(); | 726 WillPerformImplSideInvalidationInternal(); |
| 683 impl_side_invalidation_funnel_ = true; | 727 impl_side_invalidation_funnel_ = true; |
| 684 | 728 |
| 685 // Pending tree only exists if commit had updates. | 729 // We have a new pending tree. |
| 686 has_pending_tree_ = true; | 730 has_pending_tree_ = true; |
| 687 pending_tree_is_ready_for_activation_ = false; | 731 pending_tree_is_ready_for_activation_ = false; |
| 732 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 733 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 688 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; | 734 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; |
| 689 } | 735 } |
| 690 | 736 |
| 691 // Update state related to forced draws. | 737 // Update state related to forced draws. |
| 692 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 738 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
| 693 forced_redraw_state_ = has_pending_tree_ | 739 forced_redraw_state_ = has_pending_tree_ |
| 694 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 740 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
| 695 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 741 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 696 } | 742 } |
| 697 | 743 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 709 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) | 755 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) |
| 710 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; | 756 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; |
| 711 | 757 |
| 712 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) | 758 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) |
| 713 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 759 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 714 | 760 |
| 715 has_pending_tree_ = false; | 761 has_pending_tree_ = false; |
| 716 pending_tree_is_ready_for_activation_ = false; | 762 pending_tree_is_ready_for_activation_ = false; |
| 717 active_tree_needs_first_draw_ = true; | 763 active_tree_needs_first_draw_ = true; |
| 718 needs_redraw_ = true; | 764 needs_redraw_ = true; |
| 765 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 766 last_begin_frame_sequence_number_pending_tree_was_fresh_; |
| 719 | 767 |
| 720 previous_pending_tree_was_impl_side_ = current_pending_tree_is_impl_side_; | 768 previous_pending_tree_was_impl_side_ = current_pending_tree_is_impl_side_; |
| 721 current_pending_tree_is_impl_side_ = false; | 769 current_pending_tree_is_impl_side_ = false; |
| 722 } | 770 } |
| 723 | 771 |
| 724 void SchedulerStateMachine::WillDrawInternal() { | 772 void SchedulerStateMachine::WillDrawInternal() { |
| 725 // If a new active tree is pending after the one we are about to draw, | 773 // If a new active tree is pending after the one we are about to draw, |
| 726 // the main thread is in a high latency mode. | 774 // the main thread is in a high latency mode. |
| 727 // main_thread_missed_last_deadline_ is here in addition to | 775 // main_thread_missed_last_deadline_ is here in addition to |
| 728 // OnBeginImplFrameIdle for cases where the scheduler aborts draws outside | 776 // OnBeginImplFrameIdle for cases where the scheduler aborts draws outside |
| (...skipping 14 matching lines...) Expand all Loading... |
| 743 } | 791 } |
| 744 | 792 |
| 745 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { | 793 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { |
| 746 switch (draw_result) { | 794 switch (draw_result) { |
| 747 case INVALID_RESULT: | 795 case INVALID_RESULT: |
| 748 case DRAW_ABORTED_CANT_DRAW: | 796 case DRAW_ABORTED_CANT_DRAW: |
| 749 case DRAW_ABORTED_CONTEXT_LOST: | 797 case DRAW_ABORTED_CONTEXT_LOST: |
| 750 NOTREACHED() << "Invalid return DrawResult:" << draw_result; | 798 NOTREACHED() << "Invalid return DrawResult:" << draw_result; |
| 751 break; | 799 break; |
| 752 case DRAW_ABORTED_DRAINING_PIPELINE: | 800 case DRAW_ABORTED_DRAINING_PIPELINE: |
| 801 consecutive_checkerboard_animations_ = 0; |
| 802 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 803 break; |
| 753 case DRAW_SUCCESS: | 804 case DRAW_SUCCESS: |
| 754 consecutive_checkerboard_animations_ = 0; | 805 consecutive_checkerboard_animations_ = 0; |
| 755 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 806 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 807 // The draw either didn't have damage or had damage and submitted a |
| 808 // CompositorFrame. In either case, the compositor frame freshness should |
| 809 // be updated to match the active tree. |
| 810 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 811 last_begin_frame_sequence_number_active_tree_was_fresh_; |
| 756 break; | 812 break; |
| 757 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | 813 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: |
| 758 DCHECK(!did_submit_in_last_frame_); | 814 DCHECK(!did_submit_in_last_frame_); |
| 759 needs_begin_main_frame_ = true; | 815 needs_begin_main_frame_ = true; |
| 760 needs_redraw_ = true; | 816 needs_redraw_ = true; |
| 761 consecutive_checkerboard_animations_++; | 817 consecutive_checkerboard_animations_++; |
| 762 | 818 |
| 763 if (consecutive_checkerboard_animations_ >= | 819 if (consecutive_checkerboard_animations_ >= |
| 764 settings_.maximum_number_of_failed_draws_before_draw_is_forced && | 820 settings_.maximum_number_of_failed_draws_before_draw_is_forced && |
| 765 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && | 821 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 return true; | 969 return true; |
| 914 | 970 |
| 915 // If the last commit was aborted because of early out (no updates), we should | 971 // If the last commit was aborted because of early out (no updates), we should |
| 916 // still want a begin frame in case there is a commit coming again. | 972 // still want a begin frame in case there is a commit coming again. |
| 917 if (last_commit_had_no_updates_) | 973 if (last_commit_had_no_updates_) |
| 918 return true; | 974 return true; |
| 919 | 975 |
| 920 return false; | 976 return false; |
| 921 } | 977 } |
| 922 | 978 |
| 923 void SchedulerStateMachine::OnBeginImplFrame() { | 979 void SchedulerStateMachine::OnBeginFrameDroppedNotObserving( |
| 980 uint32_t source_id, |
| 981 uint64_t sequence_number) { |
| 982 DCHECK(!BeginFrameNeeded()); |
| 983 DCHECK_EQ(BEGIN_IMPL_FRAME_STATE_IDLE, begin_impl_frame_state_); |
| 984 |
| 985 // Confirms the dropped BeginFrame, since we don't have updates. |
| 986 UpdateBeginFrameSequenceNumbersForBeginFrame(source_id, sequence_number); |
| 987 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 988 } |
| 989 |
| 990 void SchedulerStateMachine::UpdateBeginFrameSequenceNumbersForBeginFrame( |
| 991 uint32_t source_id, |
| 992 uint64_t sequence_number) { |
| 993 if (source_id != begin_frame_source_id_) { |
| 994 begin_frame_source_id_ = source_id; |
| 995 begin_frame_sequence_number_ = sequence_number; |
| 996 |
| 997 // Reset freshness sequence numbers. |
| 998 last_begin_frame_sequence_number_begin_main_frame_sent_ = |
| 999 BeginFrameArgs::kInvalidFrameNumber; |
| 1000 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 1001 BeginFrameArgs::kInvalidFrameNumber; |
| 1002 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 1003 BeginFrameArgs::kInvalidFrameNumber; |
| 1004 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 1005 BeginFrameArgs::kInvalidFrameNumber; |
| 1006 } else { |
| 1007 DCHECK_GT(sequence_number, begin_frame_sequence_number_); |
| 1008 begin_frame_sequence_number_ = sequence_number; |
| 1009 } |
| 1010 } |
| 1011 |
| 1012 void SchedulerStateMachine:: |
| 1013 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline() { |
| 1014 // Update frame numbers for freshness in case no updates were necessary. |
| 1015 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE || |
| 1016 needs_begin_main_frame_) { |
| 1017 return; |
| 1018 } |
| 1019 |
| 1020 if (has_pending_tree_) { |
| 1021 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 1022 begin_frame_sequence_number_; |
| 1023 return; |
| 1024 } |
| 1025 |
| 1026 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 1027 begin_frame_sequence_number_; |
| 1028 |
| 1029 if (!needs_redraw_) |
| 1030 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 1031 begin_frame_sequence_number_; |
| 1032 } |
| 1033 |
| 1034 void SchedulerStateMachine::OnBeginImplFrame(uint32_t source_id, |
| 1035 uint64_t sequence_number) { |
| 1036 UpdateBeginFrameSequenceNumbersForBeginFrame(source_id, sequence_number); |
| 1037 |
| 924 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; | 1038 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; |
| 925 current_frame_number_++; | 1039 current_frame_number_++; |
| 926 | 1040 |
| 927 last_commit_had_no_updates_ = false; | 1041 last_commit_had_no_updates_ = false; |
| 928 did_draw_in_last_frame_ = false; | 1042 did_draw_in_last_frame_ = false; |
| 929 did_submit_in_last_frame_ = false; | 1043 did_submit_in_last_frame_ = false; |
| 930 needs_one_begin_impl_frame_ = false; | 1044 needs_one_begin_impl_frame_ = false; |
| 931 | 1045 |
| 932 // Clear funnels for any actions we perform during the frame. | 1046 // Clear funnels for any actions we perform during the frame. |
| 933 send_begin_main_frame_funnel_ = false; | 1047 send_begin_main_frame_funnel_ = false; |
| 934 invalidate_compositor_frame_sink_funnel_ = false; | 1048 invalidate_compositor_frame_sink_funnel_ = false; |
| 935 impl_side_invalidation_funnel_ = false; | 1049 impl_side_invalidation_funnel_ = false; |
| 936 | 1050 |
| 937 // "Drain" the PrepareTiles funnel. | 1051 // "Drain" the PrepareTiles funnel. |
| 938 if (prepare_tiles_funnel_ > 0) | 1052 if (prepare_tiles_funnel_ > 0) |
| 939 prepare_tiles_funnel_--; | 1053 prepare_tiles_funnel_--; |
| 940 } | 1054 } |
| 941 | 1055 |
| 942 void SchedulerStateMachine::OnBeginImplFrameDeadline() { | 1056 void SchedulerStateMachine::OnBeginImplFrameDeadline() { |
| 943 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; | 1057 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; |
| 944 | 1058 |
| 945 // Clear funnels for any actions we perform during the deadline. | 1059 // Clear funnels for any actions we perform during the deadline. |
| 946 draw_funnel_ = false; | 1060 draw_funnel_ = false; |
| 947 | 1061 |
| 948 // Allow one PrepareTiles per draw for synchronous compositor. | 1062 // Allow one PrepareTiles per draw for synchronous compositor. |
| 949 if (settings_.using_synchronous_renderer_compositor) { | 1063 if (settings_.using_synchronous_renderer_compositor) { |
| 950 if (prepare_tiles_funnel_ > 0) | 1064 if (prepare_tiles_funnel_ > 0) |
| 951 prepare_tiles_funnel_--; | 1065 prepare_tiles_funnel_--; |
| 952 } | 1066 } |
| 1067 |
| 1068 if (!settings_.using_synchronous_renderer_compositor) |
| 1069 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 953 } | 1070 } |
| 954 | 1071 |
| 955 void SchedulerStateMachine::OnBeginImplFrameIdle() { | 1072 void SchedulerStateMachine::OnBeginImplFrameIdle() { |
| 956 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; | 1073 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; |
| 957 | 1074 |
| 958 skip_next_begin_main_frame_to_reduce_latency_ = false; | 1075 skip_next_begin_main_frame_to_reduce_latency_ = false; |
| 959 | 1076 |
| 960 // If a new or undrawn active tree is pending after the deadline, | 1077 // If a new or undrawn active tree is pending after the deadline, |
| 961 // then the main thread is in a high latency mode. | 1078 // then the main thread is in a high latency mode. |
| 962 main_thread_missed_last_deadline_ = | 1079 main_thread_missed_last_deadline_ = |
| 963 CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_; | 1080 CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_; |
| 964 | 1081 |
| 965 // If we're entering a state where we won't get BeginFrames set all the | 1082 // If we're entering a state where we won't get BeginFrames set all the |
| 966 // funnels so that we don't perform any actions that we shouldn't. | 1083 // funnels so that we don't perform any actions that we shouldn't. |
| 967 if (!BeginFrameNeeded()) | 1084 if (!BeginFrameNeeded()) |
| 968 send_begin_main_frame_funnel_ = true; | 1085 send_begin_main_frame_funnel_ = true; |
| 1086 |
| 1087 // Synchronous compositor finishes BeginFrames before triggering their |
| 1088 // deadline. Therefore, we update sequence numbers when becoming idle, before |
| 1089 // the Scheduler sends its BeginFrameAck. |
| 1090 if (settings_.using_synchronous_renderer_compositor) |
| 1091 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 969 } | 1092 } |
| 970 | 1093 |
| 971 SchedulerStateMachine::BeginImplFrameDeadlineMode | 1094 SchedulerStateMachine::BeginImplFrameDeadlineMode |
| 972 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { | 1095 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { |
| 973 if (settings_.using_synchronous_renderer_compositor) { | 1096 if (settings_.using_synchronous_renderer_compositor) { |
| 974 // No deadline for synchronous compositor. | 1097 // No deadline for synchronous compositor. |
| 975 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; | 1098 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; |
| 976 } else if (wait_for_ready_to_draw_) { | 1099 } else if (wait_for_ready_to_draw_) { |
| 977 // In browser compositor, wait for active tree to be rasterized. | 1100 // In browser compositor, wait for active tree to be rasterized. |
| 978 DCHECK(settings_.commit_to_active_tree); | 1101 DCHECK(settings_.commit_to_active_tree); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 case COMPOSITOR_FRAME_SINK_ACTIVE: | 1332 case COMPOSITOR_FRAME_SINK_ACTIVE: |
| 1210 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: | 1333 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
| 1211 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: | 1334 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
| 1212 return true; | 1335 return true; |
| 1213 } | 1336 } |
| 1214 NOTREACHED(); | 1337 NOTREACHED(); |
| 1215 return false; | 1338 return false; |
| 1216 } | 1339 } |
| 1217 | 1340 |
| 1218 } // namespace cc | 1341 } // namespace cc |
| OLD | NEW |