Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qwaylandeglwindow.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
// Qt-Security score:significant reason:default
4
5
#
include
"qwaylandeglwindow_p.h"
6
7
#
include
<
QtWaylandClient
/
private
/
qwaylandscreen_p
.
h
>
8
#
include
<
QtWaylandClient
/
private
/
qwaylandsurface_p
.
h
>
9
#
include
"qwaylandglcontext_p.h"
10
11
#
include
<
QtGui
/
private
/
qeglconvenience_p
.
h
>
12
13
#
include
<
QDebug
>
14
#
include
<
QtGui
/
QWindow
>
15
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
16
#
include
<
QOpenGLFramebufferObject
>
17
#
include
<
QOpenGLContext
>
18
19
QT_BEGIN_NAMESPACE
20
21
namespace
QtWaylandClient
{
22
23
QWaylandEglWindow
::
QWaylandEglWindow
(
QWindow
*
window
,
QWaylandDisplay
*
display
)
24
:
QWaylandWindow
(
window
,
display
)
25
,
m_clientBufferIntegration
(
static_cast
<
QWaylandEglClientBufferIntegration
*>(
mDisplay
->
clientBufferIntegration
()))
26
{
27
connect
(
display
, &
QWaylandDisplay
::
connected
,
this
, [
this
] {
28
m_clientBufferIntegration
=
static_cast
<
QWaylandEglClientBufferIntegration
*>(
29
mDisplay
->
clientBufferIntegration
());
30
});
31
ensureSize
();
32
}
33
34
QWaylandEglWindow
::~
QWaylandEglWindow
()
35
{
36
if
(
m_eglSurface
) {
37
eglDestroySurface
(
m_clientBufferIntegration
->
eglDisplay
(),
m_eglSurface
);
38
m_eglSurface
= 0;
39
}
40
41
if
(
m_waylandEglWindow
)
42
wl_egl_window_destroy
(
m_waylandEglWindow
);
43
}
44
45
QWaylandWindow
::
WindowType
QWaylandEglWindow
::
windowType
()
const
46
{
47
return
QWaylandWindow
::
Egl
;
48
}
49
50
void
QWaylandEglWindow
::
ensureSize
()
51
{
52
// this is always called on the main thread
53
{
54
// keep a cache of the size that is safely accessible from the render thread
55
QWriteLocker
lock
(&
m_bufferSizeLock
);
56
m_bufferSize
=
geometry
().
size
() *
scale
();
57
}
58
}
59
60
QSize
QWaylandEglWindow
::
bufferSize
()
const
61
{
62
QReadLocker
lock
(&
m_bufferSizeLock
);
63
return
m_bufferSize
;
64
}
65
66
void
QWaylandEglWindow
::
updateSurfaceSize
(
const
QSize
&
initialSize
)
67
{
68
// potentially called from a render thread
69
// eglSurfaceLock should be locked before calling this method
70
71
if
(!
m_waylandEglWindow
)
72
return
;
73
74
int
current_width
= 0;
75
int
current_height
= 0;
76
static
bool
disableResizeCheck
=
qgetenv
(
"QT_WAYLAND_DISABLE_RESIZECHECK"
).
toInt
();
77
78
if
(!
disableResizeCheck
) {
79
wl_egl_window_get_attached_size
(
m_waylandEglWindow
, &
current_width
, &
current_height
);
80
}
81
if
(
disableResizeCheck
|| (
current_width
!=
initialSize
.
width
() ||
current_height
!=
initialSize
.
height
()) ||
m_appliedBufferSize
!=
initialSize
) {
82
wl_egl_window_resize
(
m_waylandEglWindow
,
initialSize
.
width
(),
initialSize
.
height
(),
mOffset
.
x
(),
mOffset
.
y
());
83
m_appliedBufferSize
=
initialSize
;
84
mOffset
=
QPoint
();
85
m_resize
=
true
;
86
}
87
}
88
89
void
QWaylandEglWindow
::
createSurface
(
const
QSize
&
initialSize
)
90
{
91
// potentially called from a render thread
92
// eglSurfaceLock should be locked before calling this method
93
94
QReadLocker
locker
(&
mSurfaceLock
);
95
if
(
mSurface
) {
96
wl_egl_window
*
eglWindow
=
wl_egl_window_create
(
mSurface
->
object
(),
initialSize
.
width
(),
initialSize
.
height
());
97
if
(
Q_UNLIKELY
(!
eglWindow
)) {
98
qCWarning
(
lcQpaWayland
,
"Could not create wl_egl_window with size %dx%d\n"
,
initialSize
.
width
(),
initialSize
.
height
());
99
return
;
100
}
101
102
const
QSurfaceFormat
fmt
=
103
m_clientBufferIntegration
->
adjustedFormat
(
window
()->
requestedFormat
());
104
EGLConfig
eglConfig
=
q_configFromGLFormat
(
m_clientBufferIntegration
->
eglDisplay
(),
fmt
);
105
setFormat
(
q_glFormatFromConfig
(
m_clientBufferIntegration
->
eglDisplay
(),
eglConfig
,
fmt
));
106
107
EGLSurface
eglSurface
=
eglCreateWindowSurface
(
m_clientBufferIntegration
->
eglDisplay
(),
eglConfig
, (
EGLNativeWindowType
)
eglWindow
, 0);
108
if
(
Q_UNLIKELY
(
eglSurface
==
EGL_NO_SURFACE
)) {
109
qCWarning
(
lcQpaWayland
,
"Could not create EGL surface (EGL error 0x%x)\n"
,
eglGetError
());
110
wl_egl_window_destroy
(
eglWindow
);
111
return
;
112
}
113
114
m_waylandEglWindow
=
eglWindow
;
115
m_eglSurface
=
eglSurface
;
116
m_appliedBufferSize
=
initialSize
;
117
}
118
}
119
120
EGLSurface
QWaylandEglWindow
::
eglSurface
()
const
121
{
122
return
m_eglSurface
;
123
}
124
125
void
QWaylandEglWindow
::
invalidateSurface
()
126
{
127
QMutexLocker
lock
(&
m_eglSurfaceLock
);
128
129
if
(
m_eglSurface
) {
130
eglDestroySurface
(
m_clientBufferIntegration
->
eglDisplay
(),
m_eglSurface
);
131
m_eglSurface
= 0;
132
}
133
if
(
m_waylandEglWindow
) {
134
wl_egl_window_destroy
(
m_waylandEglWindow
);
135
m_waylandEglWindow
=
nullptr
;
136
}
137
}
138
139
QMutex
*
QWaylandEglWindow
::
eglSurfaceLock
()
140
{
141
return
&
m_eglSurfaceLock
;
142
}
143
144
}
145
146
QT_END_NAMESPACE
147
148
#
include
"moc_qwaylandeglwindow_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtbase
src
plugins
platforms
wayland
plugins
hardwareintegration
wayland-egl
qwaylandeglwindow.cpp
Generated on
for Qt by
1.18.0