summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-26 22:43:33 +0000
committerbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-26 22:43:33 +0000
commitd7223948ec8e300af9553ae963624f415ba7352f (patch)
treea3eaaecc04ed9e526686ed13cc204566ff93c143 /cc
parent2123ca8cde0b6bdb799b7825025295a955e604bf (diff)
downloadchromium_src-d7223948ec8e300af9553ae963624f415ba7352f.zip
chromium_src-d7223948ec8e300af9553ae963624f415ba7352f.tar.gz
chromium_src-d7223948ec8e300af9553ae963624f415ba7352f.tar.bz2
cc: Do not allow CCScheduler::processScheduledActions to recurse
BUG=151420 Review URL: https://chromiumcodereview.appspot.com/10969027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/CCScheduler.cpp27
-rw-r--r--cc/CCScheduler.h1
2 files changed, 13 insertions, 15 deletions
diff --git a/cc/CCScheduler.cpp b/cc/CCScheduler.cpp
index 78fcca8..d9d4ea0 100644
--- a/cc/CCScheduler.cpp
+++ b/cc/CCScheduler.cpp
@@ -7,6 +7,7 @@
#include "CCScheduler.h"
#include "TraceEvent.h"
+#include <base/auto_reset.h>
namespace cc {
@@ -14,6 +15,7 @@ CCScheduler::CCScheduler(CCSchedulerClient* client, PassOwnPtr<CCFrameRateContro
: m_client(client)
, m_frameRateController(frameRateController)
, m_updateResourcesCompletePending(false)
+ , m_insideProcessScheduledActions(false)
{
ASSERT(m_client);
m_frameRateController->setClient(this);
@@ -40,11 +42,7 @@ void CCScheduler::setVisible(bool visible)
void CCScheduler::setCanDraw(bool canDraw)
{
m_stateMachine.setCanDraw(canDraw);
-
- // Defer processScheduleActions so we don't recurse and commit/draw
- // multiple frames. We can call processScheduledActions directly
- // once it is no longer re-entrant.
- m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
+ processScheduledActions();
}
void CCScheduler::setNeedsCommit()
@@ -149,17 +147,15 @@ void CCScheduler::updateResourcesComplete()
void CCScheduler::processScheduledActions()
{
- // Early out so we don't spam TRACE_EVENTS with useless processScheduledActions.
- if (m_stateMachine.nextAction() == CCSchedulerStateMachine::ACTION_NONE) {
- m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
+ // We do not allow processScheduledActions to be recursive.
+ // The top-level call will iteratively execute the next action for us anyway.
+ if (m_insideProcessScheduledActions)
return;
- }
- // This function can re-enter itself. For example, draw may call
- // setNeedsCommit. Proceeed with caution.
- CCSchedulerStateMachine::Action action;
- do {
- action = m_stateMachine.nextAction();
+ AutoReset<bool> markInside(&m_insideProcessScheduledActions, true);
+
+ CCSchedulerStateMachine::Action action = m_stateMachine.nextAction();
+ while (action != CCSchedulerStateMachine::ACTION_NONE) {
m_stateMachine.updateState(action);
TRACE_EVENT1("cc", "CCScheduler::processScheduledActions()", "action", action);
@@ -196,7 +192,8 @@ void CCScheduler::processScheduledActions()
m_client->scheduledActionAcquireLayerTexturesForMainThread();
break;
}
- } while (action != CCSchedulerStateMachine::ACTION_NONE);
+ action = m_stateMachine.nextAction();
+ }
// Activate or deactivate the frame rate controller.
m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
diff --git a/cc/CCScheduler.h b/cc/CCScheduler.h
index 2d276a6..2600f780 100644
--- a/cc/CCScheduler.h
+++ b/cc/CCScheduler.h
@@ -100,6 +100,7 @@ private:
OwnPtr<CCFrameRateController> m_frameRateController;
CCSchedulerStateMachine m_stateMachine;
bool m_updateResourcesCompletePending;
+ bool m_insideProcessScheduledActions;
};
}