[frameworks/ksvg] src/ksvg: Revert "Make sure cached pixmap has correct DPR"
Nicolas Fella <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 0280fc3e95e9ed567a0b8dc59465cacacf80f026 by Nicolas Fella.
Committed on 07/08/2026 at 11:15.
Pushed by nicolasfella into branch 'master'.
Revert "Make sure cached pixmap has correct DPR"
The KImageCache change is being reverted.
This reverts commit baafa7325cf8ae97d2ce73e13e509bd99c862353.
M +8 -3 src/ksvg/framesvg.cpp
M +9 -2 src/ksvg/private/imageset_p.cpp
M +11 -1 src/ksvg/private/imageset_p.h
M +2 -2 src/ksvg/svg.cpp
https://invent.kde.org/frameworks/ksvg/-/commit/0280fc3e95e9ed567a0b8dc59465cacacf80f026
diff --git a/src/ksvg/framesvg.cpp b/src/ksvg/framesvg.cpp
index fc637263..ff9a62c7 100644
--- a/src/ksvg/framesvg.cpp
+++ b/src/ksvg/framesvg.cpp
@@ -562,12 +562,17 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer<FrameData> &frame)
const bool overlayAvailable = !frame->prefix.startsWith(QLatin1String("mask-")) && q->hasElement(frame->prefix % QLatin1String("overlay"));
QPixmap overlay;
if (q->isUsingRenderingCache()) {
- frameCached = q->imageSet()->d->findInCache(QString::number(id), frame->cachedBackground, frame->lastModified, q->devicePixelRatio())
- && !frame->cachedBackground.isNull();
+ frameCached = q->imageSet()->d->findInCache(QString::number(id), frame->cachedBackground, frame->lastModified) && !frame->cachedBackground.isNull();
+ if (frameCached) {
+ frame->cachedBackground.setDevicePixelRatio(q->devicePixelRatio());
+ }
if (overlayAvailable) {
const size_t overlayId = qHash(cacheId(frame.data(), frame->prefix % QLatin1String("overlay")));
- overlayCached = q->imageSet()->d->findInCache(QString::number(overlayId), overlay, frame->lastModified, q->devicePixelRatio()) && !overlay.isNull();
+ overlayCached = q->imageSet()->d->findInCache(QString::number(overlayId), overlay, frame->lastModified) && !overlay.isNull();
+ if (overlayCached) {
+ overlay.setDevicePixelRatio(q->devicePixelRatio());
+ }
}
}
diff --git a/src/ksvg/private/imageset_p.cpp b/src/ksvg/private/imageset_p.cpp
index f007e00c..b16ce7dd 100644
--- a/src/ksvg/private/imageset_p.cpp
+++ b/src/ksvg/private/imageset_p.cpp
@@ -604,7 +604,7 @@ const QString ImageSetPrivate::svgStyleSheet(KSvg::Svg *svg)
return stylesheet;
}
-bool ImageSetPrivate::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified, qreal devicePixelRatio)
+bool ImageSetPrivate::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
{
if (!useCache()) {
return false;
@@ -638,7 +638,7 @@ bool ImageSetPrivate::findInCache(const QString &key, QPixmap &pix, unsigned int
}
QPixmap temp;
- if (pixmapCache->findPixmapWithDevicePixelRatio(key, &temp, devicePixelRatio) && !temp.isNull()) {
+ if (pixmapCache->findPixmap(key, &temp) && !temp.isNull()) {
pix = temp;
return true;
}
@@ -646,6 +646,13 @@ bool ImageSetPrivate::findInCache(const QString &key, QPixmap &pix, unsigned int
return false;
}
+void ImageSetPrivate::insertIntoCache(const QString &key, const QPixmap &pix)
+{
+ if (useCache()) {
+ pixmapCache->insertPixmap(key, pix);
+ }
+}
+
void ImageSetPrivate::insertIntoCache(const QString &key, const QPixmap &pix, const QString &id)
{
if (useCache()) {
diff --git a/src/ksvg/private/imageset_p.h b/src/ksvg/private/imageset_p.h
index 0317b954..a8e2c1bb 100644
--- a/src/ksvg/private/imageset_p.h
+++ b/src/ksvg/private/imageset_p.h
@@ -73,7 +73,17 @@ public:
*
* Returns true when pixmap was found and loaded from cache, false otherwise
**/
- bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified, qreal devicePixelRatio);
+ bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified);
+
+ /*!
+ * Insert specified pixmap into the cache.
+ * If the cache already contains pixmap with the specified key then it is
+ * overwritten.
+ *
+ * \param key the name to use in the cache for this pixmap
+ * \param pix the pixmap data to store in the cache
+ **/
+ void insertIntoCache(const QString &key, const QPixmap &pix);
/*!
* Insert specified pixmap into the cache.
diff --git a/src/ksvg/svg.cpp b/src/ksvg/svg.cpp
index a6172f95..208f50eb 100644
--- a/src/ksvg/svg.cpp
+++ b/src/ksvg/svg.cpp
@@ -603,8 +603,8 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
const QString id = cachePath(actualElementId, size);
QPixmap p;
- if (cacheRendering && lastModified == SvgRectsCache::instance()->lastModifiedTimeFromCache(path)
- && actualImageSet()->d->findInCache(id, p, lastModified, ratio)) {
+ if (cacheRendering && lastModified == SvgRectsCache::instance()->lastModifiedTimeFromCache(path) && actualImageSet()->d->findInCache(id, p, lastModified)) {
+ p.setDevicePixelRatio(ratio);
// qCDebug(LOG_PLASMA) << "found cached version of " << id << p.size();
return p;
}