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
qeglplatformcontext_p.h
Go to the documentation of this file.
1
// Copyright (C) 2020 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
#
ifndef
QEGLPLATFORMCONTEXT_H
5
#
define
QEGLPLATFORMCONTEXT_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtCore
/
qtextstream
.
h
>
19
#
include
<
qpa
/
qplatformwindow
.
h
>
20
#
include
<
qpa
/
qplatformopenglcontext
.
h
>
21
#
include
<
QtCore
/
qvariant
.
h
>
22
#
include
<
QtGui
/
private
/
qt_egl_p
.
h
>
23
#
include
<
QtGui
/
private
/
qopenglcontext_p
.
h
>
24
25
QT_BEGIN_NAMESPACE
26
27
class
Q_GUI_EXPORT
QEGLPlatformContext
:
public
QPlatformOpenGLContext,
28
public
QNativeInterface::QEGLContext
29
{
30
public
:
31
enum
Flag {
32
NoSurfaceless = 0x01
33
};
34
Q_DECLARE_FLAGS(Flags, Flag)
35
36
QEGLPlatformContext(
const
QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
37
EGLConfig *config =
nullptr
, Flags flags = { });
38
39
template
<
typename
T>
40
static
QOpenGLContext *createFrom(EGLContext context, EGLDisplay contextDisplay,
41
EGLDisplay platformDisplay, QOpenGLContext *shareContext)
42
{
43
if
(!context)
44
return
nullptr
;
45
46
// A context belonging to a given EGLDisplay cannot be used with another one
47
if
(contextDisplay != platformDisplay) {
48
qWarning(
"QEGLPlatformContext: Cannot adopt context from different display"
);
49
return
nullptr
;
50
}
51
52
QPlatformOpenGLContext *shareHandle = shareContext ? shareContext->handle() :
nullptr
;
53
54
auto
*resultingContext =
new
QOpenGLContext;
55
auto
*contextPrivate = QOpenGLContextPrivate::get(resultingContext);
56
auto
*platformContext =
new
T;
57
platformContext->adopt(context, contextDisplay, shareHandle);
58
contextPrivate->adopt(platformContext);
59
return
resultingContext;
60
}
61
62
~QEGLPlatformContext();
63
64
void
initialize() override;
65
bool
makeCurrent(QPlatformSurface *surface) override;
66
void
doneCurrent() override;
67
void
swapBuffers(QPlatformSurface *surface) override;
68
QFunctionPointer getProcAddress(
const
char
*procName) override;
69
70
QSurfaceFormat format()
const
override;
71
bool
isSharing()
const
override {
return
m_shareContext != EGL_NO_CONTEXT; }
72
bool
isValid()
const
override {
return
m_eglContext != EGL_NO_CONTEXT && !m_markedInvalid; }
73
74
EGLContext nativeContext()
const
override {
return
eglContext(); }
75
EGLConfig config()
const
override {
return
eglConfig(); }
76
EGLDisplay display()
const
override {
return
eglDisplay(); }
77
78
virtual
void
invalidateContext() override { m_markedInvalid =
true
; }
79
80
EGLContext eglContext()
const
;
81
EGLDisplay eglDisplay()
const
;
82
EGLConfig eglConfig()
const
;
83
84
protected
:
85
QEGLPlatformContext() {}
// For adoption
86
virtual
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
87
virtual
EGLSurface createTemporaryOffscreenSurface();
88
virtual
void
destroyTemporaryOffscreenSurface(EGLSurface surface);
89
virtual
void
runGLChecks();
90
bool
checkGraphicsReset();
91
92
private
:
93
QList<EGLint> buildContextAttributes(
const
QSurfaceFormat &format);
94
void
adopt(EGLContext context, EGLDisplay display, QPlatformOpenGLContext *shareContext);
95
void
updateFormatFromGL();
96
97
#
ifndef
QT_NO_OPENGL
98
bool
hasExtension(
const
char
*name);
99
#
endif
100
101
EGLContext m_eglContext;
102
EGLContext m_shareContext;
103
EGLDisplay m_eglDisplay;
104
EGLConfig m_eglConfig;
105
QSurfaceFormat m_format;
106
EGLenum m_api;
107
int
m_swapInterval = -1;
108
bool
m_swapIntervalEnvChecked =
false
;
109
int
m_swapIntervalFromEnv = -1;
110
Flags m_flags;
111
bool
m_ownsContext =
false
;
112
QList<EGLint> m_contextAttrs;
113
114
bool
m_markedInvalid =
false
;
115
GLenum (QOPENGLF_APIENTRYP m_getGraphicsResetStatus)() =
nullptr
;
116
};
117
118
Q_DECLARE_OPERATORS_FOR_FLAGS(QEGLPlatformContext::Flags)
119
120
QT_END_NAMESPACE
121
122
#
endif
//QEGLPLATFORMCONTEXT_H
QEGLPlatformContext
An EGL context implementation.
Definition
qeglplatformcontext_p.h:29
GL_RESET_NOTIFICATION_STRATEGY_EXT
#define GL_RESET_NOTIFICATION_STRATEGY_EXT
Definition
qeglplatformcontext.cpp:109
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR
Definition
qeglplatformcontext.cpp:61
EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT
Definition
qeglplatformcontext.cpp:75
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
Definition
qeglplatformcontext.cpp:49
EGL_LOSE_CONTEXT_ON_RESET_EXT
#define EGL_LOSE_CONTEXT_ON_RESET_EXT
Definition
qeglplatformcontext.cpp:78
GL_CONTEXT_PROFILE_MASK
#define GL_CONTEXT_PROFILE_MASK
Definition
qeglplatformcontext.cpp:92
EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR
Definition
qeglplatformcontext.cpp:52
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR
Definition
qeglplatformcontext.cpp:67
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR
Definition
qeglplatformcontext.cpp:55
EGL_CONTEXT_MINOR_VERSION_KHR
#define EGL_CONTEXT_MINOR_VERSION_KHR
Definition
qeglplatformcontext.cpp:40
GL_RESET_NOTIFICATION_STRATEGY
#define GL_RESET_NOTIFICATION_STRATEGY
Definition
qeglplatformcontext.cpp:101
EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV
#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV
Definition
qeglplatformcontext.cpp:117
GL_LOSE_CONTEXT_ON_RESET
#define GL_LOSE_CONTEXT_ON_RESET
Definition
qeglplatformcontext.cpp:104
GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
Definition
qeglplatformcontext.cpp:98
EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR
Definition
qeglplatformcontext.cpp:58
EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT
Definition
qeglplatformcontext.cpp:72
GL_CONTEXT_CORE_PROFILE_BIT
#define GL_CONTEXT_CORE_PROFILE_BIT
Definition
qeglplatformcontext.cpp:95
GL_LOSE_CONTEXT_ON_RESET_EXT
#define GL_LOSE_CONTEXT_ON_RESET_EXT
Definition
qeglplatformcontext.cpp:112
EGL_CONTEXT_FLAGS_KHR
#define EGL_CONTEXT_FLAGS_KHR
Definition
qeglplatformcontext.cpp:43
EGL_LOSE_CONTEXT_ON_RESET_KHR
#define EGL_LOSE_CONTEXT_ON_RESET_KHR
Definition
qeglplatformcontext.cpp:64
GL_CONTEXT_FLAGS
#define GL_CONTEXT_FLAGS
Definition
qeglplatformcontext.cpp:83
GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
Definition
qeglplatformcontext.cpp:86
GL_CONTEXT_FLAG_DEBUG_BIT
#define GL_CONTEXT_FLAG_DEBUG_BIT
Definition
qeglplatformcontext.cpp:89
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR
Definition
qeglplatformcontext.cpp:46
qtbase
src
gui
opengl
platform
egl
qeglplatformcontext_p.h
Generated on
for Qt by
1.18.0