cc: Remove partial texture updates from scheduler.
The texture update controller now completes when all full size texture
uploads are done and the texture uploader isn't busy. All partial
texture updates are now done at the same time as commit.
BUG=149194
TEST=cc_unittests
Review URL: https://codereview.chromium.org/10917265
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157220 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/CCTextureUpdateController.cpp b/cc/CCTextureUpdateController.cpp
index 73e22c79..22207de 100644
--- a/cc/CCTextureUpdateController.cpp
+++ b/cc/CCTextureUpdateController.cpp
@@ -19,6 +19,9 @@
// Measured in seconds.
static const double textureUpdateTickRate = 0.004;
+// Measured in seconds.
+static const double uploaderBusyTickRate = 0.001;
+
// Flush interval when performing texture uploads.
static const int textureUploadFlushPeriod = 4;
@@ -108,7 +111,8 @@
{
}
-void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit)
+void CCTextureUpdateController::performMoreUpdates(
+ double monotonicTimeLimit)
{
ASSERT(monotonicTimeLimit >= m_monotonicTimeLimit);
m_monotonicTimeLimit = monotonicTimeLimit;
@@ -122,7 +126,7 @@
// amount of time.
if (m_firstUpdateAttempt) {
// Post a 0-delay task when no updates were left. When it runs,
- // updateTexturesCompleted() will be called.
+ // readyToFinalizeTextureUpdates() will be called.
if (!updateMoreTexturesIfEnoughTimeRemaining())
m_timer->startOneShot(0);
@@ -131,10 +135,17 @@
updateMoreTexturesNow();
}
+void CCTextureUpdateController::finalize()
+{
+ while (m_queue->hasMoreUpdates())
+ updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(),
+ updateMoreTexturesSize());
+}
+
void CCTextureUpdateController::onTimerFired()
{
if (!updateMoreTexturesIfEnoughTimeRemaining())
- m_client->updateTexturesCompleted();
+ m_client->readyToFinalizeTextureUpdates();
}
double CCTextureUpdateController::monotonicTimeNow() const
@@ -154,7 +165,15 @@
bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
{
- if (!m_queue->hasMoreUpdates())
+ // Uploader might be busy when we're too aggressive in our upload time
+ // estimate. We use a different timeout here to prevent unnecessary
+ // amounts of idle time.
+ if (m_uploader->isBusy()) {
+ m_timer->startOneShot(uploaderBusyTickRate);
+ return true;
+ }
+
+ if (!m_queue->fullUploadSize())
return false;
bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMoreTexturesTime();
@@ -166,8 +185,30 @@
void CCTextureUpdateController::updateMoreTexturesNow()
{
- m_timer->startOneShot(updateMoreTexturesTime());
- updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), updateMoreTexturesSize());
+ size_t uploads = std::min(
+ m_queue->fullUploadSize(), updateMoreTexturesSize());
+ m_timer->startOneShot(
+ updateMoreTexturesTime() / updateMoreTexturesSize() * uploads);
+
+ if (!uploads)
+ return;
+
+ m_uploader->beginUploads();
+
+ size_t uploadCount = 0;
+ while (uploads--) {
+ m_uploader->uploadTexture(
+ m_resourceProvider, m_queue->takeFirstFullUpload());
+ uploadCount++;
+ if (!(uploadCount % textureUploadFlushPeriod))
+ m_resourceProvider->shallowFlushIfSupported();
+ }
+
+ // Make sure there are no dangling partial uploads without a flush.
+ if (uploadCount % textureUploadFlushPeriod)
+ m_resourceProvider->shallowFlushIfSupported();
+
+ m_uploader->endUploads();
}
}