Skip to content
Verified Commit bc9119a9 authored by snooxx 💤's avatar snooxx 💤
Browse files

Fix HiDPI rendering in game views

Although HiDPI rendering of various UI elements in KSudoku was mostly
fixed over the last years (e.g. via 2293c8c5 in KSudoku and through
patches to various libraries), the main game canvas would still show
pixelated in HiDPI mode.

While QGraphicsScene already uses `qreal` for its coordinate system,
some dimensions and offsets used for rendering sprites as well as
functions passing `int` sizes around were still missing HiDPI
enablement. By implementing the necessary changes, rendering quality can
be improved substantially.

Notes:
    - In selected places rounding is employed strategically to avoid gaps
    with some themes.
    - The general fuzziness when zooming 3D content is still there and not
    specific to HiDPI.

Test Plan:
    - Run KSudoku in HiDPI mode, e.g. with `QT_SCALE_FACTOR=1.9 ksudoku`.
    - Check all themes, as each can highlight different rendering issues.
    - Test every game variant, since lots of them have custom rendering of
    elements.
    - Try cell markers too (Shift + number/letter key or right click).
    - Watch out for hover remnants and rendering gaps, in particular for
    slightly differing fractional scaling factors and when slowly
    increasing window size.

Porting note: While this commit is based on a cherry pick of commit
cdaba58a, some parts were substantially
rewritten. Improvements include:
    - Elimination of generic `qApp->devicePixelRatio()` calls, instead the
    dpr is taken directly from the associated scene.
    - Better separation between plain rendering and dpr logic.
    - Less layout shifts compared to dpr=1.0 upscaling.
    - Solved one of the remaining fractional scaling hover remnants.

(cherry picked from commit f3bfbb14)
parent e12df85b
Pipeline #643688 passed with stages
in 6 minutes and 8 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment