From aca3b95700130191b35e4428fb606a074482e32b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 12 Jun 2024 09:53:47 +0200 Subject: [PATCH] eglfs: Revive QWidget rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After recent changes to widgets and backingstores, attempting to run any widget-based application with eglfs resulted in a crash. The backingstore implementation used here was not fully migrated. Update flush() to create the rendering infrastructure if needed, and make it call into rhiFlush(). Amends eb4cb719257d3b57cd801273d4011579d8c81714 Change-Id: I253c37200f5a902a0e61b62581ac456549f3aeba Fixes: QTBUG-126221 Reviewed-by: Tor Arne Vestbø (cherry picked from commit 0a10d23c4a49dd14a1ded41b7cc6921909b0ee7a) Reviewed-by: Qt Cherry-pick Bot --- src/opengl/qopenglcompositorbackingstore.cpp | 34 +++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/opengl/qopenglcompositorbackingstore.cpp b/src/opengl/qopenglcompositorbackingstore.cpp index 371ca868f85..052f29d41e6 100644 --- a/src/opengl/qopenglcompositorbackingstore.cpp +++ b/src/opengl/qopenglcompositorbackingstore.cpp @@ -134,36 +134,24 @@ void QOpenGLCompositorBackingStore::updateTexture() } } -void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QOpenGLCompositorBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, const QPoint &offset) { // Called for ordinary raster windows. - auto *handle = dynamic_cast(window->handle()); - if (handle && !handle->backingStore()) - handle->setBackingStore(this); Q_UNUSED(region); Q_UNUSED(offset); - m_rhi = rhi(window); - Q_ASSERT(m_rhi); + if (!rhi(flushedWindow)) { + QPlatformBackingStoreRhiConfig rhiConfig; + rhiConfig.setApi(QPlatformBackingStoreRhiConfig::OpenGL); + rhiConfig.setEnabled(true); + createRhi(flushedWindow, rhiConfig); + } - QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); - QOpenGLContext *dstCtx = compositor->context(); - if (!dstCtx) - return; - - QWindow *dstWin = compositor->targetWindow(); - if (!dstWin) - return; - - if (!dstCtx->makeCurrent(dstWin)) - return; - - updateTexture(); - m_textures->clear(); - m_textures->appendTexture(nullptr, m_bsTextureWrapper, window->geometry()); - - compositor->update(); + static QPlatformTextureList emptyTextureList; + bool translucentBackground = m_image.hasAlphaChannel(); + rhiFlush(flushedWindow, flushedWindow->devicePixelRatio(), + region, offset, &emptyTextureList, translucentBackground); } QPlatformBackingStore::FlushResult QOpenGLCompositorBackingStore::rhiFlush(QWindow *window,