HighDPI: Extend exposed region to avoid artifacts by rounding.
Introduce a special scaling function fromNativeLocalExposedRegion() for exposed regions that uses the floor of the top left point and the ceiling of the bottom right point similarly to how it was done in the XCB plugin in 5.5. Task-number: QTBUG-46615 Task-number: QTBUG-50463 Change-Id: I95e4a571b814357c014605ed79e374a821fa155b Reviewed-by: Błażej Szczygieł <spaz16@wp.pl> Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
parent
4c1b6cdd29
commit
f5b9cdbb08
@ -47,6 +47,7 @@
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qmargins.h>
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
@ -382,6 +383,24 @@ inline QRegion fromNativeLocalRegion(const QRegion &pixelRegion, const QWindow *
|
||||
return pointRegion;
|
||||
}
|
||||
|
||||
// When mapping expose events to Qt rects: round top/left towards the origin and
|
||||
// bottom/right away from the origin, making sure that we cover the whole window.
|
||||
inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QWindow *window)
|
||||
{
|
||||
if (!QHighDpiScaling::isActive())
|
||||
return pixelRegion;
|
||||
|
||||
const qreal scaleFactor = QHighDpiScaling::factor(window);
|
||||
QRegion pointRegion;
|
||||
foreach (const QRect &rect, pixelRegion.rects()) {
|
||||
const QPointF topLeftP = QPointF(rect.topLeft()) / scaleFactor;
|
||||
const QPointF bottomRightP = QPointF(rect.bottomRight()) / scaleFactor;
|
||||
pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())),
|
||||
QPoint(qCeil(bottomRightP.x()), qCeil(bottomRightP.y())));
|
||||
}
|
||||
return pointRegion;
|
||||
}
|
||||
|
||||
inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window)
|
||||
{
|
||||
if (!QHighDpiScaling::isActive())
|
||||
@ -498,6 +517,8 @@ namespace QHighDpi {
|
||||
template <typename T> inline
|
||||
T fromNativeLocalRegion(const T &value, ...) { return value; }
|
||||
template <typename T> inline
|
||||
T fromNativeLocalExposedRegion(const T &value, ...) { return value; }
|
||||
template <typename T> inline
|
||||
T toNativeLocalRegion(const T &value, ...) { return value; }
|
||||
|
||||
template <typename T> inline
|
||||
|
@ -582,7 +582,8 @@ void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
|
||||
|
||||
void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion ®ion)
|
||||
{
|
||||
QWindowSystemInterfacePrivate::ExposeEvent *e = new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalRegion(region, tlw));
|
||||
QWindowSystemInterfacePrivate::ExposeEvent *e =
|
||||
new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalExposedRegion(region, tlw));
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user