diff options
| author | Eirik Aavitsland <[email protected]> | 2024-05-07 16:22:53 +0200 |
|---|---|---|
| committer | Eirik Aavitsland <[email protected]> | 2024-05-30 20:51:46 +0200 |
| commit | a5953d20e27ab73774058dd06ac514f9310a41e8 (patch) | |
| tree | d57ed79a39f7430bfa5d8f1495e9ad2e6a11a249 /src/opengl/qopenglpaintdevice.cpp | |
| parent | 890c270b9b27de5075bda668dbe8117649673b05 (diff) | |
Add QPaintDevice metric query to get precise fractional DPR value
For compatibility reasons, QPaintDevice needs to query subclasses for
device metrics as int values. To report fractional DPR values, they
have been multiplied with a large constant and divided back
afterwards. However, the loss of accuracy introduced by this, though
tiny, could still lead to rounding errors and painting artefacts when
the values where multiplied up for large coordinates.
Avoid this issue by adding a metric query that transports the full
floating point value encoded as two ints.
[ChangeLog][QtGui] Added new QPaintDevice metrics for querying
fractional device pixel ratios with high precision. Custom paintdevice
classes that support fractional DPRs are recommended to implement
support for these queries in metric(). Others can ignore them.
Fixes: QTBUG-124342
Change-Id: Ia6fa46e68e9fe981bdcbafb41daf080b4d1fb6d7
Reviewed-by: Tor Arne Vestbø <[email protected]>
Diffstat (limited to 'src/opengl/qopenglpaintdevice.cpp')
| -rw-r--r-- | src/opengl/qopenglpaintdevice.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/opengl/qopenglpaintdevice.cpp b/src/opengl/qopenglpaintdevice.cpp index fbc54c46fb9..aaee7f18fe0 100644 --- a/src/opengl/qopenglpaintdevice.cpp +++ b/src/opengl/qopenglpaintdevice.cpp @@ -247,6 +247,10 @@ int QOpenGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const return d_ptr->devicePixelRatio; case PdmDevicePixelRatioScaled: return d_ptr->devicePixelRatio * QPaintDevice::devicePixelRatioFScale(); + case PdmDevicePixelRatioF_EncodedA: + Q_FALLTHROUGH(); + case PdmDevicePixelRatioF_EncodedB: + return QPaintDevice::encodeMetricF(metric, d_ptr->devicePixelRatio); default: qWarning("QOpenGLPaintDevice::metric() - metric %d not known", metric); |
