Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeglfskmsgbmwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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
8
9#include <QtGui/private/qeglconvenience_p.h>
10
12
13#ifndef EGL_EXT_platform_base
15#endif
16
17void QEglFSKmsGbmWindow::resetSurface()
18{
19 QEglFSKmsGbmScreen *gbmScreen = static_cast<QEglFSKmsGbmScreen *>(screen());
20 EGLDisplay display = gbmScreen->display();
21 QSurfaceFormat platformFormat = m_integration->surfaceFormatFor(window()->requestedFormat());
22 m_config = QEglFSDeviceIntegration::chooseConfig(display, platformFormat);
23 m_format = q_glFormatFromConfig(display, m_config, platformFormat);
24 // One fullscreen window per screen -> the native window is simply the gbm_surface the screen created.
25 m_window = reinterpret_cast<EGLNativeWindowType>(gbmScreen->createSurface(m_config));
26
27 PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createPlatformWindowSurface = nullptr;
28 const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
29 if (extensions && (strstr(extensions, "EGL_KHR_platform_gbm") || strstr(extensions, "EGL_MESA_platform_gbm"))) {
30 createPlatformWindowSurface = reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>(
31 eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"));
32 }
33
34 if (createPlatformWindowSurface) {
35 QVector<EGLint> contextAttributes;
36#ifdef EGL_EXT_protected_content
37 if (platformFormat.testOption(QSurfaceFormat::ProtectedContent)) {
38 if (q_hasEglExtension(display, "EGL_EXT_protected_content")) {
39 contextAttributes.append(EGL_PROTECTED_CONTENT_EXT);
40 contextAttributes.append(EGL_TRUE);
41 qCDebug(qLcEglfsKmsDebug, "Enabled EGL_PROTECTED_CONTENT_EXT for eglCreatePlatformWindowSurfaceEXT");
42 } else {
43 m_format.setOption(QSurfaceFormat::ProtectedContent, false);
44 }
45 }
46#endif
47 contextAttributes.append(EGL_NONE);
48
49 m_surface = createPlatformWindowSurface(display, m_config, reinterpret_cast<void *>(m_window), contextAttributes.constData());
50 } else {
51 qCDebug(qLcEglfsKmsDebug, "No eglCreatePlatformWindowSurface for GBM, falling back to eglCreateWindowSurface");
52 m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr);
53 }
54}
55
56void QEglFSKmsGbmWindow::invalidateSurface()
57{
58 QEglFSKmsGbmScreen *gbmScreen = static_cast<QEglFSKmsGbmScreen *>(screen());
59 QEglFSWindow::invalidateSurface();
60 gbmScreen->resetSurface();
61}
62
63QT_END_NAMESPACE
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE typedef EGLConfig void const EGLint * attrib_list
QT_BEGIN_NAMESPACE typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay dpy
QT_BEGIN_NAMESPACE typedef EGLConfig config
QT_BEGIN_NAMESPACE typedef EGLConfig void * native_window