diff --git a/src/plugins/platforms/kms/qkmsnativeinterface.cpp b/src/plugins/platforms/kms/qkmsnativeinterface.cpp index b24e9d70e7..a192d1e87b 100644 --- a/src/plugins/platforms/kms/qkmsnativeinterface.cpp +++ b/src/plugins/platforms/kms/qkmsnativeinterface.cpp @@ -44,6 +44,8 @@ #include "qkmsdevice.h" #include "qscreen.h" +#include "qkmscontext.h" +#include class QKmsResourceMap : public QMap { @@ -76,6 +78,17 @@ void *QKmsNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr return result; } +QPlatformNativeInterface::NativeResourceForContextFunction QKmsNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) +{ + QByteArray lowerCaseResource = resource.toLower(); + if (lowerCaseResource == "get_egl_context") { + return eglContextForContext; + } + return 0; +} + + + void *QKmsNativeInterface::eglDisplayForWindow(QWindow *window) { QKmsScreen *screen = qPlatformScreenForWindow(window); @@ -97,3 +110,12 @@ QKmsScreen *QKmsNativeInterface::qPlatformScreenForWindow(QWindow *window) QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen(); return static_cast(screen->handle()); } + +void *QKmsNativeInterface::eglContextForContext(QOpenGLContext *context) +{ + Q_ASSERT(context); + + QKmsContext *eglPlatformContext = static_cast(context->handle()); + + return eglPlatformContext->eglContext(); +} diff --git a/src/plugins/platforms/kms/qkmsnativeinterface.h b/src/plugins/platforms/kms/qkmsnativeinterface.h index 20949becba..9141e4b770 100644 --- a/src/plugins/platforms/kms/qkmsnativeinterface.h +++ b/src/plugins/platforms/kms/qkmsnativeinterface.h @@ -56,8 +56,11 @@ public: void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window); + NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource); + void *eglDisplayForWindow(QWindow *window); void *eglContextForWindow(QWindow *window); + static void *eglContextForContext(QOpenGLContext *context); private: static QKmsScreen *qPlatformScreenForWindow(QWindow *window);