Wayland's fractional scale and Fedora

Maxim Kartashev maxim.kartashev at jetbrains.com
Thu May 16 11:34:51 UTC 2024


Fedora 40 is a major Linux distro that supports Wayland's
fractional-scale-v1 protocol
(https://wayland.app/protocols/fractional-scale-v1), so I decided to
base my experiments with the true fractional scaling support for this
Wakefield project on such a system. In parenthesis, I was a bit
surprised that in order to be able to actually specify non-integer
scale, one has to execute a command in a terminal (gsettings set
org.gnome.mutter experimental-features
"['scale-monitor-framebuffer']"). Perhaps, it is a work in progress
affair?

After having implemented all the necessary protocols on the JDK side
(fractional-scale-v1, viewporter), the results were quite unexpected.
Instead of getting a sharper image at, say, 150%, the overall quality
seemed more blurry than before. Looking at screenshots at 2-3x, this
has become even more apparent. So for the moment I'm putting
fractional scaling support on hold and will only implement the basis
for it, i.e. the viewporter protocol.

Some data to better illustrate my expectation considering the same
150% scaling: currently the scale reported by the server to us will be
2x or 200%. So for a Swing window of 300x300 units we create a backing
buffer of 600x600 pixels and this buffer is then shared with the
Wayland server. The server (compositor) then must shrink it to 450x450
pixels before sending it to the screen to comply with 150% scaling.
Shrinking 600 pixels to 450 pixels may make the resulting picture
somewhat blurry, but probably not significantly more blurry. After
all, this transformation does not have to pull pixels out of thin air
unlike the opposite when an image is made larger than the original.

By employing the viewporter protocol and upon learning the actual
window scale from fractional-scale-v1, we create the backing buffer of
only 450x450 pixels now. And it seems that the job of the compositor
is way simpler now - the final transformation is that of identity,
i.e. a buffer pixel corresponds to a screen pixel 1:1.

I don't really understand how to experimentally verify that; the best
I could think of is to take a screenshot and look at it at 100% scale.
To my surprise, the screenshot size was 600x600. This may explain the
blurriness: if the compositor had to upscale the image to the closest
larger integer scale and then scale it back again by the factor of
0.75, the result could be expected to be more blurry. But this may
just be an artifact of screenshotting.

I wonder if our RedHat colleagues can provide any commentary?

P.S. Cursors in gnome applications are still scaled using the "old"
buffer scaling technique that only supports integer scale and do not
employ viewporter. Also work in progress?


More information about the wakefield-dev mailing list