QtBase  v6.3.1
qeglfsemulatorscreen.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qeglfsemulatorscreen.h"
41 
43 
45  : QEglFSScreen(eglGetDisplay(EGL_DEFAULT_DISPLAY))
46  , m_id(0)
47 {
48  initFromJsonObject(screenDescription);
49 }
50 
52 {
53  return m_geometry;
54 }
55 
57 {
58  return QRect(QPoint(0, 0), m_geometry.size());
59 }
60 
62 {
63  return m_depth;
64 }
65 
67 {
68  return m_format;
69 }
70 
72 {
73  return m_physicalSize;
74 }
75 
77 {
78  return logicalBaseDpi();
79 }
80 
82 {
83  return QDpi(100, 100);
84 }
85 
87 {
88  return m_refreshRate;
89 }
90 
92 {
93  return m_nativeOrientation;
94 }
95 
97 {
98  return m_orientation;
99 }
100 
102 {
103  return m_id;
104 }
105 
107 {
108  return m_description;
109 }
110 
111 void QEglFSEmulatorScreen::initFromJsonObject(const QJsonObject &description)
112 {
114 
115  value = description.value(QLatin1String("id"));
116  if (!value.isUndefined() && value.isDouble())
117  m_id = value.toInt();
118 
119  value = description.value(QLatin1String("description"));
120  if (!value.isUndefined() && value.isString())
121  m_description = value.toString();
122 
123  value = description.value(QLatin1String("geometry"));
124  if (!value.isUndefined() && value.isObject()) {
125  QJsonObject geometryObject = value.toObject();
126  value = geometryObject.value(QLatin1String("x"));
127  if (!value.isUndefined() && value.isDouble())
128  m_geometry.setX(value.toInt());
129  value = geometryObject.value(QLatin1String("y"));
130  if (!value.isUndefined() && value.isDouble())
131  m_geometry.setY(value.toInt());
132  value = geometryObject.value(QLatin1String("width"));
133  if (!value.isUndefined() && value.isDouble())
134  m_geometry.setWidth(value.toInt());
135  value = geometryObject.value(QLatin1String("height"));
136  if (!value.isUndefined() && value.isDouble())
137  m_geometry.setHeight(value.toInt());
138  }
139 
140  value = description.value(QLatin1String("depth"));
141  if (!value.isUndefined() && value.isDouble())
142  m_depth = value.toInt();
143 
144  value = description.value(QLatin1String("format"));
145  if (!value.isUndefined() && value.isDouble())
146  m_format = static_cast<QImage::Format>(value.toInt());
147 
148  value = description.value(QLatin1String("physicalSize"));
149  if (!value.isUndefined() && value.isObject()) {
150  QJsonObject physicalSizeObject = value.toObject();
151  value = physicalSizeObject.value(QLatin1String("width"));
152  if (!value.isUndefined() && value.isDouble())
153  m_physicalSize.setWidth(value.toInt());
154  value = physicalSizeObject.value(QLatin1String("height"));
155  if (!value.isUndefined() && value.isDouble())
156  m_physicalSize.setHeight(value.toInt());
157  }
158 
159 
160  value = description.value(QLatin1String("refreshRate"));
161  if (!value.isUndefined() && value.isDouble())
162  m_refreshRate = value.toDouble();
163 
164  value = description.value(QLatin1String("nativeOrientation"));
165  if (!value.isUndefined() && value.isDouble())
166  m_nativeOrientation = static_cast<Qt::ScreenOrientation>(value.toInt());
167 
168  value = description.value(QLatin1String("orientation"));
169  if (!value.isUndefined() && value.isDouble())
170  m_orientation = static_cast<Qt::ScreenOrientation>(value.toInt());
171 }
172 
#define value
[5]
QSizeF physicalSize() const override
QRect geometry() const override
int depth() const override
qreal refreshRate() const override
QDpi logicalBaseDpi() const override
Qt::ScreenOrientation orientation() const override
Qt::ScreenOrientation nativeOrientation() const override
QString name() const override
QDpi logicalDpi() const override
QImage::Format format() const override
QRect rawGeometry() const override
QEglFSEmulatorScreen(const QJsonObject &screenDescription)
Format
Definition: qimage.h:77
The QJsonObject class encapsulates a JSON object.
Definition: qjsonobject.h:56
QJsonValue value(const QString &key) const
The QJsonValue class encapsulates a value in JSON.
Definition: qjsonvalue.h:60
double toDouble(double defaultValue=0) const
Definition: qjsonvalue.cpp:705
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
constexpr void setWidth(int w) noexcept
Definition: qrect.h:408
constexpr void setX(int x) noexcept
Definition: qrect.h:242
constexpr QSize size() const noexcept
Definition: qrect.h:269
constexpr void setHeight(int h) noexcept
Definition: qrect.h:411
constexpr void setY(int y) noexcept
Definition: qrect.h:245
The QSizeF class defines the size of a two-dimensional object using floating point precision.
Definition: qsize.h:235
constexpr void setHeight(qreal h) noexcept
Definition: qsize.h:358
constexpr void setWidth(qreal w) noexcept
Definition: qsize.h:355
The QString class provides a Unicode character string.
Definition: qstring.h:388
ScreenOrientation
Definition: qnamespace.h:296
EGLOutputLayerEXT EGLint EGLAttrib value
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
unsigned int uint
Definition: qglobal.h:334
QPair< qreal, qreal > QDpi