Compile-time option for disabling high-DPI scaling
Even if QHighDpiScaling::isActive() returns false, there is a small overhead from calling functions and multiplying with 1.0. This change adds a QT_NO_HIGHDPISCALING #ifdef that replaces all conversion functions with empty inline functions. Task-number: QTBUG-46615 Change-Id: Idf85e1700e3adf7f7174c6fa3f5e1d006d74c826 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
parent
6c4bd85c1f
commit
62a56adfa6
@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_LOGGING_CATEGORY(lcScaling, "qt.scaling");
|
||||
|
||||
#ifndef QT_NO_HIGHDPISCALING
|
||||
static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO";
|
||||
static const char scaleFactorEnvVar[] = "QT_SCALE_FACTOR";
|
||||
static const char autoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR";
|
||||
@ -317,4 +318,5 @@ QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen)
|
||||
return platformScreen->geometry().topLeft();
|
||||
}
|
||||
|
||||
#endif //QT_NO_HIGHDPISCALING
|
||||
QT_END_NAMESPACE
|
||||
|
@ -62,6 +62,7 @@ class QScreen;
|
||||
class QPlatformScreen;
|
||||
typedef QPair<qreal, qreal> QDpi;
|
||||
|
||||
#ifndef QT_NO_HIGHDPISCALING
|
||||
class Q_GUI_EXPORT QHighDpiScaling {
|
||||
public:
|
||||
static void initHighDpiScaling();
|
||||
@ -464,7 +465,50 @@ QVector<T> toNativePixels(const QVector<T> &pointValues, const QWindow *window)
|
||||
}
|
||||
|
||||
} // namespace QHighDpi
|
||||
#else // QT_NO_HIGHDPISCALING
|
||||
class Q_GUI_EXPORT QHighDpiScaling {
|
||||
public:
|
||||
static inline void initHighDpiScaling() {}
|
||||
static inline void updateHighDpiScaling() {}
|
||||
static inline void setGlobalFactor(qreal) {}
|
||||
static inline void setScreenFactor(QScreen *, qreal) {}
|
||||
|
||||
static inline bool isActive() { return false; }
|
||||
static inline qreal factor(const QWindow *) { return 1.0; }
|
||||
static inline qreal factor(const QScreen *) { return 1.0; }
|
||||
static inline qreal factor(const QPlatformScreen *) { return 1.0; }
|
||||
static inline QPoint origin(const QScreen *) { return QPoint(); }
|
||||
static inline QPoint origin(const QPlatformScreen *) { return QPoint(); }
|
||||
static inline QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *) { return pos; }
|
||||
static inline QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *) { return pos; }
|
||||
static inline QDpi logicalDpi() { return QDpi(-1,-1); }
|
||||
};
|
||||
|
||||
namespace QHighDpi {
|
||||
template <typename T> inline
|
||||
T toNative(const T &value, ...) { return value; }
|
||||
template <typename T> inline
|
||||
T fromNative(const T &value, ...) { return value; }
|
||||
|
||||
template <typename T> inline
|
||||
T fromNativeLocalPosition(const T &value, ...) { return value; }
|
||||
template <typename T> inline
|
||||
T toNativeLocalPosition(const T &value, ...) { return value; }
|
||||
|
||||
template <typename T> inline
|
||||
T fromNativeLocalRegion(const T &value, ...) { return value; }
|
||||
template <typename T> inline
|
||||
T toNativeLocalRegion(const T &value, ...) { return value; }
|
||||
|
||||
template <typename T> inline
|
||||
T fromNativeScreenGeometry(const T &value, ...) { return value; }
|
||||
|
||||
template <typename T, typename U> inline
|
||||
T toNativePixels(const T &value, const U*) {return value;}
|
||||
template <typename T, typename U> inline
|
||||
T fromNativePixels(const T &value, const U*) {return value;}
|
||||
}
|
||||
#endif // QT_NO_HIGHDPISCALING
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QHIGHDPISCALING_P_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user