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

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: rename some method, only check for incomplete frames when impl-side painting 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 5d6229703f8fd5285d6c4bf5e0b9d09e884f6a59..7fa22cb40c703c5d08edb4f52341a63bfd5b9833 100644
--- a/cc/scheduler_state_machine.cc
+++ b/cc/scheduler_state_machine.cc
@@ -15,9 +15,11 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
, m_currentFrameNumber(0)
, m_lastFrameNumberWhereDrawWasCalled(-1)
, m_lastFrameNumberWhereTreeActivationAttempted(-1)
+ , m_lastFrameNumberWhereCheckForNewTexturesCalled(-1)
, m_consecutiveFailedDraws(0)
, m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3)
, m_needsRedraw(false)
+ , m_swapUsedIncompleteTexture(false)
, m_needsForcedRedraw(false)
, m_needsForcedRedrawAfterNextCommit(false)
, m_needsCommit(false)
@@ -38,12 +40,16 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
std::string SchedulerStateMachine::toString()
{
std::string str;
+ base::StringAppendF(&str, "m_settings.implSidePainting = %d; ", m_settings.implSidePainting);
base::StringAppendF(&str, "m_commitState = %d; ", m_commitState);
base::StringAppendF(&str, "m_currentFrameNumber = %d; ", m_currentFrameNumber);
base::StringAppendF(&str, "m_lastFrameNumberWhereDrawWasCalled = %d; ", m_lastFrameNumberWhereDrawWasCalled);
+ base::StringAppendF(&str, "m_lastFrameNumberWhereTreeActivationAttempted = %d; ", m_lastFrameNumberWhereTreeActivationAttempted);
+ base::StringAppendF(&str, "m_lastFrameNumberWhereCheckForNewTexturesCalled = %d; ", m_lastFrameNumberWhereCheckForNewTexturesCalled);
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_swapUsedIncompleteTexture = %d; ", m_swapUsedIncompleteTexture);
base::StringAppendF(&str, "m_needsForcedRedraw = %d; ", m_needsForcedRedraw);
base::StringAppendF(&str, "m_needsForcedRedrawAfterNextCommit = %d; ", m_needsForcedRedrawAfterNextCommit);
base::StringAppendF(&str, "m_needsCommit = %d; ", m_needsCommit);
@@ -71,6 +77,12 @@ bool SchedulerStateMachine::hasAttemptedTreeActivationThisFrame() const
return m_currentFrameNumber == m_lastFrameNumberWhereTreeActivationAttempted;
}
+bool SchedulerStateMachine::hasCheckedForNewTexturesThisFrame() const
+{
+ return m_currentFrameNumber ==
+ m_lastFrameNumberWhereCheckForNewTexturesCalled;
+}
+
bool SchedulerStateMachine::drawSuspendedUntilCommit() const
{
if (!m_canDraw)
@@ -109,7 +121,19 @@ bool SchedulerStateMachine::shouldDraw() const
bool SchedulerStateMachine::shouldAttemptTreeActivation() const
{
- return m_hasPendingTree && m_insideVSync && !hasAttemptedTreeActivationThisFrame();
+ return m_hasPendingTree && m_insideVSync && !hasAttemptedTreeActivationThisFrame();
+}
+
+bool SchedulerStateMachine::shouldCheckForNewTextures() const
+{
+ if (!m_settings.implSidePainting)
+ return false;
+ if (hasCheckedForNewTexturesThisFrame())
+ return false;
+
+ return shouldAttemptTreeActivation() ||
+ shouldDraw() ||
+ m_swapUsedIncompleteTexture;
}
bool SchedulerStateMachine::shouldAcquireLayerTexturesForMainThread() const
@@ -144,6 +168,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_BEGIN_OUTPUT_SURFACE_RECREATION;
if (m_outputSurfaceState == OUTPUT_SURFACE_RECREATING)
return ACTION_NONE;
+ if (shouldCheckForNewTextures())
+ return ACTION_CHECK_FOR_NEW_TEXTURES;
if (shouldAttemptTreeActivation())
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (shouldDraw())
@@ -154,6 +180,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_NONE;
case COMMIT_STATE_FRAME_IN_PROGRESS:
+ if (shouldCheckForNewTextures())
+ return ACTION_CHECK_FOR_NEW_TEXTURES;
if (shouldAttemptTreeActivation())
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (shouldDraw())
@@ -164,6 +192,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_COMMIT;
case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: {
+ if (shouldCheckForNewTextures())
+ return ACTION_CHECK_FOR_NEW_TEXTURES;
if (shouldAttemptTreeActivation())
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (shouldDraw() || m_outputSurfaceState == OUTPUT_SURFACE_LOST)
@@ -177,6 +207,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
}
case COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW:
+ if (shouldCheckForNewTextures())
+ return ACTION_CHECK_FOR_NEW_TEXTURES;
if (shouldAttemptTreeActivation())
return ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED;
if (m_needsForcedRedraw)
@@ -193,6 +225,10 @@ void SchedulerStateMachine::updateState(Action action)
case ACTION_NONE:
return;
+ case ACTION_CHECK_FOR_NEW_TEXTURES:
+ m_lastFrameNumberWhereCheckForNewTexturesCalled = m_currentFrameNumber;
+ return;
+
case ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED:
m_lastFrameNumberWhereTreeActivationAttempted = m_currentFrameNumber;
return;
@@ -277,6 +313,9 @@ bool SchedulerStateMachine::vsyncCallbackNeeded() const
if (m_needsForcedRedraw)
return true;
+ if (m_visible && m_swapUsedIncompleteTexture)
+ return true;
+
return m_needsRedraw && m_visible && m_outputSurfaceState == OUTPUT_SURFACE_ACTIVE;
}
@@ -301,6 +340,11 @@ void SchedulerStateMachine::setNeedsRedraw()
m_needsRedraw = true;
}
+void SchedulerStateMachine::didSwapUseIncompleteTexture()
+{
+ m_swapUsedIncompleteTexture = true;
+}
+
void SchedulerStateMachine::setNeedsForcedRedraw()
{
m_needsForcedRedraw = true;
« cc/scheduler.h ('K') | « cc/scheduler_state_machine.h ('k') | cc/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698