Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglfskmsgbmintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// Copyright (C) 2016 The Qt Company Ltd.
3// Copyright (C) 2016 Pelagicore AG
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5
11#include "private/qeglfscursor_p.h"
12
13#include <QtCore/QLoggingCategory>
14#include <QtGui/QScreen>
15#include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h>
16
17#include <gbm.h>
18
20
22{
23 qCDebug(qLcEglfsKmsDebug, "New DRM/KMS via GBM integration created");
24}
25
26#ifndef EGL_EXT_platform_base
27typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
28#endif
29
30#ifndef EGL_PLATFORM_GBM_KHR
31#define EGL_PLATFORM_GBM_KHR 0x31D7
32#endif
33
34EGLDisplay QEglFSKmsGbmIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
35{
36 qCDebug(qLcEglfsKmsDebug, "Querying EGLDisplay");
38
39 PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = nullptr;
40 const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
41 if (extensions && (strstr(extensions, "EGL_KHR_platform_gbm") || strstr(extensions, "EGL_MESA_platform_gbm"))) {
42 getPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
43 eglGetProcAddress("eglGetPlatformDisplayEXT"));
44 }
45
46 if (getPlatformDisplay) {
47 display = getPlatformDisplay(EGL_PLATFORM_GBM_KHR, nativeDisplay, nullptr);
48 } else {
49 qCDebug(qLcEglfsKmsDebug, "No eglGetPlatformDisplay for GBM, falling back to eglGetDisplay");
50 display = eglGetDisplay(nativeDisplay);
51 }
52
53 return display;
54}
55
57{
60
61 gbm_surface *surface = gbm_surface_create(static_cast<QEglFSKmsGbmDevice *>(device())->gbmDevice(),
62 1, 1,
63 GBM_FORMAT_XRGB8888,
64 GBM_BO_USE_RENDERING);
65
66 return reinterpret_cast<EGLNativeWindowType>(surface);
67}
68
70{
71 gbm_surface *surface = reinterpret_cast<gbm_surface *>(window);
72 gbm_surface_destroy(surface);
73}
74
76{
77#if QT_CONFIG(opengl)
78 if (!screenConfig()->hwCursor()) {
79 qCDebug(qLcEglfsKmsDebug, "Using plain OpenGL mouse cursor");
80 return new QEglFSCursor(screen);
81 }
82#else
84#endif
85 return nullptr;
86}
87
89{
90 QWindow *window = static_cast<QWindow *>(surface->surface());
91 QEglFSKmsGbmScreen *screen = static_cast<QEglFSKmsGbmScreen *>(window->screen()->handle());
92 screen->flip();
93}
94
96{
98 if (!path.isEmpty()) {
99 qCDebug(qLcEglfsKmsDebug) << "GBM: Using DRM device" << path << "specified in config file";
100 } else {
102 const QStringList devices = d->scanConnectedDevices();
103 qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices;
104 d->deleteLater();
105
106 if (Q_UNLIKELY(devices.isEmpty()))
107 qFatal("Could not find DRM device!");
108
109 path = devices.first();
110 qCDebug(qLcEglfsKmsDebug) << "Using" << path;
111 }
112
113 return new QEglFSKmsGbmDevice(screenConfig(), path);
114}
115
120
static QDeviceDiscovery * create(QDeviceTypes type, QObject *parent=nullptr)
QEglFSWindow * createWindow(QWindow *window) const override
QKmsDevice * createDevice() override
EGLDisplay createDisplay(EGLNativeDisplayType nativeDisplay) override
void destroyNativeWindow(EGLNativeWindowType window) override
EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format) override
void presentBuffer(QPlatformSurface *surface) override
QPlatformCursor * createCursor(QPlatformScreen *screen) const override
QKmsScreenConfig * screenConfig() const
QKmsDevice * device() const
QString devicePath() const
The QPlatformCursor class provides information about pointer device events (movement,...
The QPlatformScreen class provides an abstraction for visual displays.
The QPlatformSurface class provides an abstraction for a surface.
QSurface * surface() const
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
\inmodule QtGui
Definition qwindow.h:63
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
#define Q_UNLIKELY(x)
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
void * native_display
void const EGLint * attrib_list
#define EGL_PLATFORM_GBM_KHR
EGLDeviceEXT * devices
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
#define qFatal
Definition qlogging.h:168
#define qCDebug(category,...)
GLint GLsizei GLsizei GLenum format
GLsizei const GLchar *const * path
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScreen * screen
[1]
Definition main.cpp:29
#define Q_UNUSED(x)
QT_BEGIN_NAMESPACE Platform platform()
EGLDisplay(* PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform, void *native_display, const EGLint *attrib_list)
aWidget window() -> setWindowTitle("New Window Title")
[2]