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

Unified Diff: cc/CCTextureUpdateController.cpp

Issue 10911262: cc: Scheduler will never process a commit until it receives a vsync tick. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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/CCTextureUpdateController.h ('k') | cc/CCTextureUpdateControllerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCTextureUpdateController.cpp
diff --git a/cc/CCTextureUpdateController.cpp b/cc/CCTextureUpdateController.cpp
index 25d41cca581bb25b83adb03ad0fbf5172fee4c23..ca49d77ff3c554b013865350d5808228724468a1 100644
--- a/cc/CCTextureUpdateController.cpp
+++ b/cc/CCTextureUpdateController.cpp
@@ -92,8 +92,9 @@ void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi
copier->flush();
}
-CCTextureUpdateController::CCTextureUpdateController(CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader)
- : m_timer(adoptPtr(new CCTimer(thread, this)))
+CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerClient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader)
+ : m_client(client)
+ , m_timer(adoptPtr(new CCTimer(thread, this)))
, m_queue(queue)
, m_resourceProvider(resourceProvider)
, m_copier(copier)
@@ -107,23 +108,24 @@ CCTextureUpdateController::~CCTextureUpdateController()
{
}
-bool CCTextureUpdateController::hasMoreUpdates() const
-{
- return m_queue->hasMoreUpdates();
-}
-
void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit)
{
+ ASSERT(monotonicTimeLimit >= m_monotonicTimeLimit);
m_monotonicTimeLimit = monotonicTimeLimit;
- if (!m_queue->hasMoreUpdates())
+ // Update already in progress.
+ if (m_timer->isActive())
return;
// Call updateMoreTexturesNow() directly unless it's the first update
// attempt. This ensures that we empty the update queue in a finite
// amount of time.
if (m_firstUpdateAttempt) {
- updateMoreTexturesIfEnoughTimeRemaining();
+ // Post a 0-delay task when no updates were left. When it runs,
+ // updateTexturesCompleted() will be called.
+ if (!updateMoreTexturesIfEnoughTimeRemaining())
+ m_timer->startOneShot(0);
+
m_firstUpdateAttempt = false;
} else
updateMoreTexturesNow();
@@ -131,10 +133,8 @@ void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit)
void CCTextureUpdateController::onTimerFired()
{
- if (!m_queue->hasMoreUpdates())
- return;
-
- updateMoreTexturesIfEnoughTimeRemaining();
+ if (!updateMoreTexturesIfEnoughTimeRemaining())
+ m_client->updateTexturesCompleted();
}
double CCTextureUpdateController::monotonicTimeNow() const
@@ -152,11 +152,16 @@ size_t CCTextureUpdateController::updateMoreTexturesSize() const
return textureUpdatesPerTick;
}
-void CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
+bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
{
+ if (!m_queue->hasMoreUpdates())
+ return false;
+
bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMoreTexturesTime();
if (hasTimeRemaining)
updateMoreTexturesNow();
+
+ return true;
}
void CCTextureUpdateController::updateMoreTexturesNow()
« no previous file with comments | « cc/CCTextureUpdateController.h ('k') | cc/CCTextureUpdateControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698