Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: cc/scheduler/scheduler_state_machine.cc

Issue 1133673004: cc: Heuristic for Renderer latency recovery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 last_frame_number_begin_main_frame_sent_(-1), 28 last_frame_number_begin_main_frame_sent_(-1),
29 last_frame_number_invalidate_output_surface_performed_(-1), 29 last_frame_number_invalidate_output_surface_performed_(-1),
30 animate_funnel_(false), 30 animate_funnel_(false),
31 request_swap_funnel_(false), 31 request_swap_funnel_(false),
32 send_begin_main_frame_funnel_(false), 32 send_begin_main_frame_funnel_(false),
33 invalidate_output_surface_funnel_(false), 33 invalidate_output_surface_funnel_(false),
34 prepare_tiles_funnel_(0), 34 prepare_tiles_funnel_(0),
35 consecutive_checkerboard_animations_(0), 35 consecutive_checkerboard_animations_(0),
36 max_pending_swaps_(1), 36 max_pending_swaps_(1),
37 pending_swaps_(0), 37 pending_swaps_(0),
38 swaps_are_likely_high_latency_(false),
39 swap_throttled_in_last_deadline_(false),
38 needs_redraw_(false), 40 needs_redraw_(false),
39 needs_animate_(false), 41 needs_animate_(false),
40 needs_prepare_tiles_(false), 42 needs_prepare_tiles_(false),
41 needs_commit_(false), 43 needs_commit_(false),
42 visible_(false), 44 visible_(false),
43 can_start_(false), 45 can_start_(false),
44 can_draw_(false), 46 can_draw_(false),
45 has_pending_tree_(false), 47 has_pending_tree_(false),
46 pending_tree_is_ready_for_activation_(false), 48 pending_tree_is_ready_for_activation_(false),
47 active_tree_needs_first_draw_(false), 49 active_tree_needs_first_draw_(false),
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 return true; 813 return true;
812 814
813 // If the last commit was aborted because of early out (no updates), we should 815 // If the last commit was aborted because of early out (no updates), we should
814 // still want a begin frame in case there is a commit coming again. 816 // still want a begin frame in case there is a commit coming again.
815 if (last_commit_had_no_updates_) 817 if (last_commit_had_no_updates_)
816 return true; 818 return true;
817 819
818 return false; 820 return false;
819 } 821 }
820 822
823 void SchedulerStateMachine::DidSkipBeginImplFrameToReduceLatency() {
824 // If there are no swap ack's pending to update swaps_are_likely_high_latency
825 // later, reset it now.
826 if (!pending_swaps_)
827 swaps_are_likely_high_latency_ = false;
828 }
829
821 void SchedulerStateMachine::OnBeginImplFrame() { 830 void SchedulerStateMachine::OnBeginImplFrame() {
822 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; 831 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING;
823 current_frame_number_++; 832 current_frame_number_++;
824 833
825 last_commit_had_no_updates_ = false; 834 last_commit_had_no_updates_ = false;
826 did_request_swap_in_last_frame_ = false; 835 did_request_swap_in_last_frame_ = false;
827 836
828 // Clear funnels for any actions we perform during the frame. 837 // Clear funnels for any actions we perform during the frame.
829 animate_funnel_ = false; 838 animate_funnel_ = false;
830 send_begin_main_frame_funnel_ = false; 839 send_begin_main_frame_funnel_ = false;
(...skipping 12 matching lines...) Expand all
843 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; 852 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME;
844 } 853 }
845 854
846 void SchedulerStateMachine::OnBeginImplFrameDeadline() { 855 void SchedulerStateMachine::OnBeginImplFrameDeadline() {
847 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 856 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
848 857
849 did_perform_swap_in_last_draw_ = false; 858 did_perform_swap_in_last_draw_ = false;
850 859
851 // Clear funnels for any actions we perform during the deadline. 860 // Clear funnels for any actions we perform during the deadline.
852 request_swap_funnel_ = false; 861 request_swap_funnel_ = false;
862
863 swap_throttled_in_last_deadline_ = pending_swaps_ >= max_pending_swaps_;
864 swaps_are_likely_high_latency_ =
865 swaps_are_likely_high_latency_ || swap_throttled_in_last_deadline_;
853 } 866 }
854 867
855 void SchedulerStateMachine::OnBeginImplFrameIdle() { 868 void SchedulerStateMachine::OnBeginImplFrameIdle() {
856 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; 869 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE;
857 } 870 }
858 871
859 SchedulerStateMachine::BeginImplFrameDeadlineMode 872 SchedulerStateMachine::BeginImplFrameDeadlineMode
860 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { 873 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
861 if (settings_.using_synchronous_renderer_compositor) { 874 if (settings_.using_synchronous_renderer_compositor) {
862 // No deadline for synchronous compositor. 875 // No deadline for synchronous compositor.
(...skipping 12 matching lines...) Expand all
875 } else { 888 } else {
876 // The impl thread doesn't have anything it wants to draw and we are just 889 // The impl thread doesn't have anything it wants to draw and we are just
877 // waiting for a new active tree or we are swap throttled. In short we are 890 // waiting for a new active tree or we are swap throttled. In short we are
878 // blocked. 891 // blocked.
879 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; 892 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE;
880 } 893 }
881 } 894 }
882 895
883 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() 896 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
884 const { 897 const {
885 // TODO(brianderson): This should take into account multiple commit sources.
886 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) 898 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
887 return false; 899 return false;
888 900
889 // If we just forced activation, we should end the deadline right now. 901 // If we just forced activation, we should end the deadline right now.
890 if (PendingActivationsShouldBeForced() && !has_pending_tree_) 902 if (PendingActivationsShouldBeForced() && !has_pending_tree_)
891 return true; 903 return true;
892 904
893 // SwapAck throttle the deadline since we wont draw and swap anyway. 905 // SwapAck throttle the deadline since we wont draw and swap anyway.
894 if (pending_swaps_ >= max_pending_swaps_) 906 if (pending_swaps_ >= max_pending_swaps_)
895 return false; 907 return false;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 pending_swaps_++; 998 pending_swaps_++;
987 DCHECK_LE(pending_swaps_, max_pending_swaps_); 999 DCHECK_LE(pending_swaps_, max_pending_swaps_);
988 1000
989 did_perform_swap_in_last_draw_ = true; 1001 did_perform_swap_in_last_draw_ = true;
990 last_frame_number_swap_performed_ = current_frame_number_; 1002 last_frame_number_swap_performed_ = current_frame_number_;
991 } 1003 }
992 1004
993 void SchedulerStateMachine::DidSwapBuffersComplete() { 1005 void SchedulerStateMachine::DidSwapBuffersComplete() {
994 DCHECK_GT(pending_swaps_, 0); 1006 DCHECK_GT(pending_swaps_, 0);
995 pending_swaps_--; 1007 pending_swaps_--;
1008
1009 swaps_are_likely_high_latency_ =
1010 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME ||
sunnyps 2015/05/12 00:36:25 I don't understand what the frame state has to do
brianderson 2015/05/12 19:25:17 Regarding frame state: The code is hard to follow.
1011 swap_throttled_in_last_deadline_;
996 } 1012 }
997 1013
998 void SchedulerStateMachine::SetImplLatencyTakesPriority( 1014 void SchedulerStateMachine::SetImplLatencyTakesPriority(
999 bool impl_latency_takes_priority) { 1015 bool impl_latency_takes_priority) {
1000 impl_latency_takes_priority_ = impl_latency_takes_priority; 1016 impl_latency_takes_priority_ = impl_latency_takes_priority;
1001 } 1017 }
1002 1018
1003 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { 1019 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
1004 switch (result) { 1020 switch (result) {
1005 case INVALID_RESULT: 1021 case INVALID_RESULT:
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 static_cast<int>(begin_impl_frame_state_), 1154 static_cast<int>(begin_impl_frame_state_),
1139 static_cast<int>(commit_state_), 1155 static_cast<int>(commit_state_),
1140 has_pending_tree_ ? 'T' : 'F', 1156 has_pending_tree_ ? 'T' : 'F',
1141 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1157 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1142 active_tree_needs_first_draw_ ? 'T' : 'F', 1158 active_tree_needs_first_draw_ ? 'T' : 'F',
1143 max_pending_swaps_, 1159 max_pending_swaps_,
1144 pending_swaps_); 1160 pending_swaps_);
1145 } 1161 }
1146 1162
1147 } // namespace cc 1163 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698