xcb_egl: Prefer eglCreatePlatformWindowSurfaceEXT to eglCreateWindowSurface

Change-Id: I32de5b241cce786318434e7653ff979cf8e82f0e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Ilya Fedin 2023-03-24 17:41:24 +04:00
parent 6f5136ef66
commit 12d6fc5229
3 changed files with 17 additions and 7 deletions

View File

@ -58,6 +58,7 @@ std::optional<VisualInfo> getVisualInfo(xcb_screen_t *screen,
QXcbEglIntegration::QXcbEglIntegration()
: m_connection(nullptr)
, m_egl_display(EGL_NO_DISPLAY)
, m_using_platform_display(false)
{
qCDebug(lcQpaGl) << "Xcb EGL gl-integration created";
}
@ -80,6 +81,7 @@ bool QXcbEglIntegration::initialize(QXcbConnection *connection)
m_egl_display = streamFuncs.get_platform_display(EGL_PLATFORM_X11_KHR,
m_connection->xlib_display(),
nullptr);
m_using_platform_display = true;
}
#if QT_CONFIG(egl_x11)
@ -92,6 +94,7 @@ bool QXcbEglIntegration::initialize(QXcbConnection *connection)
m_egl_display = streamFuncs.get_platform_display(EGL_PLATFORM_XCB_KHR,
reinterpret_cast<void *>(connection->xcb_connection()),
nullptr);
m_using_platform_display = true;
}
#endif

View File

@ -39,10 +39,13 @@ public:
EGLDisplay eglDisplay() const { return m_egl_display; }
bool usingPlatformDisplay() const { return m_using_platform_display; }
xcb_visualid_t getCompatibleVisualId(xcb_screen_t *screen, EGLConfig config) const;
private:
QXcbConnection *m_connection;
EGLDisplay m_egl_display;
bool m_using_platform_display;
QScopedPointer<QXcbEglNativeInterfaceHandler> m_native_interface_handler;
};

View File

@ -46,15 +46,19 @@ void QXcbEglWindow::create()
{
QXcbWindow::create();
// this is always true without egl_x11
if (m_glIntegration->usingPlatformDisplay()) {
auto createPlatformWindowSurface = reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>(
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"));
m_surface = createPlatformWindowSurface(m_glIntegration->eglDisplay(),
m_config,
reinterpret_cast<void *>(&m_window),
nullptr);
return;
}
#if QT_CONFIG(egl_x11)
m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, nullptr);
#else
auto createPlatformWindowSurface = reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>(
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"));
m_surface = createPlatformWindowSurface(m_glIntegration->eglDisplay(),
m_config,
reinterpret_cast<void *>(m_window),
nullptr);
#endif
}