| 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 kMaxPendingSubmitFrames = 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 compositor_frame_sink_state_(COMPOSITOR_FRAME_SINK_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_submit_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_compositor_frame_sink_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_compositor_frame_sink_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_submit_frames_(0), |
| 39 swaps_with_current_compositor_frame_sink_(0), | 39 submit_frames_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_compositor_frame_sink_(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_submit_in_last_frame_(false) {} |
| 64 | 64 |
| 65 const char* SchedulerStateMachine::CompositorFrameSinkStateToString( | 65 const char* SchedulerStateMachine::CompositorFrameSinkStateToString( |
| 66 CompositorFrameSinkState state) { | 66 CompositorFrameSinkState state) { |
| 67 switch (state) { | 67 switch (state) { |
| 68 case COMPOSITOR_FRAME_SINK_NONE: | 68 case COMPOSITOR_FRAME_SINK_NONE: |
| 69 return "COMPOSITOR_FRAME_SINK_NONE"; | 69 return "COMPOSITOR_FRAME_SINK_NONE"; |
| 70 case COMPOSITOR_FRAME_SINK_ACTIVE: | 70 case COMPOSITOR_FRAME_SINK_ACTIVE: |
| 71 return "COMPOSITOR_FRAME_SINK_ACTIVE"; | 71 return "COMPOSITOR_FRAME_SINK_ACTIVE"; |
| 72 case COMPOSITOR_FRAME_SINK_CREATING: | 72 case COMPOSITOR_FRAME_SINK_CREATING: |
| 73 return "COMPOSITOR_FRAME_SINK_CREATING"; | 73 return "COMPOSITOR_FRAME_SINK_CREATING"; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 const char* SchedulerStateMachine::ActionToString(Action action) { | 158 const char* SchedulerStateMachine::ActionToString(Action action) { |
| 159 switch (action) { | 159 switch (action) { |
| 160 case ACTION_NONE: | 160 case ACTION_NONE: |
| 161 return "ACTION_NONE"; | 161 return "ACTION_NONE"; |
| 162 case ACTION_SEND_BEGIN_MAIN_FRAME: | 162 case ACTION_SEND_BEGIN_MAIN_FRAME: |
| 163 return "ACTION_SEND_BEGIN_MAIN_FRAME"; | 163 return "ACTION_SEND_BEGIN_MAIN_FRAME"; |
| 164 case ACTION_COMMIT: | 164 case ACTION_COMMIT: |
| 165 return "ACTION_COMMIT"; | 165 return "ACTION_COMMIT"; |
| 166 case ACTION_ACTIVATE_SYNC_TREE: | 166 case ACTION_ACTIVATE_SYNC_TREE: |
| 167 return "ACTION_ACTIVATE_SYNC_TREE"; | 167 return "ACTION_ACTIVATE_SYNC_TREE"; |
| 168 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: | 168 case ACTION_SUBMIT_COMPOSITOR_FRAME_IF_POSSIBLE: |
| 169 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; | 169 return "ACTION_SUBMIT_COMPOSITOR_FRAME_IF_POSSIBLE"; |
| 170 case ACTION_DRAW_AND_SWAP_FORCED: | 170 case ACTION_SUBMIT_COMPOSITOR_FRAME_FORCED: |
| 171 return "ACTION_DRAW_AND_SWAP_FORCED"; | 171 return "ACTION_SUBMIT_COMPOSITOR_FRAME_FORCED"; |
| 172 case ACTION_DRAW_AND_SWAP_ABORT: | 172 case ACTION_SUBMIT_COMPOSITOR_FRAME_ABORT: |
| 173 return "ACTION_DRAW_AND_SWAP_ABORT"; | 173 return "ACTION_SUBMIT_COMPOSITOR_FRAME_ABORT"; |
| 174 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: | 174 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: |
| 175 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION"; | 175 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION"; |
| 176 case ACTION_PREPARE_TILES: | 176 case ACTION_PREPARE_TILES: |
| 177 return "ACTION_PREPARE_TILES"; | 177 return "ACTION_PREPARE_TILES"; |
| 178 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK: | 178 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK: |
| 179 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK"; | 179 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK"; |
| 180 } | 180 } |
| 181 NOTREACHED(); | 181 NOTREACHED(); |
| 182 return "???"; | 182 return "???"; |
| 183 } | 183 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 201 state->SetString( | 201 state->SetString( |
| 202 "compositor_frame_sink_state_", | 202 "compositor_frame_sink_state_", |
| 203 CompositorFrameSinkStateToString(compositor_frame_sink_state_)); | 203 CompositorFrameSinkStateToString(compositor_frame_sink_state_)); |
| 204 state->SetString("forced_redraw_state", | 204 state->SetString("forced_redraw_state", |
| 205 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); | 205 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); |
| 206 state->EndDictionary(); | 206 state->EndDictionary(); |
| 207 | 207 |
| 208 state->BeginDictionary("minor_state"); | 208 state->BeginDictionary("minor_state"); |
| 209 state->SetInteger("commit_count", commit_count_); | 209 state->SetInteger("commit_count", commit_count_); |
| 210 state->SetInteger("current_frame_number", current_frame_number_); | 210 state->SetInteger("current_frame_number", current_frame_number_); |
| 211 state->SetInteger("last_frame_number_swap_performed", | 211 state->SetInteger("last_frame_number_submit_performed", |
| 212 last_frame_number_swap_performed_); | 212 last_frame_number_submit_performed_); |
| 213 state->SetInteger("last_frame_number_draw_performed", | 213 state->SetInteger("last_frame_number_draw_performed", |
| 214 last_frame_number_draw_performed_); | 214 last_frame_number_draw_performed_); |
| 215 state->SetInteger("last_frame_number_begin_main_frame_sent", | 215 state->SetInteger("last_frame_number_begin_main_frame_sent", |
| 216 last_frame_number_begin_main_frame_sent_); | 216 last_frame_number_begin_main_frame_sent_); |
| 217 state->SetBoolean("funnel: draw_funnel", draw_funnel_); | 217 state->SetBoolean("funnel: draw_funnel", draw_funnel_); |
| 218 state->SetBoolean("funnel: send_begin_main_frame_funnel", | 218 state->SetBoolean("funnel: send_begin_main_frame_funnel", |
| 219 send_begin_main_frame_funnel_); | 219 send_begin_main_frame_funnel_); |
| 220 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); | 220 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); |
| 221 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", | 221 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", |
| 222 invalidate_compositor_frame_sink_funnel_); | 222 invalidate_compositor_frame_sink_funnel_); |
| 223 state->SetInteger("consecutive_checkerboard_animations", | 223 state->SetInteger("consecutive_checkerboard_animations", |
| 224 consecutive_checkerboard_animations_); | 224 consecutive_checkerboard_animations_); |
| 225 state->SetInteger("pending_swaps_", pending_swaps_); | 225 state->SetInteger("pending_submit_frames_", pending_submit_frames_); |
| 226 state->SetInteger("swaps_with_current_compositor_frame_sink", | 226 state->SetInteger("submit_frames_with_current_compositor_frame_sink", |
| 227 swaps_with_current_compositor_frame_sink_); | 227 submit_frames_with_current_compositor_frame_sink_); |
| 228 state->SetBoolean("needs_redraw", needs_redraw_); | 228 state->SetBoolean("needs_redraw", needs_redraw_); |
| 229 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); | 229 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); |
| 230 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); | 230 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); |
| 231 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_); | 231 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_); |
| 232 state->SetBoolean("visible", visible_); | 232 state->SetBoolean("visible", visible_); |
| 233 state->SetBoolean("begin_frame_source_paused", begin_frame_source_paused_); | 233 state->SetBoolean("begin_frame_source_paused", begin_frame_source_paused_); |
| 234 state->SetBoolean("can_draw", can_draw_); | 234 state->SetBoolean("can_draw", can_draw_); |
| 235 state->SetBoolean("resourceless_draw", resourceless_draw_); | 235 state->SetBoolean("resourceless_draw", resourceless_draw_); |
| 236 state->SetBoolean("has_pending_tree", has_pending_tree_); | 236 state->SetBoolean("has_pending_tree", has_pending_tree_); |
| 237 state->SetBoolean("pending_tree_is_ready_for_activation", | 237 state->SetBoolean("pending_tree_is_ready_for_activation", |
| 238 pending_tree_is_ready_for_activation_); | 238 pending_tree_is_ready_for_activation_); |
| 239 state->SetBoolean("active_tree_needs_first_draw", | 239 state->SetBoolean("active_tree_needs_first_draw", |
| 240 active_tree_needs_first_draw_); | 240 active_tree_needs_first_draw_); |
| 241 state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_); | 241 state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_); |
| 242 state->SetBoolean("did_create_and_initialize_first_compositor_frame_sink", | 242 state->SetBoolean("did_create_and_initialize_first_compositor_frame_sink", |
| 243 did_create_and_initialize_first_compositor_frame_sink_); | 243 did_create_and_initialize_first_compositor_frame_sink_); |
| 244 state->SetString("tree_priority", TreePriorityToString(tree_priority_)); | 244 state->SetString("tree_priority", TreePriorityToString(tree_priority_)); |
| 245 state->SetString("scroll_handler_state", | 245 state->SetString("scroll_handler_state", |
| 246 ScrollHandlerStateToString(scroll_handler_state_)); | 246 ScrollHandlerStateToString(scroll_handler_state_)); |
| 247 state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", | 247 state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", |
| 248 critical_begin_main_frame_to_activate_is_fast_); | 248 critical_begin_main_frame_to_activate_is_fast_); |
| 249 state->SetBoolean("main_thread_missed_last_deadline", | 249 state->SetBoolean("main_thread_missed_last_deadline", |
| 250 main_thread_missed_last_deadline_); | 250 main_thread_missed_last_deadline_); |
| 251 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 251 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
| 252 skip_next_begin_main_frame_to_reduce_latency_); | 252 skip_next_begin_main_frame_to_reduce_latency_); |
| 253 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); | 253 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); |
| 254 state->SetBoolean("defer_commits", defer_commits_); | 254 state->SetBoolean("defer_commits", defer_commits_); |
| 255 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); | 255 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); |
| 256 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_); | 256 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_); |
| 257 state->SetBoolean("did_swap_in_last_frame", did_swap_in_last_frame_); | 257 state->SetBoolean("did_submit_in_last_frame", did_submit_in_last_frame_); |
| 258 state->EndDictionary(); | 258 state->EndDictionary(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { | 261 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
| 262 // Normally when |visible_| is false or |begin_frame_source_paused_| is true, | 262 // Normally when |visible_| is false or |begin_frame_source_paused_| is true, |
| 263 // pending activations will be forced and draws will be aborted. However, | 263 // pending activations will be forced and draws will be aborted. However, |
| 264 // when the embedder is Android WebView, software draws could be scheduled by | 264 // when the embedder is Android WebView, software draws could be scheduled by |
| 265 // the Android OS at any time and draws should not be aborted in this case. | 265 // the Android OS at any time and draws should not be aborted in this case. |
| 266 bool is_compositor_frame_sink_lost = | 266 bool is_compositor_frame_sink_lost = |
| 267 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE); | 267 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 // this before checking for aborted draws because aborted draws do not request | 348 // this before checking for aborted draws because aborted draws do not request |
| 349 // a swap. | 349 // a swap. |
| 350 if (draw_funnel_) | 350 if (draw_funnel_) |
| 351 return false; | 351 return false; |
| 352 | 352 |
| 353 // Don't draw if we are waiting on the first commit after a surface. | 353 // Don't draw if we are waiting on the first commit after a surface. |
| 354 if (compositor_frame_sink_state_ != COMPOSITOR_FRAME_SINK_ACTIVE) | 354 if (compositor_frame_sink_state_ != COMPOSITOR_FRAME_SINK_ACTIVE) |
| 355 return false; | 355 return false; |
| 356 | 356 |
| 357 // Do not queue too many swaps. | 357 // Do not queue too many swaps. |
| 358 if (SwapThrottled()) | 358 if (SubmitThrottled()) |
| 359 return false; | 359 return false; |
| 360 | 360 |
| 361 // Except for the cases above, do not draw outside of the BeginImplFrame | 361 // Except for the cases above, do not draw outside of the BeginImplFrame |
| 362 // deadline. | 362 // deadline. |
| 363 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 363 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
| 364 return false; | 364 return false; |
| 365 | 365 |
| 366 // Wait for active tree to be rasterized before drawing in browser compositor. | 366 // Wait for active tree to be rasterized before drawing in browser compositor. |
| 367 if (wait_for_ready_to_draw_) { | 367 if (wait_for_ready_to_draw_) { |
| 368 DCHECK(settings_.commit_to_active_tree); | 368 DCHECK(settings_.commit_to_active_tree); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // immediately to IDLE. | 435 // immediately to IDLE. |
| 436 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) | 436 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) |
| 437 return false; | 437 return false; |
| 438 | 438 |
| 439 // MFBA is disabled and we are waiting for previous activation. | 439 // MFBA is disabled and we are waiting for previous activation. |
| 440 if (!settings_.main_frame_before_activation_enabled && has_pending_tree_) | 440 if (!settings_.main_frame_before_activation_enabled && has_pending_tree_) |
| 441 return false; | 441 return false; |
| 442 | 442 |
| 443 // We are waiting for previous frame to be drawn, swapped and acked. | 443 // We are waiting for previous frame to be drawn, swapped and acked. |
| 444 if (settings_.commit_to_active_tree && | 444 if (settings_.commit_to_active_tree && |
| 445 (active_tree_needs_first_draw_ || SwapThrottled())) { | 445 (active_tree_needs_first_draw_ || SubmitThrottled())) { |
| 446 return false; | 446 return false; |
| 447 } | 447 } |
| 448 | 448 |
| 449 // Don't send BeginMainFrame early if we are prioritizing the active tree | 449 // Don't send BeginMainFrame early if we are prioritizing the active tree |
| 450 // because of ImplLatencyTakesPriority. | 450 // because of ImplLatencyTakesPriority. |
| 451 if (ImplLatencyTakesPriority() && | 451 if (ImplLatencyTakesPriority() && |
| 452 (has_pending_tree_ || active_tree_needs_first_draw_)) { | 452 (has_pending_tree_ || active_tree_needs_first_draw_)) { |
| 453 return false; | 453 return false; |
| 454 } | 454 } |
| 455 | 455 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 466 | 466 |
| 467 // We need a new commit for the forced redraw. This honors the | 467 // We need a new commit for the forced redraw. This honors the |
| 468 // single commit per interval because the result will be swapped to screen. | 468 // single commit per interval because the result will be swapped to screen. |
| 469 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) | 469 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) |
| 470 return true; | 470 return true; |
| 471 | 471 |
| 472 // We shouldn't normally accept commits if there isn't an CompositorFrameSink. | 472 // We shouldn't normally accept commits if there isn't an CompositorFrameSink. |
| 473 if (!HasInitializedCompositorFrameSink()) | 473 if (!HasInitializedCompositorFrameSink()) |
| 474 return false; | 474 return false; |
| 475 | 475 |
| 476 if (!settings_.main_frame_while_swap_throttled_enabled) { | 476 if (!settings_.main_frame_while_submit_frame_throttled_enabled) { |
| 477 // SwapAck throttle the BeginMainFrames unless we just swapped to | 477 // Throttle the BeginMainFrames on CompositorFrameAck unless we just |
| 478 // potentially improve impl-thread latency over main-thread throughput. | 478 // submitted a frame to potentially improve impl-thread latency over |
| 479 // main-thread throughput. |
| 479 // TODO(brianderson): Remove this restriction to improve throughput or | 480 // TODO(brianderson): Remove this restriction to improve throughput or |
| 480 // make it conditional on ImplLatencyTakesPriority. | 481 // make it conditional on ImplLatencyTakesPriority. |
| 481 bool just_swapped_in_deadline = | 482 bool just_submitted_in_deadline = |
| 482 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && | 483 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && |
| 483 did_swap_in_last_frame_; | 484 did_submit_in_last_frame_; |
| 484 if (SwapThrottled() && !just_swapped_in_deadline) | 485 if (SubmitThrottled() && !just_submitted_in_deadline) |
| 485 return false; | 486 return false; |
| 486 } | 487 } |
| 487 | 488 |
| 488 if (skip_next_begin_main_frame_to_reduce_latency_) | 489 if (skip_next_begin_main_frame_to_reduce_latency_) |
| 489 return false; | 490 return false; |
| 490 | 491 |
| 491 return true; | 492 return true; |
| 492 } | 493 } |
| 493 | 494 |
| 494 bool SchedulerStateMachine::ShouldCommit() const { | 495 bool SchedulerStateMachine::ShouldCommit() const { |
| 495 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) | 496 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) |
| 496 return false; | 497 return false; |
| 497 | 498 |
| 498 // We must not finish the commit until the pending tree is free. | 499 // We must not finish the commit until the pending tree is free. |
| 499 if (has_pending_tree_) { | 500 if (has_pending_tree_) { |
| 500 DCHECK(settings_.main_frame_before_activation_enabled); | 501 DCHECK(settings_.main_frame_before_activation_enabled); |
| 501 return false; | 502 return false; |
| 502 } | 503 } |
| 503 | 504 |
| 504 // If we only have an active tree, it is incorrect to replace it before we've | 505 // If we only have an active tree, it is incorrect to replace it before we've |
| 505 // drawn it. | 506 // drawn it. |
| 506 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); | 507 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); |
| 507 | 508 |
| 508 // In browser compositor commit reclaims any resources submitted during draw. | 509 // In browser compositor commit reclaims any resources submitted during draw. |
| 509 DCHECK(!settings_.commit_to_active_tree || !SwapThrottled()); | 510 DCHECK(!settings_.commit_to_active_tree || !SubmitThrottled()); |
| 510 | 511 |
| 511 return true; | 512 return true; |
| 512 } | 513 } |
| 513 | 514 |
| 514 bool SchedulerStateMachine::ShouldPrepareTiles() const { | 515 bool SchedulerStateMachine::ShouldPrepareTiles() const { |
| 515 // PrepareTiles only really needs to be called immediately after commit | 516 // PrepareTiles only really needs to be called immediately after commit |
| 516 // and then periodically after that. Use a funnel to make sure we average | 517 // and then periodically after that. Use a funnel to make sure we average |
| 517 // one PrepareTiles per BeginImplFrame in the long run. | 518 // one PrepareTiles per BeginImplFrame in the long run. |
| 518 if (prepare_tiles_funnel_ > 0) | 519 if (prepare_tiles_funnel_ > 0) |
| 519 return false; | 520 return false; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 545 return needs_redraw_ || needs_prepare_tiles_; | 546 return needs_redraw_ || needs_prepare_tiles_; |
| 546 } | 547 } |
| 547 | 548 |
| 548 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { | 549 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { |
| 549 if (ShouldActivatePendingTree()) | 550 if (ShouldActivatePendingTree()) |
| 550 return ACTION_ACTIVATE_SYNC_TREE; | 551 return ACTION_ACTIVATE_SYNC_TREE; |
| 551 if (ShouldCommit()) | 552 if (ShouldCommit()) |
| 552 return ACTION_COMMIT; | 553 return ACTION_COMMIT; |
| 553 if (ShouldDraw()) { | 554 if (ShouldDraw()) { |
| 554 if (PendingDrawsShouldBeAborted()) | 555 if (PendingDrawsShouldBeAborted()) |
| 555 return ACTION_DRAW_AND_SWAP_ABORT; | 556 return ACTION_SUBMIT_COMPOSITOR_FRAME_ABORT; |
| 556 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 557 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| 557 return ACTION_DRAW_AND_SWAP_FORCED; | 558 return ACTION_SUBMIT_COMPOSITOR_FRAME_FORCED; |
| 558 else | 559 else |
| 559 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; | 560 return ACTION_SUBMIT_COMPOSITOR_FRAME_IF_POSSIBLE; |
| 560 } | 561 } |
| 561 if (ShouldPrepareTiles()) | 562 if (ShouldPrepareTiles()) |
| 562 return ACTION_PREPARE_TILES; | 563 return ACTION_PREPARE_TILES; |
| 563 if (ShouldSendBeginMainFrame()) | 564 if (ShouldSendBeginMainFrame()) |
| 564 return ACTION_SEND_BEGIN_MAIN_FRAME; | 565 return ACTION_SEND_BEGIN_MAIN_FRAME; |
| 565 if (ShouldInvalidateCompositorFrameSink()) | 566 if (ShouldInvalidateCompositorFrameSink()) |
| 566 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK; | 567 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK; |
| 567 if (ShouldBeginCompositorFrameSinkCreation()) | 568 if (ShouldBeginCompositorFrameSinkCreation()) |
| 568 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION; | 569 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION; |
| 569 return ACTION_NONE; | 570 return ACTION_NONE; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 case DRAW_ABORTED_CANT_DRAW: | 653 case DRAW_ABORTED_CANT_DRAW: |
| 653 case DRAW_ABORTED_CONTEXT_LOST: | 654 case DRAW_ABORTED_CONTEXT_LOST: |
| 654 NOTREACHED() << "Invalid return DrawResult:" << draw_result; | 655 NOTREACHED() << "Invalid return DrawResult:" << draw_result; |
| 655 break; | 656 break; |
| 656 case DRAW_ABORTED_DRAINING_PIPELINE: | 657 case DRAW_ABORTED_DRAINING_PIPELINE: |
| 657 case DRAW_SUCCESS: | 658 case DRAW_SUCCESS: |
| 658 consecutive_checkerboard_animations_ = 0; | 659 consecutive_checkerboard_animations_ = 0; |
| 659 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 660 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 660 break; | 661 break; |
| 661 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | 662 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: |
| 662 DCHECK(!did_swap_in_last_frame_); | 663 DCHECK(!did_submit_in_last_frame_); |
| 663 needs_begin_main_frame_ = true; | 664 needs_begin_main_frame_ = true; |
| 664 needs_redraw_ = true; | 665 needs_redraw_ = true; |
| 665 consecutive_checkerboard_animations_++; | 666 consecutive_checkerboard_animations_++; |
| 666 | 667 |
| 667 if (consecutive_checkerboard_animations_ >= | 668 if (consecutive_checkerboard_animations_ >= |
| 668 settings_.maximum_number_of_failed_draws_before_draw_is_forced && | 669 settings_.maximum_number_of_failed_draws_before_draw_is_forced && |
| 669 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && | 670 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && |
| 670 settings_.timeout_and_draw_when_animation_checkerboards) { | 671 settings_.timeout_and_draw_when_animation_checkerboards) { |
| 671 // We need to force a draw, but it doesn't make sense to do this until | 672 // We need to force a draw, but it doesn't make sense to do this until |
| 672 // we've committed and have new textures. | 673 // we've committed and have new textures. |
| 673 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; | 674 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; |
| 674 } | 675 } |
| 675 break; | 676 break; |
| 676 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: | 677 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: |
| 677 DCHECK(!did_swap_in_last_frame_); | 678 DCHECK(!did_submit_in_last_frame_); |
| 678 // It's not clear whether this missing content is because of missing | 679 // It's not clear whether this missing content is because of missing |
| 679 // pictures (which requires a commit) or because of memory pressure | 680 // pictures (which requires a commit) or because of memory pressure |
| 680 // removing textures (which might not). To be safe, request a commit | 681 // removing textures (which might not). To be safe, request a commit |
| 681 // anyway. | 682 // anyway. |
| 682 needs_begin_main_frame_ = true; | 683 needs_begin_main_frame_ = true; |
| 683 break; | 684 break; |
| 684 } | 685 } |
| 685 } | 686 } |
| 686 | 687 |
| 687 void SchedulerStateMachine::WillDraw() { | 688 void SchedulerStateMachine::WillDraw() { |
| 688 DCHECK(!draw_funnel_); | 689 DCHECK(!draw_funnel_); |
| 689 WillDrawInternal(); | 690 WillDrawInternal(); |
| 690 } | 691 } |
| 691 | 692 |
| 692 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { | 693 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { |
| 693 DidDrawInternal(draw_result); | 694 DidDrawInternal(draw_result); |
| 694 } | 695 } |
| 695 | 696 |
| 696 void SchedulerStateMachine::AbortDrawAndSwap() { | 697 void SchedulerStateMachine::AbortSubmitCompositorFrame() { |
| 697 // Pretend like the draw was successful. | 698 // Pretend like the draw was successful. |
| 698 // Note: We may abort at any time and cannot DCHECK that | 699 // Note: We may abort at any time and cannot DCHECK that |
| 699 // we haven't drawn in or swapped in the last frame here. | 700 // we haven't drawn in or swapped in the last frame here. |
| 700 WillDrawInternal(); | 701 WillDrawInternal(); |
| 701 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); | 702 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); |
| 702 } | 703 } |
| 703 | 704 |
| 704 void SchedulerStateMachine::WillPrepareTiles() { | 705 void SchedulerStateMachine::WillPrepareTiles() { |
| 705 needs_prepare_tiles_ = false; | 706 needs_prepare_tiles_ = false; |
| 706 } | 707 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 // If the pending tree activates quickly, we'll want a BeginImplFrame soon | 802 // If the pending tree activates quickly, we'll want a BeginImplFrame soon |
| 802 // to draw the new active tree. | 803 // to draw the new active tree. |
| 803 if (has_pending_tree_) | 804 if (has_pending_tree_) |
| 804 return true; | 805 return true; |
| 805 | 806 |
| 806 // Changing priorities may allow us to activate (given the new priorities), | 807 // Changing priorities may allow us to activate (given the new priorities), |
| 807 // which may result in a new frame. | 808 // which may result in a new frame. |
| 808 if (needs_prepare_tiles_) | 809 if (needs_prepare_tiles_) |
| 809 return true; | 810 return true; |
| 810 | 811 |
| 811 // If we just tried to DrawAndSwap, it's likely that we are going to produce | 812 // If we just tried to SubmitCompositorFrame, it's likely that we are going to |
| 812 // another frame soon. This helps avoid negative glitches in our | 813 // produce another frame soon. This helps avoid negative glitches in our |
| 813 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame | 814 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame |
| 814 // provider and get sampled at an inopportune time, delaying the next | 815 // provider and get sampled at an inopportune time, delaying the next |
| 815 // BeginImplFrame. | 816 // BeginImplFrame. |
| 816 if (did_draw_in_last_frame_) | 817 if (did_draw_in_last_frame_) |
| 817 return true; | 818 return true; |
| 818 | 819 |
| 819 // If the last commit was aborted because of early out (no updates), we should | 820 // If the last commit was aborted because of early out (no updates), we should |
| 820 // still want a begin frame in case there is a commit coming again. | 821 // still want a begin frame in case there is a commit coming again. |
| 821 if (last_commit_had_no_updates_) | 822 if (last_commit_had_no_updates_) |
| 822 return true; | 823 return true; |
| 823 | 824 |
| 824 return false; | 825 return false; |
| 825 } | 826 } |
| 826 | 827 |
| 827 void SchedulerStateMachine::OnBeginImplFrame() { | 828 void SchedulerStateMachine::OnBeginImplFrame() { |
| 828 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; | 829 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; |
| 829 current_frame_number_++; | 830 current_frame_number_++; |
| 830 | 831 |
| 831 last_commit_had_no_updates_ = false; | 832 last_commit_had_no_updates_ = false; |
| 832 did_draw_in_last_frame_ = false; | 833 did_draw_in_last_frame_ = false; |
| 833 did_swap_in_last_frame_ = false; | 834 did_submit_in_last_frame_ = false; |
| 834 needs_one_begin_impl_frame_ = false; | 835 needs_one_begin_impl_frame_ = false; |
| 835 | 836 |
| 836 // Clear funnels for any actions we perform during the frame. | 837 // Clear funnels for any actions we perform during the frame. |
| 837 send_begin_main_frame_funnel_ = false; | 838 send_begin_main_frame_funnel_ = false; |
| 838 invalidate_compositor_frame_sink_funnel_ = false; | 839 invalidate_compositor_frame_sink_funnel_ = false; |
| 839 | 840 |
| 840 // "Drain" the PrepareTiles funnel. | 841 // "Drain" the PrepareTiles funnel. |
| 841 if (prepare_tiles_funnel_ > 0) | 842 if (prepare_tiles_funnel_ > 0) |
| 842 prepare_tiles_funnel_--; | 843 prepare_tiles_funnel_--; |
| 843 } | 844 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; | 893 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; |
| 893 } | 894 } |
| 894 } | 895 } |
| 895 | 896 |
| 896 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() | 897 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() |
| 897 const { | 898 const { |
| 898 // If we just forced activation, we should end the deadline right now. | 899 // If we just forced activation, we should end the deadline right now. |
| 899 if (PendingActivationsShouldBeForced() && !has_pending_tree_) | 900 if (PendingActivationsShouldBeForced() && !has_pending_tree_) |
| 900 return true; | 901 return true; |
| 901 | 902 |
| 902 // SwapAck throttle the deadline since we wont draw and swap anyway. | 903 // Throttle the deadline on CompositorFrameAck since we wont draw and submit |
| 903 if (SwapThrottled()) | 904 // anyway. |
| 905 if (SubmitThrottled()) |
| 904 return false; | 906 return false; |
| 905 | 907 |
| 906 if (active_tree_needs_first_draw_) | 908 if (active_tree_needs_first_draw_) |
| 907 return true; | 909 return true; |
| 908 | 910 |
| 909 if (!needs_redraw_) | 911 if (!needs_redraw_) |
| 910 return false; | 912 return false; |
| 911 | 913 |
| 912 // This is used to prioritize impl-thread draws when the main thread isn't | 914 // This is used to prioritize impl-thread draws when the main thread isn't |
| 913 // producing anything, e.g., after an aborted commit. We also check that we | 915 // producing anything, e.g., after an aborted commit. We also check that we |
| 914 // don't have a pending tree -- otherwise we should give it a chance to | 916 // don't have a pending tree -- otherwise we should give it a chance to |
| 915 // activate. | 917 // activate. |
| 916 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. | 918 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. |
| 917 if (!CommitPending() && !has_pending_tree_) | 919 if (!CommitPending() && !has_pending_tree_) |
| 918 return true; | 920 return true; |
| 919 | 921 |
| 920 // Prioritize impl-thread draws in ImplLatencyTakesPriority mode. | 922 // Prioritize impl-thread draws in ImplLatencyTakesPriority mode. |
| 921 if (ImplLatencyTakesPriority()) | 923 if (ImplLatencyTakesPriority()) |
| 922 return true; | 924 return true; |
| 923 | 925 |
| 924 return false; | 926 return false; |
| 925 } | 927 } |
| 926 | 928 |
| 927 bool SchedulerStateMachine::SwapThrottled() const { | 929 bool SchedulerStateMachine::SubmitThrottled() const { |
| 928 return pending_swaps_ >= kMaxPendingSwaps; | 930 return pending_submit_frames_ >= kMaxPendingSubmitFrames; |
| 929 } | 931 } |
| 930 | 932 |
| 931 void SchedulerStateMachine::SetVisible(bool visible) { | 933 void SchedulerStateMachine::SetVisible(bool visible) { |
| 932 if (visible_ == visible) | 934 if (visible_ == visible) |
| 933 return; | 935 return; |
| 934 | 936 |
| 935 visible_ = visible; | 937 visible_ = visible; |
| 936 | 938 |
| 937 if (visible) | 939 if (visible) |
| 938 main_thread_missed_last_deadline_ = false; | 940 main_thread_missed_last_deadline_ = false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 967 has_pending_tree_; | 969 has_pending_tree_; |
| 968 return has_impl_updates && !main_updates_expected; | 970 return has_impl_updates && !main_updates_expected; |
| 969 } | 971 } |
| 970 | 972 |
| 971 void SchedulerStateMachine::SetNeedsPrepareTiles() { | 973 void SchedulerStateMachine::SetNeedsPrepareTiles() { |
| 972 if (!needs_prepare_tiles_) { | 974 if (!needs_prepare_tiles_) { |
| 973 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); | 975 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); |
| 974 needs_prepare_tiles_ = true; | 976 needs_prepare_tiles_ = true; |
| 975 } | 977 } |
| 976 } | 978 } |
| 977 void SchedulerStateMachine::DidSwapBuffers() { | 979 void SchedulerStateMachine::DidSubmitCompositorFrame() { |
| 978 TRACE_EVENT_ASYNC_BEGIN1("cc", "Scheduler:pending_swaps", this, | 980 TRACE_EVENT_ASYNC_BEGIN1("cc", "Scheduler:pending_submit_frames", this, |
| 979 "pending_frames", pending_swaps_); | 981 "pending_frames", pending_submit_frames_); |
| 980 DCHECK_LT(pending_swaps_, kMaxPendingSwaps); | 982 DCHECK_LT(pending_submit_frames_, kMaxPendingSubmitFrames); |
| 981 | 983 |
| 982 pending_swaps_++; | 984 pending_submit_frames_++; |
| 983 swaps_with_current_compositor_frame_sink_++; | 985 submit_frames_with_current_compositor_frame_sink_++; |
| 984 | 986 |
| 985 did_swap_in_last_frame_ = true; | 987 did_submit_in_last_frame_ = true; |
| 986 last_frame_number_swap_performed_ = current_frame_number_; | 988 last_frame_number_submit_performed_ = current_frame_number_; |
| 987 } | 989 } |
| 988 | 990 |
| 989 void SchedulerStateMachine::DidSwapBuffersComplete() { | 991 void SchedulerStateMachine::DidReceiveCompositorFrameAck() { |
| 990 TRACE_EVENT_ASYNC_END1("cc", "Scheduler:pending_swaps", this, | 992 TRACE_EVENT_ASYNC_END1("cc", "Scheduler:pending_submit_frames", this, |
| 991 "pending_frames", pending_swaps_); | 993 "pending_frames", pending_submit_frames_); |
| 992 pending_swaps_--; | 994 pending_submit_frames_--; |
| 993 } | 995 } |
| 994 | 996 |
| 995 void SchedulerStateMachine::SetTreePrioritiesAndScrollState( | 997 void SchedulerStateMachine::SetTreePrioritiesAndScrollState( |
| 996 TreePriority tree_priority, | 998 TreePriority tree_priority, |
| 997 ScrollHandlerState scroll_handler_state) { | 999 ScrollHandlerState scroll_handler_state) { |
| 998 tree_priority_ = tree_priority; | 1000 tree_priority_ = tree_priority; |
| 999 scroll_handler_state_ = scroll_handler_state; | 1001 scroll_handler_state_ = scroll_handler_state; |
| 1000 } | 1002 } |
| 1001 | 1003 |
| 1002 void SchedulerStateMachine::SetCriticalBeginMainFrameToActivateIsFast( | 1004 void SchedulerStateMachine::SetCriticalBeginMainFrameToActivateIsFast( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 void SchedulerStateMachine::DidCreateAndInitializeCompositorFrameSink() { | 1087 void SchedulerStateMachine::DidCreateAndInitializeCompositorFrameSink() { |
| 1086 DCHECK_EQ(compositor_frame_sink_state_, COMPOSITOR_FRAME_SINK_CREATING); | 1088 DCHECK_EQ(compositor_frame_sink_state_, COMPOSITOR_FRAME_SINK_CREATING); |
| 1087 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT; | 1089 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT; |
| 1088 | 1090 |
| 1089 if (did_create_and_initialize_first_compositor_frame_sink_) { | 1091 if (did_create_and_initialize_first_compositor_frame_sink_) { |
| 1090 // TODO(boliu): See if we can remove this when impl-side painting is always | 1092 // TODO(boliu): See if we can remove this when impl-side painting is always |
| 1091 // on. Does anything on the main thread need to update after recreate? | 1093 // on. Does anything on the main thread need to update after recreate? |
| 1092 needs_begin_main_frame_ = true; | 1094 needs_begin_main_frame_ = true; |
| 1093 } | 1095 } |
| 1094 did_create_and_initialize_first_compositor_frame_sink_ = true; | 1096 did_create_and_initialize_first_compositor_frame_sink_ = true; |
| 1095 pending_swaps_ = 0; | 1097 pending_submit_frames_ = 0; |
| 1096 swaps_with_current_compositor_frame_sink_ = 0; | 1098 submit_frames_with_current_compositor_frame_sink_ = 0; |
| 1097 main_thread_missed_last_deadline_ = false; | 1099 main_thread_missed_last_deadline_ = false; |
| 1098 } | 1100 } |
| 1099 | 1101 |
| 1100 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { | 1102 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { |
| 1101 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_SENT); | 1103 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_SENT); |
| 1102 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_STARTED; | 1104 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_STARTED; |
| 1103 } | 1105 } |
| 1104 | 1106 |
| 1105 bool SchedulerStateMachine::HasInitializedCompositorFrameSink() const { | 1107 bool SchedulerStateMachine::HasInitializedCompositorFrameSink() const { |
| 1106 switch (compositor_frame_sink_state_) { | 1108 switch (compositor_frame_sink_state_) { |
| 1107 case COMPOSITOR_FRAME_SINK_NONE: | 1109 case COMPOSITOR_FRAME_SINK_NONE: |
| 1108 case COMPOSITOR_FRAME_SINK_CREATING: | 1110 case COMPOSITOR_FRAME_SINK_CREATING: |
| 1109 return false; | 1111 return false; |
| 1110 | 1112 |
| 1111 case COMPOSITOR_FRAME_SINK_ACTIVE: | 1113 case COMPOSITOR_FRAME_SINK_ACTIVE: |
| 1112 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: | 1114 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
| 1113 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: | 1115 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
| 1114 return true; | 1116 return true; |
| 1115 } | 1117 } |
| 1116 NOTREACHED(); | 1118 NOTREACHED(); |
| 1117 return false; | 1119 return false; |
| 1118 } | 1120 } |
| 1119 | 1121 |
| 1120 } // namespace cc | 1122 } // namespace cc |
| OLD | NEW |