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 16 matching lines...) Expand all Loading... |
27 last_frame_number_begin_main_frame_sent_(-1), | 27 last_frame_number_begin_main_frame_sent_(-1), |
28 last_frame_number_invalidate_output_surface_performed_(-1), | 28 last_frame_number_invalidate_output_surface_performed_(-1), |
29 animate_funnel_(false), | 29 animate_funnel_(false), |
30 request_swap_funnel_(false), | 30 request_swap_funnel_(false), |
31 send_begin_main_frame_funnel_(false), | 31 send_begin_main_frame_funnel_(false), |
32 invalidate_output_surface_funnel_(false), | 32 invalidate_output_surface_funnel_(false), |
33 prepare_tiles_funnel_(0), | 33 prepare_tiles_funnel_(0), |
34 consecutive_checkerboard_animations_(0), | 34 consecutive_checkerboard_animations_(0), |
35 max_pending_swaps_(1), | 35 max_pending_swaps_(1), |
36 pending_swaps_(0), | 36 pending_swaps_(0), |
| 37 swaps_with_current_output_surface_(0), |
37 needs_redraw_(false), | 38 needs_redraw_(false), |
38 needs_animate_(false), | 39 needs_animate_(false), |
39 needs_prepare_tiles_(false), | 40 needs_prepare_tiles_(false), |
40 needs_commit_(false), | 41 needs_commit_(false), |
41 visible_(false), | 42 visible_(false), |
42 can_start_(false), | 43 can_start_(false), |
43 can_draw_(false), | 44 can_draw_(false), |
44 has_pending_tree_(false), | 45 has_pending_tree_(false), |
45 pending_tree_is_ready_for_activation_(false), | 46 pending_tree_is_ready_for_activation_(false), |
46 active_tree_needs_first_draw_(false), | 47 active_tree_needs_first_draw_(false), |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 state->SetBoolean("funnel: request_swap_funnel", request_swap_funnel_); | 211 state->SetBoolean("funnel: request_swap_funnel", request_swap_funnel_); |
211 state->SetBoolean("funnel: send_begin_main_frame_funnel", | 212 state->SetBoolean("funnel: send_begin_main_frame_funnel", |
212 send_begin_main_frame_funnel_); | 213 send_begin_main_frame_funnel_); |
213 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); | 214 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); |
214 state->SetBoolean("funnel: invalidate_output_surface_funnel", | 215 state->SetBoolean("funnel: invalidate_output_surface_funnel", |
215 invalidate_output_surface_funnel_); | 216 invalidate_output_surface_funnel_); |
216 state->SetInteger("consecutive_checkerboard_animations", | 217 state->SetInteger("consecutive_checkerboard_animations", |
217 consecutive_checkerboard_animations_); | 218 consecutive_checkerboard_animations_); |
218 state->SetInteger("max_pending_swaps_", max_pending_swaps_); | 219 state->SetInteger("max_pending_swaps_", max_pending_swaps_); |
219 state->SetInteger("pending_swaps_", pending_swaps_); | 220 state->SetInteger("pending_swaps_", pending_swaps_); |
| 221 state->SetInteger("swaps_with_current_output_surface", |
| 222 swaps_with_current_output_surface_); |
220 state->SetBoolean("needs_redraw", needs_redraw_); | 223 state->SetBoolean("needs_redraw", needs_redraw_); |
221 state->SetBoolean("needs_animate_", needs_animate_); | 224 state->SetBoolean("needs_animate_", needs_animate_); |
222 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); | 225 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); |
223 state->SetBoolean("needs_commit", needs_commit_); | 226 state->SetBoolean("needs_commit", needs_commit_); |
224 state->SetBoolean("visible", visible_); | 227 state->SetBoolean("visible", visible_); |
225 state->SetBoolean("can_start", can_start_); | 228 state->SetBoolean("can_start", can_start_); |
226 state->SetBoolean("can_draw", can_draw_); | 229 state->SetBoolean("can_draw", can_draw_); |
227 state->SetBoolean("has_pending_tree", has_pending_tree_); | 230 state->SetBoolean("has_pending_tree", has_pending_tree_); |
228 state->SetBoolean("pending_tree_is_ready_for_activation", | 231 state->SetBoolean("pending_tree_is_ready_for_activation", |
229 pending_tree_is_ready_for_activation_); | 232 pending_tree_is_ready_for_activation_); |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 needs_prepare_tiles_ = true; | 1015 needs_prepare_tiles_ = true; |
1013 } | 1016 } |
1014 } | 1017 } |
1015 | 1018 |
1016 void SchedulerStateMachine::SetMaxSwapsPending(int max) { | 1019 void SchedulerStateMachine::SetMaxSwapsPending(int max) { |
1017 max_pending_swaps_ = max; | 1020 max_pending_swaps_ = max; |
1018 } | 1021 } |
1019 | 1022 |
1020 void SchedulerStateMachine::DidSwapBuffers() { | 1023 void SchedulerStateMachine::DidSwapBuffers() { |
1021 pending_swaps_++; | 1024 pending_swaps_++; |
| 1025 swaps_with_current_output_surface_++; |
| 1026 |
1022 DCHECK_LE(pending_swaps_, max_pending_swaps_); | 1027 DCHECK_LE(pending_swaps_, max_pending_swaps_); |
1023 | 1028 |
1024 did_perform_swap_in_last_draw_ = true; | 1029 did_perform_swap_in_last_draw_ = true; |
1025 last_frame_number_swap_performed_ = current_frame_number_; | 1030 last_frame_number_swap_performed_ = current_frame_number_; |
1026 } | 1031 } |
1027 | 1032 |
1028 void SchedulerStateMachine::DidSwapBuffersComplete() { | 1033 void SchedulerStateMachine::DidSwapBuffersComplete() { |
1029 DCHECK_GT(pending_swaps_, 0); | |
1030 pending_swaps_--; | 1034 pending_swaps_--; |
1031 } | 1035 } |
1032 | 1036 |
1033 void SchedulerStateMachine::SetImplLatencyTakesPriority( | 1037 void SchedulerStateMachine::SetImplLatencyTakesPriority( |
1034 bool impl_latency_takes_priority) { | 1038 bool impl_latency_takes_priority) { |
1035 impl_latency_takes_priority_ = impl_latency_takes_priority; | 1039 impl_latency_takes_priority_ = impl_latency_takes_priority; |
1036 } | 1040 } |
1037 | 1041 |
1038 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { | 1042 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { |
1039 switch (result) { | 1043 switch (result) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_CREATING); | 1141 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_CREATING); |
1138 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT; | 1142 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT; |
1139 | 1143 |
1140 if (did_create_and_initialize_first_output_surface_) { | 1144 if (did_create_and_initialize_first_output_surface_) { |
1141 // TODO(boliu): See if we can remove this when impl-side painting is always | 1145 // TODO(boliu): See if we can remove this when impl-side painting is always |
1142 // on. Does anything on the main thread need to update after recreate? | 1146 // on. Does anything on the main thread need to update after recreate? |
1143 needs_commit_ = true; | 1147 needs_commit_ = true; |
1144 } | 1148 } |
1145 did_create_and_initialize_first_output_surface_ = true; | 1149 did_create_and_initialize_first_output_surface_ = true; |
1146 pending_swaps_ = 0; | 1150 pending_swaps_ = 0; |
| 1151 swaps_with_current_output_surface_ = 0; |
1147 } | 1152 } |
1148 | 1153 |
1149 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { | 1154 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { |
1150 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); | 1155 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); |
1151 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED; | 1156 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED; |
1152 } | 1157 } |
1153 | 1158 |
1154 bool SchedulerStateMachine::HasInitializedOutputSurface() const { | 1159 bool SchedulerStateMachine::HasInitializedOutputSurface() const { |
1155 switch (output_surface_state_) { | 1160 switch (output_surface_state_) { |
1156 case OUTPUT_SURFACE_LOST: | 1161 case OUTPUT_SURFACE_LOST: |
(...skipping 16 matching lines...) Expand all Loading... |
1173 static_cast<int>(begin_impl_frame_state_), | 1178 static_cast<int>(begin_impl_frame_state_), |
1174 static_cast<int>(commit_state_), | 1179 static_cast<int>(commit_state_), |
1175 has_pending_tree_ ? 'T' : 'F', | 1180 has_pending_tree_ ? 'T' : 'F', |
1176 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1181 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1177 active_tree_needs_first_draw_ ? 'T' : 'F', | 1182 active_tree_needs_first_draw_ ? 'T' : 'F', |
1178 max_pending_swaps_, | 1183 max_pending_swaps_, |
1179 pending_swaps_); | 1184 pending_swaps_); |
1180 } | 1185 } |
1181 | 1186 |
1182 } // namespace cc | 1187 } // namespace cc |
OLD | NEW |