From d48f08edb6ed78a639a4c84693f983c6efca7a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 1 Aug 2023 18:39:10 +0200 Subject: [PATCH] Avoid extending dirty region in beginPaint When the raster window is resized, we need to resize the backingstore, and make sure we repaint the entire window. We defer the backingstore resize to beginPaint, in case multiple resize events come in before we have a chance to paint, but we can't defer the invalidation of the paint device window, because QPaintDeviceWindowPrivate::paint() has already subtracted the paint region from its dirty region at this point. Invalidating yet again will result in the dirty region of window not clearing fully until after the final resize, and when that happens we will also repaint the window with the wrong dirty region, based on the window's original size. My moving the window invalidation to the resize event, while keeping the deferred backingstore resize we avoid this problem. Pick-to: 6.5 Change-Id: I44662778f5b1bcd259b20ca86124e6487561ef4f Reviewed-by: Qt CI Bot Reviewed-by: Eirik Aavitsland Reviewed-by: Laszlo Agocs (cherry picked from commit e0eb2818face4ffb7dafd87464f355d4654b7be0) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qrasterwindow.cpp | 12 +++++++++--- src/gui/kernel/qrasterwindow.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qrasterwindow.cpp b/src/gui/kernel/qrasterwindow.cpp index 19d84c601d8..7888db67777 100644 --- a/src/gui/kernel/qrasterwindow.cpp +++ b/src/gui/kernel/qrasterwindow.cpp @@ -38,10 +38,9 @@ public: { Q_Q(QRasterWindow); const QSize size = q->size(); - if (backingstore->size() != size) { + if (backingstore->size() != size) backingstore->resize(size); - markWindowAsDirty(); - } + backingstore->beginPaint(region); } @@ -102,6 +101,13 @@ QPaintDevice *QRasterWindow::redirected(QPoint *) const return d->backingstore->paintDevice(); } +void QRasterWindow::resizeEvent(QResizeEvent *) +{ + Q_D(QRasterWindow); + if (d->backingstore->size() != size()) + d->markWindowAsDirty(); +} + QT_END_NAMESPACE #include "moc_qrasterwindow.cpp" diff --git a/src/gui/kernel/qrasterwindow.h b/src/gui/kernel/qrasterwindow.h index 05d71e16552..986bf6b511d 100644 --- a/src/gui/kernel/qrasterwindow.h +++ b/src/gui/kernel/qrasterwindow.h @@ -23,6 +23,7 @@ public: protected: int metric(PaintDeviceMetric metric) const override; QPaintDevice *redirected(QPoint *) const override; + void resizeEvent(QResizeEvent *event) override; private: Q_DISABLE_COPY(QRasterWindow)