diff options
author | Andras Becsi <andras.becsi@digia.com> | 2014-07-29 14:10:50 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2014-07-30 22:30:50 +0200 |
commit | 00b63b18ce62c6932a0b0fe566239649162be0d4 (patch) | |
tree | 71e4dfa9a085d37d8be6e5e1a91f429d9a1b25cb | |
parent | 4010cfbf2d91390f8cae1f6c5dbb352c1f5bf1d2 (diff) |
Allow lower case resource names in native interface on Windows
The native interface implementation in QEGLPlatformIntegration
lower-cases the resource key strings, where as in the Windows
implementation we currently only check for camel-case resource
names to retriece the same resources.
Make it possible to use lower-case strings on Windows as well
by using the same key look-up mechanism as used in the eglfs
implementation.
Change-Id: Id2a594310df610cadbe420409c090f0abb316474
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
-rw-r--r-- | src/plugins/platforms/windows/qwindowsnativeinterface.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 8ec1d8eb2f..ce28166e4f 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -51,6 +51,36 @@ QT_BEGIN_NAMESPACE +enum ResourceType { + RenderingContextType, + EglContextType, + EglDisplayType, + EglConfigType, + HandleType, + GlHandleType, + GetDCType, + ReleaseDCType +}; + +static int resourceType(const QByteArray &key) +{ + static const QByteArray names[] = { // match ResourceType + "renderingcontext", + "eglcontext", + "egldisplay", + "eglconfig", + "handle", + "glhandle", + "getdc", + "releasedc" + }; + 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 *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { if (!window || !window->handle()) { @@ -58,14 +88,15 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc return 0; } QWindowsWindow *bw = static_cast<QWindowsWindow *>(window->handle()); - if (resource == "handle") + int type = resourceType(resource); + if (type == HandleType) return bw->handle(); switch (window->surfaceType()) { case QWindow::RasterSurface: case QWindow::RasterGLSurface: - if (resource == "getDC") + if (type == GetDCType) return bw->getDC(); - if (resource == "releaseDC") { + if (type == ReleaseDCType) { bw->releaseDC(); return 0; } @@ -111,7 +142,7 @@ QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) c void *QWindowsNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { #ifndef QT_NO_OPENGL - if (resource == QByteArrayLiteral("glhandle")) + if (resourceType(resource) == GlHandleType) return QWindowsIntegration::staticOpenGLContext()->moduleHandle(); #endif @@ -127,12 +158,17 @@ void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resour } QWindowsOpenGLContext *glcontext = static_cast<QWindowsOpenGLContext *>(context->handle()); - if (resource == QByteArrayLiteral("renderingContext") || resource == QByteArrayLiteral("eglContext")) + switch (resourceType(resource)) { + case RenderingContextType: // Fall through. + case EglContextType: return glcontext->nativeContext(); - if (resource == QByteArrayLiteral("eglDisplay")) + case EglDisplayType: return glcontext->nativeDisplay(); - if (resource == QByteArrayLiteral("eglConfig")) + case EglConfigType: return glcontext->nativeConfig(); + default: + break; + } qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); return 0; |