After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791405 - Implement wp_viewporter protocol
Implement wp_viewporter protocol
Status: RESOLVED OBSOLETE
Product: mutter
Classification: Core
Component: wayland
3.27.x
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on: 792203
Blocks:
 
 
Reported: 2017-12-08 18:36 UTC by RobertMader
Modified: 2018-04-26 15:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
implement wp_viewporter based on old patches (WIP) (27.94 KB, patch)
2017-12-08 18:36 UTC, RobertMader
none Details | Review
implement wp_viewporter based on old patches (WIP) (24.93 KB, patch)
2017-12-08 18:50 UTC, RobertMader
none Details | Review
implement wp_viewporter (32.28 KB, patch)
2018-01-06 15:31 UTC, RobertMader
none Details | Review
implement wp_viewporter (30.72 KB, patch)
2018-01-08 13:45 UTC, RobertMader
none Details | Review
implement wp_viewporter (30.11 KB, patch)
2018-01-13 15:21 UTC, RobertMader
none Details | Review

Description RobertMader 2017-12-08 18:36:33 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
Comment 1 RobertMader 2017-12-08 18:50:29 UTC
Created attachment 365267 [details] [review]
implement wp_viewporter based on old patches (WIP)

Some patch a bit cleaner
Comment 2 RobertMader 2017-12-08 18:58:18 UTC
Note: it doesn't yet let me start a working gnome-shell, so don't bother trying just yet.
Comment 3 RobertMader 2017-12-11 21:43:30 UTC
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
Comment 4 RobertMader 2017-12-15 12:54:43 UTC
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.
Comment 5 Jonas Ådahl 2017-12-18 07:50:28 UTC
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.
Comment 6 Jonas Ådahl 2017-12-18 09:09:13 UTC
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".
Comment 7 RobertMader 2017-12-21 16:34:46 UTC
@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.
Comment 8 RobertMader 2017-12-28 15:59:01 UTC
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
Comment 9 RobertMader 2018-01-04 17:56:24 UTC
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 :)
Comment 10 RobertMader 2018-01-05 17:13:28 UTC
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.
Comment 11 RobertMader 2018-01-06 15:31:51 UTC
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.
Comment 12 RobertMader 2018-01-08 13:45:23 UTC
Created attachment 366491 [details] [review]
implement wp_viewporter

Reupload, don't include patch from bug 792203
Comment 13 RobertMader 2018-01-13 15:21:29 UTC
Created attachment 366767 [details] [review]
implement wp_viewporter

updated against bug 792203 and git master
Comment 14 RobertMader 2018-04-26 15:13:31 UTC
This has moved to gitlab: https://gitlab.gnome.org/GNOME/mutter/issues/132