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>
bb10
Tor Arne Vestbø 2023-12-10 12:29:44 +01:00
parent da473f3a80
commit cd21ae6cdf
1 changed files with 12 additions and 4 deletions

View File

@ -15,17 +15,24 @@ QRhiBackingStore::~QRhiBackingStore()
{
}
void QRhiBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
void QRhiBackingStore::flush(QWindow *flushedWindow, const QRegion &region, 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 &region, 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