KDE Frameworks 6.6.0

OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks/kf6-ksvg?expand=0&rev=19
This commit is contained in:
Christophe Marin 2024-09-14 08:27:38 +00:00 committed by Git OBS Bridge
commit 63ff283eab
15 changed files with 933 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,40 @@
From 74f9f9cbd226407f8cde08c5cd5a711444e2775d Mon Sep 17 00:00:00 2001
From: Marco Martin <notmart@gmail.com>
Date: Wed, 19 Jun 2024 09:11:56 +0000
Subject: [PATCH] Restore proper devicepixelratio when extracting from cache
like in base Svg, also in FrameSvg restore the proper devicepixelratio
when getting the image from the cache, as KImageCache doesn't save or
restore the information about it.
This fixes blur region mask sometimes wrong behind floating panels
BUG:488295
---
src/ksvg/framesvg.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/ksvg/framesvg.cpp b/src/ksvg/framesvg.cpp
index c1d22b1a..3b094abd 100644
--- a/src/ksvg/framesvg.cpp
+++ b/src/ksvg/framesvg.cpp
@@ -524,10 +524,16 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer<FrameData> &frame)
QPixmap overlay;
if (q->isUsingRenderingCache()) {
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) && !overlay.isNull();
+ if (overlayCached) {
+ overlay.setDevicePixelRatio(q->devicePixelRatio());
+ }
}
}
--
2.45.2

View File

@ -0,0 +1,607 @@
From ca06055c3eaeb716109f8126cd3e3e1976ed3e1c Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Sun, 9 Jun 2024 21:42:10 +0200
Subject: [PATCH] Revert "Support for fractional scaling"
This reverts commit 3dd28b0640d2c613654f992ad3453a0b92beebe1.
---
src/declarativeimports/framesvgitem.cpp | 9 ++-
src/declarativeimports/svgitem.cpp | 7 +-
src/ksvg/framesvg.cpp | 102 ++++++++++--------------
src/ksvg/private/framesvg_helpers.h | 22 ++---
src/ksvg/private/framesvg_p.h | 62 +++++++-------
src/ksvg/private/svg_p.h | 6 +-
src/ksvg/svg.cpp | 27 ++++---
7 files changed, 115 insertions(+), 120 deletions(-)
diff --git a/src/declarativeimports/framesvgitem.cpp b/src/declarativeimports/framesvgitem.cpp
index 56c2b3a..678bdcb 100644
--- a/src/declarativeimports/framesvgitem.cpp
+++ b/src/declarativeimports/framesvgitem.cpp
@@ -122,7 +122,7 @@ public:
void reposition(const QRect &frameGeometry, QSize &fullSize)
{
- QRectF nodeRect = FrameSvgHelpers::sectionRect(m_border, frameGeometry, fullSize);
+ QRect nodeRect = FrameSvgHelpers::sectionRect(m_border, frameGeometry, fullSize);
// ensure we're not passing a weird rectangle to updateTexturedRectGeometry
if (!nodeRect.isValid() || nodeRect.isEmpty()) {
@@ -152,7 +152,7 @@ public:
QString elementId = prefix + FrameSvgHelpers::borderToElementId(m_border);
// re-render the SVG at new size
- updateTexture(nodeRect.size().toSize(), elementId);
+ updateTexture(nodeRect.size(), elementId);
textureRect = texture()->normalizedTextureSubRect();
} else if (texture()) { // for fast stretch.
textureRect = texture()->normalizedTextureSubRect();
@@ -726,7 +726,10 @@ void FrameSvgItem::componentComplete()
void FrameSvgItem::updateDevicePixelRatio()
{
- const auto newDevicePixelRatio = std::max<qreal>(1.0, (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
+ // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up.
+ //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned)
+ const auto newDevicePixelRatio = std::max<qreal>(1.0, floor(window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
+
if (newDevicePixelRatio != m_frameSvg->devicePixelRatio()) {
m_frameSvg->setDevicePixelRatio(newDevicePixelRatio);
m_textureChanged = true;
diff --git a/src/declarativeimports/svgitem.cpp b/src/declarativeimports/svgitem.cpp
index bec4533..aa1f2a2 100644
--- a/src/declarativeimports/svgitem.cpp
+++ b/src/declarativeimports/svgitem.cpp
@@ -16,6 +16,8 @@
#include "managedtexturenode.h"
+#include <cmath> //floor()
+
#include <Kirigami/Platform/PlatformTheme>
#include <debug_p.h>
@@ -265,7 +267,10 @@ void SvgItem::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometr
void SvgItem::updateDevicePixelRatio()
{
- const auto newDevicePixelRatio = std::max<qreal>(1.0, (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
+ // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up.
+ //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned)
+ const auto newDevicePixelRatio = std::max<qreal>(1.0, floor(window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
+
if (newDevicePixelRatio != m_svg->devicePixelRatio()) {
m_svg->setDevicePixelRatio(newDevicePixelRatio);
m_textureChanged = true;
diff --git a/src/ksvg/framesvg.cpp b/src/ksvg/framesvg.cpp
index 3b094ab..f2c8663 100644
--- a/src/ksvg/framesvg.cpp
+++ b/src/ksvg/framesvg.cpp
@@ -15,7 +15,7 @@
#include <QCryptographicHash>
#include <QPainter>
#include <QRegion>
-#include <QSizeF>
+#include <QSize>
#include <QStringBuilder>
#include <QTimer>
@@ -188,7 +188,7 @@ void FrameSvg::resizeFrame(const QSizeF &size)
QSizeF FrameSvg::frameSize() const
{
if (!d->frame) {
- return QSizeF(-1, -1);
+ return QSize(-1, -1);
} else {
return d->frameSize(d->frame.data());
}
@@ -478,6 +478,9 @@ QPixmap FrameSvgPrivate::alphaMask()
if (maskFrame->cachedBackground.isNull()) {
generateBackground(maskFrame);
+ // When we take the maskFrame from cache, the pixel ratio gets
+ // reset to 1
+ maskFrame->cachedBackground.setDevicePixelRatio(q->devicePixelRatio());
}
return maskFrame->cachedBackground;
@@ -542,8 +545,8 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer<FrameData> &frame)
}
// Overlays
- QSizeF overlaySize;
- QPointF actualOverlayPos = QPointF(0, 0);
+ QSize overlaySize;
+ QPoint actualOverlayPos = QPoint(0, 0);
if (overlayAvailable && !overlayCached) {
overlaySize = q->elementSize(frame->prefix % QLatin1String("overlay")).toSize();
@@ -569,13 +572,13 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer<FrameData> &frame)
// Tiling?
if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-horizontal"))
|| q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-vertical"))) {
- QSizeF s = q->size().toSize();
+ QSize s = q->size().toSize();
q->resize(q->elementSize(frame->prefix % QLatin1String("overlay")));
- overlayPainter.drawTiledPixmap(QRectF(QPointF(0, 0), overlaySize), q->pixmap(frame->prefix % QLatin1String("overlay")));
+ overlayPainter.drawTiledPixmap(QRect(QPoint(0, 0), overlaySize), q->pixmap(frame->prefix % QLatin1String("overlay")));
q->resize(s);
} else {
- q->paint(&overlayPainter, QRectF(actualOverlayPos, overlaySize), frame->prefix % QLatin1String("overlay"));
+ q->paint(&overlayPainter, QRect(actualOverlayPos, overlaySize), frame->prefix % QLatin1String("overlay"));
}
overlayPainter.end();
@@ -588,14 +591,14 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer<FrameData> &frame)
if (!overlay.isNull()) {
QPainter p(&frame->cachedBackground);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
- p.drawPixmap(actualOverlayPos, overlay, QRectF(actualOverlayPos, overlaySize));
+ p.drawPixmap(actualOverlayPos, overlay, QRect(actualOverlayPos, overlaySize));
}
}
void FrameSvgPrivate::generateFrameBackground(const QSharedPointer<FrameData> &frame)
{
// qCDebug(LOG_KSVG) << "generating background";
- const QSizeF size = frameSize(frame) * q->devicePixelRatio();
+ const QSize size = frameSize(frame).toSize() * q->devicePixelRatio();
if (!size.isValid()) {
#ifndef NDEBUG
@@ -608,14 +611,13 @@ void FrameSvgPrivate::generateFrameBackground(const QSharedPointer<FrameData> &f
return;
}
- // Don't cut away pieces of the frame
- frame->cachedBackground = QPixmap(QSize(std::ceil(size.width()), std::ceil(size.height())));
+ frame->cachedBackground = QPixmap(size);
frame->cachedBackground.fill(Qt::transparent);
QPainter p(&frame->cachedBackground);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.setRenderHint(QPainter::SmoothPixmapTransform);
- QRectF contentRect = contentGeometry(frame, size);
+ QRect contentRect = contentGeometry(frame, size);
paintCenter(p, frame, contentRect, size);
paintCorner(p, frame, FrameSvg::LeftBorder | FrameSvg::TopBorder, contentRect);
@@ -624,26 +626,25 @@ void FrameSvgPrivate::generateFrameBackground(const QSharedPointer<FrameData> &f
paintCorner(p, frame, FrameSvg::RightBorder | FrameSvg::BottomBorder, contentRect);
// Sides
- const qreal leftHeight = q->elementSize(frame->prefix % QLatin1String("left")).height();
- paintBorder(p, frame, FrameSvg::LeftBorder, QSizeF(frame->leftWidth, leftHeight) * q->devicePixelRatio(), contentRect);
- const qreal rightHeight = q->elementSize(frame->prefix % QLatin1String("right")).height();
- paintBorder(p, frame, FrameSvg::RightBorder, QSizeF(frame->rightWidth, rightHeight) * q->devicePixelRatio(), contentRect);
-
- const qreal topWidth = q->elementSize(frame->prefix % QLatin1String("top")).width();
- paintBorder(p, frame, FrameSvg::TopBorder, QSizeF(topWidth, frame->topHeight) * q->devicePixelRatio(), contentRect);
- const qreal bottomWidth = q->elementSize(frame->prefix % QLatin1String("bottom")).width();
- paintBorder(p, frame, FrameSvg::BottomBorder, QSizeF(bottomWidth, frame->bottomHeight) * q->devicePixelRatio(), contentRect);
+ const int leftHeight = q->elementSize(frame->prefix % QLatin1String("left")).height();
+ paintBorder(p, frame, FrameSvg::LeftBorder, QSize(frame->leftWidth, leftHeight) * q->devicePixelRatio(), contentRect);
+ const int rightHeight = q->elementSize(frame->prefix % QLatin1String("right")).height();
+ paintBorder(p, frame, FrameSvg::RightBorder, QSize(frame->rightWidth, rightHeight) * q->devicePixelRatio(), contentRect);
+
+ const int topWidth = q->elementSize(frame->prefix % QLatin1String("top")).width();
+ paintBorder(p, frame, FrameSvg::TopBorder, QSize(topWidth, frame->topHeight) * q->devicePixelRatio(), contentRect);
+ const int bottomWidth = q->elementSize(frame->prefix % QLatin1String("bottom")).width();
+ paintBorder(p, frame, FrameSvg::BottomBorder, QSize(bottomWidth, frame->bottomHeight) * q->devicePixelRatio(), contentRect);
p.end();
- // Set the devicePixelRatio only at the end, drawing all happened in device pixels
frame->cachedBackground.setDevicePixelRatio(q->devicePixelRatio());
}
-QRectF FrameSvgPrivate::contentGeometry(const QSharedPointer<FrameData> &frame, const QSizeF &size) const
+QRect FrameSvgPrivate::contentGeometry(const QSharedPointer<FrameData> &frame, const QSize &size) const
{
- const QSizeF contentSize(size.width() - frame->leftWidth * q->devicePixelRatio() - frame->rightWidth * q->devicePixelRatio(),
- size.height() - frame->topHeight * q->devicePixelRatio() - frame->bottomHeight * q->devicePixelRatio());
- QRectF contentRect(QPointF(0, 0), contentSize);
+ const QSize contentSize(size.width() - frame->leftWidth * q->devicePixelRatio() - frame->rightWidth * q->devicePixelRatio(),
+ size.height() - frame->topHeight * q->devicePixelRatio() - frame->bottomHeight * q->devicePixelRatio());
+ QRect contentRect(QPoint(0, 0), contentSize);
if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(frame->prefix % QLatin1String("left"))) {
contentRect.translate(frame->leftWidth * q->devicePixelRatio(), 0);
}
@@ -665,7 +666,7 @@ void FrameSvgPrivate::updateFrameData(uint lastModified, UpdateType updateType)
const QString oldPath = fd->imagePath;
const FrameSvg::EnabledBorders oldBorders = fd->enabledBorders;
- const QSizeF currentSize = fd->frameSize;
+ const QSize currentSize = fd->frameSize;
fd->enabledBorders = enabledBorders;
fd->frameSize = pendingFrameSize;
@@ -722,28 +723,27 @@ void FrameSvgPrivate::updateFrameData(uint lastModified, UpdateType updateType)
}
}
-void FrameSvgPrivate::paintCenter(QPainter &p, const QSharedPointer<FrameData> &frame, const QRectF &contentRect, const QSizeF &fullSize)
+void FrameSvgPrivate::paintCenter(QPainter &p, const QSharedPointer<FrameData> &frame, const QRect &contentRect, const QSize &fullSize)
{
- // fullSize and contentRect are in device pixels
if (!contentRect.isEmpty()) {
const QString centerElementId = frame->prefix % QLatin1String("center");
if (frame->tileCenter) {
- QSizeF centerTileSize = q->elementSize(centerElementId);
- QPixmap center(centerTileSize.toSize());
+ QSize centerTileSize = q->elementSize(centerElementId).toSize();
+ QPixmap center(centerTileSize);
center.fill(Qt::transparent);
QPainter centerPainter(&center);
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
- q->paint(&centerPainter, QRectF(QPointF(0, 0), centerTileSize), centerElementId);
+ q->paint(&centerPainter, QRect(QPoint(0, 0), centerTileSize), centerElementId);
if (frame->composeOverBorder) {
- p.drawTiledPixmap(QRectF(QPointF(0, 0), fullSize), center);
+ p.drawTiledPixmap(QRect(QPoint(0, 0), fullSize), center);
} else {
p.drawTiledPixmap(FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), center);
}
} else {
if (frame->composeOverBorder) {
- q->paint(&p, QRectF(QPointF(0, 0), fullSize), centerElementId);
+ q->paint(&p, QRect(QPoint(0, 0), fullSize), centerElementId);
} else {
q->paint(&p, FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), centerElementId);
}
@@ -752,7 +752,7 @@ void FrameSvgPrivate::paintCenter(QPainter &p, const QSharedPointer<FrameData> &
if (frame->composeOverBorder) {
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- p.drawPixmap(QRectF(QPointF(0, 0), fullSize), alphaMask(), QRectF(QPointF(0, 0), alphaMask().size()));
+ p.drawPixmap(QRect(QPoint(0, 0), fullSize), alphaMask());
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
}
}
@@ -760,51 +760,35 @@ void FrameSvgPrivate::paintCenter(QPainter &p, const QSharedPointer<FrameData> &
void FrameSvgPrivate::paintBorder(QPainter &p,
const QSharedPointer<FrameData> &frame,
const FrameSvg::EnabledBorders borders,
- const QSizeF &size,
- const QRectF &contentRect) const
+ const QSize &size,
+ const QRect &contentRect) const
{
- // size and contentRect are in device pixels
QString side = frame->prefix % FrameSvgHelpers::borderToElementId(borders);
if (frame->enabledBorders & borders && q->hasElement(side) && !size.isEmpty()) {
if (frame->stretchBorders) {
q->paint(&p, FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio()), side);
} else {
- QSize grownSize(std::ceil(size.width()), std::ceil(size.height()));
- QPixmap px(grownSize);
- // QPixmap px(QSize(std::ceil(size.width()), std::ceil(size.height())));
+ QPixmap px(size);
px.fill(Qt::transparent);
QPainter sidePainter(&px);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
- // A QRect as we have to exactly fill a QPixmap of integer size, prefer going slightly outside it to not have empty edges in the pixmap to tile
- q->paint(&sidePainter, QRect(QPoint(0, 0), grownSize), side);
+ q->paint(&sidePainter, QRect(QPoint(0, 0), size), side);
- // We are composing QPixmaps here, so all objects with integer size
- // Rounding the position and ceiling the size is the way that gives better tiled results
- auto r = FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio());
- r.setTopLeft(r.topLeft().toPoint());
- r.setSize(QSizeF(std::ceil(r.size().width()), std::ceil(r.size().height())));
-
- p.drawTiledPixmap(r, px);
+ p.drawTiledPixmap(FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio()), px);
}
}
}
-void FrameSvgPrivate::paintCorner(QPainter &p, const QSharedPointer<FrameData> &frame, KSvg::FrameSvg::EnabledBorders border, const QRectF &contentRect) const
+void FrameSvgPrivate::paintCorner(QPainter &p, const QSharedPointer<FrameData> &frame, KSvg::FrameSvg::EnabledBorders border, const QRect &contentRect) const
{
- // contentRect is in device pixels
// Draw the corner only if both borders in both directions are enabled.
if ((frame->enabledBorders & border) != border) {
return;
}
const QString corner = frame->prefix % FrameSvgHelpers::borderToElementId(border);
if (q->hasElement(corner)) {
- auto r = FrameSvgHelpers::sectionRect(border, contentRect, frame->frameSize * q->devicePixelRatio());
- // We are composing QPixmaps here, so all objects with integer size
- // Rounding the position and ceiling the size is the way that gives better tiled results
- r.setTopLeft(r.topLeft().toPoint());
- r.setSize(QSizeF(std::ceil(r.size().width()), std::ceil(r.size().height())));
- q->paint(&p, r.toRect(), corner);
+ q->paint(&p, FrameSvgHelpers::sectionRect(border, contentRect, frame->frameSize * q->devicePixelRatio()), corner);
}
}
@@ -852,7 +836,7 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const
// qCDebug(LOG_KSVG) << "!!!!!!!!!!!!!!!!!!!!!! updating sizes" << prefix;
Q_ASSERT(frame);
- QSizeF s = q->size();
+ QSize s = q->size().toSize();
q->resize();
if (!frame->cachedBackground.isNull()) {
frame->cachedBackground = QPixmap();
diff --git a/src/ksvg/private/framesvg_helpers.h b/src/ksvg/private/framesvg_helpers.h
index 95cd6ba..691aa3c 100644
--- a/src/ksvg/private/framesvg_helpers.h
+++ b/src/ksvg/private/framesvg_helpers.h
@@ -45,7 +45,7 @@ QString borderToElementId(FrameSvg::EnabledBorders borders)
/**
* @returns the suggested geometry for the @p borders given a @p fullSize frame size and a @p contentRect
*/
-QRectF sectionRect(KSvg::FrameSvg::EnabledBorders borders, const QRectF &contentRect, const QSizeF &fullSize)
+QRect sectionRect(KSvg::FrameSvg::EnabledBorders borders, const QRect &contentRect, const QSize &fullSize)
{
// don't use QRect corner methods here, they have semantics that might come as unexpected.
// prefer constructing the points explicitly. e.g. from QRect::topRight docs:
@@ -54,26 +54,26 @@ QRectF sectionRect(KSvg::FrameSvg::EnabledBorders borders, const QRectF &content
if (borders == FrameSvg::NoBorder) {
return contentRect;
} else if (borders == FrameSvg::TopBorder) {
- return QRectF(QPointF(contentRect.left(), 0), QSizeF(contentRect.width(), contentRect.top()));
+ return QRect(QPoint(contentRect.left(), 0), QSize(contentRect.width(), contentRect.top()));
} else if (borders == FrameSvg::BottomBorder) {
- return QRectF(QPointF(contentRect.left(), contentRect.bottom()), QSizeF(contentRect.width(), fullSize.height() - contentRect.bottom()));
+ return QRect(QPoint(contentRect.left(), contentRect.bottom() + 1), QSize(contentRect.width(), fullSize.height() - contentRect.bottom() - 1));
} else if (borders == FrameSvg::LeftBorder) {
- return QRectF(QPointF(0, contentRect.top()), QSizeF(contentRect.left(), contentRect.height()));
+ return QRect(QPoint(0, contentRect.top()), QSize(contentRect.left(), contentRect.height()));
} else if (borders == FrameSvg::RightBorder) {
- return QRectF(QPointF(contentRect.right(), contentRect.top()), QSizeF(fullSize.width() - contentRect.right(), contentRect.height()));
+ return QRect(QPoint(contentRect.right() + 1, contentRect.top()), QSize(fullSize.width() - contentRect.right() - 1, contentRect.height()));
} else if (borders == (FrameSvg::TopBorder | FrameSvg::LeftBorder)) {
- return QRectF(QPointF(0, 0), QSizeF(contentRect.left(), contentRect.top()));
+ return QRect(QPoint(0, 0), QSize(contentRect.left(), contentRect.top()));
} else if (borders == (FrameSvg::TopBorder | FrameSvg::RightBorder)) {
- return QRectF(QPointF(contentRect.right(), 0), QSizeF(fullSize.width() - contentRect.right(), contentRect.top()));
+ return QRect(QPoint(contentRect.right() + 1, 0), QSize(fullSize.width() - contentRect.right() - 1, contentRect.top()));
} else if (borders == (FrameSvg::BottomBorder | FrameSvg::LeftBorder)) {
- return QRectF(QPointF(0, contentRect.bottom()), QSizeF(contentRect.left(), fullSize.height() - contentRect.bottom()));
+ return QRect(QPoint(0, contentRect.bottom() + 1), QSize(contentRect.left(), fullSize.height() - contentRect.bottom() - 1));
} else if (borders == (FrameSvg::BottomBorder | FrameSvg::RightBorder)) {
- return QRectF(QPointF(contentRect.right(), contentRect.bottom()),
- QSizeF(fullSize.width() - contentRect.right(), fullSize.height() - contentRect.bottom()));
+ return QRect(QPoint(contentRect.right() + 1, contentRect.bottom() + 1),
+ QSize(fullSize.width() - contentRect.right() - 1, fullSize.height() - contentRect.bottom() - 1));
} else {
qWarning() << "unrecognized border" << borders;
}
- return QRectF();
+ return QRect();
}
}
diff --git a/src/ksvg/private/framesvg_p.h b/src/ksvg/private/framesvg_p.h
index 463b2ee..2b9e881 100644
--- a/src/ksvg/private/framesvg_p.h
+++ b/src/ksvg/private/framesvg_p.h
@@ -78,39 +78,38 @@ public:
static const int MAX_CACHED_MASKS = 10;
uint lastModified = 0;
- // Those sizes are in logical pixels
- QSizeF frameSize;
+ QSize frameSize;
uint cacheId;
// measures
- qreal topHeight;
- qreal leftWidth;
- qreal rightWidth;
- qreal bottomHeight;
+ int topHeight;
+ int leftWidth;
+ int rightWidth;
+ int bottomHeight;
// margins, are equal to the measures by default
- qreal topMargin;
- qreal leftMargin;
- qreal rightMargin;
- qreal bottomMargin;
+ int topMargin;
+ int leftMargin;
+ int rightMargin;
+ int bottomMargin;
// measures
- qreal fixedTopHeight;
- qreal fixedLeftWidth;
- qreal fixedRightWidth;
- qreal fixedBottomHeight;
+ int fixedTopHeight;
+ int fixedLeftWidth;
+ int fixedRightWidth;
+ int fixedBottomHeight;
// margins, are equal to the measures by default
- qreal fixedTopMargin;
- qreal fixedLeftMargin;
- qreal fixedRightMargin;
- qreal fixedBottomMargin;
+ int fixedTopMargin;
+ int fixedLeftMargin;
+ int fixedRightMargin;
+ int fixedBottomMargin;
- // margins, we only have the hqreal for insets
- qreal insetTopMargin;
- qreal insetLeftMargin;
- qreal insetRightMargin;
- qreal insetBottomMargin;
+ // margins, we only have the hint for insets
+ int insetTopMargin;
+ int insetLeftMargin;
+ int insetRightMargin;
+ int insetBottomMargin;
// size of the svg where the size of the "center"
// element is contentWidth x contentHeight
@@ -159,17 +158,14 @@ public:
return frameSize(frame.data());
}
QSizeF frameSize(FrameData *frame) const;
-
- // paintBorder, paintCorder and paintCenter sizes are in device pixels
void paintBorder(QPainter &p,
const QSharedPointer<FrameData> &frame,
KSvg::FrameSvg::EnabledBorders border,
- const QSizeF &originalSize,
- const QRectF &output) const;
- void paintCorner(QPainter &p, const QSharedPointer<FrameData> &frame, KSvg::FrameSvg::EnabledBorders border, const QRectF &output) const;
- void paintCenter(QPainter &p, const QSharedPointer<FrameData> &frame, const QRectF &contentRect, const QSizeF &fullSize);
-
- QRectF contentGeometry(const QSharedPointer<FrameData> &frame, const QSizeF &size) const;
+ const QSize &originalSize,
+ const QRect &output) const;
+ void paintCorner(QPainter &p, const QSharedPointer<FrameData> &frame, KSvg::FrameSvg::EnabledBorders border, const QRect &output) const;
+ void paintCenter(QPainter &p, const QSharedPointer<FrameData> &frame, const QRect &contentRect, const QSize &fullSize);
+ QRect contentGeometry(const QSharedPointer<FrameData> &frame, const QSize &size) const;
void updateFrameData(uint lastModified, UpdateType updateType = UpdateFrameAndMargins);
QSharedPointer<FrameData> lookupOrCreateMaskFrame(const QSharedPointer<FrameData> &frame, const QString &maskPrefix, const QString &maskRequestedPrefix);
@@ -181,7 +177,7 @@ public:
FrameSvg *const q;
- QPointF overlayPos;
+ QPoint overlayPos;
QSharedPointer<FrameData> frame;
QSharedPointer<FrameData> maskFrame;
@@ -189,7 +185,7 @@ public:
// those can differ from frame->enabledBorders if we are in a transition
FrameSvg::EnabledBorders enabledBorders;
// this can differ from frame->frameSize if we are in a transition
- QSizeF pendingFrameSize;
+ QSize pendingFrameSize;
static QHash<ImageSetPrivate *, QHash<uint, QWeakPointer<FrameData>>> s_sharedFrames;
diff --git a/src/ksvg/private/svg_p.h b/src/ksvg/private/svg_p.h
index 818a477..bb80c75 100644
--- a/src/ksvg/private/svg_p.h
+++ b/src/ksvg/private/svg_p.h
@@ -138,8 +138,8 @@ public:
void setNaturalSize(const QString &path, const QSizeF &size);
QSizeF naturalSize(const QString &path);
- QList<QSizeF> sizeHintsForId(const QString &path, const QString &id);
- void insertSizeHintForId(const QString &path, const QString &id, const QSizeF &size);
+ QList<QSize> sizeHintsForId(const QString &path, const QString &id);
+ void insertSizeHintForId(const QString &path, const QString &id, const QSize &size);
QString iconThemePath();
void setIconThemePath(const QString &path);
@@ -166,7 +166,7 @@ private:
*/
QHash<size_t, QRectF> m_localRectCache;
QHash<QString, QSet<unsigned int>> m_invalidElements;
- QHash<QString, QList<QSizeF>> m_sizeHintsForId;
+ QHash<QString, QList<QSize>> m_sizeHintsForId;
QHash<QString, unsigned int> m_lastModifiedTimes;
};
}
diff --git a/src/ksvg/svg.cpp b/src/ksvg/svg.cpp
index 1bdafd6..01ce058 100644
--- a/src/ksvg/svg.cpp
+++ b/src/ksvg/svg.cpp
@@ -272,7 +272,7 @@ void SvgRectsCache::dropImageFromCache(const QString &path)
QMetaObject::invokeMethod(m_configSyncTimer, qOverload<>(&QTimer::start));
}
-QList<QSizeF> SvgRectsCache::sizeHintsForId(const QString &path, const QString &id)
+QList<QSize> SvgRectsCache::sizeHintsForId(const QString &path, const QString &id)
{
const QString pathId = path % id;
@@ -280,7 +280,7 @@ QList<QSizeF> SvgRectsCache::sizeHintsForId(const QString &path, const QString &
if (it == m_sizeHintsForId.constEnd()) {
KConfigGroup imageGroup(m_svgElementsCache, path);
const QStringList &encoded = imageGroup.readEntry(id, QStringList());
- QList<QSizeF> sizes;
+ QList<QSize> sizes;
for (const auto &token : encoded) {
const auto &parts = token.split(QLatin1Char('x'));
if (parts.size() != 2) {
@@ -298,10 +298,10 @@ QList<QSizeF> SvgRectsCache::sizeHintsForId(const QString &path, const QString &
return *it;
}
-void SvgRectsCache::insertSizeHintForId(const QString &path, const QString &id, const QSizeF &size)
+void SvgRectsCache::insertSizeHintForId(const QString &path, const QString &id, const QSize &size)
{
// TODO: need to make this more efficient
- auto sizeListToString = [](const QList<QSizeF> &list) {
+ auto sizeListToString = [](const QList<QSize> &list) {
QString ret;
for (const auto &s : list) {
ret += QString::number(s.width()) % QLatin1Char('x') % QString::number(s.height()) % QLatin1Char(',');
@@ -561,7 +561,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
// Look at the size hinted elements and try to find the smallest one with an
// identical aspect ratio.
if (s.isValid() && !elementId.isEmpty()) {
- const QList<QSizeF> elementSizeHints = SvgRectsCache::instance()->sizeHintsForId(path, elementId);
+ const QList<QSize> elementSizeHints = SvgRectsCache::instance()->sizeHintsForId(path, elementId);
if (!elementSizeHints.isEmpty()) {
QSizeF bestFit(-1, -1);
@@ -873,11 +873,18 @@ Svg::~Svg()
void Svg::setDevicePixelRatio(qreal ratio)
{
+ // be completely integer for now
+ // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up.
+ //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned)
+ if (floor(d->devicePixelRatio) == floor(ratio)) {
+ return;
+ }
+
if (FrameSvg *f = qobject_cast<FrameSvg *>(this)) {
f->clearCache();
}
- d->devicePixelRatio = ratio;
+ d->devicePixelRatio = floor(ratio);
Q_EMIT repaintNeeded();
}
@@ -905,7 +912,7 @@ QImage Svg::image(const QSize &size, const QString &elementID)
void Svg::paint(QPainter *painter, const QPointF &point, const QString &elementID)
{
Q_ASSERT(painter->device());
- const qreal ratio = painter->device()->devicePixelRatio();
+ const int ratio = painter->device()->devicePixelRatio();
QPixmap pix((elementID.isNull() || d->multipleImages) ? d->findInCache(elementID, ratio, size()) : d->findInCache(elementID, ratio));
if (pix.isNull()) {
@@ -923,16 +930,16 @@ void Svg::paint(QPainter *painter, int x, int y, const QString &elementID)
void Svg::paint(QPainter *painter, const QRectF &rect, const QString &elementID)
{
Q_ASSERT(painter->device());
- const qreal ratio = painter->device()->devicePixelRatio();
+ const int ratio = painter->device()->devicePixelRatio();
QPixmap pix(d->findInCache(elementID, ratio, rect.size()));
- painter->drawPixmap(rect, pix, QRect(QPoint(0, 0), pix.size()));
+ painter->drawPixmap(QRectF(rect.topLeft(), rect.size()), pix, QRectF(QPointF(0, 0), pix.size()));
}
void Svg::paint(QPainter *painter, int x, int y, int width, int height, const QString &elementID)
{
Q_ASSERT(painter->device());
- const qreal ratio = painter->device()->devicePixelRatio();
+ const int ratio = painter->device()->devicePixelRatio();
QPixmap pix(d->findInCache(elementID, ratio, QSizeF(width, height)));
painter->drawPixmap(x, y, pix, 0, 0, pix.size().width(), pix.size().height());
}
--
2.45.2

BIN
frameworks.keyring Normal file

Binary file not shown.

112
kf6-ksvg.changes Normal file
View File

@ -0,0 +1,112 @@
-------------------------------------------------------------------
Sat Sep 7 09:03:29 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.6.0
* New feature release
* For more details please see:
* https://kde.org/announcements/frameworks/6/6.6.0
- Changes since 6.5.0:
* Update version to 6.6.0
-------------------------------------------------------------------
Mon Aug 5 10:47:53 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.5.0
* New feature release
* For more details please see:
* https://kde.org/announcements/frameworks/6/6.5.0
- Changes since 6.4.0:
* Update dependency version to 6.5.0
* findInCache: Compare last modified to boot time if timestamp is 0 (kde#453876)
* Update version to 6.5.0
* Drop dead code
-------------------------------------------------------------------
Tue Jul 9 09:41:57 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.4.0
* New feature release
* For more details please see:
* https://kde.org/announcements/frameworks/6/6.4.0
- Changes since 6.3.0:
* Fix masks of completely black mask frames
* Restore proper devicepixelratio when extracting from cache (kde#488295)
* Fix description in metainfo
* Remove explicit maintainer from metainfo
- Drop patch, merged upstream:
* 0001-Restore-proper-devicepixelratio-when-extracting-from.patch
-------------------------------------------------------------------
Wed Jun 19 20:38:02 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Add upstream fix (kde#488295):
* 0001-Restore-proper-devicepixelratio-when-extracting-from.patch
- Rebase 0001-Revert-Support-for-fractional-scaling.patch
-------------------------------------------------------------------
Sun Jun 9 20:14:24 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Add patch to work around themes having incorrect fractional sizes
(kde#487625):
* 0001-Revert-Support-for-fractional-scaling.patch
-------------------------------------------------------------------
Wed Jun 5 10:11:56 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.3.0
* New feature release
* For more details please see:
* https://kde.org/announcements/frameworks/6/6.3.0/
- Changes since 6.2.0:
* Support for fractional scaling
* Color also absolute path images (kde#485801)
* Reapply "Port to declarative type registration"
-------------------------------------------------------------------
Mon May 6 12:22:55 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.2.0
* New feature release
* For more details please see:
* https://kde.org/announcements/gear/6.2.0/
- Changes since 6.1.0:
* Don't call update on missing marginObject
* Make property type fully qualified
-------------------------------------------------------------------
Fri Apr 5 12:52:58 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.1.0
* New feature release
- Changes since 6.0.0:
* update version for new release
* Add test for loading svgs from qrc files
* Support loading svg from QRC files
-------------------------------------------------------------------
Wed Feb 21 19:28:09 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.0
* New bugfix release
* Release announcement not available yet
- Changes since 5.249.0:
* update version for new release
-------------------------------------------------------------------
Wed Jan 31 17:50:52 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 5.249.0 (6.0 RC 2):
* New bugfix release
* For more details see https://kde.org/announcements/megarelease/6/rc2/
-------------------------------------------------------------------
Mon Jan 15 20:01:37 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 5.248.0 (6.0 RC 1)
* For more details please see:
https://kde.org/announcements/megarelease/6/rc1/
-------------------------------------------------------------------
Tue Jun 27 12:34:44 UTC 2023 - Christophe Marin <christophe@krop.fr>
- Init kf6-ksvg

110
kf6-ksvg.spec Normal file
View File

@ -0,0 +1,110 @@
#
# spec file for package kf6-ksvg
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define qt6_version 6.6.0
%define rname ksvg
# Full KF6 version (e.g. 6.6.0)
%{!?_kf6_version: %global _kf6_version %{version}}
# Last major and minor KF6 version (e.g. 6.0)
%{!?_kf6_bugfix_version: %define _kf6_bugfix_version %(echo %{_kf6_version} | awk -F. '{print $1"."$2}')}
%bcond_without released
Name: kf6-ksvg
Version: 6.6.0
Release: 0
Summary: Components for handling SVGs
License: GPL-2.0-or-later
URL: https://www.kde.org
Source: %{rname}-%{version}.tar.xz
%if %{with released}
Source1: %{rname}-%{version}.tar.xz.sig
Source2: frameworks.keyring
%endif
# PATCH-FIX-OPENSUSE
Patch0: 0001-Revert-Support-for-fractional-scaling.patch
BuildRequires: doxygen
BuildRequires: kf6-extra-cmake-modules >= %{_kf6_bugfix_version}
BuildRequires: cmake(KF6Archive) >= %{_kf6_bugfix_version}
BuildRequires: cmake(KF6ColorScheme) >= %{_kf6_bugfix_version}
BuildRequires: cmake(KF6Config) >= %{_kf6_bugfix_version}
BuildRequires: cmake(KF6CoreAddons) >= %{_kf6_bugfix_version}
BuildRequires: cmake(KF6GuiAddons) >= %{_kf6_bugfix_version}
BuildRequires: cmake(KF6KirigamiPlatform) >= %{_kf6_bugfix_version}
BuildRequires: cmake(Qt6Gui) >= %{qt6_version}
BuildRequires: cmake(Qt6Qml) >= %{qt6_version}
BuildRequires: cmake(Qt6Quick) >= %{qt6_version}
BuildRequires: cmake(Qt6QuickControls2) >= %{qt6_version}
BuildRequires: cmake(Qt6Svg) >= %{qt6_version}
BuildRequires: cmake(Qt6ToolsTools) >= %{qt6_version}
Requires: kf6-kirigami-imports >= %{_kf6_bugfix_version}
%description
Components for handling SVGs
%package imports
Summary: QML Components for ksvg
%description imports
This package contains QML imports for SVG handling.
%package -n libKF6Svg6
Summary: ksvg library
Requires: kf6-ksvg >= %{version}
Recommends: kf6-ksvg-imports = %{version}
%description -n libKF6Svg6
The ksvg library.
%package devel
Summary: Development Files for the ksvg framework
Requires: libKF6Svg6 = %{version}
%description devel
Development Files for the ksvg framework.
%prep
%autosetup -p1 -n %{rname}-%{version}
%build
%cmake_kf6 -DBUILD_QCH:BOOL=TRUE
%kf6_build
%install
%kf6_install
%ldconfig_scriptlets -n libKF6Svg6
%files
%{_kf6_debugdir}/ksvg.categories
%files imports
%{_kf6_qmldir}/org/kde/ksvg/
%files -n libKF6Svg6
%license LICENSES/*
%doc README.md
%{_kf6_libdir}/libKF6Svg.so.*
%files devel
%doc %{_kf6_qchdir}/KF6Svg.*
%{_kf6_cmakedir}/KF6Svg/
%{_kf6_includedir}/KSvg/
%{_kf6_libdir}/libKF6Svg.so
%changelog

3
ksvg-6.3.0.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0054ed0c094c605a712bc9f8c8cc61c7e0d3eefe1ee50a93912bbd60a6cb07d7
size 83208

7
ksvg-6.3.0.tar.xz.sig Normal file
View File

@ -0,0 +1,7 @@
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQSQqWisqEU3zCe5nq8sjfWHptSqwQUCZlnQdQAKCRAsjfWHptSq
waaUAQCgGrZLLc6/HHvEH/A7VO0kUdX97KMGucDdHUgfgc1cUAEA0K7/2gfNzx/s
cekokxaJSHnOnfkfEPYAZFA+rIie8gw=
=9E6E
-----END PGP SIGNATURE-----

3
ksvg-6.4.0.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3391c74fc31526e7ff2659622d00e93b5cd8667397611d5676062e4b32d86530
size 83368

7
ksvg-6.4.0.tar.xz.sig Normal file
View File

@ -0,0 +1,7 @@
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQSQqWisqEU3zCe5nq8sjfWHptSqwQUCZohS3QAKCRAsjfWHptSq
wbbNAP9z5EG3cfdHQVUuWnl+UMHaFrZZK9Fm39BdTuzeHDwgZgD/eXbcuJ7If2LQ
RD0AvG1HWoR+CsoFYQ3KMj2AWEk4JQ0=
=BMp2
-----END PGP SIGNATURE-----

3
ksvg-6.5.0.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ae2024bd4d7e6950c92b5924deced5d55b6101749d635799b24fedac60cb26cd
size 83692

7
ksvg-6.5.0.tar.xz.sig Normal file
View File

@ -0,0 +1,7 @@
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQSQqWisqEU3zCe5nq8sjfWHptSqwQUCZqy/2gAKCRAsjfWHptSq
wa3cAQDeLclDcAMNiZKaspw3G02rlqsw4/of4KPfJKtbzAd0vgEAlZjQt0z0ctF4
59d8D7OMZ7fnF6e2nyaO/LqeSU9hsAs=
=YhFo
-----END PGP SIGNATURE-----

3
ksvg-6.6.0.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fd574866b6879809ecfd24f9d92c7ce51aadb91527e51d1f7c67dec8647d8ac6
size 83700

7
ksvg-6.6.0.tar.xz.sig Normal file
View File

@ -0,0 +1,7 @@
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQSQqWisqEU3zCe5nq8sjfWHptSqwQUCZtrqHAAKCRAsjfWHptSq
wcscAP4hFiUy+3ARVfcTyGL4zHueQ/BaUkCYgN9lmAA2i5EzMQD+Ko4mkak5N8gj
WuvRNBzdoj8fAfLRWb3OwIqQ1TK7kgc=
=guVJ
-----END PGP SIGNATURE-----