aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickimageprovider.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/qquickimageprovider.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/qquickimageprovider.cpp')
-rw-r--r--src/quick/util/qquickimageprovider.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index b306ab3419..5ded343195 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -47,6 +47,7 @@ class QQuickImageProviderPrivate
{
public:
QQuickImageProvider::ImageType type;
+ QQuickImageProvider::Flags flags;
};
/*!
@@ -203,6 +204,12 @@ QImage QQuickTextureFactory::image() const
allowing image loading to be executed in the background, and reducing the
performance impact on the user interface.
+ To force asynchronous image loading, even for image sources that do not
+ have the \c asynchronous property set to \c true, you may pass the
+ \c QQuickImageProvider::ForceAsynchronousImageLoading flag to the image
+ provider constructor. This ensures that all image requests for the
+ provider are handled in a separate thread.
+
Asynchronous loading is not supported for image providers that provide
QPixmap rather than QImage values, as pixmaps can only be created in the
main thread. In this case, if \l {Image::}{asynchronous} is set to
@@ -228,10 +235,11 @@ QImage QQuickTextureFactory::image() const
/*!
Creates an image provider that will provide images of the given \a type.
*/
-QQuickImageProvider::QQuickImageProvider(ImageType type)
+QQuickImageProvider::QQuickImageProvider(ImageType type, Flags flags)
: d(new QQuickImageProviderPrivate)
{
d->type = type;
+ d->flags = flags;
}
/*!
@@ -253,6 +261,14 @@ QQuickImageProvider::ImageType QQuickImageProvider::imageType() const
}
/*!
+ Returns the flags set for this provider.
+*/
+QQuickImageProvider::Flags QQuickImageProvider::flags() const
+{
+ return d->flags;
+}
+
+/*!
Implement this method to return the image with \a id. The default
implementation returns an empty image.