[Development] [HiDPI] Rethinking the scaling algorithm

Niccolò Belli darkbasic at linuxsystems.it
Thu Nov 10 02:40:34 CET 2016


On mercoledì 9 novembre 2016 23:25:41 CET, Allan Sandfeld Jensen wrote:
> GTK has only just recently implemented HiDPI, much much later than Qt.
> What makes you think it is "working well for them"?

I think it's working well just because I didn't hear as many complaints as 
QT's, but may be as well because it still didn't receive as much testing.

> Since most of the common configuration of HiDPI screens are following Mac 
> standards, they have been designed to work at 2x scaling with 72DPI. We can 
> not ignore all the Apple style screens out there like 4k 27" screen for 
> instance. Which are specifically designed for 2x scaling. 
> 144DPI must cause 2x 
> scaling to follow what most HiDPI hardware have been designed for.

You're right, such monitor (which would be 82dpi once scaled) wouldn't 
benefit from rounding down, because it would get no scaling at all with my 
formula.

> What we need is a better tool and configuration for high-DPI 
> tablets, phones 
> and hybrids where the ideal virtual DPI is not 72 or 96 DPI.

Definitely yes, but I think we should also switch to a better formula which 
also takes into account monitors designed to work at ~140dpi once scaled. 
It doesn't mean that we shouldn't care for monitors engineered for 
different PPIs, it simply means that my point number one about rounding 
down wasn't correct and we still have to find another formula.

Trying to get a better one I took into account two monitors (monitor A is a 
27" 4K with 163.82 PPI and monitor B is a 13" 3200x1800 with 282.42 PPI) 
and I did some math to find a formula which gets the correct scaling (2x) 
for both.
To achieve this result the slightest modification to the current formula 
that you can do is: scaling_factor=qRound(yourDpi/121.02 + 0.156) which 
gets qRound(1.51)=2 for monitor A and qRound(2.49)=2 for monitor B. This 
formula still works quite well if you need to scale higher than 2x, but the 
safety margin for the rounding operation is quite small.
So I increased the safety margin getting 
scaling_factor=qRound(yourDpi/160.27 + 0.728) which gets qRound(1.75)=2 for 
monitor A and qRound(2.49)=2 for monitor B (currently we get a 3x scaling 
for monitor B so even 2.49 is a great improvement). Unfortunately it 
doesn't work as well if you need to scale higher than 2x. Knowing which 
monitor is the worst case scenario for case A (not-so-hi-dpi 2x scaling) 
and which one for case B (very-high-dpi 2x scaling) would help alot finding 
the best compromise. If you have better ideas I'm all ears.



More information about the Development mailing list