Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
6#include "private/qeglfsintegration_p.h"
7
8#include <private/qguiapplication_p.h>
9#include <QtGui/private/qeglconvenience_p.h>
10#include <QtGui/private/qeglplatformcontext_p.h>
11
12#include <qpa/qwindowsysteminterface.h>
13
14#include <QtCore/QJsonDocument>
15#include <QtCore/QJsonArray>
16#include <QtCore/QJsonParseError>
17
19
21{
22 // The Qt Emulator provides the ability to render to multiple displays
23 // In addition to the usual EGL and OpenGLESv2 API's, there are also a
24 // few additional API's that enable the client (this plugin) to query
25 // the available screens and their properties, as well as the ability
26 // to select which screen is the active render target (as this is
27 // usually handled in a platform specific way and not by EGL itself).
28
29 getDisplays = reinterpret_cast<PFNQGSGETDISPLAYSPROC>(eglGetProcAddress("qgsGetDisplays"));
30 setDisplay = reinterpret_cast<PFNQGSSETDISPLAYPROC>(eglGetProcAddress("qgsSetDisplay"));
31}
32
36
40
42{
43 // This makes it possible to remotely query and then register our own set of screens
44 return false;
45}
46
48{
49 // Use qgsGetDisplays() call to retrieve the available screens from the Emulator
50 if (getDisplays) {
51 QByteArray displaysInfo = getDisplays();
53 QJsonDocument displaysDocument = QJsonDocument::fromJson(displaysInfo, &error);
54 if (error.error == QJsonParseError::NoError) {
55 // Document should be an array of screen objects
56 if (displaysDocument.isArray()){
57 QJsonArray screenArray = displaysDocument.array();
58 for (auto screenValue : screenArray) {
59 if (screenValue.isObject())
61 }
62 }
63 } else {
64 qWarning() << "eglfs_emu: Failed to parse display info JSON with error: " << error.errorString()
65 << " at offset " << error.offset << " : " << displaysInfo;
66
67 }
68 } else {
69 qFatal("EGL library doesn't support Emulator extensions");
70 }
71}
72
84
86 const QSize &size,
88{
91 QEglFSEmulatorScreen *screen = static_cast<QEglFSEmulatorScreen *>(platformWindow->screen());
92 if (screen && setDisplay) {
93 // Let the emulator know which screen the window surface is attached to
94 setDisplay(screen->id());
95 }
96 Q_CONSTINIT static QBasicAtomicInt uniqueWindowId = Q_BASIC_ATOMIC_INITIALIZER(0);
97 return EGLNativeWindowType(qintptr(1 + uniqueWindowId.fetchAndAddRelaxed(1)));
98}
99
\inmodule QtCore
Definition qbytearray.h:57
bool hasCapability(QPlatformIntegration::Capability cap) const override
EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow, const QSize &size, const QSurfaceFormat &format) override
\inmodule QtCore\reentrant
Definition qjsonarray.h:18
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformWindow class provides an abstraction for top-level windows.
QPlatformScreen * screen() const override
Returns the platform screen handle corresponding to this platform window, or null if the window is no...
\inmodule QtCore
Definition qsize.h:25
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary=false)
Should be called by the implementation whenever a new screen is added.
Combined button and popup list for selecting options.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
DBusConnection const char DBusError * error
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
GLenum cap
QScreen * screen
[1]
Definition main.cpp:29
#define Q_UNUSED(x)
ptrdiff_t qintptr
Definition qtypes.h:166
\inmodule QtCore\reentrant