diff options
author | Albert Astals Cid <albert.astals@canonical.com> | 2012-11-23 12:44:16 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-23 17:13:33 +0100 |
commit | 597df98c542601ff2d286c79a8002a9ae995c98b (patch) | |
tree | f5399fc3c84a2324bad56ee448892b734e55b03c /src/quick/util/qquickpixmapcache.cpp | |
parent | cef169a9eb12a860b3c0ccb1bf50b2c8cfaff9f8 (diff) |
Support requestPixmap if platform has ThreadedPixmaps feature
As discussed with Samuel enable the use of requestPixmap in a thread
for async requests if the platform support ThreadedPixmaps
Task-number: 28138
Change-Id: I106cf0123430115464b0a75071c7e6129a98d22b
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 1649e33728..3d6a8d0336 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -47,6 +47,9 @@ #include <private/qqmlglobal_p.h> #include <private/qqmlengine_p.h> +#include <QtGui/private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> + #include <QtQuick/private/qsgtexture_p.h> #include <QtQuick/private/qsgcontext_p.h> @@ -539,6 +542,18 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, textureFactoryForImage(image)); mutex.unlock(); + } else if (imageType == QQuickImageProvider::Pixmap) { + const QPixmap pixmap = provider->requestPixmap(imageId(url), &readSize, requestSize); + QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError; + QString errorStr; + if (pixmap.isNull()) { + errorCode = QQuickPixmapReply::Loading; + errorStr = QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString()); + } + mutex.lock(); + if (!cancelled.contains(runningJob)) + runningJob->postReply(errorCode, errorStr, readSize, textureFactoryForImage(pixmap.toImage())); + mutex.unlock(); } else { QQuickTextureFactory *t = provider->requestTexture(imageId(url), &readSize, requestSize); QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError; @@ -1176,7 +1191,8 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques if (iter == store->m_cache.end()) { if (url.scheme() == QLatin1String("image")) { if (QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url)))) { - if (provider->imageType() == QQuickImageProvider::Pixmap) { + const bool threadedPixmaps = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps); + if (!threadedPixmaps && provider->imageType() == QQuickImageProvider::Pixmap) { // pixmaps can only be loaded synchronously options &= ~QQuickPixmap::Asynchronous; } else if (provider->flags() & QQuickImageProvider::ForceAsynchronousImageLoading) { |