Skip to content

Commit

Permalink
eglfs: Revive QWidget rendering
Browse files Browse the repository at this point in the history
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 eb4cb71

Change-Id: I253c37200f5a902a0e61b62581ac456549f3aeba
Fixes: QTBUG-126221
Reviewed-by: Tor Arne Vestbø <[email protected]>
(cherry picked from commit 0a10d23)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
alpqr authored and Qt Cherry-pick Bot committed Jun 13, 2024
1 parent 885a495 commit aca3b95
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/opengl/qopenglcompositorbackingstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,24 @@ void QOpenGLCompositorBackingStore::updateTexture()
}
}

void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
void QOpenGLCompositorBackingStore::flush(QWindow *flushedWindow, const QRegion &region, const QPoint &offset)
{
// Called for ordinary raster windows.
auto *handle = dynamic_cast<QOpenGLCompositorWindow *>(window->handle());
if (handle && !handle->backingStore())
handle->setBackingStore(this);

Q_UNUSED(region);
Q_UNUSED(offset);

m_rhi = rhi(window);
Q_ASSERT(m_rhi);

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());
if (!rhi(flushedWindow)) {
QPlatformBackingStoreRhiConfig rhiConfig;
rhiConfig.setApi(QPlatformBackingStoreRhiConfig::OpenGL);
rhiConfig.setEnabled(true);
createRhi(flushedWindow, rhiConfig);
}

compositor->update();
static QPlatformTextureList emptyTextureList;
bool translucentBackground = m_image.hasAlphaChannel();
rhiFlush(flushedWindow, flushedWindow->devicePixelRatio(),
region, offset, &emptyTextureList, translucentBackground);
}

QPlatformBackingStore::FlushResult QOpenGLCompositorBackingStore::rhiFlush(QWindow *window,
Expand Down

0 comments on commit aca3b95

Please sign in to comment.