Skip to content

Commit 40fb898

Browse files
committed
Say hello to the new aurora-eglfs
New Qt platform plugin for Aurora Wayland compositors. This is an initial an non-functional version to test the Aurora platform abstraction library (AuroraCore). Closes: #46
1 parent 60a1e3a commit 40fb898

20 files changed

+1449
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ if(FEATURE_aurora_compositor_quick)
109109
endif()
110110
endif()
111111
if(FEATURE_aurora_qpa)
112+
add_subdirectory(src/plugins/platforms/eglfs)
112113
# add_subdirectory(src/platformsupport/libinput)
113114
endif()
114115
if(FEATURE_aurora_deviceintegration_wayland)
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
include(ECMQtDeclareLoggingCategory)
2+
ecm_qt_declare_logging_category(
3+
AuroraEglFS_SOURCES
4+
HEADER "eglfscategories.h"
5+
IDENTIFIER "gLcEglFS"
6+
CATEGORY_NAME "aurora.eglfs"
7+
DEFAULT_SEVERITY "Info"
8+
DESCRIPTION "Aurora EGLFS Qt platform plugin"
9+
)
10+
11+
qt6_add_plugin(AuroraEglFSPlatformPlugin
12+
SHARED
13+
CLASS_NAME EglFSIntegrationPlugin
14+
MANUAL_FINALIZATION
15+
eglfsconfigchooser.cpp eglfsconfigchooser.h
16+
eglfscontext.cpp eglfscontext.h
17+
eglfscursor.cpp eglfscursor.h
18+
eglfsinfo.cpp eglfsinfo.h
19+
eglfsinputmanager.cpp eglfsinputmanager.h
20+
eglfsintegration.cpp eglfsintegration.h
21+
eglfsmain.cpp
22+
eglfsscreen.cpp eglfsscreen.h
23+
eglfswindow.cpp eglfswindow.h
24+
aurora-eglfs.json
25+
${AuroraEglFS_SOURCES}
26+
)
27+
28+
set_target_properties(AuroraEglFSPlatformPlugin
29+
PROPERTIES OUTPUT_NAME aurora-eglfs
30+
)
31+
32+
target_compile_definitions(AuroraEglFSPlatformPlugin PRIVATE QT_EGL_NO_X11)
33+
34+
target_link_libraries(AuroraEglFSPlatformPlugin
35+
PRIVATE
36+
Qt6::Core
37+
Qt6::CorePrivate
38+
Qt6::DBus
39+
Qt6::Gui
40+
Qt6::GuiPrivate
41+
Fontconfig::Fontconfig
42+
EGL::EGL
43+
Liri::AuroraPlatform
44+
Liri::AuroraPlatformPrivate
45+
)
46+
47+
qt6_finalize_target(AuroraEglFSPlatformPlugin)
48+
49+
install(
50+
TARGETS AuroraEglFSPlatformPlugin
51+
DESTINATION ${KDE_INSTALL_PLUGINDIR}/platforms
52+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Keys": [ "aurora-eglfs" ]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#include "eglfsconfigchooser.h"
5+
6+
EglFSConfigChooser::EglFSConfigChooser(EGLDisplay display)
7+
: QEglConfigChooser(display)
8+
{
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#pragma once
5+
6+
#include <QtGui/private/qeglconvenience_p.h>
7+
8+
class EglFSConfigChooser : public QEglConfigChooser
9+
{
10+
public:
11+
EglFSConfigChooser(EGLDisplay display);
12+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#include <QSurface>
5+
6+
#include <QtGui/private/qeglconvenience_p.h>
7+
#include <QtGui/private/qeglpbuffer_p.h>
8+
9+
#include <LiriAuroraPlatform/private/eglfsdeviceintegration_p.h>
10+
11+
#include "eglfscategories.h"
12+
#include "eglfscontext.h"
13+
#include "eglfswindow.h"
14+
15+
EglFSContext::EglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share,
16+
EGLDisplay display, EGLConfig *config)
17+
: QEGLPlatformContext(format, share, display, config,
18+
Aurora::Platform::auroraDeviceIntegration()->supportsSurfacelessContexts()
19+
? Flags()
20+
: QEGLPlatformContext::NoSurfaceless)
21+
{
22+
}
23+
24+
void EglFSContext::swapBuffers(QPlatformSurface *surface)
25+
{
26+
auto *platformWindow = static_cast<EglFSWindow *>(surface);
27+
if (platformWindow) {
28+
Aurora::Platform::auroraDeviceIntegration()->waitForVSync(platformWindow->auroraWindow());
29+
QEGLPlatformContext::swapBuffers(surface);
30+
Aurora::Platform::auroraDeviceIntegration()->presentBuffer(platformWindow->auroraWindow());
31+
}
32+
}
33+
34+
EGLSurface EglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
35+
{
36+
if (surface->surface()->surfaceClass() == QSurface::Window)
37+
return static_cast<EglFSWindow *>(surface)->surface();
38+
else
39+
return static_cast<QEGLPbuffer *>(surface)->pbuffer();
40+
}
41+
42+
void EglFSContext::runGLChecks()
43+
{
44+
// Beware that QOpenGLContext and QOpenGLFunctions are not yet usable at this stage
45+
46+
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
47+
if (renderer) {
48+
// Warn about unsupported or limited hardware
49+
if (strstr(renderer, "llvmpipe"))
50+
qCWarning(gLcEglFS,
51+
"Running on a software rasterizer (LLVMpipe): performance will be limited");
52+
}
53+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#pragma once
5+
6+
#include <QVariant>
7+
8+
#include <QtGui/private/qeglplatformcontext_p.h>
9+
10+
class EglFSContext : public QEGLPlatformContext
11+
{
12+
public:
13+
using QEGLPlatformContext::QEGLPlatformContext;
14+
EglFSContext() = default;
15+
EglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
16+
EGLConfig *config);
17+
18+
void swapBuffers(QPlatformSurface *surface) override;
19+
20+
protected:
21+
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override;
22+
void runGLChecks() override;
23+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#include <LiriAuroraPlatform/Window>
5+
#include <LiriAuroraPlatform/private/eglfsdeviceintegration_p.h>
6+
7+
#include "eglfscursor.h"
8+
#include "eglfsscreen.h"
9+
10+
EglFSCursor::EglFSCursor(QPlatformScreen *screen)
11+
: QPlatformCursor()
12+
, m_screen(static_cast<EglFSScreen *>(screen))
13+
{
14+
}
15+
16+
EglFSCursor::~EglFSCursor()
17+
{
18+
}
19+
20+
#ifndef QT_NO_CURSOR
21+
void EglFSCursor::changeCursor(QCursor *cursor, QWindow *qtWindow)
22+
{
23+
auto *window = Aurora::Platform::auroraDeviceIntegration()->getWindow(qtWindow);
24+
if (window)
25+
window->changeCursor(cursor);
26+
}
27+
#endif
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#pragma once
5+
6+
#include <QPointer>
7+
8+
#include <QtGui/qpa/qplatformcursor.h>
9+
#include <QtGui/qpa/qplatformscreen.h>
10+
11+
class EglFSScreen;
12+
13+
class EglFSCursor : public QPlatformCursor
14+
{
15+
Q_OBJECT
16+
public:
17+
explicit EglFSCursor(QPlatformScreen *screen);
18+
~EglFSCursor();
19+
20+
#ifndef QT_NO_CURSOR
21+
void changeCursor(QCursor *cursor, QWindow *widget) override;
22+
#endif
23+
24+
private:
25+
QPointer<EglFSScreen> m_screen;
26+
};
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#include "eglfscategories.h"
5+
#include "eglfsinfo.h"
6+
7+
#include <GLES2/gl2.h>
8+
#include <EGL/egl.h>
9+
10+
const char *tab = " ";
11+
12+
static void logGLextensions(const char *prefix, const QList<QByteArray> &extensions)
13+
{
14+
QString extensionString;
15+
const int maxLineLength = 98;
16+
int currentLineLength = 0;
17+
18+
for (int i = 0; i < extensions.size(); i++) {
19+
const auto extension = extensions[i];
20+
21+
// Check if adding the current extension fits in the current line
22+
if (currentLineLength + extension.length() + 2 <= maxLineLength) { // 2 accounts for " "
23+
if (!extensionString.isEmpty()) {
24+
extensionString += QStringLiteral(" ");
25+
currentLineLength += 2;
26+
}
27+
extensionString += QString::fromUtf8(extension);
28+
currentLineLength += extension.length();
29+
} else {
30+
extensionString += QStringLiteral("\n") + QString::fromUtf8(extension);
31+
currentLineLength = extension.length();
32+
}
33+
}
34+
35+
if (!extensionString.isEmpty()) {
36+
const auto numSpaces = qMax<int>(0, 18 - strlen(prefix) - 1);
37+
auto lines = extensionString.split(QLatin1Char('\n'));
38+
39+
for (int i = 0; i < lines.size(); i++) {
40+
const auto line = lines[i];
41+
if (i == 0)
42+
qCInfo(gLcEglFS, "%s:%*s%s", prefix, numSpaces, " ", qPrintable(line));
43+
else
44+
qCInfo(gLcEglFS, "%s%s", tab, qPrintable(line));
45+
}
46+
}
47+
}
48+
49+
void logGLInfo()
50+
{
51+
const char *str;
52+
53+
str = reinterpret_cast<const char *>(glGetString(GL_VERSION));
54+
qCInfo(gLcEglFS, "GL version: %s", str ? str : "(null)");
55+
56+
str = reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
57+
qCInfo(gLcEglFS, "GLSL version: %s", str ? str : "(null)");
58+
59+
str = reinterpret_cast<const char *>(glGetString(GL_VENDOR));
60+
qCInfo(gLcEglFS, "GL vendor: %s", str ? str : "(null)");
61+
62+
str = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
63+
qCInfo(gLcEglFS, "GL renderer: %s", str ? str : "(null)");
64+
65+
QList<QByteArray> extensions =
66+
QByteArray(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))).split(' ');
67+
logGLextensions("GL extensions", extensions);
68+
}
69+
70+
void logEGLInfo(EGLDisplay display)
71+
{
72+
const char *str;
73+
74+
str = eglQueryString(display, EGL_VERSION);
75+
qCInfo(gLcEglFS, "EGL version: %s", str ? str : "(null)");
76+
77+
str = eglQueryString(display, EGL_VENDOR);
78+
qCInfo(gLcEglFS, "EGL vendor: %s", str ? str : "(null)");
79+
80+
str = eglQueryString(display, EGL_CLIENT_APIS);
81+
qCInfo(gLcEglFS, "EGL client APIs: %s", str ? str : "(null)");
82+
83+
QList<QByteArray> extensions = QByteArray(eglQueryString(display, EGL_EXTENSIONS)).split(' ');
84+
logGLextensions("EGL extensions", extensions);
85+
}
86+
87+
void logEGLConfigInfo(EGLDisplay display, EGLConfig config)
88+
{
89+
if (!config)
90+
return;
91+
92+
EGLint r, g, b, a;
93+
94+
qCInfo(gLcEglFS, "EGL attributes:");
95+
96+
if (eglGetConfigAttrib(display, config, EGL_RED_SIZE, &r)
97+
&& eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &g)
98+
&& eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &b)
99+
&& eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a))
100+
qCInfo(gLcEglFS, "%sRGBA bits: %d %d %d %d", tab, r, g, b, a);
101+
else
102+
qCInfo(gLcEglFS, "%sRGBA bits: unknown", tab);
103+
104+
if (eglGetConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL, &a)
105+
&& eglGetConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL, &b))
106+
qCInfo(gLcEglFS, "%sSwap interval range: %d - %d", tab, a, b);
107+
else
108+
qCInfo(gLcEglFS, "%sSwap interval range: unknown", tab);
109+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
#pragma once
5+
6+
#include <QList>
7+
#include <QString>
8+
9+
#include <EGL/egl.h>
10+
11+
extern "C" {
12+
13+
void logGLInfo();
14+
void logEGLInfo(EGLDisplay display);
15+
void logEGLConfigInfo(EGLDisplay display, EGLConfig config);
16+
}

0 commit comments

Comments
 (0)