| 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 |
// Qt-Security score:significant reason:default |
| 4 |
|
| 5 |
#include "qxcbeglwindow.h" |
| 6 |
|
| 7 |
#include "qxcbeglintegration.h" |
| 8 |
|
| 9 |
#include <QtGui/private/qeglconvenience_p.h> |
| 10 |
|
| 11 |
#ifndef EGL_EXT_platform_base |
| 12 |
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); |
| 13 |
#endif |
| 14 |
|
| 15 |
QT_BEGIN_NAMESPACE |
| 16 |
|
| 17 |
QXcbEglWindow::QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration) |
| 18 |
: QXcbWindow(window) |
| 19 |
, m_glIntegration(glIntegration) |
| 20 |
, m_config(nullptr) |
| 21 |
, m_surface(EGL_NO_SURFACE) |
| 22 |
{ |
| 23 |
} |
| 24 |
|
| 25 |
QXcbEglWindow::~QXcbEglWindow() |
| 26 |
{ |
| 27 |
eglDestroySurface(m_glIntegration->eglDisplay(), m_surface); |
| 28 |
} |
| 29 |
|
| 30 |
void QXcbEglWindow::resolveFormat(const QSurfaceFormat &format) |
| 31 |
{ |
| 32 |
m_config = q_configFromGLFormat(m_glIntegration->eglDisplay(), format); |
| 33 |
m_format = q_glFormatFromConfig(m_glIntegration->eglDisplay(), m_config, format); |
| 34 |
} |
| 35 |
|
| 36 |
const xcb_visualtype_t *QXcbEglWindow::createVisual() |
| 37 |
{ |
| 38 |
QXcbScreen *scr = xcbScreen(); |
| 39 |
if (!scr) |
| 40 |
return QXcbWindow::createVisual(); |
| 41 |
|
| 42 |
xcb_visualid_t id = m_glIntegration->getCompatibleVisualId(scr->screen(), m_config); |
| 43 |
return scr->visualForId(id); |
| 44 |
} |
| 45 |
|
| 46 |
void QXcbEglWindow::create() |
| 47 |
{ |
| 48 |
QXcbWindow::create(); |
| 49 |
|
| 50 |
// this is always true without egl_x11 |
| 51 |
if (m_glIntegration->usingPlatformDisplay()) { |
| 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 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
#if QT_CONFIG(egl_x11) |
| 62 |
m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, nullptr); |
| 63 |
#endif |
| 64 |
} |
| 65 |
|
| 66 |
QT_END_NAMESPACE |