Chromium Code Reviews| Index: cc/CCTextureUpdateController.cpp |
| diff --git a/cc/CCTextureUpdateController.cpp b/cc/CCTextureUpdateController.cpp |
| index 49a98a4bccd0610c1e31b5af55e9409c45258b49..e658d0939816b79d52e92dbdd80fa1e8fe9a10f9 100644 |
| --- a/cc/CCTextureUpdateController.cpp |
| +++ b/cc/CCTextureUpdateController.cpp |
| @@ -9,12 +9,14 @@ |
| #include "GraphicsContext3D.h" |
| #include "TextureCopier.h" |
| #include "TextureUploader.h" |
| +#include "TraceEvent.h" |
| +#include <limits> |
| #include <wtf/CurrentTime.h> |
| namespace { |
| -// Number of textures to update with each call to updateMoreTexturesIfEnoughTimeRemaining(). |
| -static const size_t textureUpdatesPerTick = 12; |
| +// Number of partial updates we allow. |
| +static const size_t maxPartialTextures = 12; |
|
reveman
2012/09/18 20:34:18
maybe partialTextureUpdatesCount or partialTexture
brianderson
2012/09/18 21:09:31
Going with partialTextureUpdatesMax.
|
| // Measured in seconds. |
| static const double textureUpdateTickRate = 0.004; |
| @@ -31,7 +33,14 @@ namespace cc { |
| size_t CCTextureUpdateController::maxPartialTextureUpdates() |
| { |
| - return textureUpdatesPerTick; |
| + return maxPartialTextures; |
| +} |
| + |
| +size_t CCTextureUpdateController::maxFullUpdatesPerTick(TextureUploader* uploader) |
| +{ |
| + double texturesPerSecond = uploader->estimatedTexturesPerSecond(); |
| + size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); |
| + return std::max(static_cast<size_t>(1), texturesPerTick); |
|
reveman
2012/09/18 20:34:18
you can get rid of the static_cast now, right?
brianderson
2012/09/18 21:09:31
There's a compile error without the static_cast, s
jamesr
2012/09/18 21:13:00
is "1u" as the first parameter enough to escape th
brianderson
2012/09/18 21:15:14
Nope, but 1LU is.
|
| } |
| void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvider, TextureUploader* uploader, CCTextureUpdateQueue* queue) |
| @@ -78,6 +87,7 @@ CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl |
| , m_resourceProvider(resourceProvider) |
| , m_uploader(uploader) |
| , m_monotonicTimeLimit(0) |
| + , m_textureUpdatesPerTick(maxFullUpdatesPerTick(uploader)) |
| , m_firstUpdateAttempt(true) |
| { |
| } |
| @@ -133,7 +143,7 @@ double CCTextureUpdateController::updateMoreTexturesTime() const |
| size_t CCTextureUpdateController::updateMoreTexturesSize() const |
| { |
| - return textureUpdatesPerTick; |
| + return m_textureUpdatesPerTick; |
| } |
| bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() |
| @@ -166,22 +176,16 @@ void CCTextureUpdateController::updateMoreTexturesNow() |
| 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_uploader->beginUploads(); |
| + while (m_queue->fullUploadSize() && uploadCount < uploads) { |
| + if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
| m_resourceProvider->shallowFlushIfSupported(); |
| + m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUpload()); |
| + uploadCount++; |
| } |
| - |
| - // Make sure there are no dangling partial uploads without a flush. |
| - if (uploadCount % textureUploadFlushPeriod) |
| - m_resourceProvider->shallowFlushIfSupported(); |
| - |
| m_uploader->endUploads(); |
| + m_resourceProvider->shallowFlushIfSupported(); |
| } |
| } |