High-DPI: Set the minimum scale factor to 1
Avoid painting errors with dpr < 1, also for the PassThrough mode. This limits the minimum high-dpi scale factor to 1, for the code path which determines the scale factor based on screen DPI. Task-number: QTBUG-89948 Change-Id: I14b3f130f0ae141d5f05c87437f926a9f76d1dec Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit ee409e6f0cab4aa051f75f7c7116d4b607d137fc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
93f46f303e
commit
667d0eb3c5
@ -436,11 +436,9 @@ qreal QHighDpiScaling::roundScaleFactor(qreal rawFactor)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't round down to to zero; clamp the minimum (rounded) factor to 1.
|
// Clamp the minimum factor to 1. Qt does not currently render
|
||||||
// This is not a common case but can happen if a display reports a very
|
// correctly with factors less than 1.
|
||||||
// low DPI.
|
roundedFactor = qMax(roundedFactor, qreal(1));
|
||||||
if (scaleFactorRoundingPolicy != Qt::HighDpiScaleFactorRoundingPolicy::PassThrough)
|
|
||||||
roundedFactor = qMax(roundedFactor, qreal(1));
|
|
||||||
|
|
||||||
return roundedFactor;
|
return roundedFactor;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ private slots:
|
|||||||
void initTestCase();
|
void initTestCase();
|
||||||
void qhighdpiscaling_data();
|
void qhighdpiscaling_data();
|
||||||
void qhighdpiscaling();
|
void qhighdpiscaling();
|
||||||
|
void minimumDpr();
|
||||||
void noscreens();
|
void noscreens();
|
||||||
void screenDpiAndDpr_data();
|
void screenDpiAndDpr_data();
|
||||||
void screenDpiAndDpr();
|
void screenDpiAndDpr();
|
||||||
@ -223,6 +224,20 @@ void tst_QHighDpi::screenDpiAndDpr()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QHighDpi::minimumDpr()
|
||||||
|
{
|
||||||
|
QList<qreal> dpiValues { 40, 60, 95 };
|
||||||
|
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
|
||||||
|
for (QScreen *screen : app->screens()) {
|
||||||
|
// Qt does not currently support DPR values < 1. Make sure
|
||||||
|
// the minimum DPR value is 1, also when the screen reports
|
||||||
|
// a low DPI.
|
||||||
|
QCOMPARE(screen->devicePixelRatio(), 1);
|
||||||
|
QWindow window(screen);
|
||||||
|
QCOMPARE(window.devicePixelRatio(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QHighDpi::noscreens()
|
void tst_QHighDpi::noscreens()
|
||||||
{
|
{
|
||||||
// Create application object with a no-screens configuration (should not crash)
|
// Create application object with a no-screens configuration (should not crash)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user