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 |
11 | typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); |
12 | #endif |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | QXcbEglWindow::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 | |
24 | QXcbEglWindow::~QXcbEglWindow() |
25 | { |
26 | eglDestroySurface(dpy: m_glIntegration->eglDisplay(), surface: m_surface); |
27 | } |
28 | |
29 | void 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 | |
35 | const 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 | |
45 | void QXcbEglWindow::create() |
46 | { |
47 | QXcbWindow::create(); |
48 | |
49 | // this is always true without egl_x11 |
50 | if (m_glIntegration->usingPlatformDisplay()) { |
51 | auto createPlatformWindowSurface = reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>( |
52 | eglGetProcAddress(procname: "eglCreatePlatformWindowSurfaceEXT")); |
53 | m_surface = createPlatformWindowSurface(m_glIntegration->eglDisplay(), |
54 | m_config, |
55 | reinterpret_cast<void *>(&m_window), |
56 | nullptr); |
57 | return; |
58 | } |
59 | |
60 | #if QT_CONFIG(egl_x11) |
61 | m_surface = eglCreateWindowSurface(dpy: m_glIntegration->eglDisplay(), config: m_config, win: m_window, attrib_list: nullptr); |
62 | #endif |
63 | } |
64 | |
65 | QT_END_NAMESPACE |
66 |