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
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
4
#
include
"qwaylandeglclientbufferintegration_p.h"
5
6
#
include
"qwaylandeglwindow_p.h"
7
#
include
"qwaylandglcontext_p.h"
8
9
#
include
<
wayland
-
client
-
core
.
h
>
10
11
#
include
<
QtCore
/
QDebug
>
12
#
include
<
private
/
qeglconvenience_p
.
h
>
13
#
include
<
private
/
qeglpbuffer_p
.
h
>
14
15
#
ifndef
EGL_EXT_platform_base
16
typedef
EGLDisplay
(*
PFNEGLGETPLATFORMDISPLAYEXTPROC
) (EGLenum platform,
void
*native_display,
const
EGLint *attrib_list);
17
#
endif
18
19
#
ifndef
EGL_PLATFORM_WAYLAND_KHR
20
#
define
EGL_PLATFORM_WAYLAND_KHR
0x31D8
21
#
endif
22
23
QT_BEGIN_NAMESPACE
24
25
namespace
QtWaylandClient
{
26
27
static
const
char
*
qwaylandegl_threadedgl_blacklist_vendor
[] = {
28
0
29
};
30
31
QWaylandEglClientBufferIntegration
::
QWaylandEglClientBufferIntegration
()
32
{
33
qCDebug
(
lcQpaWayland
) <<
"Using Wayland-EGL"
;
34
}
35
36
37
QWaylandEglClientBufferIntegration
::~
QWaylandEglClientBufferIntegration
()
38
{
39
eglTerminate
(
m_eglDisplay
);
40
}
41
42
void
QWaylandEglClientBufferIntegration
::
initialize
(
QWaylandDisplay
*
display
)
43
{
44
#
if
QT_CONFIG
(
egl_extension_platform_wayland
)
45
m_eglDisplay
=
eglGetPlatformDisplay
(
EGL_PLATFORM_WAYLAND_EXT
,
display
->
wl_display
(),
nullptr
);
46
#
else
47
if
(
q_hasEglExtension
(
EGL_NO_DISPLAY
,
"EGL_EXT_platform_base"
)) {
48
if
(
q_hasEglExtension
(
EGL_NO_DISPLAY
,
"EGL_KHR_platform_wayland"
) ||
49
q_hasEglExtension
(
EGL_NO_DISPLAY
,
"EGL_EXT_platform_wayland"
) ||
50
q_hasEglExtension
(
EGL_NO_DISPLAY
,
"EGL_MESA_platform_wayland"
)) {
51
52
static
PFNEGLGETPLATFORMDISPLAYEXTPROC
eglGetPlatformDisplay
=
nullptr
;
53
if
(!
eglGetPlatformDisplay
)
54
eglGetPlatformDisplay
= (
PFNEGLGETPLATFORMDISPLAYEXTPROC
)
eglGetProcAddress
(
"eglGetPlatformDisplayEXT"
);
55
56
m_eglDisplay
=
eglGetPlatformDisplay
(
EGL_PLATFORM_WAYLAND_KHR
,
display
->
wl_display
(),
nullptr
);
57
}
else
{
58
qCWarning
(
lcQpaWayland
) <<
"The EGL implementation does not support the Wayland platform"
;
59
return
;
60
}
61
}
else
{
62
QByteArray
eglPlatform
=
qgetenv
(
"EGL_PLATFORM"
);
63
if
(
eglPlatform
.
isEmpty
()) {
64
setenv
(
"EGL_PLATFORM"
,
"wayland"
,
true
);
65
}
66
67
m_eglDisplay
=
eglGetDisplay
((
EGLNativeDisplayType
)
display
->
wl_display
());
68
}
69
#
endif
70
71
m_display
=
display
;
72
73
if
(
m_eglDisplay
==
EGL_NO_DISPLAY
) {
74
qCWarning
(
lcQpaWayland
) <<
"EGL not available"
;
75
return
;
76
}
77
78
EGLint
major
,
minor
;
79
if
(!
eglInitialize
(
m_eglDisplay
, &
major
, &
minor
)) {
80
qCWarning
(
lcQpaWayland
) <<
"Failed to initialize EGL display"
<<
Qt
::
hex
<<
eglGetError
();
81
m_eglDisplay
=
EGL_NO_DISPLAY
;
82
return
;
83
}
84
85
m_supportsThreading
=
true
;
86
if
(
qEnvironmentVariableIsSet
(
"QT_OPENGL_NO_SANITY_CHECK"
))
87
return
;
88
89
const
char
*
vendor
=
eglQueryString
(
m_eglDisplay
,
EGL_VENDOR
);
90
for
(
int
i
= 0;
qwaylandegl_threadedgl_blacklist_vendor
[
i
]; ++
i
) {
91
if
(
strstr
(
vendor
,
qwaylandegl_threadedgl_blacklist_vendor
[
i
]) != 0) {
92
m_supportsThreading
=
false
;
93
break
;
94
}
95
}
96
97
// On desktop NVIDIA resizing QtQuick freezes them when using threaded rendering QTBUG-95817
98
// In order to support threaded rendering on embedded platforms where resizing is not needed
99
// we check if XDG_CURRENT_DESKTOP is set which desktop environments should set
100
if
(
qstrcmp
(
vendor
,
"NVIDIA"
) == 0 &&
qEnvironmentVariableIsSet
(
"XDG_CURRENT_DESKTOP"
)) {
101
m_supportsThreading
=
false
;
102
}
103
}
104
105
bool
QWaylandEglClientBufferIntegration
::
isValid
()
const
106
{
107
return
m_eglDisplay
!=
EGL_NO_DISPLAY
;
108
}
109
110
bool
QWaylandEglClientBufferIntegration
::
supportsThreadedOpenGL
()
const
111
{
112
return
m_supportsThreading
;
113
}
114
115
bool
QWaylandEglClientBufferIntegration
::
supportsWindowDecoration
()
const
116
{
117
return
true
;
118
}
119
120
QWaylandWindow
*
QWaylandEglClientBufferIntegration
::
createEglWindow
(
QWindow
*
window
)
121
{
122
return
new
QWaylandEglWindow
(
window
,
m_display
);
123
}
124
125
QPlatformOpenGLContext
*
QWaylandEglClientBufferIntegration
::
createPlatformOpenGLContext
(
const
QSurfaceFormat
&
glFormat
,
QPlatformOpenGLContext
*
share
)
const
126
{
127
QSurfaceFormat
fmt
=
glFormat
;
128
if
(
m_display
->
supportsWindowDecoration
())
129
fmt
.
setAlphaBufferSize
(8);
130
return
new
QWaylandGLContext
(
m_eglDisplay
,
m_display
,
fmt
,
share
);
131
}
132
133
QOpenGLContext
*
QWaylandEglClientBufferIntegration
::
createOpenGLContext
(
EGLContext
context
,
EGLDisplay
contextDisplay
,
QOpenGLContext
*
shareContext
)
const
134
{
135
return
QEGLPlatformContext
::
createFrom
<
QWaylandGLContext
>(
context
,
contextDisplay
,
m_eglDisplay
,
shareContext
);
136
}
137
138
QPlatformOffscreenSurface
*
QWaylandEglClientBufferIntegration
::
createPlatformOffscreenSurface
(
QOffscreenSurface
*
surface
)
const
139
{
140
return
new
QEGLPbuffer
(
m_eglDisplay
,
surface
->
requestedFormat
(),
surface
);
141
}
142
143
void
*
QWaylandEglClientBufferIntegration
::
nativeResource
(
NativeResource
resource
)
144
{
145
switch
(
resource
) {
146
case
EglDisplay
:
147
return
m_eglDisplay
;
148
default
:
149
break
;
150
}
151
return
nullptr
;
152
}
153
154
void
*
QWaylandEglClientBufferIntegration
::
nativeResourceForContext
(
NativeResource
resource
,
QPlatformOpenGLContext
*
context
)
155
{
156
Q_ASSERT
(
context
);
157
switch
(
resource
) {
158
case
EglConfig
:
159
return
static_cast
<
QWaylandGLContext
*>(
context
)->
eglConfig
();
160
case
EglContext
:
161
return
static_cast
<
QWaylandGLContext
*>(
context
)->
eglContext
();
162
case
EglDisplay
:
163
return
m_eglDisplay
;
164
default
:
165
break
;
166
}
167
return
nullptr
;
168
}
169
170
EGLDisplay
QWaylandEglClientBufferIntegration
::
eglDisplay
()
const
171
{
172
return
m_eglDisplay
;
173
}
174
175
}
176
177
QT_END_NAMESPACE
QtWaylandClient
Definition
qwaylandclientextension.h:15
QtWaylandClient::qwaylandegl_threadedgl_blacklist_vendor
static const char * qwaylandegl_threadedgl_blacklist_vendor[]
Definition
qwaylandeglclientbufferintegration.cpp:27
PFNEGLGETPLATFORMDISPLAYEXTPROC
EGLDisplay(* PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform, void *native_display, const EGLint *attrib_list)
Definition
qwaylandeglclientbufferintegration.cpp:16
EGL_PLATFORM_WAYLAND_KHR
#define EGL_PLATFORM_WAYLAND_KHR
Definition
qwaylandeglclientbufferintegration.cpp:20
qtbase
src
plugins
platforms
wayland
plugins
hardwareintegration
wayland-egl
qwaylandeglclientbufferintegration.cpp
Generated on
for Qt by
1.14.0