summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2010-12-05 09:07:30 +0100
committerGunnar Sletta <gunnar.sletta@nokia.com>2010-12-05 09:07:30 +0100
commit610139085223bf210740393cf72ba02340b38097 (patch)
tree688d4818447ba5a512ce445c089694925ff392ac
parentba9d5b8be115adedae5d321ccb40fa84120512ab (diff)
Delay the ready signal a bit to give upload more time on Mac
Since we don't get a signal from GL that the texture is indeed uploaded, try assing a short wait for bigger images...
-rw-r--r--src/adaptationlayers/mactexturemanager.cpp33
-rw-r--r--src/graphicsitems/qximagebase.cpp4
2 files changed, 35 insertions, 2 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;
}
diff --git a/src/graphicsitems/qximagebase.cpp b/src/graphicsitems/qximagebase.cpp
index e826f5c..416e242 100644
--- a/src/graphicsitems/qximagebase.cpp
+++ b/src/graphicsitems/qximagebase.cpp
@@ -194,6 +194,7 @@ void QxImageBase::requestFinished()
if (d->texture) {
delete d->texture;
+ d->texture = 0;
}
TextureManager *tm = QSGContext::current->textureManager();
@@ -222,8 +223,9 @@ void QxImageBase::textureStatusChanged(int status)
emit statusChanged(d->status);
}
- if (d->texture)
+ if (d->texture) {
pixmapChange();
+ }
}