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 6.6
Change-Id: I44662778f5b1bcd259b20ca86124e6487561ef4f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-08-01 18:39:10 +02:00
parent 953e7eece8
commit e0eb2818fa
2 changed files with 10 additions and 3 deletions

View File

@ -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"

View File

@ -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)