summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-06-08 20:00:36 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-07-02 10:27:50 +0200
commit6ff79478a44fce12ca18832a56db4a370a9ff417 (patch)
tree2bcd7ab7bac46fe28e0828e0a704649bbc025e8f /src/plugins/platforms/eglfs
parent037dce81fc27ec241edb6829f6df41927b80666e (diff)
Introduce platform API abstraction for QOpenGLContext
The API is available by including qopenglcontext.h as usual, but scoped in the QPlatformInterface namespace. The namespace exposes platform specific type-safe interfaces that provide: a) Factory functions for adopting native contexts, e.g. QCocoaGLContext::fromNative(nsContext, shareContext); b) Access to underlying native handles, e.g. openGLContext->platformInterface<QCocoaGLContext>->nativeContext() c) Platform specific functionality, e.g. static QWGLContext::openGLModuleHandle() openGLContext->platformInterface<QEGLContext>->doSomething(); The platform interfaces live close to the classes they extend, removing the need for complex indirection and plumbing, and avoids kitchen-sink modules and APIs such as the extras modules, QPlatformFunctions, or QPlatformNativeInterface. In the case of QOpenGLContext these platform APIs are backed by the platform plugin, so dynamic_cast is used to ensure the platform plugin supports the requested interface, but this is and implementation detail. The interface APIs are agnostic to where the implementation lives, while still being available to the user as part of the APIs they extend/augment. The documentation will be restored when the dust settles. Task-number: QTBUG-80233 Change-Id: Iac612403383991c4b24064332542a6e4bcbb3293 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/eglfs')
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscontext.cpp7
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscontext_p.h5
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration.cpp18
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration_p.h3
4 files changed, 16 insertions, 17 deletions
diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
index 48fafbda8d..2dbf762cf4 100644
--- a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
@@ -50,10 +50,9 @@
QT_BEGIN_NAMESPACE
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
- EGLConfig *config, const QVariant &nativeHandle)
- : QEGLPlatformContext(format, share, display, config, nativeHandle,
- qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags() : QEGLPlatformContext::NoSurfaceless),
- m_tempWindow(0)
+ EGLConfig *config)
+ : QEGLPlatformContext(format, share, display, config,
+ qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags() : QEGLPlatformContext::NoSurfaceless)
{
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext_p.h b/src/plugins/platforms/eglfs/api/qeglfscontext_p.h
index af8725b6b3..f3b506ac7f 100644
--- a/src/plugins/platforms/eglfs/api/qeglfscontext_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfscontext_p.h
@@ -61,8 +61,9 @@ QT_BEGIN_NAMESPACE
class Q_EGLFS_EXPORT QEglFSContext : public QEGLPlatformContext
{
public:
+ using QEGLPlatformContext::QEGLPlatformContext;
QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
- EGLConfig *config, const QVariant &nativeHandle);
+ EGLConfig *config);
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override;
EGLSurface createTemporaryOffscreenSurface() override;
void destroyTemporaryOffscreenSurface(EGLSurface surface) override;
@@ -72,7 +73,7 @@ public:
QEglFSCursorData cursorData;
private:
- EGLNativeWindowType m_tempWindow;
+ EGLNativeWindowType m_tempWindow = 0;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
index 9b479a21c1..c94a12a198 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
@@ -76,8 +76,6 @@
# include <QtOpenGL/private/qopenglcompositorbackingstore_p.h>
#endif
-#include <QtPlatformHeaders/QEGLNativeContext>
-
#if QT_CONFIG(libinput)
#include <QtInputSupport/private/qlibinputhandler_p.h>
#endif
@@ -215,22 +213,20 @@ QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLCo
{
EGLDisplay dpy = context->screen() ? static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();
QPlatformOpenGLContext *share = context->shareHandle();
- QVariant nativeHandle = context->nativeHandle();
QEglFSContext *ctx;
QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format());
- if (nativeHandle.isNull()) {
- EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
- ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant());
- } else {
- ctx = new QEglFSContext(adjustedFormat, share, dpy, nullptr, nativeHandle);
- }
- nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), dpy));
+ EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
+ ctx = new QEglFSContext(adjustedFormat, share, dpy, &config);
- context->setNativeHandle(nativeHandle);
return ctx;
}
+QOpenGLContext *QEglFSIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const
+{
+ return QEGLPlatformContext::createFrom<QEglFSContext>(context, contextDisplay, display(), shareContext);
+}
+
QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
{
EGLDisplay dpy = surface->screen() ? static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display();
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
index 7df1aa3c2c..baf9baadda 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
@@ -57,6 +57,7 @@
#include <QtGui/QWindow>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
+#include <qpa/qplatformopenglcontext.h>
#include <qpa/qplatformscreen.h>
QT_BEGIN_NAMESPACE
@@ -67,6 +68,7 @@ class QFbVtHandler;
class QEvdevKeyboardManager;
class Q_EGLFS_EXPORT QEglFSIntegration : public QPlatformIntegration, public QPlatformNativeInterface
+ , public QPlatformInterface::Private::QEGLIntegration
{
public:
QEglFSIntegration();
@@ -86,6 +88,7 @@ public:
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
+ QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const override;
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
#endif
#if QT_CONFIG(vulkan)