From 53a6f7b7836ef5084106ed63f6745c20d663affa Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 6 Aug 2019 13:15:35 +0200 Subject: eglfs: Fix raster windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also sanitize the initial WebAssembly hack. Both eglfs and wasm lack the concept of true raster windows. A QWindow with RasterSurface is rendered with OpenGL no matter what. The two platforms took two different approaches to work around the rest of the machinery: - wasm disabled the QOpenGLContext warning for non-OpenGL QWindows, - eglfs forced the QWindow surfaceType to OpenGLSurface whenever it was originally set to RasterSurface. Now, the latter breaks since c4e9eabc309a275efc222f4127f31ba4677259b7, leaving all raster window applications failing on eglfs, because flush in the backingstore is now checking the surface type and disallows OpenGLSurface windows. (just like how QOpenGLContext disallows RasterSurface windows) To solve all this correctly, introduce a new platform capability, OpenGLOnRasterSurface, and remove the special handling in the platform plugins. Change-Id: I7785dfb1c955577bbdccdc14ebaaac5babdec57c Fixes: QTBUG-77100 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qopenglcontext.cpp | 3 --- src/gui/kernel/qplatformintegration.cpp | 3 +++ src/gui/kernel/qplatformintegration.h | 3 ++- src/gui/kernel/qsurface.cpp | 6 ++++++ src/plugins/platforms/eglfs/api/qeglfsintegration.cpp | 1 + src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 9 ++------- src/plugins/platforms/eglfs/api/qeglfswindow_p.h | 1 - src/plugins/platforms/wasm/qwasmintegration.cpp | 1 + 8 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 499d16c109..e8c64bdc01 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -977,11 +977,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) if (!surface->surfaceHandle()) return false; if (!surface->supportsOpenGL()) { -#ifndef Q_OS_WASM // ### work around the WASM platform plugin using QOpenGLContext with raster surfaces. - // see QTBUG-70076 qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface; return false; -#endif } if (!d->platformGLContext->makeCurrent(surface->surfaceHandle())) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index ac4d12b024..258d214c7a 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -244,6 +244,9 @@ QPlatformServices *QPlatformIntegration::services() const \value TopStackedNativeChildWindows The platform supports native child windows via QWindowContainer without having to punch a transparent hole in the backingstore. (since 5.10) + + \value OpenGLOnRasterSurface The platform supports making a QOpenGLContext current + in combination with a QWindow of type RasterSurface. */ /*! diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 1179daeb32..0b999de264 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -103,7 +103,8 @@ public: AllGLFunctionsQueryable, ApplicationIcon, SwitchableWidgetComposition, - TopStackedNativeChildWindows + TopStackedNativeChildWindows, + OpenGLOnRasterSurface }; virtual ~QPlatformIntegration() { } diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index 415e64b39c..709f28d431 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -39,6 +39,8 @@ #include "qsurface.h" #include "qopenglcontext.h" +#include +#include QT_BEGIN_NAMESPACE @@ -103,6 +105,10 @@ QT_BEGIN_NAMESPACE bool QSurface::supportsOpenGL() const { SurfaceType type = surfaceType(); + if (type == RasterSurface) { + QPlatformIntegration *integ = QGuiApplicationPrivate::instance()->platformIntegration(); + return integ->hasCapability(QPlatformIntegration::OpenGLOnRasterSurface); + } return type == OpenGLSurface || type == RasterGLSurface; } diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index c8a1ddf9b9..674f579b4f 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -265,6 +265,7 @@ bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) cons case RasterGLSurface: return false; #endif case WindowManagement: return false; + case OpenGLOnRasterSurface: return true; default: return QPlatformIntegration::hasCapability(cap); } } diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index c1d5af47aa..1fed182882 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -64,7 +64,6 @@ QEglFSWindow::QEglFSWindow(QWindow *w) m_backingStore(0), m_rasterCompositingContext(0), #endif - m_raster(false), m_winId(0), m_surface(EGL_NO_SURFACE), m_window(0), @@ -94,11 +93,6 @@ void QEglFSWindow::create() m_winId = newWId(); - // Save the original surface type before changing to OpenGLSurface. - m_raster = (window()->surfaceType() == QSurface::RasterSurface); - if (m_raster) // change to OpenGL, but not for RasterGLSurface - window()->setSurfaceType(QSurface::OpenGLSurface); - if (window()->type() == Qt::Desktop) { QRect fullscreenRect(QPoint(), screen()->availableGeometry().size()); QWindowSystemInterface::handleGeometryChange(window(), fullscreenRect); @@ -329,7 +323,8 @@ QEglFSScreen *QEglFSWindow::screen() const bool QEglFSWindow::isRaster() const { - return m_raster || window()->surfaceType() == QSurface::RasterGLSurface; + const QWindow::SurfaceType type = window()->surfaceType(); + return type == QSurface::RasterSurface || type == QSurface::RasterGLSurface; } #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h index b0091e2a62..be2a0630d3 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h +++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h @@ -118,7 +118,6 @@ protected: QOpenGLCompositorBackingStore *m_backingStore; QOpenGLContext *m_rasterCompositingContext; #endif - bool m_raster; WId m_winId; EGLSurface m_surface; diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 3829043d07..05d6ae21f5 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -113,6 +113,7 @@ bool QWasmIntegration::hasCapability(QPlatformIntegration::Capability cap) const case RasterGLSurface: return false; // to enable this you need to fix qopenglwidget and quickwidget for wasm case MultipleWindows: return true; case WindowManagement: return true; + case OpenGLOnRasterSurface: return true; default: return QPlatformIntegration::hasCapability(cap); } } -- cgit v1.2.3