| 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 prepare_tiles_funnel_(0), | 47 prepare_tiles_funnel_(0), |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 218 |
| 208 state->BeginDictionary("minor_state"); | 219 state->BeginDictionary("minor_state"); |
| 209 state->SetInteger("commit_count", commit_count_); | 220 state->SetInteger("commit_count", commit_count_); |
| 210 state->SetInteger("current_frame_number", current_frame_number_); | 221 state->SetInteger("current_frame_number", current_frame_number_); |
| 211 state->SetInteger("last_frame_number_submit_performed", | 222 state->SetInteger("last_frame_number_submit_performed", |
| 212 last_frame_number_submit_performed_); | 223 last_frame_number_submit_performed_); |
| 213 state->SetInteger("last_frame_number_draw_performed", | 224 state->SetInteger("last_frame_number_draw_performed", |
| 214 last_frame_number_draw_performed_); | 225 last_frame_number_draw_performed_); |
| 215 state->SetInteger("last_frame_number_begin_main_frame_sent", | 226 state->SetInteger("last_frame_number_begin_main_frame_sent", |
| 216 last_frame_number_begin_main_frame_sent_); | 227 last_frame_number_begin_main_frame_sent_); |
| 228 state->SetInteger("begin_frame_source_id", begin_frame_source_id_); |
| 229 state->SetInteger("begin_frame_sequence_number", |
| 230 begin_frame_sequence_number_); |
| 231 state->SetInteger("last_begin_frame_sequence_number_begin_main_frame_sent", |
| 232 last_begin_frame_sequence_number_begin_main_frame_sent_); |
| 233 state->SetInteger("last_begin_frame_sequence_number_pending_tree_was_fresh", |
| 234 last_begin_frame_sequence_number_pending_tree_was_fresh_); |
| 235 state->SetInteger("last_begin_frame_sequence_number_active_tree_was_fresh", |
| 236 last_begin_frame_sequence_number_active_tree_was_fresh_); |
| 237 state->SetInteger( |
| 238 "last_begin_frame_sequence_number_compositor_frame_was_fresh", |
| 239 last_begin_frame_sequence_number_compositor_frame_was_fresh_); |
| 217 state->SetBoolean("funnel: draw_funnel", draw_funnel_); | 240 state->SetBoolean("funnel: draw_funnel", draw_funnel_); |
| 218 state->SetBoolean("funnel: send_begin_main_frame_funnel", | 241 state->SetBoolean("funnel: send_begin_main_frame_funnel", |
| 219 send_begin_main_frame_funnel_); | 242 send_begin_main_frame_funnel_); |
| 220 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); | 243 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); |
| 221 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", | 244 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", |
| 222 invalidate_compositor_frame_sink_funnel_); | 245 invalidate_compositor_frame_sink_funnel_); |
| 223 state->SetInteger("consecutive_checkerboard_animations", | 246 state->SetInteger("consecutive_checkerboard_animations", |
| 224 consecutive_checkerboard_animations_); | 247 consecutive_checkerboard_animations_); |
| 225 state->SetInteger("pending_submit_frames_", pending_submit_frames_); | 248 state->SetInteger("pending_submit_frames_", pending_submit_frames_); |
| 226 state->SetInteger("submit_frames_with_current_compositor_frame_sink", | 249 state->SetInteger("submit_frames_with_current_compositor_frame_sink", |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 590 |
| 568 void SchedulerStateMachine::WillSendBeginMainFrame() { | 591 void SchedulerStateMachine::WillSendBeginMainFrame() { |
| 569 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); | 592 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); |
| 570 DCHECK(visible_); | 593 DCHECK(visible_); |
| 571 DCHECK(!begin_frame_source_paused_); | 594 DCHECK(!begin_frame_source_paused_); |
| 572 DCHECK(!send_begin_main_frame_funnel_); | 595 DCHECK(!send_begin_main_frame_funnel_); |
| 573 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; | 596 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; |
| 574 needs_begin_main_frame_ = false; | 597 needs_begin_main_frame_ = false; |
| 575 send_begin_main_frame_funnel_ = true; | 598 send_begin_main_frame_funnel_ = true; |
| 576 last_frame_number_begin_main_frame_sent_ = current_frame_number_; | 599 last_frame_number_begin_main_frame_sent_ = current_frame_number_; |
| 600 last_begin_frame_sequence_number_begin_main_frame_sent_ = |
| 601 begin_frame_sequence_number_; |
| 577 } | 602 } |
| 578 | 603 |
| 579 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { | 604 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { |
| 580 DCHECK(!has_pending_tree_ || | 605 DCHECK(!has_pending_tree_ || |
| 581 (settings_.main_frame_before_activation_enabled && | 606 (settings_.main_frame_before_activation_enabled && |
| 582 commit_has_no_updates)); | 607 commit_has_no_updates)); |
| 583 commit_count_++; | 608 commit_count_++; |
| 584 last_commit_had_no_updates_ = commit_has_no_updates; | 609 last_commit_had_no_updates_ = commit_has_no_updates; |
| 585 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 610 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
| 586 | 611 |
| 587 if (!commit_has_no_updates) { | 612 if (commit_has_no_updates) { |
| 588 // Pending tree only exists if commit had updates. | 613 // Pending tree might still exist from prior commit. |
| 614 if (has_pending_tree_) { |
| 615 DCHECK(settings_.main_frame_before_activation_enabled); |
| 616 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 617 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 618 } else { |
| 619 if (last_begin_frame_sequence_number_compositor_frame_was_fresh_ == |
| 620 last_begin_frame_sequence_number_active_tree_was_fresh_) { |
| 621 // Assuming that SetNeedsRedraw() is only called at the beginning of |
| 622 // a BeginFrame, we can update the compositor frame freshness. |
| 623 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 624 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 625 } |
| 626 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 627 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 628 } |
| 629 } else { |
| 630 // We have a new pending tree. |
| 589 has_pending_tree_ = true; | 631 has_pending_tree_ = true; |
| 590 pending_tree_is_ready_for_activation_ = false; | 632 pending_tree_is_ready_for_activation_ = false; |
| 633 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 634 last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 591 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; | 635 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; |
| 592 } | 636 } |
| 593 | 637 |
| 594 // Update state related to forced draws. | 638 // Update state related to forced draws. |
| 595 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 639 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
| 596 forced_redraw_state_ = has_pending_tree_ | 640 forced_redraw_state_ = has_pending_tree_ |
| 597 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 641 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
| 598 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 642 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 599 } | 643 } |
| 600 | 644 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 612 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) | 656 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) |
| 613 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; | 657 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; |
| 614 | 658 |
| 615 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) | 659 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) |
| 616 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 660 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 617 | 661 |
| 618 has_pending_tree_ = false; | 662 has_pending_tree_ = false; |
| 619 pending_tree_is_ready_for_activation_ = false; | 663 pending_tree_is_ready_for_activation_ = false; |
| 620 active_tree_needs_first_draw_ = true; | 664 active_tree_needs_first_draw_ = true; |
| 621 needs_redraw_ = true; | 665 needs_redraw_ = true; |
| 666 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 667 last_begin_frame_sequence_number_pending_tree_was_fresh_; |
| 622 } | 668 } |
| 623 | 669 |
| 624 void SchedulerStateMachine::WillDrawInternal() { | 670 void SchedulerStateMachine::WillDrawInternal() { |
| 625 // If a new active tree is pending after the one we are about to draw, | 671 // If a new active tree is pending after the one we are about to draw, |
| 626 // the main thread is in a high latency mode. | 672 // the main thread is in a high latency mode. |
| 627 // main_thread_missed_last_deadline_ is here in addition to | 673 // main_thread_missed_last_deadline_ is here in addition to |
| 628 // OnBeginImplFrameIdle for cases where the scheduler aborts draws outside | 674 // OnBeginImplFrameIdle for cases where the scheduler aborts draws outside |
| 629 // of the deadline. | 675 // of the deadline. |
| 630 main_thread_missed_last_deadline_ = CommitPending() || has_pending_tree_; | 676 main_thread_missed_last_deadline_ = CommitPending() || has_pending_tree_; |
| 631 | 677 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 643 } | 689 } |
| 644 | 690 |
| 645 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { | 691 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { |
| 646 switch (draw_result) { | 692 switch (draw_result) { |
| 647 case INVALID_RESULT: | 693 case INVALID_RESULT: |
| 648 case DRAW_ABORTED_CANT_DRAW: | 694 case DRAW_ABORTED_CANT_DRAW: |
| 649 case DRAW_ABORTED_CONTEXT_LOST: | 695 case DRAW_ABORTED_CONTEXT_LOST: |
| 650 NOTREACHED() << "Invalid return DrawResult:" << draw_result; | 696 NOTREACHED() << "Invalid return DrawResult:" << draw_result; |
| 651 break; | 697 break; |
| 652 case DRAW_ABORTED_DRAINING_PIPELINE: | 698 case DRAW_ABORTED_DRAINING_PIPELINE: |
| 699 consecutive_checkerboard_animations_ = 0; |
| 700 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 701 break; |
| 653 case DRAW_SUCCESS: | 702 case DRAW_SUCCESS: |
| 654 consecutive_checkerboard_animations_ = 0; | 703 consecutive_checkerboard_animations_ = 0; |
| 655 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 704 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 705 // The draw either didn't have damage or had damage and submitted a |
| 706 // CompositorFrame. In either case, the compositor frame freshness should |
| 707 // be updated to match the active tree. |
| 708 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 709 last_begin_frame_sequence_number_active_tree_was_fresh_; |
| 656 break; | 710 break; |
| 657 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | 711 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: |
| 658 DCHECK(!did_submit_in_last_frame_); | 712 DCHECK(!did_submit_in_last_frame_); |
| 659 needs_begin_main_frame_ = true; | 713 needs_begin_main_frame_ = true; |
| 660 needs_redraw_ = true; | 714 needs_redraw_ = true; |
| 661 consecutive_checkerboard_animations_++; | 715 consecutive_checkerboard_animations_++; |
| 662 | 716 |
| 663 if (consecutive_checkerboard_animations_ >= | 717 if (consecutive_checkerboard_animations_ >= |
| 664 settings_.maximum_number_of_failed_draws_before_draw_is_forced && | 718 settings_.maximum_number_of_failed_draws_before_draw_is_forced && |
| 665 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && | 719 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 return true; | 862 return true; |
| 809 | 863 |
| 810 // If the last commit was aborted because of early out (no updates), we should | 864 // If the last commit was aborted because of early out (no updates), we should |
| 811 // still want a begin frame in case there is a commit coming again. | 865 // still want a begin frame in case there is a commit coming again. |
| 812 if (last_commit_had_no_updates_) | 866 if (last_commit_had_no_updates_) |
| 813 return true; | 867 return true; |
| 814 | 868 |
| 815 return false; | 869 return false; |
| 816 } | 870 } |
| 817 | 871 |
| 818 void SchedulerStateMachine::OnBeginImplFrame() { | 872 void SchedulerStateMachine::OnBeginFrameDroppedNotObserving( |
| 873 uint32_t source_id, |
| 874 uint64_t sequence_number) { |
| 875 DCHECK(!BeginFrameNeeded()); |
| 876 DCHECK_EQ(BEGIN_IMPL_FRAME_STATE_IDLE, begin_impl_frame_state_); |
| 877 |
| 878 // Confirms the dropped BeginFrame, since we don't have updates. |
| 879 UpdateBeginFrameSequenceNumbersForBeginFrame(source_id, sequence_number); |
| 880 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 881 } |
| 882 |
| 883 void SchedulerStateMachine::UpdateBeginFrameSequenceNumbersForBeginFrame( |
| 884 uint32_t source_id, |
| 885 uint64_t sequence_number) { |
| 886 if (source_id != begin_frame_source_id_) { |
| 887 begin_frame_source_id_ = source_id; |
| 888 begin_frame_sequence_number_ = sequence_number; |
| 889 |
| 890 // Reset freshness sequence numbers. |
| 891 last_begin_frame_sequence_number_begin_main_frame_sent_ = |
| 892 BeginFrameArgs::kInvalidFrameNumber; |
| 893 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 894 BeginFrameArgs::kInvalidFrameNumber; |
| 895 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 896 BeginFrameArgs::kInvalidFrameNumber; |
| 897 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 898 BeginFrameArgs::kInvalidFrameNumber; |
| 899 } else { |
| 900 DCHECK_GT(sequence_number, begin_frame_sequence_number_); |
| 901 begin_frame_sequence_number_ = sequence_number; |
| 902 } |
| 903 } |
| 904 |
| 905 void SchedulerStateMachine:: |
| 906 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline() { |
| 907 // Update frame numbers for freshness in case no updates were necessary. |
| 908 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE || |
| 909 needs_begin_main_frame_) { |
| 910 return; |
| 911 } |
| 912 |
| 913 if (has_pending_tree_) { |
| 914 last_begin_frame_sequence_number_pending_tree_was_fresh_ = |
| 915 begin_frame_sequence_number_; |
| 916 return; |
| 917 } |
| 918 |
| 919 last_begin_frame_sequence_number_active_tree_was_fresh_ = |
| 920 begin_frame_sequence_number_; |
| 921 |
| 922 if (!needs_redraw_) |
| 923 last_begin_frame_sequence_number_compositor_frame_was_fresh_ = |
| 924 begin_frame_sequence_number_; |
| 925 } |
| 926 |
| 927 void SchedulerStateMachine::OnBeginImplFrame(uint32_t source_id, |
| 928 uint64_t sequence_number) { |
| 929 UpdateBeginFrameSequenceNumbersForBeginFrame(source_id, sequence_number); |
| 930 |
| 819 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; | 931 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; |
| 820 current_frame_number_++; | 932 current_frame_number_++; |
| 821 | 933 |
| 822 last_commit_had_no_updates_ = false; | 934 last_commit_had_no_updates_ = false; |
| 823 did_draw_in_last_frame_ = false; | 935 did_draw_in_last_frame_ = false; |
| 824 did_submit_in_last_frame_ = false; | 936 did_submit_in_last_frame_ = false; |
| 825 needs_one_begin_impl_frame_ = false; | 937 needs_one_begin_impl_frame_ = false; |
| 826 | 938 |
| 827 // Clear funnels for any actions we perform during the frame. | 939 // Clear funnels for any actions we perform during the frame. |
| 828 send_begin_main_frame_funnel_ = false; | 940 send_begin_main_frame_funnel_ = false; |
| 829 invalidate_compositor_frame_sink_funnel_ = false; | 941 invalidate_compositor_frame_sink_funnel_ = false; |
| 830 | 942 |
| 831 // "Drain" the PrepareTiles funnel. | 943 // "Drain" the PrepareTiles funnel. |
| 832 if (prepare_tiles_funnel_ > 0) | 944 if (prepare_tiles_funnel_ > 0) |
| 833 prepare_tiles_funnel_--; | 945 prepare_tiles_funnel_--; |
| 834 } | 946 } |
| 835 | 947 |
| 836 void SchedulerStateMachine::OnBeginImplFrameDeadline() { | 948 void SchedulerStateMachine::OnBeginImplFrameDeadline() { |
| 837 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; | 949 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; |
| 838 | 950 |
| 839 // Clear funnels for any actions we perform during the deadline. | 951 // Clear funnels for any actions we perform during the deadline. |
| 840 draw_funnel_ = false; | 952 draw_funnel_ = false; |
| 841 | 953 |
| 842 // Allow one PrepareTiles per draw for synchronous compositor. | 954 // Allow one PrepareTiles per draw for synchronous compositor. |
| 843 if (settings_.using_synchronous_renderer_compositor) { | 955 if (settings_.using_synchronous_renderer_compositor) { |
| 844 if (prepare_tiles_funnel_ > 0) | 956 if (prepare_tiles_funnel_ > 0) |
| 845 prepare_tiles_funnel_--; | 957 prepare_tiles_funnel_--; |
| 846 } | 958 } |
| 959 |
| 960 if (!settings_.using_synchronous_renderer_compositor) |
| 961 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 847 } | 962 } |
| 848 | 963 |
| 849 void SchedulerStateMachine::OnBeginImplFrameIdle() { | 964 void SchedulerStateMachine::OnBeginImplFrameIdle() { |
| 850 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; | 965 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; |
| 851 | 966 |
| 852 skip_next_begin_main_frame_to_reduce_latency_ = false; | 967 skip_next_begin_main_frame_to_reduce_latency_ = false; |
| 853 | 968 |
| 854 // If a new or undrawn active tree is pending after the deadline, | 969 // If a new or undrawn active tree is pending after the deadline, |
| 855 // then the main thread is in a high latency mode. | 970 // then the main thread is in a high latency mode. |
| 856 main_thread_missed_last_deadline_ = | 971 main_thread_missed_last_deadline_ = |
| 857 CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_; | 972 CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_; |
| 858 | 973 |
| 859 // If we're entering a state where we won't get BeginFrames set all the | 974 // If we're entering a state where we won't get BeginFrames set all the |
| 860 // funnels so that we don't perform any actions that we shouldn't. | 975 // funnels so that we don't perform any actions that we shouldn't. |
| 861 if (!BeginFrameNeeded()) | 976 if (!BeginFrameNeeded()) |
| 862 send_begin_main_frame_funnel_ = true; | 977 send_begin_main_frame_funnel_ = true; |
| 978 |
| 979 // Synchronous compositor finishes BeginFrames before triggering their |
| 980 // deadline. Therefore, we update sequence numbers when becoming idle, before |
| 981 // the Scheduler sends its BeginFrameAck. |
| 982 if (settings_.using_synchronous_renderer_compositor) |
| 983 UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 863 } | 984 } |
| 864 | 985 |
| 865 SchedulerStateMachine::BeginImplFrameDeadlineMode | 986 SchedulerStateMachine::BeginImplFrameDeadlineMode |
| 866 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { | 987 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { |
| 867 if (settings_.using_synchronous_renderer_compositor) { | 988 if (settings_.using_synchronous_renderer_compositor) { |
| 868 // No deadline for synchronous compositor. | 989 // No deadline for synchronous compositor. |
| 869 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; | 990 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; |
| 870 } else if (wait_for_ready_to_draw_) { | 991 } else if (wait_for_ready_to_draw_) { |
| 871 // In browser compositor, wait for active tree to be rasterized. | 992 // In browser compositor, wait for active tree to be rasterized. |
| 872 DCHECK(settings_.commit_to_active_tree); | 993 DCHECK(settings_.commit_to_active_tree); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 case COMPOSITOR_FRAME_SINK_ACTIVE: | 1224 case COMPOSITOR_FRAME_SINK_ACTIVE: |
| 1104 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: | 1225 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
| 1105 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: | 1226 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
| 1106 return true; | 1227 return true; |
| 1107 } | 1228 } |
| 1108 NOTREACHED(); | 1229 NOTREACHED(); |
| 1109 return false; | 1230 return false; |
| 1110 } | 1231 } |
| 1111 | 1232 |
| 1112 } // namespace cc | 1233 } // namespace cc |
| OLD | NEW |