aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@nokia.com>2012-05-08 10:28:24 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-11 15:12:15 +0200
commit125f4ceb393886015574a3c3fd0fc264a4f2deb6 (patch)
treec552a05bd3030dd8c3d9a2c307e9dca0a1b9e7e9 /src/quick/util/qquickpixmapcache.cpp
parent9b224d33216b0e21292b44743aa4594665ebf970 (diff)
Allow image providers to force their loading to be asynchronous
The request methods of an image provider are assumed to be synchronous, but sometimes the provider will be implemented in an async manner, eg. through network request or doing the I/O on a different thread. In that case, the provider can't expose this async behavior to clients, but needs to block in the request method. This is less then ideal for clients, since the default behvior of an image element is to load synchronously, so we introduce a new flag to image providers that let's the provider force the loading to happen on the async image loading thread. Similar to network requests (which are always async), this does not affect the 'asynchronous' property of the image element. Change-Id: I9542abbcc594b9aab565210bc3005a95592c1e9c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com> Reviewed-by: Michalina Ziemba <michalina.ziemba@nokia.com>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 0400c9580c..2ef95a5959 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -1168,12 +1168,13 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.find(key);
if (iter == store->m_cache.end()) {
- if (options & QQuickPixmap::Asynchronous) {
- // pixmaps can only be loaded synchronously
- if (url.scheme() == QLatin1String("image")) {
- QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url)));
- if (provider && provider->imageType() == QQuickImageProvider::Pixmap) {
+ if (url.scheme() == QLatin1String("image")) {
+ if (QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url)))) {
+ if (provider->imageType() == QQuickImageProvider::Pixmap) {
+ // pixmaps can only be loaded synchronously
options &= ~QQuickPixmap::Asynchronous;
+ } else if (provider->flags() & QQuickImageProvider::ForceAsynchronousImageLoading) {
+ options |= QQuickPixmap::Asynchronous;
}
}
}