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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 2339633003: Reland of cc: Remove frame queuing from the scheduler. (Closed)
Patch Set: prevent draw if commit is pending 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..70c7f67cc66398046fac720c643fcf25ce3c2cc1 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:
brianderson 2016/09/26 23:10:28 Nice way to remove these states.
- 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,17 @@ bool SchedulerStateMachine::ShouldDraw() const {
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;
@@ -429,6 +436,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,10 +501,13 @@ bool SchedulerStateMachine::ShouldCommit() const {
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;
}
@@ -566,12 +586,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 +612,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 +644,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 +734,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;
}
@@ -872,12 +876,12 @@ SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
if (settings_.using_synchronous_renderer_compositor) {
// No deadline for synchronous compositor.
return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE;
- } 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.
+ // 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 (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.
@@ -895,11 +899,6 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
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;
@@ -915,8 +914,7 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
// 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 (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE &&
- !has_pending_tree_)
+ if (!CommitPending() && !has_pending_tree_)
return true;
// Prioritize impl-thread draws in ImplLatencyTakesPriority mode.
@@ -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,9 +1031,8 @@ 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.
+ // 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