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 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 namespace { | 16 namespace { |
17 // Surfaces and CompositorTimingHistory don't support more than 1 pending swap. | 17 // Surfaces and CompositorTimingHistory don't support more than 1 pending swap. |
18 const int kMaxPendingSwaps = 1; | 18 const int kMaxPendingSwaps = 1; |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) | 21 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
22 : settings_(settings), | 22 : settings_(settings), |
23 output_surface_state_(OUTPUT_SURFACE_NONE), | 23 compositor_frame_sink_state_(COMPOSITOR_FRAME_SINK_NONE), |
24 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), | 24 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), |
25 begin_main_frame_state_(BEGIN_MAIN_FRAME_STATE_IDLE), | 25 begin_main_frame_state_(BEGIN_MAIN_FRAME_STATE_IDLE), |
26 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), | 26 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), |
27 commit_count_(0), | 27 commit_count_(0), |
28 current_frame_number_(0), | 28 current_frame_number_(0), |
29 last_frame_number_swap_performed_(-1), | 29 last_frame_number_swap_performed_(-1), |
30 last_frame_number_draw_performed_(-1), | 30 last_frame_number_draw_performed_(-1), |
31 last_frame_number_begin_main_frame_sent_(-1), | 31 last_frame_number_begin_main_frame_sent_(-1), |
32 last_frame_number_invalidate_output_surface_performed_(-1), | 32 last_frame_number_invalidate_compositor_frame_sink_performed_(-1), |
33 draw_funnel_(false), | 33 draw_funnel_(false), |
34 send_begin_main_frame_funnel_(true), | 34 send_begin_main_frame_funnel_(true), |
35 invalidate_output_surface_funnel_(false), | 35 invalidate_compositor_frame_sink_funnel_(false), |
36 prepare_tiles_funnel_(0), | 36 prepare_tiles_funnel_(0), |
37 consecutive_checkerboard_animations_(0), | 37 consecutive_checkerboard_animations_(0), |
38 pending_swaps_(0), | 38 pending_swaps_(0), |
39 swaps_with_current_output_surface_(0), | 39 swaps_with_current_compositor_frame_sink_(0), |
40 needs_redraw_(false), | 40 needs_redraw_(false), |
41 needs_prepare_tiles_(false), | 41 needs_prepare_tiles_(false), |
42 needs_begin_main_frame_(false), | 42 needs_begin_main_frame_(false), |
43 needs_one_begin_impl_frame_(false), | 43 needs_one_begin_impl_frame_(false), |
44 visible_(false), | 44 visible_(false), |
45 begin_frame_source_paused_(false), | 45 begin_frame_source_paused_(false), |
46 resourceless_draw_(false), | 46 resourceless_draw_(false), |
47 can_draw_(false), | 47 can_draw_(false), |
48 has_pending_tree_(false), | 48 has_pending_tree_(false), |
49 pending_tree_is_ready_for_activation_(false), | 49 pending_tree_is_ready_for_activation_(false), |
50 active_tree_needs_first_draw_(false), | 50 active_tree_needs_first_draw_(false), |
51 did_create_and_initialize_first_output_surface_(false), | 51 did_create_and_initialize_first_compositor_frame_sink_(false), |
52 tree_priority_(NEW_CONTENT_TAKES_PRIORITY), | 52 tree_priority_(NEW_CONTENT_TAKES_PRIORITY), |
53 scroll_handler_state_( | 53 scroll_handler_state_( |
54 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER), | 54 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER), |
55 critical_begin_main_frame_to_activate_is_fast_(true), | 55 critical_begin_main_frame_to_activate_is_fast_(true), |
56 main_thread_missed_last_deadline_(false), | 56 main_thread_missed_last_deadline_(false), |
57 skip_next_begin_main_frame_to_reduce_latency_(false), | 57 skip_next_begin_main_frame_to_reduce_latency_(false), |
58 defer_commits_(false), | 58 defer_commits_(false), |
59 video_needs_begin_frames_(false), | 59 video_needs_begin_frames_(false), |
60 last_commit_had_no_updates_(false), | 60 last_commit_had_no_updates_(false), |
61 wait_for_ready_to_draw_(false), | 61 wait_for_ready_to_draw_(false), |
62 did_draw_in_last_frame_(false), | 62 did_draw_in_last_frame_(false), |
63 did_swap_in_last_frame_(false) {} | 63 did_swap_in_last_frame_(false) {} |
64 | 64 |
65 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 65 const char* SchedulerStateMachine::CompositorFrameSinkStateToString( |
66 OutputSurfaceState state) { | 66 CompositorFrameSinkState state) { |
67 switch (state) { | 67 switch (state) { |
68 case OUTPUT_SURFACE_NONE: | 68 case COMPOSITOR_FRAME_SINK_NONE: |
69 return "OUTPUT_SURFACE_NONE"; | 69 return "COMPOSITOR_FRAME_SINK_NONE"; |
70 case OUTPUT_SURFACE_ACTIVE: | 70 case COMPOSITOR_FRAME_SINK_ACTIVE: |
71 return "OUTPUT_SURFACE_ACTIVE"; | 71 return "COMPOSITOR_FRAME_SINK_ACTIVE"; |
72 case OUTPUT_SURFACE_CREATING: | 72 case COMPOSITOR_FRAME_SINK_CREATING: |
73 return "OUTPUT_SURFACE_CREATING"; | 73 return "COMPOSITOR_FRAME_SINK_CREATING"; |
74 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 74 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
75 return "OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT"; | 75 return "COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT"; |
76 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 76 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
77 return "OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION"; | 77 return "COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION"; |
78 } | 78 } |
79 NOTREACHED(); | 79 NOTREACHED(); |
80 return "???"; | 80 return "???"; |
81 } | 81 } |
82 | 82 |
83 const char* SchedulerStateMachine::BeginImplFrameStateToString( | 83 const char* SchedulerStateMachine::BeginImplFrameStateToString( |
84 BeginImplFrameState state) { | 84 BeginImplFrameState state) { |
85 switch (state) { | 85 switch (state) { |
86 case BEGIN_IMPL_FRAME_STATE_IDLE: | 86 case BEGIN_IMPL_FRAME_STATE_IDLE: |
87 return "BEGIN_IMPL_FRAME_STATE_IDLE"; | 87 return "BEGIN_IMPL_FRAME_STATE_IDLE"; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 case ACTION_COMMIT: | 168 case ACTION_COMMIT: |
169 return "ACTION_COMMIT"; | 169 return "ACTION_COMMIT"; |
170 case ACTION_ACTIVATE_SYNC_TREE: | 170 case ACTION_ACTIVATE_SYNC_TREE: |
171 return "ACTION_ACTIVATE_SYNC_TREE"; | 171 return "ACTION_ACTIVATE_SYNC_TREE"; |
172 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: | 172 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: |
173 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; | 173 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; |
174 case ACTION_DRAW_AND_SWAP_FORCED: | 174 case ACTION_DRAW_AND_SWAP_FORCED: |
175 return "ACTION_DRAW_AND_SWAP_FORCED"; | 175 return "ACTION_DRAW_AND_SWAP_FORCED"; |
176 case ACTION_DRAW_AND_SWAP_ABORT: | 176 case ACTION_DRAW_AND_SWAP_ABORT: |
177 return "ACTION_DRAW_AND_SWAP_ABORT"; | 177 return "ACTION_DRAW_AND_SWAP_ABORT"; |
178 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 178 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: |
179 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; | 179 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION"; |
180 case ACTION_PREPARE_TILES: | 180 case ACTION_PREPARE_TILES: |
181 return "ACTION_PREPARE_TILES"; | 181 return "ACTION_PREPARE_TILES"; |
182 case ACTION_INVALIDATE_OUTPUT_SURFACE: | 182 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK: |
183 return "ACTION_INVALIDATE_OUTPUT_SURFACE"; | 183 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK"; |
184 } | 184 } |
185 NOTREACHED(); | 185 NOTREACHED(); |
186 return "???"; | 186 return "???"; |
187 } | 187 } |
188 | 188 |
189 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 189 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
190 SchedulerStateMachine::AsValue() const { | 190 SchedulerStateMachine::AsValue() const { |
191 std::unique_ptr<base::trace_event::TracedValue> state( | 191 std::unique_ptr<base::trace_event::TracedValue> state( |
192 new base::trace_event::TracedValue()); | 192 new base::trace_event::TracedValue()); |
193 AsValueInto(state.get()); | 193 AsValueInto(state.get()); |
194 return std::move(state); | 194 return std::move(state); |
195 } | 195 } |
196 | 196 |
197 void SchedulerStateMachine::AsValueInto( | 197 void SchedulerStateMachine::AsValueInto( |
198 base::trace_event::TracedValue* state) const { | 198 base::trace_event::TracedValue* state) const { |
199 state->BeginDictionary("major_state"); | 199 state->BeginDictionary("major_state"); |
200 state->SetString("next_action", ActionToString(NextAction())); | 200 state->SetString("next_action", ActionToString(NextAction())); |
201 state->SetString("begin_impl_frame_state", | 201 state->SetString("begin_impl_frame_state", |
202 BeginImplFrameStateToString(begin_impl_frame_state_)); | 202 BeginImplFrameStateToString(begin_impl_frame_state_)); |
203 state->SetString("begin_main_frame_state", | 203 state->SetString("begin_main_frame_state", |
204 BeginMainFrameStateToString(begin_main_frame_state_)); | 204 BeginMainFrameStateToString(begin_main_frame_state_)); |
205 state->SetString("output_surface_state_", | 205 state->SetString( |
206 OutputSurfaceStateToString(output_surface_state_)); | 206 "compositor_frame_sink_state_", |
| 207 CompositorFrameSinkStateToString(compositor_frame_sink_state_)); |
207 state->SetString("forced_redraw_state", | 208 state->SetString("forced_redraw_state", |
208 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); | 209 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); |
209 state->EndDictionary(); | 210 state->EndDictionary(); |
210 | 211 |
211 state->BeginDictionary("minor_state"); | 212 state->BeginDictionary("minor_state"); |
212 state->SetInteger("commit_count", commit_count_); | 213 state->SetInteger("commit_count", commit_count_); |
213 state->SetInteger("current_frame_number", current_frame_number_); | 214 state->SetInteger("current_frame_number", current_frame_number_); |
214 state->SetInteger("last_frame_number_swap_performed", | 215 state->SetInteger("last_frame_number_swap_performed", |
215 last_frame_number_swap_performed_); | 216 last_frame_number_swap_performed_); |
216 state->SetInteger("last_frame_number_draw_performed", | 217 state->SetInteger("last_frame_number_draw_performed", |
217 last_frame_number_draw_performed_); | 218 last_frame_number_draw_performed_); |
218 state->SetInteger("last_frame_number_begin_main_frame_sent", | 219 state->SetInteger("last_frame_number_begin_main_frame_sent", |
219 last_frame_number_begin_main_frame_sent_); | 220 last_frame_number_begin_main_frame_sent_); |
220 state->SetBoolean("funnel: draw_funnel", draw_funnel_); | 221 state->SetBoolean("funnel: draw_funnel", draw_funnel_); |
221 state->SetBoolean("funnel: send_begin_main_frame_funnel", | 222 state->SetBoolean("funnel: send_begin_main_frame_funnel", |
222 send_begin_main_frame_funnel_); | 223 send_begin_main_frame_funnel_); |
223 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); | 224 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); |
224 state->SetBoolean("funnel: invalidate_output_surface_funnel", | 225 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", |
225 invalidate_output_surface_funnel_); | 226 invalidate_compositor_frame_sink_funnel_); |
226 state->SetInteger("consecutive_checkerboard_animations", | 227 state->SetInteger("consecutive_checkerboard_animations", |
227 consecutive_checkerboard_animations_); | 228 consecutive_checkerboard_animations_); |
228 state->SetInteger("pending_swaps_", pending_swaps_); | 229 state->SetInteger("pending_swaps_", pending_swaps_); |
229 state->SetInteger("swaps_with_current_output_surface", | 230 state->SetInteger("swaps_with_current_compositor_frame_sink", |
230 swaps_with_current_output_surface_); | 231 swaps_with_current_compositor_frame_sink_); |
231 state->SetBoolean("needs_redraw", needs_redraw_); | 232 state->SetBoolean("needs_redraw", needs_redraw_); |
232 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); | 233 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); |
233 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); | 234 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); |
234 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_); | 235 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_); |
235 state->SetBoolean("visible", visible_); | 236 state->SetBoolean("visible", visible_); |
236 state->SetBoolean("begin_frame_source_paused", begin_frame_source_paused_); | 237 state->SetBoolean("begin_frame_source_paused", begin_frame_source_paused_); |
237 state->SetBoolean("can_draw", can_draw_); | 238 state->SetBoolean("can_draw", can_draw_); |
238 state->SetBoolean("resourceless_draw", resourceless_draw_); | 239 state->SetBoolean("resourceless_draw", resourceless_draw_); |
239 state->SetBoolean("has_pending_tree", has_pending_tree_); | 240 state->SetBoolean("has_pending_tree", has_pending_tree_); |
240 state->SetBoolean("pending_tree_is_ready_for_activation", | 241 state->SetBoolean("pending_tree_is_ready_for_activation", |
241 pending_tree_is_ready_for_activation_); | 242 pending_tree_is_ready_for_activation_); |
242 state->SetBoolean("active_tree_needs_first_draw", | 243 state->SetBoolean("active_tree_needs_first_draw", |
243 active_tree_needs_first_draw_); | 244 active_tree_needs_first_draw_); |
244 state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_); | 245 state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_); |
245 state->SetBoolean("did_create_and_initialize_first_output_surface", | 246 state->SetBoolean("did_create_and_initialize_first_compositor_frame_sink", |
246 did_create_and_initialize_first_output_surface_); | 247 did_create_and_initialize_first_compositor_frame_sink_); |
247 state->SetString("tree_priority", TreePriorityToString(tree_priority_)); | 248 state->SetString("tree_priority", TreePriorityToString(tree_priority_)); |
248 state->SetString("scroll_handler_state", | 249 state->SetString("scroll_handler_state", |
249 ScrollHandlerStateToString(scroll_handler_state_)); | 250 ScrollHandlerStateToString(scroll_handler_state_)); |
250 state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", | 251 state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", |
251 critical_begin_main_frame_to_activate_is_fast_); | 252 critical_begin_main_frame_to_activate_is_fast_); |
252 state->SetBoolean("main_thread_missed_last_deadline", | 253 state->SetBoolean("main_thread_missed_last_deadline", |
253 main_thread_missed_last_deadline_); | 254 main_thread_missed_last_deadline_); |
254 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 255 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
255 skip_next_begin_main_frame_to_reduce_latency_); | 256 skip_next_begin_main_frame_to_reduce_latency_); |
256 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); | 257 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); |
257 state->SetBoolean("defer_commits", defer_commits_); | 258 state->SetBoolean("defer_commits", defer_commits_); |
258 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); | 259 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); |
259 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_); | 260 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_); |
260 state->SetBoolean("did_swap_in_last_frame", did_swap_in_last_frame_); | 261 state->SetBoolean("did_swap_in_last_frame", did_swap_in_last_frame_); |
261 state->EndDictionary(); | 262 state->EndDictionary(); |
262 } | 263 } |
263 | 264 |
264 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { | 265 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
265 // Normally when |visible_| is false or |begin_frame_source_paused_| is true, | 266 // Normally when |visible_| is false or |begin_frame_source_paused_| is true, |
266 // pending activations will be forced and draws will be aborted. However, | 267 // pending activations will be forced and draws will be aborted. However, |
267 // when the embedder is Android WebView, software draws could be scheduled by | 268 // when the embedder is Android WebView, software draws could be scheduled by |
268 // the Android OS at any time and draws should not be aborted in this case. | 269 // the Android OS at any time and draws should not be aborted in this case. |
269 bool is_output_surface_lost = (output_surface_state_ == OUTPUT_SURFACE_NONE); | 270 bool is_compositor_frame_sink_lost = |
| 271 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE); |
270 if (resourceless_draw_) | 272 if (resourceless_draw_) |
271 return is_output_surface_lost || !can_draw_; | 273 return is_compositor_frame_sink_lost || !can_draw_; |
272 | 274 |
273 // These are all the cases where we normally cannot or do not want to draw | 275 // These are all the cases where we normally cannot or do not want to draw |
274 // but, if needs_redraw_ is true and we do not draw to make forward progress, | 276 // but, if needs_redraw_ is true and we do not draw to make forward progress, |
275 // we might deadlock with the main thread. | 277 // we might deadlock with the main thread. |
276 // This should be a superset of PendingActivationsShouldBeForced() since | 278 // This should be a superset of PendingActivationsShouldBeForced() since |
277 // activation of the pending tree is blocked by drawing of the active tree and | 279 // activation of the pending tree is blocked by drawing of the active tree and |
278 // the main thread might be blocked on activation of the most recent commit. | 280 // the main thread might be blocked on activation of the most recent commit. |
279 return is_output_surface_lost || !can_draw_ || !visible_ || | 281 return is_compositor_frame_sink_lost || !can_draw_ || !visible_ || |
280 begin_frame_source_paused_; | 282 begin_frame_source_paused_; |
281 } | 283 } |
282 | 284 |
283 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const { | 285 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const { |
284 // There is no output surface to trigger our activations. | 286 // There is no output surface to trigger our activations. |
285 // If we do not force activations to make forward progress, we might deadlock | 287 // If we do not force activations to make forward progress, we might deadlock |
286 // with the main thread. | 288 // with the main thread. |
287 if (output_surface_state_ == OUTPUT_SURFACE_NONE) | 289 if (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE) |
288 return true; | 290 return true; |
289 | 291 |
290 // If we're not visible, we should force activation. | 292 // If we're not visible, we should force activation. |
291 // Since we set RequiresHighResToDraw when becoming visible, we ensure that we | 293 // Since we set RequiresHighResToDraw when becoming visible, we ensure that we |
292 // don't checkerboard until all visible resources are done. Furthermore, if we | 294 // don't checkerboard until all visible resources are done. Furthermore, if we |
293 // do keep the pending tree around, when becoming visible we might activate | 295 // do keep the pending tree around, when becoming visible we might activate |
294 // prematurely causing RequiresHighResToDraw flag to be reset. In all cases, | 296 // prematurely causing RequiresHighResToDraw flag to be reset. In all cases, |
295 // we can simply activate on becoming invisible since we don't need to draw | 297 // we can simply activate on becoming invisible since we don't need to draw |
296 // the active tree when we're in this state. | 298 // the active tree when we're in this state. |
297 if (!visible_) | 299 if (!visible_) |
298 return true; | 300 return true; |
299 | 301 |
300 // Force pending activations when BeginFrameSource is paused to avoid | 302 // Force pending activations when BeginFrameSource is paused to avoid |
301 // deadlocking the main thread. | 303 // deadlocking the main thread. |
302 if (begin_frame_source_paused_) | 304 if (begin_frame_source_paused_) |
303 return true; | 305 return true; |
304 | 306 |
305 return false; | 307 return false; |
306 } | 308 } |
307 | 309 |
308 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const { | 310 bool SchedulerStateMachine::ShouldBeginCompositorFrameSinkCreation() const { |
309 if (!visible_) | 311 if (!visible_) |
310 return false; | 312 return false; |
311 | 313 |
312 // We only want to start output surface initialization after the | 314 // We only want to start output surface initialization after the |
313 // previous commit is complete. | 315 // previous commit is complete. |
314 // We make an exception if the embedder explicitly allows beginning output | 316 // We make an exception if the embedder explicitly allows beginning output |
315 // surface creation while the previous commit has not been aborted. This | 317 // surface creation while the previous commit has not been aborted. This |
316 // assumes that any state passed from the client during the commit will not be | 318 // assumes that any state passed from the client during the commit will not be |
317 // tied to the output surface. | 319 // tied to the output surface. |
318 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE && | 320 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE && |
319 settings_.abort_commit_before_output_surface_creation) { | 321 settings_.abort_commit_before_compositor_frame_sink_creation) { |
320 return false; | 322 return false; |
321 } | 323 } |
322 | 324 |
323 // Make sure the BeginImplFrame from any previous OutputSurfaces | 325 // Make sure the BeginImplFrame from any previous CompositorFrameSinks |
324 // are complete before creating the new OutputSurface. | 326 // are complete before creating the new CompositorFrameSink. |
325 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) | 327 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) |
326 return false; | 328 return false; |
327 | 329 |
328 // We want to clear the pipeline of any pending draws and activations | 330 // We want to clear the pipeline of any pending draws and activations |
329 // before starting output surface initialization. This allows us to avoid | 331 // before starting output surface initialization. This allows us to avoid |
330 // weird corner cases where we abort draws or force activation while we | 332 // weird corner cases where we abort draws or force activation while we |
331 // are initializing the output surface. | 333 // are initializing the output surface. |
332 if (active_tree_needs_first_draw_ || has_pending_tree_) | 334 if (active_tree_needs_first_draw_ || has_pending_tree_) |
333 return false; | 335 return false; |
334 | 336 |
335 // We need to create the output surface if we don't have one and we haven't | 337 // We need to create the output surface if we don't have one and we haven't |
336 // started creating one yet. | 338 // started creating one yet. |
337 return output_surface_state_ == OUTPUT_SURFACE_NONE; | 339 return compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE; |
338 } | 340 } |
339 | 341 |
340 bool SchedulerStateMachine::ShouldDraw() const { | 342 bool SchedulerStateMachine::ShouldDraw() const { |
341 // If we need to abort draws, we should do so ASAP since the draw could | 343 // If we need to abort draws, we should do so ASAP since the draw could |
342 // be blocking other important actions (like output surface initialization), | 344 // be blocking other important actions (like output surface initialization), |
343 // from occurring. If we are waiting for the first draw, then perform the | 345 // from occurring. If we are waiting for the first draw, then perform the |
344 // aborted draw to keep things moving. If we are not waiting for the first | 346 // aborted draw to keep things moving. If we are not waiting for the first |
345 // draw however, we don't want to abort for no reason. | 347 // draw however, we don't want to abort for no reason. |
346 if (PendingDrawsShouldBeAborted()) | 348 if (PendingDrawsShouldBeAborted()) |
347 return active_tree_needs_first_draw_; | 349 return active_tree_needs_first_draw_; |
348 | 350 |
349 // Do not draw too many times in a single frame. It's okay that we don't check | 351 // Do not draw too many times in a single frame. It's okay that we don't check |
350 // this before checking for aborted draws because aborted draws do not request | 352 // this before checking for aborted draws because aborted draws do not request |
351 // a swap. | 353 // a swap. |
352 if (draw_funnel_) | 354 if (draw_funnel_) |
353 return false; | 355 return false; |
354 | 356 |
355 // Don't draw if we are waiting on the first commit after a surface. | 357 // Don't draw if we are waiting on the first commit after a surface. |
356 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) | 358 if (compositor_frame_sink_state_ != COMPOSITOR_FRAME_SINK_ACTIVE) |
357 return false; | 359 return false; |
358 | 360 |
359 // Do not queue too many swaps. | 361 // Do not queue too many swaps. |
360 if (SwapThrottled()) | 362 if (SwapThrottled()) |
361 return false; | 363 return false; |
362 | 364 |
363 // Except for the cases above, do not draw outside of the BeginImplFrame | 365 // Except for the cases above, do not draw outside of the BeginImplFrame |
364 // deadline. | 366 // deadline. |
365 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 367 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
366 return false; | 368 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 if (!settings_.using_synchronous_renderer_compositor && | 445 if (!settings_.using_synchronous_renderer_compositor && |
444 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE) { | 446 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE) { |
445 return false; | 447 return false; |
446 } | 448 } |
447 | 449 |
448 // We need a new commit for the forced redraw. This honors the | 450 // We need a new commit for the forced redraw. This honors the |
449 // single commit per interval because the result will be swapped to screen. | 451 // single commit per interval because the result will be swapped to screen. |
450 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) | 452 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) |
451 return true; | 453 return true; |
452 | 454 |
453 // We shouldn't normally accept commits if there isn't an OutputSurface. | 455 // We shouldn't normally accept commits if there isn't an CompositorFrameSink. |
454 if (!HasInitializedOutputSurface()) | 456 if (!HasInitializedCompositorFrameSink()) |
455 return false; | 457 return false; |
456 | 458 |
457 if (!settings_.main_frame_while_swap_throttled_enabled) { | 459 if (!settings_.main_frame_while_swap_throttled_enabled) { |
458 // SwapAck throttle the BeginMainFrames unless we just swapped to | 460 // SwapAck throttle the BeginMainFrames unless we just swapped to |
459 // potentially improve impl-thread latency over main-thread throughput. | 461 // potentially improve impl-thread latency over main-thread throughput. |
460 // TODO(brianderson): Remove this restriction to improve throughput or | 462 // TODO(brianderson): Remove this restriction to improve throughput or |
461 // make it conditional on ImplLatencyTakesPriority. | 463 // make it conditional on ImplLatencyTakesPriority. |
462 bool just_swapped_in_deadline = | 464 bool just_swapped_in_deadline = |
463 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && | 465 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && |
464 did_swap_in_last_frame_; | 466 did_swap_in_last_frame_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 return false; | 499 return false; |
498 | 500 |
499 // Limiting to once per-frame is not enough, since we only want to | 501 // Limiting to once per-frame is not enough, since we only want to |
500 // prepare tiles _after_ draws. | 502 // prepare tiles _after_ draws. |
501 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 503 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
502 return false; | 504 return false; |
503 | 505 |
504 return needs_prepare_tiles_; | 506 return needs_prepare_tiles_; |
505 } | 507 } |
506 | 508 |
507 bool SchedulerStateMachine::ShouldInvalidateOutputSurface() const { | 509 bool SchedulerStateMachine::ShouldInvalidateCompositorFrameSink() const { |
508 // Do not invalidate too many times in a frame. | 510 // Do not invalidate too many times in a frame. |
509 if (invalidate_output_surface_funnel_) | 511 if (invalidate_compositor_frame_sink_funnel_) |
510 return false; | 512 return false; |
511 | 513 |
512 // Only the synchronous compositor requires invalidations. | 514 // Only the synchronous compositor requires invalidations. |
513 if (!settings_.using_synchronous_renderer_compositor) | 515 if (!settings_.using_synchronous_renderer_compositor) |
514 return false; | 516 return false; |
515 | 517 |
516 // Invalidations are only performed inside a BeginFrame. | 518 // Invalidations are only performed inside a BeginFrame. |
517 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) | 519 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) |
518 return false; | 520 return false; |
519 | 521 |
(...skipping 13 matching lines...) Expand all Loading... |
533 return ACTION_DRAW_AND_SWAP_ABORT; | 535 return ACTION_DRAW_AND_SWAP_ABORT; |
534 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 536 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
535 return ACTION_DRAW_AND_SWAP_FORCED; | 537 return ACTION_DRAW_AND_SWAP_FORCED; |
536 else | 538 else |
537 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; | 539 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; |
538 } | 540 } |
539 if (ShouldPrepareTiles()) | 541 if (ShouldPrepareTiles()) |
540 return ACTION_PREPARE_TILES; | 542 return ACTION_PREPARE_TILES; |
541 if (ShouldSendBeginMainFrame()) | 543 if (ShouldSendBeginMainFrame()) |
542 return ACTION_SEND_BEGIN_MAIN_FRAME; | 544 return ACTION_SEND_BEGIN_MAIN_FRAME; |
543 if (ShouldInvalidateOutputSurface()) | 545 if (ShouldInvalidateCompositorFrameSink()) |
544 return ACTION_INVALIDATE_OUTPUT_SURFACE; | 546 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK; |
545 if (ShouldBeginOutputSurfaceCreation()) | 547 if (ShouldBeginCompositorFrameSinkCreation()) |
546 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; | 548 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION; |
547 return ACTION_NONE; | 549 return ACTION_NONE; |
548 } | 550 } |
549 | 551 |
550 void SchedulerStateMachine::WillSendBeginMainFrame() { | 552 void SchedulerStateMachine::WillSendBeginMainFrame() { |
551 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); | 553 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); |
552 DCHECK(visible_); | 554 DCHECK(visible_); |
553 DCHECK(!begin_frame_source_paused_); | 555 DCHECK(!begin_frame_source_paused_); |
554 DCHECK(!send_begin_main_frame_funnel_); | 556 DCHECK(!send_begin_main_frame_funnel_); |
555 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; | 557 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; |
556 needs_begin_main_frame_ = false; | 558 needs_begin_main_frame_ = false; |
(...skipping 22 matching lines...) Expand all Loading... |
579 } | 581 } |
580 | 582 |
581 // Update state related to forced draws. | 583 // Update state related to forced draws. |
582 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 584 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
583 forced_redraw_state_ = has_pending_tree_ | 585 forced_redraw_state_ = has_pending_tree_ |
584 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 586 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
585 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 587 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
586 } | 588 } |
587 | 589 |
588 // Update the output surface state. | 590 // Update the output surface state. |
589 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) { | 591 if (compositor_frame_sink_state_ == |
590 output_surface_state_ = has_pending_tree_ | 592 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT) { |
591 ? OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION | 593 compositor_frame_sink_state_ = |
592 : OUTPUT_SURFACE_ACTIVE; | 594 has_pending_tree_ ? COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION |
| 595 : COMPOSITOR_FRAME_SINK_ACTIVE; |
593 } | 596 } |
594 } | 597 } |
595 | 598 |
596 void SchedulerStateMachine::WillActivate() { | 599 void SchedulerStateMachine::WillActivate() { |
597 if (begin_main_frame_state_ == | 600 if (begin_main_frame_state_ == |
598 BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) { | 601 BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) { |
599 begin_main_frame_state_ = settings_.commit_to_active_tree | 602 begin_main_frame_state_ = settings_.commit_to_active_tree |
600 ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW | 603 ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW |
601 : BEGIN_MAIN_FRAME_STATE_IDLE; | 604 : BEGIN_MAIN_FRAME_STATE_IDLE; |
602 } | 605 } |
603 | 606 |
604 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) | 607 if (compositor_frame_sink_state_ == |
605 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | 608 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) |
| 609 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; |
606 | 610 |
607 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) | 611 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) |
608 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 612 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
609 | 613 |
610 has_pending_tree_ = false; | 614 has_pending_tree_ = false; |
611 pending_tree_is_ready_for_activation_ = false; | 615 pending_tree_is_ready_for_activation_ = false; |
612 active_tree_needs_first_draw_ = true; | 616 active_tree_needs_first_draw_ = true; |
613 needs_redraw_ = true; | 617 needs_redraw_ = true; |
614 } | 618 } |
615 | 619 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 // Note: We may abort at any time and cannot DCHECK that | 693 // Note: We may abort at any time and cannot DCHECK that |
690 // we haven't drawn in or swapped in the last frame here. | 694 // we haven't drawn in or swapped in the last frame here. |
691 WillDrawInternal(); | 695 WillDrawInternal(); |
692 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); | 696 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); |
693 } | 697 } |
694 | 698 |
695 void SchedulerStateMachine::WillPrepareTiles() { | 699 void SchedulerStateMachine::WillPrepareTiles() { |
696 needs_prepare_tiles_ = false; | 700 needs_prepare_tiles_ = false; |
697 } | 701 } |
698 | 702 |
699 void SchedulerStateMachine::WillBeginOutputSurfaceCreation() { | 703 void SchedulerStateMachine::WillBeginCompositorFrameSinkCreation() { |
700 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_NONE); | 704 DCHECK_EQ(compositor_frame_sink_state_, COMPOSITOR_FRAME_SINK_NONE); |
701 output_surface_state_ = OUTPUT_SURFACE_CREATING; | 705 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_CREATING; |
702 | 706 |
703 // The following DCHECKs make sure we are in the proper quiescent state. | 707 // The following DCHECKs make sure we are in the proper quiescent state. |
704 // The pipeline should be flushed entirely before we start output | 708 // The pipeline should be flushed entirely before we start output |
705 // surface creation to avoid complicated corner cases. | 709 // surface creation to avoid complicated corner cases. |
706 | 710 |
707 // We allow output surface creation while the previous commit has not been | 711 // We allow output surface creation while the previous commit has not been |
708 // aborted if the embedder explicitly allows it. | 712 // aborted if the embedder explicitly allows it. |
709 DCHECK(!settings_.abort_commit_before_output_surface_creation || | 713 DCHECK(!settings_.abort_commit_before_compositor_frame_sink_creation || |
710 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE); | 714 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE); |
711 DCHECK(!has_pending_tree_); | 715 DCHECK(!has_pending_tree_); |
712 DCHECK(!active_tree_needs_first_draw_); | 716 DCHECK(!active_tree_needs_first_draw_); |
713 } | 717 } |
714 | 718 |
715 void SchedulerStateMachine::WillInvalidateOutputSurface() { | 719 void SchedulerStateMachine::WillInvalidateCompositorFrameSink() { |
716 DCHECK(!invalidate_output_surface_funnel_); | 720 DCHECK(!invalidate_compositor_frame_sink_funnel_); |
717 invalidate_output_surface_funnel_ = true; | 721 invalidate_compositor_frame_sink_funnel_ = true; |
718 last_frame_number_invalidate_output_surface_performed_ = | 722 last_frame_number_invalidate_compositor_frame_sink_performed_ = |
719 current_frame_number_; | 723 current_frame_number_; |
720 | 724 |
721 // The synchronous compositor makes no guarantees about a draw coming in after | 725 // The synchronous compositor makes no guarantees about a draw coming in after |
722 // an invalidate so clear any flags that would cause the compositor's pipeline | 726 // an invalidate so clear any flags that would cause the compositor's pipeline |
723 // to stall. | 727 // to stall. |
724 active_tree_needs_first_draw_ = false; // blocks commit if true | 728 active_tree_needs_first_draw_ = false; // blocks commit if true |
725 } | 729 } |
726 | 730 |
727 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { | 731 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { |
728 TRACE_EVENT_INSTANT0("cc", | 732 TRACE_EVENT_INSTANT0("cc", |
729 "Scheduler: SkipNextBeginMainFrameToReduceLatency", | 733 "Scheduler: SkipNextBeginMainFrameToReduceLatency", |
730 TRACE_EVENT_SCOPE_THREAD); | 734 TRACE_EVENT_SCOPE_THREAD); |
731 skip_next_begin_main_frame_to_reduce_latency_ = true; | 735 skip_next_begin_main_frame_to_reduce_latency_ = true; |
732 } | 736 } |
733 | 737 |
734 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { | 738 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { |
735 return video_needs_begin_frames_; | 739 return video_needs_begin_frames_; |
736 } | 740 } |
737 | 741 |
738 bool SchedulerStateMachine::BeginFrameNeeded() const { | 742 bool SchedulerStateMachine::BeginFrameNeeded() const { |
739 // We can't handle BeginFrames when output surface isn't initialized. | 743 // We can't handle BeginFrames when output surface isn't initialized. |
740 // TODO(brianderson): Support output surface creation inside a BeginFrame. | 744 // TODO(brianderson): Support output surface creation inside a BeginFrame. |
741 if (!HasInitializedOutputSurface()) | 745 if (!HasInitializedCompositorFrameSink()) |
742 return false; | 746 return false; |
743 | 747 |
744 // If we are not visible, we don't need BeginFrame messages. | 748 // If we are not visible, we don't need BeginFrame messages. |
745 if (!visible_) | 749 if (!visible_) |
746 return false; | 750 return false; |
747 | 751 |
748 return BeginFrameRequiredForAction() || BeginFrameNeededForVideo() || | 752 return BeginFrameRequiredForAction() || BeginFrameNeededForVideo() || |
749 ProactiveBeginFrameWanted(); | 753 ProactiveBeginFrameWanted(); |
750 } | 754 } |
751 | 755 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; | 824 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; |
821 current_frame_number_++; | 825 current_frame_number_++; |
822 | 826 |
823 last_commit_had_no_updates_ = false; | 827 last_commit_had_no_updates_ = false; |
824 did_draw_in_last_frame_ = false; | 828 did_draw_in_last_frame_ = false; |
825 did_swap_in_last_frame_ = false; | 829 did_swap_in_last_frame_ = false; |
826 needs_one_begin_impl_frame_ = false; | 830 needs_one_begin_impl_frame_ = false; |
827 | 831 |
828 // Clear funnels for any actions we perform during the frame. | 832 // Clear funnels for any actions we perform during the frame. |
829 send_begin_main_frame_funnel_ = false; | 833 send_begin_main_frame_funnel_ = false; |
830 invalidate_output_surface_funnel_ = false; | 834 invalidate_compositor_frame_sink_funnel_ = false; |
831 | 835 |
832 // "Drain" the PrepareTiles funnel. | 836 // "Drain" the PrepareTiles funnel. |
833 if (prepare_tiles_funnel_ > 0) | 837 if (prepare_tiles_funnel_ > 0) |
834 prepare_tiles_funnel_--; | 838 prepare_tiles_funnel_--; |
835 } | 839 } |
836 | 840 |
837 void SchedulerStateMachine::OnBeginImplFrameDeadline() { | 841 void SchedulerStateMachine::OnBeginImplFrameDeadline() { |
838 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; | 842 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; |
839 | 843 |
840 // Clear funnels for any actions we perform during the deadline. | 844 // Clear funnels for any actions we perform during the deadline. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); | 971 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); |
968 needs_prepare_tiles_ = true; | 972 needs_prepare_tiles_ = true; |
969 } | 973 } |
970 } | 974 } |
971 void SchedulerStateMachine::DidSwapBuffers() { | 975 void SchedulerStateMachine::DidSwapBuffers() { |
972 TRACE_EVENT_ASYNC_BEGIN1("cc", "Scheduler:pending_swaps", this, | 976 TRACE_EVENT_ASYNC_BEGIN1("cc", "Scheduler:pending_swaps", this, |
973 "pending_frames", pending_swaps_); | 977 "pending_frames", pending_swaps_); |
974 DCHECK_LT(pending_swaps_, kMaxPendingSwaps); | 978 DCHECK_LT(pending_swaps_, kMaxPendingSwaps); |
975 | 979 |
976 pending_swaps_++; | 980 pending_swaps_++; |
977 swaps_with_current_output_surface_++; | 981 swaps_with_current_compositor_frame_sink_++; |
978 | 982 |
979 did_swap_in_last_frame_ = true; | 983 did_swap_in_last_frame_ = true; |
980 last_frame_number_swap_performed_ = current_frame_number_; | 984 last_frame_number_swap_performed_ = current_frame_number_; |
981 } | 985 } |
982 | 986 |
983 void SchedulerStateMachine::DidSwapBuffersComplete() { | 987 void SchedulerStateMachine::DidSwapBuffersComplete() { |
984 TRACE_EVENT_ASYNC_END1("cc", "Scheduler:pending_swaps", this, | 988 TRACE_EVENT_ASYNC_END1("cc", "Scheduler:pending_swaps", this, |
985 "pending_frames", pending_swaps_); | 989 "pending_frames", pending_swaps_); |
986 pending_swaps_--; | 990 pending_swaps_--; |
987 } | 991 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1037 } |
1034 | 1038 |
1035 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { | 1039 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { |
1036 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); | 1040 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); |
1037 | 1041 |
1038 // If the main thread aborted, it doesn't matter if the main thread missed | 1042 // If the main thread aborted, it doesn't matter if the main thread missed |
1039 // the last deadline since it didn't have an update anyway. | 1043 // the last deadline since it didn't have an update anyway. |
1040 main_thread_missed_last_deadline_ = false; | 1044 main_thread_missed_last_deadline_ = false; |
1041 | 1045 |
1042 switch (reason) { | 1046 switch (reason) { |
1043 case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST: | 1047 case CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST: |
1044 case CommitEarlyOutReason::ABORTED_NOT_VISIBLE: | 1048 case CommitEarlyOutReason::ABORTED_NOT_VISIBLE: |
1045 case CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT: | 1049 case CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT: |
1046 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 1050 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
1047 SetNeedsBeginMainFrame(); | 1051 SetNeedsBeginMainFrame(); |
1048 return; | 1052 return; |
1049 case CommitEarlyOutReason::FINISHED_NO_UPDATES: | 1053 case CommitEarlyOutReason::FINISHED_NO_UPDATES: |
1050 bool commit_has_no_updates = true; | 1054 bool commit_has_no_updates = true; |
1051 WillCommit(commit_has_no_updates); | 1055 WillCommit(commit_has_no_updates); |
1052 return; | 1056 return; |
1053 } | 1057 } |
1054 } | 1058 } |
1055 | 1059 |
1056 void SchedulerStateMachine::DidPrepareTiles() { | 1060 void SchedulerStateMachine::DidPrepareTiles() { |
1057 needs_prepare_tiles_ = false; | 1061 needs_prepare_tiles_ = false; |
1058 // "Fill" the PrepareTiles funnel. | 1062 // "Fill" the PrepareTiles funnel. |
1059 prepare_tiles_funnel_++; | 1063 prepare_tiles_funnel_++; |
1060 } | 1064 } |
1061 | 1065 |
1062 void SchedulerStateMachine::DidLoseOutputSurface() { | 1066 void SchedulerStateMachine::DidLoseCompositorFrameSink() { |
1063 if (output_surface_state_ == OUTPUT_SURFACE_NONE || | 1067 if (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE || |
1064 output_surface_state_ == OUTPUT_SURFACE_CREATING) | 1068 compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_CREATING) |
1065 return; | 1069 return; |
1066 output_surface_state_ = OUTPUT_SURFACE_NONE; | 1070 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_NONE; |
1067 needs_redraw_ = false; | 1071 needs_redraw_ = false; |
1068 wait_for_ready_to_draw_ = false; | 1072 wait_for_ready_to_draw_ = false; |
1069 } | 1073 } |
1070 | 1074 |
1071 void SchedulerStateMachine::NotifyReadyToActivate() { | 1075 void SchedulerStateMachine::NotifyReadyToActivate() { |
1072 if (has_pending_tree_) | 1076 if (has_pending_tree_) |
1073 pending_tree_is_ready_for_activation_ = true; | 1077 pending_tree_is_ready_for_activation_ = true; |
1074 } | 1078 } |
1075 | 1079 |
1076 void SchedulerStateMachine::NotifyReadyToDraw() { | 1080 void SchedulerStateMachine::NotifyReadyToDraw() { |
1077 wait_for_ready_to_draw_ = false; | 1081 wait_for_ready_to_draw_ = false; |
1078 } | 1082 } |
1079 | 1083 |
1080 void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() { | 1084 void SchedulerStateMachine::DidCreateAndInitializeCompositorFrameSink() { |
1081 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_CREATING); | 1085 DCHECK_EQ(compositor_frame_sink_state_, COMPOSITOR_FRAME_SINK_CREATING); |
1082 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT; | 1086 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT; |
1083 | 1087 |
1084 if (did_create_and_initialize_first_output_surface_) { | 1088 if (did_create_and_initialize_first_compositor_frame_sink_) { |
1085 // TODO(boliu): See if we can remove this when impl-side painting is always | 1089 // TODO(boliu): See if we can remove this when impl-side painting is always |
1086 // on. Does anything on the main thread need to update after recreate? | 1090 // on. Does anything on the main thread need to update after recreate? |
1087 needs_begin_main_frame_ = true; | 1091 needs_begin_main_frame_ = true; |
1088 } | 1092 } |
1089 did_create_and_initialize_first_output_surface_ = true; | 1093 did_create_and_initialize_first_compositor_frame_sink_ = true; |
1090 pending_swaps_ = 0; | 1094 pending_swaps_ = 0; |
1091 swaps_with_current_output_surface_ = 0; | 1095 swaps_with_current_compositor_frame_sink_ = 0; |
1092 main_thread_missed_last_deadline_ = false; | 1096 main_thread_missed_last_deadline_ = false; |
1093 } | 1097 } |
1094 | 1098 |
1095 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { | 1099 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { |
1096 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_SENT); | 1100 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_SENT); |
1097 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_STARTED; | 1101 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_STARTED; |
1098 } | 1102 } |
1099 | 1103 |
1100 bool SchedulerStateMachine::HasInitializedOutputSurface() const { | 1104 bool SchedulerStateMachine::HasInitializedCompositorFrameSink() const { |
1101 switch (output_surface_state_) { | 1105 switch (compositor_frame_sink_state_) { |
1102 case OUTPUT_SURFACE_NONE: | 1106 case COMPOSITOR_FRAME_SINK_NONE: |
1103 case OUTPUT_SURFACE_CREATING: | 1107 case COMPOSITOR_FRAME_SINK_CREATING: |
1104 return false; | 1108 return false; |
1105 | 1109 |
1106 case OUTPUT_SURFACE_ACTIVE: | 1110 case COMPOSITOR_FRAME_SINK_ACTIVE: |
1107 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1111 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
1108 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1112 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
1109 return true; | 1113 return true; |
1110 } | 1114 } |
1111 NOTREACHED(); | 1115 NOTREACHED(); |
1112 return false; | 1116 return false; |
1113 } | 1117 } |
1114 | 1118 |
1115 } // namespace cc | 1119 } // namespace cc |
OLD | NEW |