GNOME Bugzilla – Bug 791405
Implement wp_viewporter protocol
Last modified: 2018-04-26 15:18:09 UTC
Created attachment 365266 [details] [review] implement wp_viewporter based on old patches (WIP) Hello, I'd like to see wp_viewporter to be implemented in mutter and did some first work, based on old patches by Jasper St. Pierre which basically have everything we need. See: https://mail.gnome.org/archives/commits-list/2014-November/msg00799.html and https://mail.gnome.org/archives/commits-list/2014-November/msg00800.html It's not done yet, but the patches build against mutter-3.26.2 and have the stabilized wp_viewporter protocol instead of wl_scaler. I'm happy for feedback and suggestions :) Known issues: - some code should get moved from meta-wayland-surface-c to meta-wayland-viewporter.c/h
Created attachment 365267 [details] [review] implement wp_viewporter based on old patches (WIP) Some patch a bit cleaner
Note: it doesn't yet let me start a working gnome-shell, so don't bother trying just yet.
Little update 1. here's the my github branch with the current code: https://github.com/treba123/mutter 2. it runs properly now, doesn't crash the session. Only destroy_wl_viewport still crashes unless I comment out it's content 3. when testing with weston-scaler example client, two out of four modes display things right (n and d mode), while the other two display something a bit different from weston. Anyway, things start to work out just fine
Another update: seems to be a little more more work than I thought. The initial patches linked above were most likely just adoptions of the weston implementation, so I'm now trying copy as much as possible from the current one. Turns out that in weston, the viewport also contains scaling (the hidpi stuff, in numerical steps) and transforming (rotating in 90 degree steps). This totally makes sense but also means we have to touch more code.
I haven't looked at how the buffer scaling is implemented, just some things to keep in mind: 1) We have two "modes" in which we draw in: scaled stage views, or scaled window actors. With scaled stage views, window sizes (i.e. actor size) have the same coordinate space as the clutter stage. A window that is 100x100 always has the clutter actor size 100x100 no matter what scale a monitor has. This feature is only enabled if you set the 'scale-monitor-framebuffer' experimental feature (see the org.gnome.mutter experimental-features gsetting). With scaled window actors, the above is only true for scale=1 monitors. If you have a HiDPI monitor with scale=2, then the window (thus surface) size is doubled when the window is positioned on the scale=2 monitor. This is still the default mode. 2) The wayland protocol implementation should be added to a new file, probably "src/wayland/meta-wayland-viewporter.c". Any changes to MetaShapedTexture, MetaSurfaceActor etc must be windowing system agnostic.
Other notes: * You should use the XML file installed by wayland-protocols directly, thus not copy it into the mutter repository. * When attaching patches, either use "git-bz" for doing it automatically, or attach the result of "git format-patch".
@Jonas Ådahl: thanks for the feedback, I'll keep that in mind, especially with the experimental scaling. Apart from that a little update: after some more tinkering (found here: https://github.com/treba123/mutter/commit/751e35dd32890bc4f7d3056f4ce3c422183a3fba), I got the viewporter working for statical content in combination with scaling. That means weston-scaler now displays everything correctly in all modes. But partial redrawing and buffer damage detection does not yet work correctly, making the output of 'weston-simple-damage --use-viewport' not update correctly so far. Further more the patches are still a bit raw. I'll try to move everything into the correct places.
Little after-christmas update: with the latest commit (1), surface-damage now matches buffer-damage, making the weston-simple-damage demo work as expected. That means that both weston clients that utilize viewport are now fully functional with the code. What works so far: - output of weston demo clients (weston-scaler, weston-simple-damage --use-viewport) in all modes I tested What not: - input translation (not tested so far, any demo clients for that?) - check for gl texture filter, so far linear usually gets used - blended-region detection when a source rectangle is used in combination with scale (weston-scaler -b), thus always triggering a full repaint. If no scale is set, things work as expected, only repainting the damaged region. 1: https://github.com/treba123/mutter/commit/d26649dd6b3a9e956d67299e65a0ed3db3740eb8
Update: I did some cleanups and moved some code in its own files and fixed a bug of the build system not building stable protocols (https://bugzilla.gnome.org/show_bug.cgi?id=792203). So the code is getting into shape and I'd be happy about any more feedback :)
Update concerning input: as of weston, it doesn't do any mouse input translation. Not sure if that's right, though :( Anyway, that makes this implementation being feature complete as far as the reference implementation goes.
Created attachment 366423 [details] [review] implement wp_viewporter This implement wp_viewporter. It's basically feature complete, but some details might be missing. For example I'm not yet sure whether mouse coordinate translation and window size should be handled by this or are out of scope. Rebased agains git-master and hopefully formated correctly.
Created attachment 366491 [details] [review] implement wp_viewporter Reupload, don't include patch from bug 792203
Created attachment 366767 [details] [review] implement wp_viewporter updated against bug 792203 and git master
This has moved to gitlab: https://gitlab.gnome.org/GNOME/mutter/issues/132