diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-07 05:04:13 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-07 05:04:13 (GMT) |
commit | 53d7bcc2f535807ec6edd1df20194675d3cc357e (patch) | |
tree | 2afd5dc4dc74fc56850c93a2cccf5286d40f7ef2 /src/declarative/fx/qfximage.cpp | |
parent | d6843baff3f344de4c63c5559d23595dbf2bdfea (diff) | |
download | Qt-53d7bcc2f535807ec6edd1df20194675d3cc357e.zip Qt-53d7bcc2f535807ec6edd1df20194675d3cc357e.tar.gz Qt-53d7bcc2f535807ec6edd1df20194675d3cc357e.tar.bz2 |
Start refactoring QFxPixmap so it isn't as slow to use.
Diffstat (limited to 'src/declarative/fx/qfximage.cpp')
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 792b015..26e2727 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -437,7 +437,8 @@ void QFxImage::setSource(const QUrl &url) QFxPerfTimer<QFxPerf::PixmapLoad> perf; #endif Q_D(QFxImage); - if (url == d->url) + //equality is fairly expensive, so we bypass for simple, common case + if ((d->url.isEmpty() == url.isEmpty()) && url == d->url) return; if (d->sciReply) { @@ -485,13 +486,23 @@ void QFxImage::setSource(const QUrl &url) this, SLOT(sciRequestFinished())); } } else { - d->reply = QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(requestFinished())); + d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->pix); if (d->reply) { + connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); } else { + //### should be unified with requestFinished + setImplicitWidth(d->pix.width()); + setImplicitHeight(d->pix.height()); + + if (d->status == Loading) + d->status = Ready; d->progress = 1.0; - emit progressChanged(d->progress); + emit statusChanged(d->status); + emit sourceChanged(d->url); + emit progressChanged(1.0); + update(); } } } @@ -503,15 +514,16 @@ void QFxImage::requestFinished() { Q_D(QFxImage); if (d->url.path().endsWith(QLatin1String(".sci"))) { - d->pix = QFxPixmap(d->sciurl); + QFxPixmap::find(d->sciurl, &d->pix); } else { if (d->reply) { + //###disconnect really needed? disconnect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); if (d->reply->error() != QNetworkReply::NoError) d->status = Error; } - d->pix = QFxPixmap(d->url); + QFxPixmap::find(d->url, &d->pix); } setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); @@ -566,13 +578,23 @@ void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci) sg->setVerticalTileRule(sci.verticalTileRule()); d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - d->reply = QFxPixmap::get(qmlEngine(this), d->sciurl, this, SLOT(requestFinished())); + d->reply = QFxPixmap::get(qmlEngine(this), d->sciurl, &d->pix); if (d->reply) { + connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); } else { + //### should be unified with requestFinished + setImplicitWidth(d->pix.width()); + setImplicitHeight(d->pix.height()); + + if (d->status == Loading) + d->status = Ready; d->progress = 1.0; - emit progressChanged(d->progress); + emit statusChanged(d->status); + emit sourceChanged(d->url); + emit progressChanged(1.0); + update(); } } } |