Debian Codegraph @

src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorscreen.cpp

raw
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
4 #include "qeglfsemulatorscreen.h"
5
6 QT_BEGIN_NAMESPACE
7
8 using namespace Qt::StringLiterals;
9
10 QEglFSEmulatorScreen::QEglFSEmulatorScreen(const QJsonObject &screenDescription)
11 : QEglFSScreen(eglGetDisplay(EGL_DEFAULT_DISPLAY))
12 , m_id(0)
13 {
14 initFromJsonObject(screenDescription);
15 }
16
17 QRect QEglFSEmulatorScreen::geometry() const
18 {
19 return m_geometry;
20 }
21
22 QRect QEglFSEmulatorScreen::rawGeometry() const
23 {
24 return QRect(QPoint(0, 0), m_geometry.size());
25 }
26
27 int QEglFSEmulatorScreen::depth() const
28 {
29 return m_depth;
30 }
31
32 QImage::Format QEglFSEmulatorScreen::format() const
33 {
34 return m_format;
35 }
36
37 QSizeF QEglFSEmulatorScreen::physicalSize() const
38 {
39 return m_physicalSize;
40 }
41
42 QDpi QEglFSEmulatorScreen::logicalDpi() const
43 {
44 return logicalBaseDpi();
45 }
46
47 QDpi QEglFSEmulatorScreen::logicalBaseDpi() const
48 {
49 return QDpi(100, 100);
50 }
51
52 qreal QEglFSEmulatorScreen::refreshRate() const
53 {
54 return m_refreshRate;
55 }
56
57 Qt::ScreenOrientation QEglFSEmulatorScreen::nativeOrientation() const
58 {
59 return m_nativeOrientation;
60 }
61
62 Qt::ScreenOrientation QEglFSEmulatorScreen::orientation() const
63 {
64 return m_orientation;
65 }
66
67 uint QEglFSEmulatorScreen::id() const
68 {
69 return m_id;
70 }
71
72 QString QEglFSEmulatorScreen::name() const
73 {
74 return m_description;
75 }
76
77 void QEglFSEmulatorScreen::initFromJsonObject(const QJsonObject &description)
78 {
79 QJsonValue value;
80
81 value = description.value("id"_L1);
82 if (!value.isUndefined() && value.isDouble())
83 m_id = value.toInt();
84
85 value = description.value("description"_L1);
86 if (!value.isUndefined() && value.isString())
87 m_description = value.toString();
88
89 value = description.value("geometry"_L1);
90 if (!value.isUndefined() && value.isObject()) {
91 QJsonObject geometryObject = value.toObject();
92 value = geometryObject.value("x"_L1);
93 if (!value.isUndefined() && value.isDouble())
94 m_geometry.setX(value.toInt());
95 value = geometryObject.value("y"_L1);
96 if (!value.isUndefined() && value.isDouble())
97 m_geometry.setY(value.toInt());
98 value = geometryObject.value("width"_L1);
99 if (!value.isUndefined() && value.isDouble())
100 m_geometry.setWidth(value.toInt());
101 value = geometryObject.value("height"_L1);
102 if (!value.isUndefined() && value.isDouble())
103 m_geometry.setHeight(value.toInt());
104 }
105
106 value = description.value("depth"_L1);
107 if (!value.isUndefined() && value.isDouble())
108 m_depth = value.toInt();
109
110 value = description.value("format"_L1);
111 if (!value.isUndefined() && value.isDouble())
112 m_format = static_cast<QImage::Format>(value.toInt());
113
114 value = description.value("physicalSize"_L1);
115 if (!value.isUndefined() && value.isObject()) {
116 QJsonObject physicalSizeObject = value.toObject();
117 value = physicalSizeObject.value("width"_L1);
118 if (!value.isUndefined() && value.isDouble())
119 m_physicalSize.setWidth(value.toInt());
120 value = physicalSizeObject.value("height"_L1);
121 if (!value.isUndefined() && value.isDouble())
122 m_physicalSize.setHeight(value.toInt());
123 }
124
125
126 value = description.value("refreshRate"_L1);
127 if (!value.isUndefined() && value.isDouble())
128 m_refreshRate = value.toDouble();
129
130 value = description.value("nativeOrientation"_L1);
131 if (!value.isUndefined() && value.isDouble())
132 m_nativeOrientation = static_cast<Qt::ScreenOrientation>(value.toInt());
133
134 value = description.value("orientation"_L1);
135 if (!value.isUndefined() && value.isDouble())
136 m_orientation = static_cast<Qt::ScreenOrientation>(value.toInt());
137 }
138
139 QT_END_NAMESPACE