summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-04-26 03:57:12 -0700
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-04-27 06:13:13 -0700
commit8161726619b71fb5bd8f77c7fd020d53d5ac7c9e (patch)
tree7dfd7bf41a5ba821dab0c304d244d49e8b4653fe /src/plugins/platforms/eglfs
parent9861fd09cba4fe220f668585c78a7324d069ef94 (diff)
Revive eglfs' raster window support
A number of consequences of the new rhi-based backingstore composition were not handled. Most importantly, the fact that RasterGLSurface is not a thing anymore in practice causes challenges because we can no longer decide just based on the surfaceType what a QWindow with OpenGLSurface would be. (a plain GL window or a GL window with a backing store?) Also, the backingstore needs to be able to initialize its backing QRhi by itself, because with eglfs going through OpenGL is the only way. Amends 68a4c5da9a080101cccd8a3b2edb1c908da0ca8e Fixes: QTBUG-102750 Change-Id: Ia1ca59d01e3012264a76b50e591612fdcc2a0bd6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/platforms/eglfs')
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp21
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h7
3 files changed, 20 insertions, 11 deletions
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index 0b133c55a7..703259d66c 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -201,7 +201,8 @@ QPixmap QEglFSScreen::grabWindow(WId wid, int x, int y, int width, int height) c
QImage img;
- if (static_cast<QEglFSWindow *>(windows.first()->sourceWindow()->handle())->isRaster()) {
+ QEglFSWindow *primaryWin = static_cast<QEglFSWindow *>(windows.first()->sourceWindow()->handle());
+ if (primaryWin->isRaster() || primaryWin->backingStore()) {
// Request the compositor to render everything into an FBO and read it back. This
// is of course slow, but it's safe and reliable. It will not include the mouse
// cursor, which is a plus.
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index 47f6d88e5c..13cc65bdaf 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -110,7 +110,7 @@ void QEglFSWindow::create()
#ifndef QT_NO_OPENGL
QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
if (screen->primarySurface() != EGL_NO_SURFACE) {
- if (Q_UNLIKELY(!isRaster() || !compositor->targetWindow())) {
+ if (Q_UNLIKELY(isRaster() != (compositor->targetWindow() != nullptr))) {
# ifndef Q_OS_ANDROID
// We can have either a single OpenGL window or multiple raster windows.
// Other combinations cannot work.
@@ -137,21 +137,30 @@ void QEglFSWindow::create()
screen->setPrimarySurface(m_surface);
#ifndef QT_NO_OPENGL
- if (isRaster()) {
+ compositor->setTargetWindow(window(), screen->rawGeometry());
+ compositor->setRotation(qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION"));
+#endif
+}
+
+void QEglFSWindow::setBackingStore(QOpenGLCompositorBackingStore *backingStore)
+{
+#ifndef QT_NO_OPENGL
+ if (!m_rasterCompositingContext) {
m_rasterCompositingContext = new QOpenGLContext;
m_rasterCompositingContext->setShareContext(qt_gl_global_share_context());
m_rasterCompositingContext->setFormat(m_format);
m_rasterCompositingContext->setScreen(window()->screen());
if (Q_UNLIKELY(!m_rasterCompositingContext->create()))
qFatal("EGLFS: Failed to create compositing context");
- compositor->setTarget(m_rasterCompositingContext, window(), screen->rawGeometry());
- compositor->setRotation(qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION"));
// If there is a "root" window into which raster and QOpenGLWidget content is
// composited, all other contexts must share with its context.
if (!qt_gl_global_share_context())
qt_gl_set_global_share_context(m_rasterCompositingContext);
}
-#endif // QT_NO_OPENGL
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ compositor->setTargetContext(m_rasterCompositingContext);
+#endif
+ m_backingStore = backingStore;
}
void QEglFSWindow::destroy()
@@ -352,7 +361,7 @@ WId QEglFSWindow::winId() const
void QEglFSWindow::setOpacity(qreal)
{
- if (!isRaster())
+ if (!isRaster() && !backingStore())
qWarning("QEglFSWindow: Cannot set opacity for non-raster windows");
// Nothing to do here. The opacity is stored in the QWindow.
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index 6b34071d1a..1418ef82a1 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -103,12 +103,11 @@ public:
void invalidateSurface() override;
virtual void resetSurface();
-#ifndef QT_NO_OPENGL
- QOpenGLCompositorBackingStore *backingStore() { return m_backingStore; }
- void setBackingStore(QOpenGLCompositorBackingStore *backingStore) { m_backingStore = backingStore; }
-#endif
bool isRaster() const;
+
#ifndef QT_NO_OPENGL
+ QOpenGLCompositorBackingStore *backingStore() { return m_backingStore; }
+ void setBackingStore(QOpenGLCompositorBackingStore *backingStore);
QWindow *sourceWindow() const override;
const QPlatformTextureList *textures() const override;
void endCompositing() override;