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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 2379343003: Revert of cc: Remove frame queuing from the scheduler. (Closed)
Patch Set: 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 70c7f67cc66398046fac720c643fcf25ce3c2cc1..800f4131779189e3e5da873f3fe735f11405e59a 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -123,6 +123,10 @@
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 "???";
@@ -363,17 +367,6 @@
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
return false;
- // Wait for active tree to be rasterized before drawing in browser compositor.
- if (wait_for_ready_to_draw_) {
- DCHECK(settings_.commit_to_active_tree);
- return false;
- }
-
- // Browser compositor commit steals any resources submitted in draw. Therefore
- // drawing while a commit is pending is wasteful.
- if (settings_.commit_to_active_tree && CommitPending())
- 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;
@@ -435,16 +428,6 @@
// immediately to IDLE.
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.
@@ -501,12 +484,9 @@
return false;
}
- // If we only have an active tree, it is incorrect to replace it before we've
- // drawn it.
+ // 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_);
-
- // In browser compositor commit reclaims any resources submitted during draw.
- DCHECK(!settings_.commit_to_active_tree || !SwapThrottled());
return true;
}
@@ -586,7 +566,12 @@
commit_has_no_updates));
commit_count_++;
last_commit_had_no_updates_ = commit_has_no_updates;
- begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
+
+ 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;
+ }
if (!commit_has_no_updates) {
// Pending tree only exists if commit had updates.
@@ -612,6 +597,13 @@
}
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;
@@ -644,6 +636,9 @@
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) {
@@ -734,7 +729,8 @@
}
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;
}
@@ -876,12 +872,12 @@
if (settings_.using_synchronous_renderer_compositor) {
// No deadline for synchronous compositor.
return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE;
- } else if (wait_for_ready_to_draw_) {
- // In browser compositor, wait for active tree to be rasterized.
- DCHECK(settings_.commit_to_active_tree);
- return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW;
} else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) {
return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE;
+ } else if (wait_for_ready_to_draw_) {
+ // When we are waiting for ready to draw signal, we do not wait to post a
+ // deadline yet.
+ return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW;
} else if (needs_redraw_) {
// We have an animation or fast input path on the impl thread that wants
// to draw, so don't wait too long for a new active tree.
@@ -899,6 +895,11 @@
if (PendingActivationsShouldBeForced() && !has_pending_tree_)
return true;
+ // Do not trigger deadline immediately if we're waiting for READY_TO_DRAW
+ // unless it's one of the forced cases.
+ if (wait_for_ready_to_draw_)
+ return false;
+
// SwapAck throttle the deadline since we wont draw and swap anyway.
if (SwapThrottled())
return false;
@@ -914,7 +915,8 @@
// don't have a pending tree -- otherwise we should give it a chance to
// activate.
// TODO(skyostil): Revisit this when we have more accurate deadline estimates.
- if (!CommitPending() && !has_pending_tree_)
+ if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE &&
+ !has_pending_tree_)
return true;
// Prioritize impl-thread draws in ImplLatencyTakesPriority mode.
@@ -951,13 +953,9 @@
resourceless_draw_ = resourceless_draw;
}
-void SchedulerStateMachine::SetCanDraw(bool can_draw) {
- can_draw_ = can_draw;
-}
-
-void SchedulerStateMachine::SetNeedsRedraw() {
- needs_redraw_ = true;
-}
+void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; }
+
+void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; }
bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const {
bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_;
@@ -1031,8 +1029,9 @@
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.
+ // 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());
}
« 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