/**************************************************************************** ** ** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ******************************************************************************/ #include "qeglfsemulatorscreen.h" QT_BEGIN_NAMESPACE QEglFSEmulatorScreen::QEglFSEmulatorScreen(const QJsonObject &screenDescription) : QEglFSScreen(eglGetDisplay(EGL_DEFAULT_DISPLAY)) , m_id(0) { initFromJsonObject(screenDescription); } QRect QEglFSEmulatorScreen::geometry() const { return m_geometry; } QRect QEglFSEmulatorScreen::rawGeometry() const { return QRect(QPoint(0, 0), m_geometry.size()); } int QEglFSEmulatorScreen::depth() const { return m_depth; } QImage::Format QEglFSEmulatorScreen::format() const { return m_format; } QSizeF QEglFSEmulatorScreen::physicalSize() const { return m_physicalSize; } QDpi QEglFSEmulatorScreen::logicalDpi() const { return logicalBaseDpi(); } QDpi QEglFSEmulatorScreen::logicalBaseDpi() const { return QDpi(100, 100); } qreal QEglFSEmulatorScreen::refreshRate() const { return m_refreshRate; } Qt::ScreenOrientation QEglFSEmulatorScreen::nativeOrientation() const { return m_nativeOrientation; } Qt::ScreenOrientation QEglFSEmulatorScreen::orientation() const { return m_orientation; } uint QEglFSEmulatorScreen::id() const { return m_id; } QString QEglFSEmulatorScreen::name() const { return m_description; } void QEglFSEmulatorScreen::initFromJsonObject(const QJsonObject &description) { QJsonValue value; value = description.value(QLatin1String("id")); if (!value.isUndefined() && value.isDouble()) m_id = value.toInt(); value = description.value(QLatin1String("description")); if (!value.isUndefined() && value.isString()) m_description = value.toString(); value = description.value(QLatin1String("geometry")); if (!value.isUndefined() && value.isObject()) { QJsonObject geometryObject = value.toObject(); value = geometryObject.value(QLatin1String("x")); if (!value.isUndefined() && value.isDouble()) m_geometry.setX(value.toInt()); value = geometryObject.value(QLatin1String("y")); if (!value.isUndefined() && value.isDouble()) m_geometry.setY(value.toInt()); value = geometryObject.value(QLatin1String("width")); if (!value.isUndefined() && value.isDouble()) m_geometry.setWidth(value.toInt()); value = geometryObject.value(QLatin1String("height")); if (!value.isUndefined() && value.isDouble()) m_geometry.setHeight(value.toInt()); } value = description.value(QLatin1String("depth")); if (!value.isUndefined() && value.isDouble()) m_depth = value.toInt(); value = description.value(QLatin1String("format")); if (!value.isUndefined() && value.isDouble()) m_format = static_cast(value.toInt()); value = description.value(QLatin1String("physicalSize")); if (!value.isUndefined() && value.isObject()) { QJsonObject physicalSizeObject = value.toObject(); value = physicalSizeObject.value(QLatin1String("width")); if (!value.isUndefined() && value.isDouble()) m_physicalSize.setWidth(value.toInt()); value = physicalSizeObject.value(QLatin1String("height")); if (!value.isUndefined() && value.isDouble()) m_physicalSize.setHeight(value.toInt()); } value = description.value(QLatin1String("refreshRate")); if (!value.isUndefined() && value.isDouble()) m_refreshRate = value.toDouble(); value = description.value(QLatin1String("nativeOrientation")); if (!value.isUndefined() && value.isDouble()) m_nativeOrientation = static_cast(value.toInt()); value = description.value(QLatin1String("orientation")); if (!value.isUndefined() && value.isDouble()) m_orientation = static_cast(value.toInt()); } QT_END_NAMESPACE