diff options
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index d96ebe70b2..bc1b267797 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -250,6 +250,9 @@ public: providerOptions(po), appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform), textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) +#ifdef Q_OS_WEBOS + , storeToCache(true) +#endif { declarativePixmaps.insert(pixmap); } @@ -261,6 +264,9 @@ public: providerOptions(po), appliedTransform(aTransform), textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) +#ifdef Q_OS_WEBOS + , storeToCache(true) +#endif { declarativePixmaps.insert(pixmap); } @@ -273,6 +279,9 @@ public: providerOptions(po), appliedTransform(aTransform), textureFactory(texture), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) +#ifdef Q_OS_WEBOS + , storeToCache(true) +#endif { declarativePixmaps.insert(pixmap); } @@ -282,6 +291,9 @@ public: appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform), textureFactory(texture), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) +#ifdef Q_OS_WEBOS + , storeToCache(true) +#endif { if (texture) requestSize = implicitSize = texture->textureSize(); @@ -328,6 +340,10 @@ public: QQuickPixmapData *prevUnreferenced; QQuickPixmapData**prevUnreferencedPtr; QQuickPixmapData *nextUnreferenced; + +#ifdef Q_OS_WEBOS + bool storeToCache; +#endif }; int QQuickPixmapReply::finishedIndex = -1; @@ -1287,7 +1303,11 @@ void QQuickPixmapData::release() QQuickPixmapReader::readerMutex.unlock(); } - if (pixmapStatus == QQuickPixmap::Ready) { + if (pixmapStatus == QQuickPixmap::Ready +#ifdef Q_OS_WEBOS + && storeToCache +#endif + ) { if (inCache) pixmapStore()->unreferencePixmap(this); else @@ -1643,6 +1663,13 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &reques QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.end(); +#ifdef Q_OS_WEBOS + QQuickPixmap::Options orgOptions = options; + // In webOS, we suppose that cache is always enabled to share image instances along its source. + // So, original option(orgOptions) for cache only decides whether to store the instances when it's unreferenced. + options |= QQuickPixmap::Cache; +#endif + // If Cache is disabled, the pixmap will always be loaded, even if there is an existing // cached version. Unless it's an itemgrabber url, since the cache is used to pass // the result between QQuickItemGrabResult and QQuickImage. @@ -1678,6 +1705,9 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &reques PIXMAP_PROFILE(pixmapLoadingFinished(url, QSize(width(), height()))); if (options & QQuickPixmap::Cache) d->addToCache(); +#ifdef Q_OS_WEBOS + d->storeToCache = orgOptions & QQuickPixmap::Cache; +#endif return; } if (d) { // loadable, but encountered error while loading @@ -1694,6 +1724,9 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &reques QQuickImageProviderOptions::UsePluginDefaultTransform, frame, frameCount); if (options & QQuickPixmap::Cache) d->addToCache(); +#ifdef Q_OS_WEBOS + d->storeToCache = orgOptions & QQuickPixmap::Cache; +#endif QQuickPixmapReader::readerMutex.lock(); d->reply = QQuickPixmapReader::instance(engine)->getImage(d); |