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
qandroidplatformopenglcontext.cpp
Go to the documentation of this file.
1
// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
2
// Copyright (C) 2026 The Qt Company Ltd.
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
// Qt-Security score:significant reason:default
5
6
#
include
"qandroidplatformopenglcontext.h"
7
#
include
"qandroidplatformoffscreensurface.h"
8
#
include
"qandroidplatformopenglwindow.h"
9
10
#
include
<
QtGui
/
QOffscreenSurface
>
11
#
include
<
QtGui
/
QSurface
>
12
#
include
<
QtGui
/
private
/
qopenglcontext_p
.
h
>
13
#
include
<
QtGui
/
private
/
qeglpbuffer_p
.
h
>
14
15
QT_BEGIN_NAMESPACE
16
17
QAndroidPlatformOpenGLContext::QAndroidPlatformOpenGLContext(
const
QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display)
18
: QEGLPlatformContext(format, share, display,
nullptr
)
19
{
20
}
21
22
QAndroidPlatformOpenGLContext::~QAndroidPlatformOpenGLContext()
23
{
24
if
(m_fallbackPbuffer != EGL_NO_SURFACE)
25
eglDestroySurface(eglDisplay(), m_fallbackPbuffer);
26
}
27
28
EGLSurface QAndroidPlatformOpenGLContext::ensureFallbackPbuffer()
29
{
30
if
(m_fallbackPbuffer != EGL_NO_SURFACE)
31
return
m_fallbackPbuffer;
32
m_fallbackPbuffer = createTemporaryOffscreenSurface();
33
if
(Q_UNLIKELY(m_fallbackPbuffer == EGL_NO_SURFACE))
34
qWarning(
"EGL Error: could not create pbuffer fallback surface: 0x%x"
, eglGetError());
35
return
m_fallbackPbuffer;
36
}
37
38
void
QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface)
39
{
40
if
(surface->surface()->surfaceClass() != QSurface::Window) {
41
QEGLPlatformContext::swapBuffers(surface);
42
return
;
43
}
44
45
QAndroidPlatformOpenGLWindow
*window =
static_cast
<
QAndroidPlatformOpenGLWindow
*>(surface);
46
// No Surface yet, so there is nothing visible to swap.
47
if
(window->eglSurface(eglConfig()) == EGL_NO_SURFACE)
48
return
;
49
50
if
(!QEGLPlatformContext::makeCurrent(surface))
51
return
;
52
QEGLPlatformContext::swapBuffers(surface);
53
}
54
55
bool
QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface)
56
{
57
return
QEGLPlatformContext::makeCurrent(surface);
58
}
59
60
EGLSurface QAndroidPlatformOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
61
{
62
if
(surface->surface()->surfaceClass() == QSurface::Window) {
63
EGLSurface eglSurface =
64
static_cast
<
QAndroidPlatformOpenGLWindow
*>(surface)->eglSurface(eglConfig());
65
// No Surface from Android yet. Use a 1x1 pbuffer so makeCurrent()
66
// succeeds, a later makeCurrent() binds the real surface.
67
if
(eglSurface == EGL_NO_SURFACE)
68
eglSurface = ensureFallbackPbuffer();
69
70
return
eglSurface;
71
}
72
73
if
(
auto
*platformOffscreenSurface =
dynamic_cast
<QAndroidPlatformOffscreenSurface *>(surface))
74
return
platformOffscreenSurface->surface();
75
76
return
static_cast
<QEGLPbuffer *>(surface)->pbuffer();
77
}
78
79
QT_END_NAMESPACE
QAndroidPlatformOpenGLWindow
Definition
qandroidplatformopenglwindow.h:19
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
plugins
platforms
android
qandroidplatformopenglcontext.cpp
Generated on
for Qt by
1.18.0