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
7
8#include <QtGui/private/qeglconvenience_p.h>
9
11
12#ifndef EGL_EXT_platform_base
14#endif
15
16void QEglFSKmsGbmWindow::resetSurface()
17{
18 QEglFSKmsGbmScreen *gbmScreen = static_cast<QEglFSKmsGbmScreen *>(screen());
19 EGLDisplay display = gbmScreen->display();
20 QSurfaceFormat platformFormat = m_integration->surfaceFormatFor(window()->requestedFormat());
21 m_config = QEglFSDeviceIntegration::chooseConfig(display, platformFormat);
22 m_format = q_glFormatFromConfig(display, m_config, platformFormat);
23 // One fullscreen window per screen -> the native window is simply the gbm_surface the screen created.
24 m_window = reinterpret_cast<EGLNativeWindowType>(gbmScreen->createSurface(m_config));
25
26 PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createPlatformWindowSurface = nullptr;
27 const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
28 if (extensions && (strstr(extensions, "EGL_KHR_platform_gbm") || strstr(extensions, "EGL_MESA_platform_gbm"))) {
29 createPlatformWindowSurface = reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>(
30 eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"));
31 }
32
33 if (createPlatformWindowSurface) {
34 QVector<EGLint> contextAttributes;
35#ifdef EGL_EXT_protected_content
36 if (platformFormat.testOption(QSurfaceFormat::ProtectedContent)) {
37 if (q_hasEglExtension(display, "EGL_EXT_protected_content")) {
38 contextAttributes.append(EGL_PROTECTED_CONTENT_EXT);
39 contextAttributes.append(EGL_TRUE);
40 qCDebug(qLcEglfsKmsDebug, "Enabled EGL_PROTECTED_CONTENT_EXT for eglCreatePlatformWindowSurfaceEXT");
41 } else {
42 m_format.setOption(QSurfaceFormat::ProtectedContent, false);
43 }
44 }
45#endif
46 contextAttributes.append(EGL_NONE);
47
48 m_surface = createPlatformWindowSurface(display, m_config, reinterpret_cast<void *>(m_window), contextAttributes.constData());
49 } else {
50 qCDebug(qLcEglfsKmsDebug, "No eglCreatePlatformWindowSurface for GBM, falling back to eglCreateWindowSurface");
51 m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr);
52 }
53}
54
55void QEglFSKmsGbmWindow::invalidateSurface()
56{
57 QEglFSKmsGbmScreen *gbmScreen = static_cast<QEglFSKmsGbmScreen *>(screen());
58 QEglFSWindow::invalidateSurface();
59 gbmScreen->resetSurface();
60}
61
62QT_END_NAMESPACE
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