1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qxcbeglwindow.h"
5
6#include "qxcbeglintegration.h"
7
8#include <QtGui/private/qeglconvenience_p.h>
9
10#ifndef EGL_EXT_platform_base
11typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
12#endif
13
14QT_BEGIN_NAMESPACE
15
16QXcbEglWindow::QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration)
17 : QXcbWindow(window)
18 , m_glIntegration(glIntegration)
19 , m_config(nullptr)
20 , m_surface(EGL_NO_SURFACE)
21{
22}
23
24QXcbEglWindow::~QXcbEglWindow()
25{
26 eglDestroySurface(dpy: m_glIntegration->eglDisplay(), surface: m_surface);
27}
28
29void QXcbEglWindow::resolveFormat(const QSurfaceFormat &format)
30{
31 m_config = q_configFromGLFormat(display: m_glIntegration->eglDisplay(), format);
32 m_format = q_glFormatFromConfig(display: m_glIntegration->eglDisplay(), config: m_config, referenceFormat: format);
33}
34
35const xcb_visualtype_t *QXcbEglWindow::createVisual()
36{
37 QXcbScreen *scr = xcbScreen();
38 if (!scr)
39 return QXcbWindow::createVisual();
40
41 xcb_visualid_t id = m_glIntegration->getCompatibleVisualId(screen: scr->screen(), config: m_config);
42 return scr->visualForId(visualid: id);
43}
44
45void QXcbEglWindow::create()
46{
47 QXcbWindow::create();
48
49#if QT_CONFIG(egl_x11)
50 m_surface = eglCreateWindowSurface(dpy: m_glIntegration->eglDisplay(), config: m_config, win: m_window, attrib_list: nullptr);
51#else
52 auto createPlatformWindowSurface = reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>(
53 eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"));
54 m_surface = createPlatformWindowSurface(m_glIntegration->eglDisplay(),
55 m_config,
56 reinterpret_cast<void *>(m_window),
57 nullptr);
58#endif
59}
60
61QT_END_NAMESPACE
62

source code of qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp