Client: Fix copying shm buffer data with fractional scaling

The QWaylandShmBackingStore computes the device pixels in the source
image manually. But it does not match what the QPainter does one to one.
Visually, it produces artifacts where the contents of an app is
jiggling or moves back and forth by one pixel.

In order to address the issue, the QWaylandShmBackingStore can copy
whole buffers but with a clip region set. That way, the QPainter can
consistently compute the coordinates in the device pixels.

Pick-to: 6.9
Change-Id: Ib4832c4d687f43f6cc1de4a1760c32f1abd2ab03
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Vlad Zahorodnii 2025-04-03 12:33:34 +03:00
parent f197456481
commit 26968c3802

View File

@ -364,13 +364,8 @@ bool QWaylandShmBackingStore::recreateBackBufferIfNeeded()
QPainter painter(targetImage); QPainter painter(targetImage);
painter.setCompositionMode(QPainter::CompositionMode_Source); painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.setClipRegion(buffer->dirtyRegion());
const qreal sourceDevicePixelRatio = sourceImage->devicePixelRatio(); painter.drawImage(QRectF(QPointF(), targetImage->deviceIndependentSize()), *sourceImage, sourceImage->rect());
for (const QRect &rect : buffer->dirtyRegion()) {
QRectF sourceRect(QPointF(rect.topLeft()) * sourceDevicePixelRatio,
QSizeF(rect.size()) * sourceDevicePixelRatio);
painter.drawImage(rect, *sourceImage, sourceRect);
}
} }
mBackBuffer = buffer; mBackBuffer = buffer;