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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 2339633003: Reland of cc: Remove frame queuing from the scheduler. (Closed)
Patch Set: delay begin main frame until swap ack in browser compositor Created 4 years, 3 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
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler_state_machine.cc
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index 800f4131779189e3e5da873f3fe735f11405e59a..ecc131b434c75ac0bd03994bdf62503381807b22 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -123,10 +123,6 @@ const char* SchedulerStateMachine::BeginMainFrameStateToString(
return "BEGIN_MAIN_FRAME_STATE_STARTED";
case BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT:
return "BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT";
- case BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION:
- return "BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION";
- case BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW:
- return "BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW";
}
NOTREACHED();
return "???";
@@ -367,6 +363,9 @@ bool SchedulerStateMachine::ShouldDraw() const {
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
return false;
+ if (wait_for_ready_to_draw_)
+ return false;
+
// Only handle forced redraws due to timeouts on the regular deadline.
if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
return true;
@@ -429,6 +428,16 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE)
return false;
+ // MFBA is disabled and we are waiting for previous activation.
+ if (!settings_.main_frame_before_activation_enabled && has_pending_tree_)
+ return false;
+
+ // We are waiting for previous frame to be drawn, swapped and acked.
+ if (settings_.commit_to_active_tree &&
+ (active_tree_needs_first_draw_ || SwapThrottled())) {
+ return false;
+ }
+
// Don't send BeginMainFrame early if we are prioritizing the active tree
// because of ImplLatencyTakesPriority.
if (ImplLatencyTakesPriority() &&
@@ -484,6 +493,11 @@ bool SchedulerStateMachine::ShouldCommit() const {
return false;
}
+ // Active tree resources might still be in use until the Display draws.
+ // if (settings_.commit_to_active_tree && SwapThrottled())
enne (OOO) 2016/09/22 19:01:47 Leftover code?
sunnyps 2016/09/24 01:15:02 Removed.
+ // return false;
+ DCHECK(!settings_.commit_to_active_tree || !SwapThrottled());
enne (OOO) 2016/09/22 19:01:47 It's nice to DCHECK this.
sunnyps 2016/09/24 01:15:02 Yes, although this crashes when we have pure impl-
+
// If we only have an active tree, it is incorrect to replace it
// before we've drawn it.
DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_);
@@ -566,12 +580,7 @@ void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
commit_has_no_updates));
commit_count_++;
last_commit_had_no_updates_ = commit_has_no_updates;
-
- if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) {
- begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
- } else {
- begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION;
- }
+ begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
if (!commit_has_no_updates) {
// Pending tree only exists if commit had updates.
@@ -597,13 +606,6 @@ void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
}
void SchedulerStateMachine::WillActivate() {
- if (begin_main_frame_state_ ==
- BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) {
- begin_main_frame_state_ = settings_.commit_to_active_tree
- ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW
- : BEGIN_MAIN_FRAME_STATE_IDLE;
- }
-
if (compositor_frame_sink_state_ ==
COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION)
compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE;
@@ -636,9 +638,6 @@ void SchedulerStateMachine::WillDrawInternal() {
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;
}
void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) {
@@ -729,8 +728,7 @@ void SchedulerStateMachine::WillInvalidateCompositorFrameSink() {
}
void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
- TRACE_EVENT_INSTANT0("cc",
- "Scheduler: SkipNextBeginMainFrameToReduceLatency",
+ TRACE_EVENT_INSTANT0("cc", "Scheduler: SkipNextBeginMainFrameToReduceLatency",
TRACE_EVENT_SCOPE_THREAD);
skip_next_begin_main_frame_to_reduce_latency_ = true;
}
@@ -953,9 +951,13 @@ void SchedulerStateMachine::SetResourcelessSoftwareDraw(
resourceless_draw_ = resourceless_draw;
}
-void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; }
+void SchedulerStateMachine::SetCanDraw(bool can_draw) {
+ can_draw_ = can_draw;
+}
-void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; }
+void SchedulerStateMachine::SetNeedsRedraw() {
+ needs_redraw_ = true;
+}
bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const {
bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_;
@@ -1029,11 +1031,6 @@ void SchedulerStateMachine::NotifyReadyToCommit() {
DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED)
<< AsValue()->ToString();
begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT;
- // In commit_to_active_tree mode, commit should happen right after
- // BeginFrame, meaning when this function is called, next action should be
- // commit.
- if (settings_.commit_to_active_tree)
- DCHECK(ShouldCommit());
}
void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698