android: Implement nativeResourceForContext

To bring the plugin on par with xcb and eglfs in this regard.

New code has a better way to query these via
QOpenGLContext::nativeInterface() (or, more correctly, will have a
better way once the ability to query the config and display is added
in a follow up patch), but having some symmetry between the EGL-based
plugins won't hurt.

This is relevant in particular with OpenXR: not knowing the EGLConfig
makes it impossible to use the API on Android:
https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrGraphicsBindingOpenGLESAndroidKHR

Pick-to: 6.2
Change-Id: I163aed070096a4b58d3f650906c2f70ea31b3231
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2021-09-10 20:55:30 +02:00
parent 0dbed05bbc
commit 0cea6384ae
2 changed files with 14 additions and 0 deletions

View File

@ -143,6 +143,19 @@ void *QAndroidPlatformNativeInterface::nativeResourceForWindow(const QByteArray
return nullptr;
}
void *QAndroidPlatformNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
{
if (QEGLPlatformContext *platformContext = static_cast<QEGLPlatformContext *>(context->handle())) {
if (resource == "eglcontext")
return platformContext->eglContext();
else if (resource == "eglconfig")
return platformContext->eglConfig();
else if (resource == "egldisplay")
return platformContext->eglDisplay();
}
return nullptr;
}
void QAndroidPlatformNativeInterface::customEvent(QEvent *event)
{
if (event->type() != QEvent::User)

View File

@ -65,6 +65,7 @@ class QAndroidPlatformNativeInterface: public QPlatformNativeInterface
public:
void *nativeResourceForIntegration(const QByteArray &resource) override;
void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override;
std::shared_ptr<AndroidStyle> m_androidStyle;
protected: