From b73a5a4da0924f383a3103e8ef52275afa61b8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=93=81=E9=BE=99?= Date: Mon, 19 Jun 2023 14:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8F=8C=E5=B1=8F=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E9=9D=A2=E9=94=81=E5=B1=8F=E5=BC=82=E5=B8=B8?= =?UTF-8?q?patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/corelib/global/archdetect.cpp | 4 ++++ src/corelib/global/qprocessordetection.h | 7 +++++++ src/gui/kernel/qhighdpiscaling.cpp | 13 +++---------- src/gui/kernel/qhighdpiscaling_p.h | 4 ++-- src/gui/kernel/qscreen.cpp | 6 ++++++ src/gui/painting/qtransform.cpp | 2 +- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp index 1d00b7f5..8ca6efef 100644 --- a/src/corelib/global/archdetect.cpp +++ b/src/corelib/global/archdetect.cpp @@ -59,6 +59,10 @@ # define ARCH_PROCESSOR "x86_64" #elif defined(Q_PROCESSOR_IA64) # define ARCH_PROCESSOR "ia64" +#elif defined(Q_PROCESSOR_LOONGARCH_64) +# define ARCH_PROCESSOR "loongarch64" +#elif defined(Q_PROCESSOR_LOONGARCH) +# define ARCH_PROCESSOR "loongarch" #elif defined(Q_PROCESSOR_MIPS_64) # define ARCH_PROCESSOR "mips64" #elif defined(Q_PROCESSOR_MIPS) diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index a6ead549..2a0382c7 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -228,6 +228,13 @@ # define Q_PROCESSOR_WORDSIZE 8 // Q_BYTE_ORDER not defined, use endianness auto-detection +#elif defined(_loongarch) || defined(__loongarch__) +# define Q_PROCESSOR_LOONGARCH +# if defined(__loongarch64) +# define Q_PROCESSOR_LOONGARCH_64 +# define Q_PROCESSOR_WORDSIZE 8 +# endif + /* MIPS family, known revisions: I, II, III, IV, 32, 64 diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 85ff58c1..ebd16d08 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -396,10 +396,7 @@ qreal QHighDpiScaling::roundScaleFactor(qreal rawFactor) } // Check application object if no environment value was set. - if (scaleFactorRoundingPolicy == Qt::HighDpiScaleFactorRoundingPolicy::Unset) { - scaleFactorRoundingPolicy = QGuiApplication::highDpiScaleFactorRoundingPolicy(); - } else { - // Make application setting reflect environment + if (scaleFactorRoundingPolicy != Qt::HighDpiScaleFactorRoundingPolicy::Unset) { QGuiApplication::setHighDpiScaleFactorRoundingPolicy(scaleFactorRoundingPolicy); } } @@ -460,8 +457,6 @@ QDpi QHighDpiScaling::effectiveLogicalDpi(const QPlatformScreen *screen, qreal r policyText.constData(), values.constData()); } } - if (dpiAdjustmentPolicy == DpiAdjustmentPolicy::Unset) - dpiAdjustmentPolicy = DpiAdjustmentPolicy::UpOnly; } // Apply adjustment policy. @@ -539,7 +534,7 @@ void QHighDpiScaling::updateHighDpiScaling() ++i; } } - m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive; + m_active = m_globalScalingActive || m_usePixelDensity; } /* @@ -684,9 +679,7 @@ QDpi QHighDpiScaling::logicalDpi(const QScreen *screen) return QDpi(96, 96); if (!m_usePixelDensity) { - const qreal screenScaleFactor = screenSubfactor(screen->handle()); - const QDpi dpi = QPlatformScreen::overrideDpi(screen->handle()->logicalDpi()); - return QDpi{ dpi.first / screenScaleFactor, dpi.second / screenScaleFactor }; + return screen->handle()->logicalDpi(); } const qreal scaleFactor = rawScaleFactor(screen->handle()); diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 5b02c5d6..e4714c99 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -159,12 +159,12 @@ inline QVector2D scale(const QVector2D &value, qreal scaleFactor, QPointF /* ori inline QPointF scale(const QPointF &pos, qreal scaleFactor, QPointF origin = QPointF(0, 0)) { - return (pos - origin) * scaleFactor + origin; + return (pos - origin) * scaleFactor + origin * scaleFactor; } inline QPoint scale(const QPoint &pos, qreal scaleFactor, QPoint origin = QPoint(0, 0)) { - return (pos - origin) * scaleFactor + origin; + return (pos - origin) * scaleFactor + origin * scaleFactor; } inline QRect scale(const QRect &rect, qreal scaleFactor, QPoint origin = QPoint(0, 0)) diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 990272b0..a5fb80a5 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -410,6 +410,12 @@ QSize QScreen::availableSize() const QRect QScreen::geometry() const { Q_D(const QScreen); + + if (d->platformScreen) + { + return QHighDpi::fromNativePixels(d->platformScreen->geometry(), this); + } + return d->geometry; } diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index e86aff1c..9d281f66 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1568,7 +1568,7 @@ QRegion QTransform::map(const QRegion &r) const } QPainterPath p = map(qt_regionToPath(r)); - return p.toFillPolygon(QTransform()).toPolygon(); + return p.toFillPolygon().toPolygon(); } struct QHomogeneousCoordinate