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
qeglfsemulatorintegration.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
"qeglfsemulatorintegration.h"
6
#
include
"qeglfsemulatorscreen.h"
7
#
include
"private/qeglfsintegration_p.h"
8
9
#
include
<
private
/
qguiapplication_p
.
h
>
10
#
include
<
QtGui
/
private
/
qeglconvenience_p
.
h
>
11
#
include
<
QtGui
/
private
/
qeglplatformcontext_p
.
h
>
12
13
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
14
15
#
include
<
QtCore
/
QJsonDocument
>
16
#
include
<
QtCore
/
QJsonArray
>
17
#
include
<
QtCore
/
QJsonParseError
>
18
19
QT_BEGIN_NAMESPACE
20
21
QEglFSEmulatorIntegration::QEglFSEmulatorIntegration()
22
{
23
// The Qt Emulator provides the ability to render to multiple displays
24
// In addition to the usual EGL and OpenGLESv2 API's, there are also a
25
// few additional API's that enable the client (this plugin) to query
26
// the available screens and their properties, as well as the ability
27
// to select which screen is the active render target (as this is
28
// usually handled in a platform specific way and not by EGL itself).
29
30
getDisplays =
reinterpret_cast
<PFNQGSGETDISPLAYSPROC>(eglGetProcAddress(
"qgsGetDisplays"
));
31
setDisplay =
reinterpret_cast
<PFNQGSSETDISPLAYPROC>(eglGetProcAddress(
"qgsSetDisplay"
));
32
}
33
34
void
QEglFSEmulatorIntegration
::
platformInit
()
35
{
36
}
37
38
void
QEglFSEmulatorIntegration
::
platformDestroy
()
39
{
40
}
41
42
bool
QEglFSEmulatorIntegration
::
usesDefaultScreen
()
43
{
44
// This makes it possible to remotely query and then register our own set of screens
45
return
false
;
46
}
47
48
void
QEglFSEmulatorIntegration
::
screenInit
()
49
{
50
// Use qgsGetDisplays() call to retrieve the available screens from the Emulator
51
if
(getDisplays) {
52
QByteArray
displaysInfo = getDisplays();
53
QJsonParseError error;
54
QJsonDocument displaysDocument = QJsonDocument::fromJson(displaysInfo, &error);
55
if
(error.error == QJsonParseError::NoError) {
56
// Document should be an array of screen objects
57
if
(displaysDocument.isArray()){
58
QJsonArray screenArray = displaysDocument.array();
59
for
(
auto
screenValue : screenArray) {
60
if
(screenValue.isObject())
61
QWindowSystemInterface::handleScreenAdded(
new
QEglFSEmulatorScreen(screenValue.toObject()));
62
}
63
}
64
}
else
{
65
qWarning() <<
"eglfs_emu: Failed to parse display info JSON with error: "
<< error.errorString()
66
<<
" at offset "
<< error.offset <<
" : "
<< displaysInfo;
67
68
}
69
}
else
{
70
qFatal(
"EGL library doesn't support Emulator extensions"
);
71
}
72
}
73
74
bool
QEglFSEmulatorIntegration
::
hasCapability
(QPlatformIntegration::Capability cap)
const
75
{
76
switch
(cap) {
77
case
QPlatformIntegration::ThreadedPixmaps:
78
case
QPlatformIntegration::OpenGL:
79
case
QPlatformIntegration::ThreadedOpenGL:
80
return
true
;
81
default
:
82
return
false
;
83
}
84
}
85
86
EGLNativeWindowType
QEglFSEmulatorIntegration
::
createNativeWindow
(QPlatformWindow *platformWindow,
87
const
QSize &size,
88
const
QSurfaceFormat &format)
89
{
90
Q_UNUSED(size);
91
Q_UNUSED(format);
92
QEglFSEmulatorScreen
*screen =
static_cast
<
QEglFSEmulatorScreen
*>(platformWindow->screen());
93
if
(screen && setDisplay) {
94
// Let the emulator know which screen the window surface is attached to
95
setDisplay(screen->id());
96
}
97
Q_CONSTINIT
static
QBasicAtomicInt uniqueWindowId = Q_BASIC_ATOMIC_INITIALIZER(0);
98
return
EGLNativeWindowType(qintptr(1 + uniqueWindowId.fetchAndAddRelaxed(1)));
99
}
100
101
QT_END_NAMESPACE
QEglFSEmulatorIntegration
Definition
qeglfsemulatorintegration.h:21
QEglFSEmulatorIntegration::screenInit
void screenInit() override
Definition
qeglfsemulatorintegration.cpp:48
QEglFSEmulatorIntegration::hasCapability
bool hasCapability(QPlatformIntegration::Capability cap) const override
Definition
qeglfsemulatorintegration.cpp:74
QEglFSEmulatorIntegration::usesDefaultScreen
bool usesDefaultScreen() override
Definition
qeglfsemulatorintegration.cpp:42
QEglFSEmulatorIntegration::createNativeWindow
EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow, const QSize &size, const QSurfaceFormat &format) override
Definition
qeglfsemulatorintegration.cpp:86
QEglFSEmulatorIntegration::platformDestroy
void platformDestroy() override
Definition
qeglfsemulatorintegration.cpp:38
QEglFSEmulatorIntegration::platformInit
void platformInit() override
Definition
qeglfsemulatorintegration.cpp:34
QEglFSEmulatorScreen
Definition
qeglfsemulatorscreen.h:16
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QByteArray
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
qtbase
src
plugins
platforms
eglfs
deviceintegration
eglfs_emu
qeglfsemulatorintegration.cpp
Generated on
for Qt by
1.18.0