diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 3b20d2e7e47..130b479c645 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -229,6 +229,11 @@ QPlatformServices *QPlatformIntegration::services() const \value ScreenWindowGrabbing The platform supports grabbing window on screen. On Wayland, this capability can be reported as \c false. The default implementation of hasCapability() returns \c true. + + \value BackingStoreStaticContents The platform backingstore supports static contents. + On resize of the backingstore the static contents region is provided, and the backing + store is expected to propagate the static content to the resized backing store, without + clients needing to repaint the static content region. */ /*! diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 71bf23a55c9..a18ae821c7b 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -99,7 +99,8 @@ public: MaximizeUsingFullscreenGeometry, PaintEvents, RhiBasedRendering, - ScreenWindowGrabbing // whether QScreen::grabWindow() is supported + ScreenWindowGrabbing, // whether QScreen::grabWindow() is supported + BackingStoreStaticContents }; virtual ~QPlatformIntegration() { } diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 586c19885ec..2304ee2256e 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -267,6 +267,13 @@ bool QBackingStore::scroll(const QRegion &area, int dx, int dy) */ void QBackingStore::setStaticContents(const QRegion ®ion) { + [[maybe_unused]] static const bool didCheckPlatformSupport = []{ + const auto *integration = QGuiApplicationPrivate::platformIntegration(); + if (!integration->hasCapability(QPlatformIntegration::BackingStoreStaticContents)) + qWarning("QBackingStore::setStaticContents(): Platform does not support static contents"); + return true; + }(); + d_ptr->staticContents = region; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index f6e377d1076..1ed5bf8330d 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -286,6 +286,8 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co return true; case SwitchableWidgetComposition: return false; // QTBUG-68329 QTBUG-53515 QTBUG-54734 + case BackingStoreStaticContents: + return true; default: return QPlatformIntegration::hasCapability(cap); } diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index c63f7454460..e6b57d9872d 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -706,7 +706,9 @@ void QWidgetRepaintManager::paintAndFlush() const QRect tlwRect = tlw->data->crect; if (!updatesDisabled && store->size() != tlwRect.size()) { - if (hasStaticContents() && !store->size().isEmpty() ) { + QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration(); + if (hasStaticContents() && !store->size().isEmpty() + && integration->hasCapability(QPlatformIntegration::BackingStoreStaticContents)) { // Repaint existing dirty area and newly visible area. const QRect clipRect(QPoint(0, 0), store->size()); const QRegion staticRegion(staticContents(nullptr, clipRect)); @@ -1140,11 +1142,7 @@ void QWidgetRepaintManager::removeStaticWidget(QWidget *widget) bool QWidgetRepaintManager::hasStaticContents() const { -#if defined(Q_OS_WIN) return !staticWidgets.isEmpty(); -#else - return !staticWidgets.isEmpty() && false; -#endif } /*! diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp index 18b4e2bd394..a830d14be88 100644 --- a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp +++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include @@ -276,9 +278,9 @@ void tst_QBackingStore::flush() void tst_QBackingStore::staticContents() { -#if !defined(Q_OS_WIN) - QSKIP("Platform does not support static backingstore content"); -#endif + const auto *integration = QGuiApplicationPrivate::platformIntegration(); + if (!integration->hasCapability(QPlatformIntegration::BackingStoreStaticContents)) + QSKIP("Platform does not support static backingstore content"); QWindow window; window.create(); diff --git a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp index 68449e1dc77..d463c8499c7 100644 --- a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp +++ b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp @@ -11,7 +11,9 @@ #include #include #include +#include #include +#include //#define MANUAL_DEBUG @@ -429,6 +431,10 @@ void tst_QWidgetRepaintManager::opaqueChildren() */ void tst_QWidgetRepaintManager::staticContents() { + const auto *integration = QGuiApplicationPrivate::platformIntegration(); + if (!integration->hasCapability(QPlatformIntegration::BackingStoreStaticContents)) + QSKIP("Platform does not support static backingstore content"); + TestWidget widget; widget.setAttribute(Qt::WA_StaticContents); widget.initialShow();