From 90c54b02f83961b1c66f10fe57bcfcf4523ebba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 1 Oct 2021 14:29:15 +0200 Subject: [PATCH] Fix scrolling of QRasterBackingStore when operating on QRasterGLSurface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were to strict in what surface type we allowed scrolling for. The RasterGLSurface type is an odd one, used by widgets to compose GL and raster content, which means we still have a raster backingstore we can scroll. It's just the flush that's different. Pick-to: 6.2 Change-Id: Ia229c21c00ad38df9e87f4fc78e341e030ef228d Reviewed-by: Morten Johan Sørvig Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qplatformsurface.cpp | 11 +++++++++++ src/gui/kernel/qplatformsurface.h | 2 ++ src/gui/painting/qbackingstore.cpp | 13 +------------ src/gui/painting/qrasterbackingstore.cpp | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qplatformsurface.cpp b/src/gui/kernel/qplatformsurface.cpp index fdb2cf567d..772207a7a9 100644 --- a/src/gui/kernel/qplatformsurface.cpp +++ b/src/gui/kernel/qplatformsurface.cpp @@ -68,6 +68,17 @@ QPlatformSurface::QPlatformSurface(QSurface *surface) : m_surface(surface) { } +bool QPlatformSurface::isRasterSurface(QSurface *surface) +{ + switch (surface->surfaceType()) { + case QSurface::RasterSurface: + case QSurface::RasterGLSurface: + return true; + default: + return false; + }; +} + #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QPlatformSurface *surface) { diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h index 475f3ef330..bf0ba81d7f 100644 --- a/src/gui/kernel/qplatformsurface.h +++ b/src/gui/kernel/qplatformsurface.h @@ -73,6 +73,8 @@ public: QSurface *surface() const; virtual QPlatformScreen *screen() const = 0; + static bool isRasterSurface(QSurface *surface); + private: explicit QPlatformSurface(QSurface *surface); diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index a2e5f7286e..f76b9864fc 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -192,17 +192,6 @@ void QBackingStore::endPaint() handle()->endPaint(); } -static bool isRasterSurface(QWindow *window) -{ - switch (window->surfaceType()) { - case QSurface::RasterSurface: - case QSurface::RasterGLSurface: - return true; - default: - return false; - }; -} - /*! Flushes the given \a region from the specified \a window onto the screen. @@ -229,7 +218,7 @@ void QBackingStore::flush(const QRegion ®ion, QWindow *window, const QPoint & return; } - if (!isRasterSurface(window)) { + if (!QPlatformSurface::isRasterSurface(window)) { qWarning() << "Attempted flush to non-raster surface" << window << "of type" << window->surfaceType() << (window->inherits("QWidgetWindow") ? "(consider using Qt::WA_PaintOnScreen to exclude " "from backingstore sync)" : ""); diff --git a/src/gui/painting/qrasterbackingstore.cpp b/src/gui/painting/qrasterbackingstore.cpp index a3ffe11d19..49dbeae774 100644 --- a/src/gui/painting/qrasterbackingstore.cpp +++ b/src/gui/painting/qrasterbackingstore.cpp @@ -82,7 +82,7 @@ QImage QRasterBackingStore::toImage() const bool QRasterBackingStore::scroll(const QRegion ®ion, int dx, int dy) { - if (window()->surfaceType() != QSurface::RasterSurface) + if (!QPlatformSurface::isRasterSurface(window())) return false; extern void qt_scrollRectInImage(QImage &, const QRect &, const QPoint &);