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

Unified Diff: cc/scheduler_state_machine.cc

Issue 11879012: cc: Redraw incomplete frames when new texture uploads finish (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_draw3b
Patch Set: Created 7 years, 11 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_state_machine.cc
diff --git a/cc/scheduler_state_machine.cc b/cc/scheduler_state_machine.cc
index 60a1ce9a3a1dffb0892ebf0fc45e3f64660f43bf..0e3c2630471491bf2cecfae0ffb377d2ebc7a2ce 100644
--- a/cc/scheduler_state_machine.cc
+++ b/cc/scheduler_state_machine.cc
@@ -16,9 +16,11 @@ SchedulerStateMachine::SchedulerStateMachine(const LayerTreeSettings &layerTreeS
, m_currentFrameNumber(0)
, m_lastFrameNumberWhereDrawWasCalled(-1)
, m_lastFrameNumberWhereTreeActivationAttempted(-1)
+ , m_lastFrameNumberWhereRedrawOnVisibleTextureUploadAttempted(-1)
, m_consecutiveFailedDraws(0)
, m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3)
, m_needsRedraw(false)
+ , m_needsRedrawOnVisibleTextureUpload(false)
, m_needsForcedRedraw(false)
, m_needsForcedRedrawAfterNextCommit(false)
, m_needsCommit(false)
@@ -45,6 +47,7 @@ std::string SchedulerStateMachine::toString()
base::StringAppendF(&str, "m_consecutiveFailedDraws = %d; ", m_consecutiveFailedDraws);
base::StringAppendF(&str, "m_maximumNumberOfFailedDrawsBeforeDrawIsForced = %d; ", m_maximumNumberOfFailedDrawsBeforeDrawIsForced);
base::StringAppendF(&str, "m_needsRedraw = %d; ", m_needsRedraw);
+ base::StringAppendF(&str, "m_needsRedrawOnVisibleTextureUpload = %d; ", m_needsRedrawOnVisibleTextureUpload);
base::StringAppendF(&str, "m_needsForcedRedraw = %d; ", m_needsForcedRedraw);
base::StringAppendF(&str, "m_needsForcedRedrawAfterNextCommit = %d; ", m_needsForcedRedrawAfterNextCommit);
base::StringAppendF(&str, "m_needsCommit = %d; ", m_needsCommit);
@@ -72,6 +75,12 @@ bool SchedulerStateMachine::hasAttemptedTreeActivationThisFrame() const
return m_currentFrameNumber == m_lastFrameNumberWhereTreeActivationAttempted;
}
+bool SchedulerStateMachine::hasAttemptedRedrawOnVisibleTextureUploadThisFrame() const
+{
+ return m_currentFrameNumber ==
+ m_lastFrameNumberWhereRedrawOnVisibleTextureUploadAttempted;
+}
+
bool SchedulerStateMachine::drawSuspendedUntilCommit() const
{
if (!m_canDraw)
@@ -110,7 +119,14 @@ bool SchedulerStateMachine::shouldDraw() const
bool SchedulerStateMachine::shouldAttemptTreeActivation() const
{
- return m_hasPendingTree && m_insideVSync && !hasAttemptedTreeActivationThisFrame();
+ return m_hasPendingTree && m_insideVSync && !hasAttemptedTreeActivationThisFrame();
+}
+
+bool SchedulerStateMachine::shouldAttemptRedrawOnVisibleTextureUpload() const
+{
+ return m_needsRedrawOnVisibleTextureUpload &&
+ !hasAttemptedRedrawOnVisibleTextureUploadThisFrame() &&
+ !hasDrawnThisFrame();
}
bool SchedulerStateMachine::shouldAcquireLayerTexturesForMainThread() const
@@ -149,6 +165,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (shouldDraw())
return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE;
+ if (shouldAttemptRedrawOnVisibleTextureUpload())
+ return ACTION_CHECK_FOR_NEW_VISIBLE_TEXTURES;
if (m_needsCommit && ((m_visible && m_canBeginFrame) || m_needsForcedCommit))
// TODO(enne): Should probably drop the active tree on force commit
return m_hasPendingTree ? ACTION_NONE : ACTION_BEGIN_FRAME;
@@ -159,6 +177,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (shouldDraw())
return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE;
+ if (shouldAttemptRedrawOnVisibleTextureUpload())
+ return ACTION_CHECK_FOR_NEW_VISIBLE_TEXTURES;
return ACTION_NONE;
case COMMIT_STATE_READY_TO_COMMIT:
@@ -169,6 +189,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (shouldDraw() || m_outputSurfaceState == OUTPUT_SURFACE_LOST)
return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE;
+ if (shouldAttemptRedrawOnVisibleTextureUpload())
+ return ACTION_CHECK_FOR_NEW_VISIBLE_TEXTURES;
// COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_canDraw is false
// or textures are not available, proceed to the next step (similar as in COMMIT_STATE_IDLE).
bool canCommit = m_visible || m_needsForcedCommit;
@@ -182,6 +204,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (m_needsForcedRedraw)
return ACTION_DRAW_FORCED;
+ if (shouldAttemptRedrawOnVisibleTextureUpload())
+ return ACTION_CHECK_FOR_NEW_VISIBLE_TEXTURES;
return ACTION_NONE;
}
NOTREACHED();
@@ -198,6 +222,13 @@ void SchedulerStateMachine::updateState(Action action)
m_lastFrameNumberWhereTreeActivationAttempted = m_currentFrameNumber;
return;
+ case ACTION_CHECK_FOR_NEW_VISIBLE_TEXTURES:
+ // We set this false here and the caller must actively set this back
+ // to true for each frame that it still needs to check for uploads.
+ m_needsRedrawOnVisibleTextureUpload = false;
+ m_lastFrameNumberWhereRedrawOnVisibleTextureUploadAttempted = m_currentFrameNumber;
+ return;
+
case ACTION_BEGIN_FRAME:
DCHECK(!m_hasPendingTree);
DCHECK(m_visible || m_needsForcedCommit);
@@ -277,6 +308,9 @@ bool SchedulerStateMachine::vsyncCallbackNeeded() const
if (m_needsForcedRedraw)
return true;
+ if (m_visible && m_needsRedrawOnVisibleTextureUpload)
+ return true;
+
return m_needsRedraw && m_visible && m_outputSurfaceState == OUTPUT_SURFACE_ACTIVE;
}
@@ -301,6 +335,11 @@ void SchedulerStateMachine::setNeedsRedraw()
m_needsRedraw = true;
}
+void SchedulerStateMachine::setNeedsRedrawOnVisibleTextureUpload()
+{
+ m_needsRedrawOnVisibleTextureUpload = true;
+}
+
void SchedulerStateMachine::setNeedsForcedRedraw()
{
m_needsForcedRedraw = true;
« no previous file with comments | « cc/scheduler_state_machine.h ('k') | cc/single_thread_proxy.h » ('j') | cc/tile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698