summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs/qeglfsintegration.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2013-09-17 14:45:24 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-21 01:25:19 +0200
commit88fb1273315b2bfde42b421ea39624d95850c7eb (patch)
tree0f88d601a133bf787444ba11a2775d3c82bf56b2 /src/plugins/platforms/eglfs/qeglfsintegration.cpp
parent73637b7d1a01ca7db5fabe9a6fd5107bafd3c4c6 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfsintegration.cpp')
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp70
1 files changed, 52 insertions, 18 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index 14b839c2dd..ff06ac223b 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -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());
-
- if (!handle)
- return 0;
-
- if (lowerCaseResource == "eglcontext")
- return handle->eglContext();
+ switch (resourceType(resource)) {
+ case EglContext:
+ if (context->handle())
+ result = static_cast<QEGLPlatformContext *>(context->handle())->eglContext();
+ break;
+ default:
+ break;
+ }
- return 0;
+ return result;
}
QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::nativeResourceFunctionForContext(const QByteArray &resource)