summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2010-12-09 11:49:34 +0100
committerGunnar Sletta <gunnar.sletta@nokia.com>2010-12-09 11:49:34 +0100
commit4d7f0bfabb315b46d9600f87452420a76a50d932 (patch)
tree58dfa99b2a09df2d9994fcd03ec68b28d9cec2ed
parent618719564b0e15ae383c2ffbf87f331375ad6778 (diff)
More work on lazy QxImage
-rw-r--r--src/graphicsitems/qximagebase.cpp25
-rw-r--r--src/graphicsitems/qximagebase_p_p.h2
-rw-r--r--src/scenegraph/coreapi/qsgtexturemanager.h2
3 files changed, 14 insertions, 15 deletions
diff --git a/src/graphicsitems/qximagebase.cpp b/src/graphicsitems/qximagebase.cpp
index e77151a..64d27e3 100644
--- a/src/graphicsitems/qximagebase.cpp
+++ b/src/graphicsitems/qximagebase.cpp
@@ -135,10 +135,11 @@ void QxImageBase::load()
if (d->url.isEmpty()) {
d->pix.clear(this);
d->status = Null;
- d->progress = 0.0;
+ d->progress = 0.0;
emit progressChanged(d->progress);
emit statusChanged(d->status);
pixmapChange();
+
} else {
d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), d->async);
if (d->pix.isLoading()) {
@@ -194,16 +195,7 @@ void QxImageBase::requestFinished()
QSGTextureManager *tm = QSGContext::current->textureManager();
if (d->async) {
-
QImage image = d->pix.pixmap().toImage();
-
- printf("%p: source size -> %dx%d imageSize: %dx%d '%s'\n",
- this,
- sourceSize().width(), sourceSize().height(),
- image.width(), image.height(),
- qPrintable(source().toLocalFile())
- );
-
d->texture = tm->requestUpload(image,
this,
SLOT(textureStatusChanged(int)));
@@ -218,7 +210,6 @@ void QxImageBase::requestFinished()
void QxImageBase::textureStatusChanged(int status)
{
Q_D(QxImageBase);
-
if (status == QSGTexture::Ready) {
d->status = Ready;
emit statusChanged(d->status);
@@ -243,6 +234,7 @@ void QxImageBase::pixmapChange()
void QxImageBase::markDirty(int flag)
{
+
Q_D(QxImageBase);
d->dirty |= flag;
if (!d->connected) {
@@ -254,16 +246,21 @@ void QxImageBase::prepare()
{
Q_D(QxImageBase);
- printf("QxImageBase(%p)::prepare(%s): dirty=%x pixmap=(%dx%d)\n", this, qPrintable(d->url.toLocalFile()), d->dirty, d->pix.width(), d->pix.height());
+ if (!isComponentComplete())
+ return;
- if (d->dirty & (QxImageBasePrivate::DirtySource | QxImageBasePrivate::DirtySourceSize))
+ if (d->dirty & (QxImageBasePrivate::DirtySource | QxImageBasePrivate::DirtySourceSize)
+ && !d->url.isEmpty()
+ && d->pix.isNull()) {
load();
+ }
- if (d->dirty & QxImageBasePrivate::DirtyTextureReady && !d->texture.isNull()) {
+ if ((d->dirty & QxImageBasePrivate::DirtyTextureReady) && d->texture.isReady()) {
// Updating the stuff...
pixmapChange();
}
disconnect(QSGContext::current, SIGNAL(aboutToRenderNextFrame()), this, SLOT(prepare()));
d->connected = false;
+ d->dirty = 0;
}
diff --git a/src/graphicsitems/qximagebase_p_p.h b/src/graphicsitems/qximagebase_p_p.h
index 553c361..9e02166 100644
--- a/src/graphicsitems/qximagebase_p_p.h
+++ b/src/graphicsitems/qximagebase_p_p.h
@@ -95,7 +95,7 @@ public:
bool explicitSourceSize : 1;
bool async : 1;
- uint dirty : 2;
+ uint dirty : 8;
uint connected : 1;
};
diff --git a/src/scenegraph/coreapi/qsgtexturemanager.h b/src/scenegraph/coreapi/qsgtexturemanager.h
index 0bc08aa..6eb25ad 100644
--- a/src/scenegraph/coreapi/qsgtexturemanager.h
+++ b/src/scenegraph/coreapi/qsgtexturemanager.h
@@ -148,6 +148,8 @@ public:
bool isNull() const { return m_texture == 0; }
+ bool isReady() const { return m_texture != 0 && m_texture->status() == QSGTexture::Ready; }
+
private:
void deref() {
if (m_texture && !--m_texture->m_ref_count) {