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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 1265023005: cc: Add SchedulerStateMachine::DidDraw and use for forced draws (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WillDidAction0
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler_state_machine.cc
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index 0661e48ef50cea3dc9dd486875e45f8e5c669915..85b566e2ac543ea5a2cdbfe702788341009e0fd2 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -36,6 +36,7 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
pending_swaps_(0),
swaps_with_current_output_surface_(0),
needs_redraw_(false),
+ last_draw_result_(DRAW_SUCCESS),
needs_animate_(false),
needs_prepare_tiles_(false),
needs_begin_main_frame_(false),
@@ -584,28 +585,63 @@ void SchedulerStateMachine::WillAction(Action action) {
}
case ACTION_DRAW_AND_SWAP_FORCED:
+ case ACTION_DRAW_AND_SWAP_IF_POSSIBLE:
+ case ACTION_DRAW_AND_SWAP_ABORT:
+ WillDraw();
+ return;
+
+ case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
+ WillBeginOutputSurfaceCreation();
+ return;
+
+ case ACTION_PREPARE_TILES:
+ WillPrepareTiles();
+ return;
+
+ case ACTION_INVALIDATE_OUTPUT_SURFACE:
+ WillInvalidateOutputSurface();
+ return;
+ }
+}
+
+void SchedulerStateMachine::DidAction(Action action) {
+ switch (action) {
+ case ACTION_NONE:
+ return;
+
+ case ACTION_ACTIVATE_SYNC_TREE:
+ return;
+
+ case ACTION_ANIMATE:
+ return;
+
+ case ACTION_SEND_BEGIN_MAIN_FRAME:
+ return;
+
+ case ACTION_COMMIT: {
+ return;
+ }
+
+ case ACTION_DRAW_AND_SWAP_FORCED:
case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: {
bool did_request_swap = true;
- WillDraw(did_request_swap);
+ DidDraw(did_request_swap);
return;
}
case ACTION_DRAW_AND_SWAP_ABORT: {
bool did_request_swap = false;
- WillDraw(did_request_swap);
+ DidDraw(did_request_swap);
return;
}
case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
- WillBeginOutputSurfaceCreation();
return;
case ACTION_PREPARE_TILES:
- WillPrepareTiles();
return;
case ACTION_INVALIDATE_OUTPUT_SURFACE:
- WillInvalidateOutputSurface();
return;
}
}
@@ -703,22 +739,70 @@ void SchedulerStateMachine::WillActivate() {
needs_redraw_ = true;
}
-void SchedulerStateMachine::WillDraw(bool did_request_swap) {
+void SchedulerStateMachine::WillDraw() {
+ // We need to reset needs_redraw_ before we draw since the
+ // draw itself might request another draw.
+ needs_redraw_ = false;
+}
+
+void SchedulerStateMachine::DidDraw(bool did_request_swap) {
+ active_tree_needs_first_draw_ = false;
+
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW)
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
- needs_redraw_ = false;
- active_tree_needs_first_draw_ = false;
-
if (did_request_swap) {
DCHECK(!request_swap_funnel_);
request_swap_funnel_ = true;
did_request_swap_in_last_frame_ = true;
last_frame_number_swap_requested_ = current_frame_number_;
}
+
+ switch (last_draw_result_) {
+ case INVALID_RESULT:
+ NOTREACHED() << "Uninitialized DrawResult.";
+ break;
+ case DRAW_ABORTED_CANT_DRAW:
+ case DRAW_ABORTED_CONTEXT_LOST:
+ NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:"
+ << last_draw_result_;
+ break;
+ case DRAW_SUCCESS:
+ consecutive_checkerboard_animations_ = 0;
+ forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
+ break;
+ case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
+ needs_redraw_ = true;
+
+ // If we're already in the middle of a redraw, we don't need to
+ // restart it.
+ if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE)
+ return;
+
+ needs_begin_main_frame_ = true;
+ consecutive_checkerboard_animations_++;
+ if (settings_.timeout_and_draw_when_animation_checkerboards &&
+ consecutive_checkerboard_animations_ >=
+ settings_.maximum_number_of_failed_draws_before_draw_is_forced) {
+ consecutive_checkerboard_animations_ = 0;
+ // We need to force a draw, but it doesn't make sense to do this until
+ // we've committed and have new textures.
+ forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT;
+ }
+ break;
+ case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT:
+ // It's not clear whether this missing content is because of missing
+ // pictures (which requires a commit) or because of memory pressure
+ // removing textures (which might not). To be safe, request a commit
+ // anyway.
+ needs_begin_main_frame_ = true;
+ break;
+ }
+
+ last_draw_result_ = DRAW_SUCCESS;
}
void SchedulerStateMachine::WillPrepareTiles() {
@@ -1032,47 +1116,8 @@ void SchedulerStateMachine::SetImplLatencyTakesPriority(
impl_latency_takes_priority_ = impl_latency_takes_priority;
}
-void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
- switch (result) {
- case INVALID_RESULT:
- NOTREACHED() << "Uninitialized DrawResult.";
- break;
- case DRAW_ABORTED_CANT_DRAW:
- case DRAW_ABORTED_CONTEXT_LOST:
- NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:"
- << result;
- break;
- case DRAW_SUCCESS:
- consecutive_checkerboard_animations_ = 0;
- forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
- break;
- case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
- needs_redraw_ = true;
-
- // If we're already in the middle of a redraw, we don't need to
- // restart it.
- if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE)
- return;
-
- needs_begin_main_frame_ = true;
- consecutive_checkerboard_animations_++;
- if (settings_.timeout_and_draw_when_animation_checkerboards &&
- consecutive_checkerboard_animations_ >=
- settings_.maximum_number_of_failed_draws_before_draw_is_forced) {
- consecutive_checkerboard_animations_ = 0;
- // We need to force a draw, but it doesn't make sense to do this until
- // we've committed and have new textures.
- forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT;
- }
- break;
- case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT:
- // It's not clear whether this missing content is because of missing
- // pictures (which requires a commit) or because of memory pressure
- // removing textures (which might not). To be safe, request a commit
- // anyway.
- needs_begin_main_frame_ = true;
- break;
- }
+void SchedulerStateMachine::SetDrawResult(DrawResult result) {
+ last_draw_result_ = result;
}
void SchedulerStateMachine::SetNeedsBeginMainFrame() {

Powered by Google App Engine
This is Rietveld 408576698