diff options
Diffstat (limited to 'src/adaptationlayers/mactexturemanager.cpp')
-rw-r--r-- | src/adaptationlayers/mactexturemanager.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/adaptationlayers/mactexturemanager.cpp b/src/adaptationlayers/mactexturemanager.cpp index dec66c6..881bd0d 100644 --- a/src/adaptationlayers/mactexturemanager.cpp +++ b/src/adaptationlayers/mactexturemanager.cpp @@ -1,5 +1,7 @@ #include "mactexturemanager.h" +#include <qevent.h> + /*! Since we are using client storage which means asynchronous DMA uploads, we need to keep the bits around for the duration @@ -8,9 +10,20 @@ class QSGMacTextureReference : public TextureReference { public: + void timerEvent(QTimerEvent *t) { + setStatus(TextureReference::Uploaded); + killTimer(t->timerId()); + --inProgress; + } + QImage image; + bool big; + + static int inProgress; }; +int QSGMacTextureReference::inProgress = 0; + QSGMacTextureManager::QSGMacTextureManager() { @@ -38,10 +51,28 @@ const TextureReference *QSGMacTextureManager::requestUploadedTexture(const QImag glBindTexture(GL_TEXTURE_2D, 0); QSGMacTextureReference *texture = new QSGMacTextureReference; + if (listener && slot) { + QObject::connect(texture, SIGNAL(statusChanged(int)), listener, slot); + } texture->image = image; texture->setTextureId(id); texture->setTextureSize(image.size()); - texture->setStatus(TextureReference::Uploaded); + texture->setOwnsTexture(true); + + if (hints & TextureManager::SynchronousUploadHint) { + texture->setStatus(TextureReference::Uploaded); + } else { + // Delay "big" images + int byteSize = image.height() * image.bytesPerLine(); + if (byteSize > 500000) { + texture->setStatus(TextureReference::Uploading); + ++QSGMacTextureReference::inProgress; + int delay = byteSize / 50000 * QSGMacTextureReference::inProgress; + texture->startTimer(delay); + } else { + texture->setStatus(TextureReference::Uploaded); + } + } return texture; } |