aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index dda2fbe2b0..c5968c2bc1 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -78,6 +78,11 @@
QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_DEBUG
+static bool qsg_leak_check = !qgetenv("QML_LEAK_CHECK").isEmpty();
+#endif
+
// The cache limit describes the maximum "junk" in the cache.
static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded in qpixmapcache.cpp
@@ -91,6 +96,17 @@ static inline QString imageId(const QUrl &url)
return url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
}
+QQuickDefaultTextureFactory::QQuickDefaultTextureFactory(const QImage &image)
+{
+ if (image.format() == QImage::Format_ARGB32_Premultiplied
+ || image.format() == QImage::Format_RGB32) {
+ im = image;
+ } else {
+ im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ }
+}
+
+
QSGTexture *QQuickDefaultTextureFactory::createTexture(QQuickWindow *) const
{
QSGPlainTexture *t = new QSGPlainTexture();
@@ -730,7 +746,9 @@ QQuickPixmapStore::~QQuickPixmapStore()
{
m_destroying = true;
+#ifndef QT_NO_DEBUG
int leakedPixmaps = 0;
+#endif
QList<QQuickPixmapData*> cachedData = m_cache.values();
// Prevent unreferencePixmap() from assuming it needs to kick
@@ -742,7 +760,9 @@ QQuickPixmapStore::~QQuickPixmapStore()
foreach (QQuickPixmapData* pixmap, cachedData) {
int currRefCount = pixmap->refCount;
if (currRefCount) {
+#ifndef QT_NO_DEBUG
leakedPixmaps++;
+#endif
while (currRefCount > 0) {
pixmap->release();
currRefCount--;
@@ -755,8 +775,10 @@ QQuickPixmapStore::~QQuickPixmapStore()
shrinkCache(20);
}
- if (leakedPixmaps)
+#ifndef QT_NO_DEBUG
+ if (leakedPixmaps && qsg_leak_check)
qDebug("Number of leaked pixmaps: %i", leakedPixmaps);
+#endif
}
void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
@@ -998,6 +1020,17 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
if (localFile.isEmpty())
return 0;
+ // check for "retina" high-dpi and use @2x file if it exixts
+ if (qApp->devicePixelRatio() > 1) {
+ const int dotIndex = localFile.lastIndexOf(QLatin1Char('.'));
+ if (dotIndex != -1) {
+ QString retinaFile = localFile;
+ retinaFile.insert(dotIndex, QStringLiteral("@2x"));
+ if (QFile(retinaFile).exists())
+ localFile = retinaFile;
+ }
+ }
+
QFile f(localFile);
QSize readSize;
QString errorString;