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

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: 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 swaps_are_likely_high_latency_ = false;
825 }
826
821 void SchedulerStateMachine::OnBeginImplFrame() { 827 void SchedulerStateMachine::OnBeginImplFrame() {
822 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; 828 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING;
823 current_frame_number_++; 829 current_frame_number_++;
824 830
825 last_commit_had_no_updates_ = false; 831 last_commit_had_no_updates_ = false;
826 did_request_swap_in_last_frame_ = false; 832 did_request_swap_in_last_frame_ = false;
827 833
828 // Clear funnels for any actions we perform during the frame. 834 // Clear funnels for any actions we perform during the frame.
829 animate_funnel_ = false; 835 animate_funnel_ = false;
830 send_begin_main_frame_funnel_ = false; 836 send_begin_main_frame_funnel_ = false;
(...skipping 12 matching lines...) Expand all
843 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; 849 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME;
844 } 850 }
845 851
846 void SchedulerStateMachine::OnBeginImplFrameDeadline() { 852 void SchedulerStateMachine::OnBeginImplFrameDeadline() {
847 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 853 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
848 854
849 did_perform_swap_in_last_draw_ = false; 855 did_perform_swap_in_last_draw_ = false;
850 856
851 // Clear funnels for any actions we perform during the deadline. 857 // Clear funnels for any actions we perform during the deadline.
852 request_swap_funnel_ = false; 858 request_swap_funnel_ = false;
859
860 swap_throttled_in_last_deadline_ = pending_swaps_ >= max_pending_swaps_;
861 swaps_are_likely_high_latency_ =
862 swaps_are_likely_high_latency_ || swap_throttled_in_last_deadline_;
853 } 863 }
854 864
855 void SchedulerStateMachine::OnBeginImplFrameIdle() { 865 void SchedulerStateMachine::OnBeginImplFrameIdle() {
856 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; 866 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE;
857 } 867 }
858 868
859 SchedulerStateMachine::BeginImplFrameDeadlineMode 869 SchedulerStateMachine::BeginImplFrameDeadlineMode
860 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { 870 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
861 if (settings_.using_synchronous_renderer_compositor) { 871 if (settings_.using_synchronous_renderer_compositor) {
862 // No deadline for synchronous compositor. 872 // No deadline for synchronous compositor.
(...skipping 12 matching lines...) Expand all
875 } else { 885 } else {
876 // 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
877 // waiting for a new active tree or we are swap throttled. In short we are 887 // waiting for a new active tree or we are swap throttled. In short we are
878 // blocked. 888 // blocked.
879 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; 889 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE;
880 } 890 }
881 } 891 }
882 892
883 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() 893 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
884 const { 894 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) 895 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
887 return false; 896 return false;
888 897
889 // If we just forced activation, we should end the deadline right now. 898 // If we just forced activation, we should end the deadline right now.
890 if (PendingActivationsShouldBeForced() && !has_pending_tree_) 899 if (PendingActivationsShouldBeForced() && !has_pending_tree_)
891 return true; 900 return true;
892 901
893 // SwapAck throttle the deadline since we wont draw and swap anyway. 902 // SwapAck throttle the deadline since we wont draw and swap anyway.
894 if (pending_swaps_ >= max_pending_swaps_) 903 if (pending_swaps_ >= max_pending_swaps_)
895 return false; 904 return false;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 pending_swaps_++; 995 pending_swaps_++;
987 DCHECK_LE(pending_swaps_, max_pending_swaps_); 996 DCHECK_LE(pending_swaps_, max_pending_swaps_);
988 997
989 did_perform_swap_in_last_draw_ = true; 998 did_perform_swap_in_last_draw_ = true;
990 last_frame_number_swap_performed_ = current_frame_number_; 999 last_frame_number_swap_performed_ = current_frame_number_;
991 } 1000 }
992 1001
993 void SchedulerStateMachine::DidSwapBuffersComplete() { 1002 void SchedulerStateMachine::DidSwapBuffersComplete() {
994 DCHECK_GT(pending_swaps_, 0); 1003 DCHECK_GT(pending_swaps_, 0);
995 pending_swaps_--; 1004 pending_swaps_--;
1005
1006 swaps_are_likely_high_latency_ =
1007 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME ||
1008 swap_throttled_in_last_deadline_;
996 } 1009 }
997 1010
998 void SchedulerStateMachine::SetImplLatencyTakesPriority( 1011 void SchedulerStateMachine::SetImplLatencyTakesPriority(
999 bool impl_latency_takes_priority) { 1012 bool impl_latency_takes_priority) {
1000 impl_latency_takes_priority_ = impl_latency_takes_priority; 1013 impl_latency_takes_priority_ = impl_latency_takes_priority;
1001 } 1014 }
1002 1015
1003 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { 1016 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
1004 switch (result) { 1017 switch (result) {
1005 case INVALID_RESULT: 1018 case INVALID_RESULT:
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 static_cast<int>(begin_impl_frame_state_), 1151 static_cast<int>(begin_impl_frame_state_),
1139 static_cast<int>(commit_state_), 1152 static_cast<int>(commit_state_),
1140 has_pending_tree_ ? 'T' : 'F', 1153 has_pending_tree_ ? 'T' : 'F',
1141 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1154 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1142 active_tree_needs_first_draw_ ? 'T' : 'F', 1155 active_tree_needs_first_draw_ ? 'T' : 'F',
1143 max_pending_swaps_, 1156 max_pending_swaps_,
1144 pending_swaps_); 1157 pending_swaps_);
1145 } 1158 }
1146 1159
1147 } // namespace cc 1160 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698