eglfs: Unify the native resource getters
Similarly to how it's done in xcb. And add support for eglwindow since the WId will soon once again cease to be an EGLNativeWindowType. Change-Id: I0e3b86a21179439821550c9423f0e747ccae5897 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
parent
73637b7d1a
commit
88fb127331
@ -194,43 +194,77 @@ QPlatformNativeInterface *QEglFSIntegration::nativeInterface() const
|
||||
return const_cast<QEglFSIntegration *>(this);
|
||||
}
|
||||
|
||||
enum ResourceType {
|
||||
EglDisplay,
|
||||
EglWindow,
|
||||
EglContext
|
||||
};
|
||||
|
||||
static int resourceType(const QByteArray &key)
|
||||
{
|
||||
static const QByteArray names[] = { // match ResourceType
|
||||
QByteArrayLiteral("egldisplay"),
|
||||
QByteArrayLiteral("eglwindow"),
|
||||
QByteArrayLiteral("eglcontext")
|
||||
};
|
||||
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
|
||||
const QByteArray *result = std::find(names, end, key);
|
||||
if (result == end)
|
||||
result = std::find(names, end, key.toLower());
|
||||
return int(result - names);
|
||||
}
|
||||
|
||||
void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource)
|
||||
{
|
||||
QByteArray lowerCaseResource = resource.toLower();
|
||||
void *result = 0;
|
||||
|
||||
if (lowerCaseResource == "egldisplay")
|
||||
return mScreen->display();
|
||||
switch (resourceType(resource)) {
|
||||
case EglDisplay:
|
||||
result = mScreen->display();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
|
||||
{
|
||||
QByteArray lowerCaseResource = resource.toLower();
|
||||
void *result = 0;
|
||||
|
||||
if (lowerCaseResource == "egldisplay") {
|
||||
switch (resourceType(resource)) {
|
||||
case EglDisplay:
|
||||
if (window && window->handle())
|
||||
return static_cast<QEglFSScreen *>(window->handle()->screen())->display();
|
||||
result = static_cast<QEglFSScreen *>(window->handle()->screen())->display();
|
||||
else
|
||||
return mScreen->display();
|
||||
result = mScreen->display();
|
||||
break;
|
||||
case EglWindow:
|
||||
if (window && window->handle())
|
||||
result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
|
||||
{
|
||||
QByteArray lowerCaseResource = resource.toLower();
|
||||
void *result = 0;
|
||||
|
||||
QEGLPlatformContext *handle = static_cast<QEGLPlatformContext *>(context->handle());
|
||||
switch (resourceType(resource)) {
|
||||
case EglContext:
|
||||
if (context->handle())
|
||||
result = static_cast<QEGLPlatformContext *>(context->handle())->eglContext();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!handle)
|
||||
return 0;
|
||||
|
||||
if (lowerCaseResource == "eglcontext")
|
||||
return handle->eglContext();
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::nativeResourceFunctionForContext(const QByteArray &resource)
|
||||
|
@ -238,6 +238,11 @@ QSurfaceFormat QEglFSWindow::format() const
|
||||
return m_format;
|
||||
}
|
||||
|
||||
EGLNativeWindowType QEglFSWindow::eglWindow() const
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
QEglFSScreen *QEglFSWindow::screen() const
|
||||
{
|
||||
return static_cast<QEglFSScreen *>(QPlatformWindow::screen());
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
|
||||
EGLSurface surface() const;
|
||||
QSurfaceFormat format() const;
|
||||
EGLNativeWindowType eglWindow() const;
|
||||
|
||||
QEglFSScreen *screen() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user