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
qmultimedia_gl_support.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 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
"qmultimedia_gl_support_p.h"
5
6
#
include
<
QtGui
/
qopenglcontext
.
h
>
7
#
include
<
QtGui
/
qopenglfunctions
.
h
>
8
#
include
<
QtGui
/
rhi
/
qrhi
.
h
>
9
10
#
include
<
QtCore
/
qdebug
.
h
>
11
12
#
if
QT_CONFIG
(
egl
)
13
#
include
<
QtMultimedia
/
private
/
qeglimagefunctions_p
.
h
>
14
#
include
<
EGL
/
egl
.
h
>
15
#
endif
16
17
QT_BEGIN_NAMESPACE
18
19
using
namespace
Qt::StringLiterals;
20
21
namespace
QtMultimediaPrivate
{
22
23
static
QString
toString
(
GLError
error)
24
{
25
switch
(error) {
26
case
GLError::NoError:
27
return
u"GL_NO_ERROR"_s;
28
case
GLError::InvalidEnum:
29
return
u"GL_INVALID_ENUM"_s;
30
case
GLError::InvalidValue:
31
return
u"GL_INVALID_VALUE"_s;
32
case
GLError::InvalidOperation:
33
return
u"GL_INVALID_OPERATION"_s;
34
case
GLError::StackOverflow:
35
return
u"GL_STACK_OVERFLOW"_s;
36
case
GLError::StackUnderflow:
37
return
u"GL_STACK_UNDERFLOW"_s;
38
case
GLError::OutOfMemory:
39
return
u"GL_OUT_OF_MEMORY"_s;
40
case
GLError::InvalidFramebufferOperation:
41
return
u"GL_INVALID_FRAMEBUFFER_OPERATION"_s;
42
}
43
return
u"unknown GL error"_s;
44
}
45
46
QDebug operator<<(QDebug debug,
GLError
error)
47
{
48
const
QDebugStateSaver saver(debug);
49
debug.nospace().noquote() <<
"GLError(0x"
<< Qt::hex << qToUnderlying(error) << Qt::dec <<
", "
50
<< toString(error) <<
')'
;
51
return
debug;
52
}
53
54
#
if
QT_CONFIG
(
egl
)
55
56
static
QString
toString
(
EGLError
error
)
57
{
58
switch
(
error
) {
59
case
EGLError
::
Success
:
60
return
u"EGL_SUCCESS"_s;
61
case
EGLError
::
NotInitialized
:
62
return
u"EGL_NOT_INITIALIZED"_s;
63
case
EGLError
::
BadAccess
:
64
return
u"EGL_BAD_ACCESS"_s;
65
case
EGLError
::
BadAlloc
:
66
return
u"EGL_BAD_ALLOC"_s;
67
case
EGLError
::
BadAttribute
:
68
return
u"EGL_BAD_ATTRIBUTE"_s;
69
case
EGLError
::
BadConfig
:
70
return
u"EGL_BAD_CONFIG"_s;
71
case
EGLError
::
BadContext
:
72
return
u"EGL_BAD_CONTEXT"_s;
73
case
EGLError
::
BadCurrentSurface
:
74
return
u"EGL_BAD_CURRENT_SURFACE"_s;
75
case
EGLError
::
BadDisplay
:
76
return
u"EGL_BAD_DISPLAY"_s;
77
case
EGLError
::
BadMatch
:
78
return
u"EGL_BAD_MATCH"_s;
79
case
EGLError
::
BadNativePixmap
:
80
return
u"EGL_BAD_NATIVE_PIXMAP"_s;
81
case
EGLError
::
BadNativeWindow
:
82
return
u"EGL_BAD_NATIVE_WINDOW"_s;
83
case
EGLError
::
BadParameter
:
84
return
u"EGL_BAD_PARAMETER"_s;
85
case
EGLError
::
BadSurface
:
86
return
u"EGL_BAD_SURFACE"_s;
87
case
EGLError
::
ContextLost
:
88
return
u"EGL_CONTEXT_LOST"_s;
89
}
90
return
u"unknown EGL error"_s;
91
}
92
93
QDebug
operator
<<(
QDebug
debug
,
EGLError
error
)
94
{
95
const
QDebugStateSaver
saver
(
debug
);
96
debug
.
nospace
().
noquote
() <<
"EGLError(0x"
<<
Qt
::
hex
<<
qToUnderlying
(
error
) <<
Qt
::
dec
<<
", "
97
<<
toString
(
error
) <<
')'
;
98
return
debug
;
99
}
100
101
EGLDisplay
resolveEglDisplay
(
QRhi
&
rhi
)
102
{
103
if
(
rhi
.
backend
() !=
QRhi
::
OpenGLES2
)
104
return
EGL_NO_DISPLAY
;
105
106
auto
*
nativeHandles
=
static_cast
<
const
QRhiGles2NativeHandles
*>(
rhi
.
nativeHandles
());
107
QOpenGLContext
*
glContext
=
nativeHandles
?
nativeHandles
->
context
:
nullptr
;
108
if
(!
glContext
)
109
return
EGL_NO_DISPLAY
;
110
111
auto
*
eglContext
=
glContext
->
nativeInterface
<
QNativeInterface
::
QEGLContext
>();
112
return
eglContext
?
eglContext
->
display
() :
EGL_NO_DISPLAY
;
113
}
114
115
void
EglImageDeleter
::
operator
()(
EGLImage
image
)
const
noexcept
116
{
117
if
(
image
!=
EGL_NO_IMAGE
)
118
QEglImageFunctions
::
instance
().
eglDestroyImage
(
m_display
,
image
);
119
}
120
#
endif
121
122
void
GlTextureDeleter
::
operator
()(
GLuint
texture
)
const
noexcept
123
{
124
if
(
texture
&&
m_context
) {
125
QOpenGLFunctions
functions
(
m_context
);
126
functions
.
glDeleteTextures
(1, &
texture
);
127
}
128
}
129
130
}
// namespace QtMultimediaPrivate
131
132
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtMultimediaPrivate::impl
Definition
qaudiosystem_p.h:257
QtMultimediaPrivate::toString
static QString toString(GLError error)
Definition
qmultimedia_gl_support.cpp:23
QtMultimediaPrivate::GLError
GLError
Definition
qmultimedia_gl_support_p.h:59
qtmultimedia
src
multimedia
video
qmultimedia_gl_support.cpp
Generated on
for Qt by
1.16.1