Closed Bug 1767142 Opened 3 years ago Closed 1 years ago

[wayland] Implement fractional-scale-v1 protocol support for fractional scaling

Categories

(Core :: Widget: Gtk, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: rmader, Assigned: emilio)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files)

The new protocol (still draft) at https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3511 allows compositors to tell us the optimal fractional scale to use with the already existing fractional scaling implementation (currently using the about:config value widget.wayland.fractional_buffer_scale). Having Firefox builds should help with the upstreaming process.

Should not be merged until the protocol is upstreamed.

Sorry, there was a problem with the detection of inactive users. I'm reverting the change.

Assignee: nobody → robert.mader
Status: NEW → ASSIGNED
Duplicate of this bug: 1420259
Summary: [wayland] Implement wp-surface-scale-v1 protocol support for fractional scaling → [wayland] Implement fractional-scale-v1 protocol support for fractional scaling
Attachment #9274550 - Attachment description: WIP: Bug 1767142 - [wayland] Implement wp-surface-scale-v1 protocol support for fractional scaling → WIP: Bug 1767142 - [wayland] Implement fractional-scale-v1 protocol support

Just updated the patch - it should work now if you use a compositor supporting the protocol (minus bugs). The about:config switch changed to a simple widget.wayland.fractional-scale.enabled bool.

Will need a bit more refining, then we should be able to land it.

Depends on: 1824552

Robert, how is that integrated with our current Gtk code? AFAIK Gtk uses fixed scales (1,2,3..) and then the frame buffer is scaled by compositor, right? So we paint only the fixed scales to the surfaces. So is there any benefit here or does it help somehow?

Flags: needinfo?(robert.mader)

(In reply to Martin Stránský [:stransky] (ni? me) from comment #7)

Robert, how is that integrated with our current Gtk code? AFAIK Gtk uses fixed scales (1,2,3..) and then the frame buffer is scaled by compositor, right? So we paint only the fixed scales to the surfaces. So is there any benefit here or does it help somehow?

This would be independent from GTK. As we create/control the (subsurface) buffer ourselves, we can use this protocol and vp_viewporter to determine an optimal buffer size which is both more performant and and many cases also sharper.

Quick example of bandwidth on a 1920x1080 @ 125% screen. The number of pixels painted on a fullscreen repaint:

  1. integer scaling: (1536 x 2) x (864 x 2) = 5308416
  2. fractional scaling: 1920 x 1080 = 2073600

2073600 / 5308416 = 0,390625 -> 60% reduction in pixel painted.

125% (and smaller values) are the most extreme though.

Flags: needinfo?(robert.mader)

KDE does actually allow you to pick a value as low as 105%

The fractional_scale_v1 protocol has been stabilised and released in wayland-protocols 1.32.

A few compositors already have support, albeit no stable releases yet.

A few compositors already have support, albeit no stable releases yet.

It was released in Plasma 5.27, no?

(In reply to equeim from comment #11)

A few compositors already have support, albeit no stable releases yet.

It was released in Plasma 5.27, no?

Yeah, it was

It's also supported in Gnome 44.

So mast of the Linux desktop space has support then

*most (wish this site had an edit feature...)

Robert, do you have any plans to rebase and maybe land the patch? I think having it in-tree at least in an experimental fashion would be good.

Alternatively I can try to poke. I added support for drawing scaled-down GTK widgets a while ago so I don't think the gtk integer scale would be an issue, necessarily.

Flags: needinfo?(robert.mader)

wp_fractional_scale_manager_v1 seems to be present on Gnome/Fedora 38.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #16)

Robert, do you have any plans to rebase and maybe land the patch? I think having it in-tree at least in an experimental fashion would be good.

Would love to, but unfortunately I'm quite busy (with related work in Mutter) atm :(

Alternatively I can try to poke. I added support for drawing scaled-down GTK widgets a while ago so I don't think the gtk integer scale would be an issue, necessarily.

Would love to see that!

Flags: needinfo?(robert.mader)

Ok, let me add it to my queue of things to poke at when I have the time :)

Flags: needinfo?(emilio)

Use C++ constructor/destructors to deal with MozContainer state, which makes
stuff a bit simpler to reason about, and a bit more correct.

For example we were relying on an std::vector<> allocated via calloc() being
correct, which seems to hold but it's UB and a bit sketchy.

This is a manually-rebased version of D145169, but with the protocol
header regenerated, various fixes and tweaks.

In particular we only check the pref once when asking for the protocol
now, the rest falls through from current_fractional_scale being 0.0.

I gave it a shot on KWin and stuff seems to work properly, but let's
keep it disabled by default for now and maybe enable on a separate bug.

Depends on D186198

Flags: needinfo?(emilio)
Assignee: robert.mader → emilio
Component: Graphics → Widget: Gtk
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1918c42903e1 [gtk] Simplify MozContainer state tracking. r=stransky https://hg.mozilla.org/integration/autoland/rev/9c5926a01415 [wayland] Implement fractional-scale-v1 protocol support for fractional scaling. r=stransky https://hg.mozilla.org/integration/autoland/rev/0d76ff7134f6 apply code formatting via Lando
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/13a48c068860 [gtk] Simplify MozContainer state tracking. r=stransky https://hg.mozilla.org/integration/autoland/rev/c01858a20255 [wayland] Implement fractional-scale-v1 protocol support for fractional scaling. r=stransky https://hg.mozilla.org/integration/autoland/rev/c97a1a56c617 apply code formatting via Lando
Status: ASSIGNED → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
Regressions: 1849109
Regressions: 1850114
No longer regressions: 1850114
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: