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

Unified Diff: cc/CCTextureUpdateController.cpp

Issue 10933095: cc: Remove resource updates from scheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: cc/CCTextureUpdateController.cpp
diff --git a/cc/CCTextureUpdateController.cpp b/cc/CCTextureUpdateController.cpp
index ca49d77ff3c554b013865350d5808228724468a1..bbf2b07f12fd32979996a6fb65ebfb5eced0760d 100644
--- a/cc/CCTextureUpdateController.cpp
+++ b/cc/CCTextureUpdateController.cpp
@@ -9,16 +9,20 @@
#include "GraphicsContext3D.h"
#include "TextureCopier.h"
#include "TextureUploader.h"
-#include <wtf/CurrentTime.h>
+
+using namespace std;
jamesr 2012/09/14 23:03:06 chromium and WebKit style is to prefer std::foo in
reveman 2012/09/14 23:38:00 Hm, I see a lot of the using directive in cc. I th
jamesr 2012/09/17 06:57:38 This changed in WebKit several months ago: http://
reveman 2012/09/17 15:32:52 ok, clear.
namespace {
-// Number of textures to update with each call to updateMoreTexturesIfEnoughTimeRemaining().
+// Number of textures to update with each call to updateMoreTextures().
static const size_t textureUpdatesPerTick = 12;
// 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;
@@ -99,8 +103,6 @@ CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl
, m_resourceProvider(resourceProvider)
, m_copier(copier)
, m_uploader(uploader)
- , m_monotonicTimeLimit(0)
- , m_firstUpdateAttempt(true)
{
}
@@ -108,40 +110,30 @@ CCTextureUpdateController::~CCTextureUpdateController()
{
}
-void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit)
+void CCTextureUpdateController::start()
{
- ASSERT(monotonicTimeLimit >= m_monotonicTimeLimit);
- m_monotonicTimeLimit = monotonicTimeLimit;
+ // Post a 0-delay task when no updates were left. When it runs,
+ // updateTexturesCompleted() will be called.
+ if (!updateMoreTextures())
+ m_timer->startOneShot(0);
+}
- // Update already in progress.
- if (m_timer->isActive())
+void CCTextureUpdateController::updateAllTexturesNow()
+{
+ if (!m_queue->hasMoreUpdates())
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) {
- // 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();
+ updateTextures(
+ m_resourceProvider, m_copier, m_uploader, m_queue.get(),
+ numeric_limits<size_t>::max());
}
void CCTextureUpdateController::onTimerFired()
{
- if (!updateMoreTexturesIfEnoughTimeRemaining())
+ if (!updateMoreTextures())
m_client->updateTexturesCompleted();
}
-double CCTextureUpdateController::monotonicTimeNow() const
-{
- return monotonicallyIncreasingTime();
-}
-
double CCTextureUpdateController::updateMoreTexturesTime() const
{
return textureUpdateTickRate;
@@ -152,22 +144,38 @@ size_t CCTextureUpdateController::updateMoreTexturesSize() const
return textureUpdatesPerTick;
}
-bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
+// Performs buffered texture updates. Currently only full uploads.
+bool CCTextureUpdateController::updateMoreTextures()
{
- if (!m_queue->hasMoreUpdates())
+ if (m_uploader->isBusy()) {
+ m_timer->startOneShot(uploaderBusyTickRate);
jamesr 2012/09/14 23:03:06 why the new 1ms delay? did anything in the previou
reveman 2012/09/14 23:38:00 So the main reason this code is here is because we
jamesr 2012/09/17 06:57:38 This is all because we poll (via the query object)
reveman 2012/09/17 15:32:52 Yes, it's because we poll.
+ return true;
+ }
+
+ if (!m_queue->fullUploadSize())
return false;
- bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMoreTexturesTime();
- if (hasTimeRemaining)
- updateMoreTexturesNow();
+ size_t uploads = min(m_queue->fullUploadSize(), updateMoreTexturesSize());
+ m_timer->startOneShot(
+ updateMoreTexturesTime() / updateMoreTexturesSize() * uploads);
- return true;
-}
+ m_uploader->beginUploads();
-void CCTextureUpdateController::updateMoreTexturesNow()
-{
- m_timer->startOneShot(updateMoreTexturesTime());
- updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), updateMoreTexturesSize());
+ 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();
+ return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698