[Development] [HiDPI] Rethinking the scaling algorithm

Niccolò Belli darkbasic at linuxsystems.it
Tue Nov 8 15:57:40 CET 2016


Hi,
My laptop's monitor is a 13" with a 16:9 aspect ratio and a 3200x1800 
resolution. As you can see[1] the EDID[2] is perfectly correct.
QT computes the scaling factor using a formula like this: 
scaling_factor=qRound(yourDpi/96)
This is far from ideal in my opinion, because if we want to scale to 96 
logical PPI it means that on a 13" 16:9 screen we want to target a 1088x612 
logical resolution. In fact qRound(282.42/96) computes a 3x scaling factor 
for my laptop, which is not a scaling factor that *anybody* would like to 
have (except maybe my old grandfather with poor eyesight). In fact a 
logical resolution of *less* than 1088x612 (it's lesser because qRound 
actually rounded up the value) is too tiny even for a 13" screen and people 
would prefer a 2x scaling factor instead, which would give you a logical 
resolution of 1600x900 (instead of an useless 1067x600).

I have some suggestions to improve the current scaling algorithm:

1) Always round down. With your current formula a 145ppi screen gets scaled 
by a 2x factor, while every other toolkit (GTK3 for example[3]) starts 
scaling at 192ppi. This is also what people expect and it would return the 
correct 2x scaling factor for my laptop. So the formula should be 
scaling_factor=qRoundDown(yourDpi/96)

2) Expose an environmental variable to allow people to choose which logical 
PPI they want to target. Such a variable should default to 96ppi. In fact 
some people might have poor eyesight or might desire a different viewing 
distance and thus they would like to target a different logical PPI. So the 
formula should be scaling_factor=qRoundDown(yourDpi/EnvVar)

The current algorithm does not work well (this is a matter of fact), 
question is if we can improve it. I thought alot about it and I can't see 
any negative impact with my proposed solution, but obviously I would like 
to hear the opinions from other developers.

Niccolo' Belli

[1]http://www.edidreader.com/
[2]https://bpaste.net/show/e2f39fad5f5e
[3]https://wiki.gnome.org/HowDoI/HiDpi



More information about the Development mailing list