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
qwaylandeglclientbufferintegration.cpp
Go to the documentation of this file.
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
5
8
9#include <wayland-client-core.h>
10
11#include <QtCore/QDebug>
12#include <private/qeglconvenience_p.h>
13
14#ifndef EGL_EXT_platform_base
16#endif
17
18#ifndef EGL_PLATFORM_WAYLAND_KHR
19#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
20#endif
21
23
24namespace QtWaylandClient {
25
27 0
28};
29
34
35
40
42{
43#if QT_CONFIG(egl_extension_platform_wayland)
44 m_eglDisplay = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, display->wl_display(), nullptr);
45#else
46 if (q_hasEglExtension(EGL_NO_DISPLAY, "EGL_EXT_platform_base")) {
47 if (q_hasEglExtension(EGL_NO_DISPLAY, "EGL_KHR_platform_wayland") ||
48 q_hasEglExtension(EGL_NO_DISPLAY, "EGL_EXT_platform_wayland") ||
49 q_hasEglExtension(EGL_NO_DISPLAY, "EGL_MESA_platform_wayland")) {
50
51 static PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplay = nullptr;
52 if (!eglGetPlatformDisplay)
53 eglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
54
55 m_eglDisplay = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, display->wl_display(), nullptr);
56 } else {
57 qCWarning(lcQpaWayland) << "The EGL implementation does not support the Wayland platform";
58 return;
59 }
60 } else {
61 QByteArray eglPlatform = qgetenv("EGL_PLATFORM");
62 if (eglPlatform.isEmpty()) {
63 setenv("EGL_PLATFORM","wayland",true);
64 }
65
66 m_eglDisplay = eglGetDisplay((EGLNativeDisplayType) display->wl_display());
67 }
68#endif
69
70 m_display = display;
71
72 if (m_eglDisplay == EGL_NO_DISPLAY) {
73 qCWarning(lcQpaWayland) << "EGL not available";
74 return;
75 }
76
77 EGLint major,minor;
78 if (!eglInitialize(m_eglDisplay, &major, &minor)) {
79 qCWarning(lcQpaWayland) << "Failed to initialize EGL display" << Qt::hex << eglGetError();
80 m_eglDisplay = EGL_NO_DISPLAY;
81 return;
82 }
83
84 m_supportsThreading = true;
85 if (qEnvironmentVariableIsSet("QT_OPENGL_NO_SANITY_CHECK"))
86 return;
87
88 const char *vendor = eglQueryString(m_eglDisplay, EGL_VENDOR);
89 for (int i = 0; qwaylandegl_threadedgl_blacklist_vendor[i]; ++i) {
90 if (strstr(vendor, qwaylandegl_threadedgl_blacklist_vendor[i]) != 0) {
91 m_supportsThreading = false;
92 break;
93 }
94 }
95
96 // On desktop NVIDIA resizing QtQuick freezes them when using threaded rendering QTBUG-95817
97 // In order to support threaded rendering on embedded platforms where resizing is not needed
98 // we check if XDG_CURRENT_DESKTOP is set which desktop environments should set
99 if (qstrcmp(vendor, "NVIDIA") == 0 && qEnvironmentVariableIsSet("XDG_CURRENT_DESKTOP")) {
100 m_supportsThreading = false;
101 }
102}
103
105{
106 return m_eglDisplay != EGL_NO_DISPLAY;
107}
108
110{
111 return m_supportsThreading;
112}
113
118
123
125{
126 QSurfaceFormat fmt = glFormat;
127 if (m_display->supportsWindowDecoration())
129 return new QWaylandGLContext(m_eglDisplay, m_display, fmt, share);
130}
131
133{
134 switch (resource) {
135 case EglDisplay:
136 return m_eglDisplay;
137 default:
138 break;
139 }
140 return nullptr;
141}
142
144{
146 switch (resource) {
147 case EglConfig:
148 return static_cast<QWaylandGLContext *>(context)->eglConfig();
149 case EglContext:
150 return static_cast<QWaylandGLContext *>(context)->eglContext();
151 case EglDisplay:
152 return m_eglDisplay;
153 default:
154 break;
155 }
156 return nullptr;
157}
158
160{
161 return m_eglDisplay;
162}
163
164}
165
\inmodule QtCore
Definition qbytearray.h:57
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
void setAlphaBufferSize(int size)
Set the desired size in bits of the alpha channel of the color buffer.
\inmodule QtGui
Definition qwindow.h:63
void * nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override
QPlatformOpenGLContext * createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
static const char * qwaylandegl_threadedgl_blacklist_vendor[]
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
static void * context
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
bool q_hasEglExtension(EGLDisplay display, const char *extensionName)
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
void * native_display
void const EGLint * attrib_list
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
QVideoFrameFormat::PixelFormat fmt
QT_BEGIN_NAMESPACE Platform platform()
EGLDisplay(* PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform, void *native_display, const EGLint *attrib_list)
aWidget window() -> setWindowTitle("New Window Title")
[2]