diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-12-10 12:29:44 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-01-16 13:50:34 +0100 |
commit | cd21ae6cdffb3118ae0195a448f7b437886c4701 (patch) | |
tree | 763feb8b7c35074d73ef17c05a1ed6fffa13305f /src/gui/painting | |
parent | da473f3a80798d84d0f1bd9175158024a548ec68 (diff) |
QRhiBackingStore: Support flushing child windows with same surface type
As long as the surface type of the child window is the same as the one
owning the backingstore we can flush it through the same code path as
for the top level window.
This code path was already exercised by QWidgetRepaintManager::flush(),
by calling rhiFlush() directly, but we now support it in those (rare)
cases of non-Widgets windows using a single QBackingStore for a full
window hierarchy.
A future improvement would be to decouple the RHI configuration from
the backingstore, so that we can flush child windows with different
surface types through the same backingstore. This is relevant for
platforms that rely on QRhiBackingStore exclusively (iOS and Android),
as in widgets we currently only switch the top level widget surface
type when enabling RHI based flushing, leaving all child windows
with QWindow::RasterSurface. This could potentially be solved by
teaching widgets to re-configure all QWidgetWindows, including
children.
Task-number: QTBUG-119309
Change-Id: Ifa3fe6125493ac1becd2538ba84f3b4a5e3a5d71
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qrhibackingstore.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gui/painting/qrhibackingstore.cpp b/src/gui/painting/qrhibackingstore.cpp index cf13df3765..72ab28f1fc 100644 --- a/src/gui/painting/qrhibackingstore.cpp +++ b/src/gui/painting/qrhibackingstore.cpp @@ -15,17 +15,24 @@ QRhiBackingStore::~QRhiBackingStore() { } -void QRhiBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QRhiBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(region); Q_UNUSED(offset); - if (window != this->window()) + if (flushedWindow->surfaceType() != window()->surfaceType()) { + qWarning() << "Cannot flush child window" << flushedWindow + << "with surface type" << flushedWindow->surfaceType() << ";" + << "Must match" << window()->surfaceType() << "of" << window(); + + // FIXME: Support different surface types by not tying the + // RHI config to the backing store itself (per window config). return; + } if (!rhi()) { QPlatformBackingStoreRhiConfig rhiConfig; - switch (window->surfaceType()) { + switch (window()->surfaceType()) { case QSurface::OpenGLSurface: rhiConfig.setApi(QPlatformBackingStoreRhiConfig::OpenGL); break; @@ -41,7 +48,8 @@ void QRhiBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin static QPlatformTextureList emptyTextureList; bool translucentBackground = m_image.hasAlphaChannel(); - rhiFlush(window, window->devicePixelRatio(), region, offset, &emptyTextureList, translucentBackground); + rhiFlush(flushedWindow, flushedWindow->devicePixelRatio(), + region, offset, &emptyTextureList, translucentBackground); } QImage::Format QRhiBackingStore::format() const |