summaryrefslogtreecommitdiffstats
path: root/src/graphicsitems/qximagebase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphicsitems/qximagebase.cpp')
-rw-r--r--src/graphicsitems/qximagebase.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/graphicsitems/qximagebase.cpp b/src/graphicsitems/qximagebase.cpp
index 285e14e..8bbae28 100644
--- a/src/graphicsitems/qximagebase.cpp
+++ b/src/graphicsitems/qximagebase.cpp
@@ -47,6 +47,7 @@
#include <private/qdeclarativepixmapcache_p.h>
#include <QtCore/qfile.h>
+#include <QTime>
QxImageBase::QxImageBase(QxImageBasePrivate &dd, QxItem *parent)
: QxItem(dd, parent)
@@ -174,7 +175,10 @@ void QxImageBase::requestFinished()
d->status = Error;
qmlInfo(this) << d->pix.error();
} else {
- d->status = Ready;
+ if (d->async)
+ d->status = Uploading;
+ else
+ d->status = Ready;
}
d->progress = 1.0;
@@ -186,7 +190,39 @@ void QxImageBase::requestFinished()
emit statusChanged(d->status);
if (d->progress != oldProgress)
emit progressChanged(d->progress);
- pixmapChange();
+
+
+ if (d->texture) {
+ delete d->texture;
+ }
+
+ TextureManager *tm = QSGContext::current->textureManager();
+
+ if (d->async) {
+ d->texture = tm->requestUploadedTexture(d->pix.pixmap().toImage(),
+ 0,
+ this,
+ SLOT(textureStatusChanged(int)));
+ if (d->texture->status() == TextureReference::Uploaded)
+ pixmapChange();
+ } else {
+ d->texture = tm->requestUploadedTexture(d->pix.pixmap().toImage(), TextureManager::SynchronousUploadHint);
+ pixmapChange();
+ }
+}
+
+void QxImageBase::textureStatusChanged(int status)
+{
+ Q_D(QxImageBase);
+
+ if (status == TextureReference::Uploaded) {
+ d->status = Ready;
+ emit statusChanged(d->status);
+ }
+
+ if (d->texture)
+ pixmapChange();
+
}
void QxImageBase::requestProgress(qint64 received, qint64 total)