Index: cc/scheduler_state_machine.cc |
diff --git a/cc/scheduler_state_machine.cc b/cc/scheduler_state_machine.cc |
index d385a432a44614098fc436d82f8c366a4d42cb59..03656ef9c6c9028b8f981438fadcaa0d55fd3ed0 100644 |
--- a/cc/scheduler_state_machine.cc |
+++ b/cc/scheduler_state_machine.cc |
@@ -16,9 +16,11 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings* const sett |
, m_currentFrameNumber(0) |
, m_lastFrameNumberWhereDrawWasCalled(-1) |
, m_lastFrameNumberWhereTreeActivationAttempted(-1) |
+ , m_lastFrameNumberWhereCheckForNewTexturesCalled(-1) |
, m_consecutiveFailedDraws(0) |
, m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3) |
, m_needsRedraw(false) |
+ , m_needsRedrawOnVisibleTextureUpload(false) |
, m_needsForcedRedraw(false) |
, m_needsForcedRedrawAfterNextCommit(false) |
, m_needsCommit(false) |
@@ -39,12 +41,16 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings* const sett |
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_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 +78,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) |
@@ -110,7 +122,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_needsRedrawOnVisibleTextureUpload; |
} |
bool SchedulerStateMachine::shouldAcquireLayerTexturesForMainThread() const |
@@ -145,6 +169,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()) |
@@ -155,6 +181,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()) |
@@ -165,6 +193,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) |
@@ -178,6 +208,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) |
@@ -194,6 +226,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; |
@@ -278,6 +314,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; |
} |
@@ -302,6 +341,11 @@ void SchedulerStateMachine::setNeedsRedraw() |
m_needsRedraw = true; |
} |
+void SchedulerStateMachine::setNeedsRedrawOnVisibleTextureUpload() |
+{ |
+ m_needsRedrawOnVisibleTextureUpload = true; |
+} |
+ |
void SchedulerStateMachine::setNeedsForcedRedraw() |
{ |
m_needsForcedRedraw = true; |