Commit graph

8410 commits

Author SHA1 Message Date
Derek Foreman 71cf2783d6 desktop-shell: Fix stuck panel
Ever since d611ab24 the panel surface's frame callback gets lost and the
panel stops updating after its first draw.

Fix this by dirtying the geometry in configure_static_view() after it
changes the layer list, since the layer list is considered part of
geometry.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-01 09:34:17 +00:00
Philipp Zabel c448819b37 backend-wayland: do not try to release uninitialized seat
Do not call weston_seat_release() if Weston aborts before
weston_seat_init() could be called. This fixes a possible
segfault due to uninitialized list traversal in the error
path.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-11-30 14:11:22 +01:00
Pekka Paalanen fdaf4cf320 libweston: deprecate weston_screenshooter_shoot()
Nothing in-tree uses this function, and its functionality has been
replaced with the weston-output-capture protocol extension which is
implemented in libweston core.

Users of this function should migrate to
weston_compositor_add_screenshot_authority() and replace custom
screenshooting protocols with weston-output-capture.xml installed by
libweston.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:12:32 +02:00
Pekka Paalanen 17df553bf3 compositor: remove weston-screenshooter protocol
There are no internal users left for this protocol, they have been
migrated to the new weston-output-capture protocol. There are no
external users, because this protocol was private and never installed.

Remove this dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:12:32 +02:00
Pekka Paalanen 949b2eb751 clients: rewrite screenshot.c for new protocol
The functionality of this screenshooting helper client is kept exactly
the same as before: if you have multiple outputs, some transformed, some
scale, in any layout, this will create a "multi-image" where the
framebuffer (the physical image) of each output is pasted into a row of
images in the order the outputs were advertised thrugh wl_registry.
Output transform or scale are not accounted for. If you have a monitor
rotated sideways, the screenshot will have the image of that monitor
reverse-sideways.

Otherwise the client is almost completely re-written, so trying to read
the diff is not that useful.

The old screenshooting protocol is replaced with the new
weston-output-capture protocol. This makes it unnecessary to listen for
wl_output information (since we do not handle output transform or scale
anyway).

The buffer sizes and formats are dictated by the compositor, which also
means we cannot hardcode the format. Hence, use Pixman for the blitting,
in case it needs to do format conversion. It is good to get rid of
hand-crafted pixel data manipulation code too.

For that reason we also need a pixel format database to convert between
DRM fourcc, wl_shm and Pixman codes. We link to libweston to borrow its
database instead of inventing another partial copy of it. It's weird to
use compositor library private API in a client, but better than the
alternative.

The original code had no tear-down code at all. Now, if everything
succeeds, the program ends with no unfreed memory according to ASan. If
something fails, it still YOLO's it (doesn't free stuff). That's how far
my pedantry carried.

I also did not bother taking output transform or scale into account,
since the old code did not either. It would be nice to create a seamless
image of the desktop with shots rotated and scaled to align, in the max
scale over all outputs. Meh.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:12:32 +02:00
Pekka Paalanen 93a94e767b compositor: authorize new screenshooter protocol
This is necessary in order to convert clients/screenshot.c into the
protocol.

We authorize a client the same way as before: if the wl_client is the
one we spawned, it's allowed.

Allowing screenshots on --debug was authorized by an earlier patch in
compositor/main.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:10:33 +02:00
Pekka Paalanen 849b87e285 tests: rewrite screenshooting to use new protocol
Migrate the tst suite to using the new screenshooting protocol. This
ensures the new protocol and implementation work, and removes a user of
the old protocol so that the old protocol can be removed in the future.

Now that the compositor chooses the pixel format,
capture_screenshot_of_output() needs to convert to the expected format
in the tests when necessary.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:10:33 +02:00
Pekka Paalanen e3046b129c tests: add output-capture-protocol test
For exercising various code paths in the server side protocol
implementation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:10:30 +02:00
Pekka Paalanen c93b18ea54 tests: use pixel-formats.h in create_shm_buffer()
Instead of starting yet another hand-crafted pixel format mapping table,
use the one we have.

Following patches want to be able to create XRGB8888 buffers, and later
even other formats.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen e40a7eae67 compositor: make new screenhots free for all on --debug
Replicating the policy of the old screenshooting interface, allow all
screenshot to anyone with the new interface as well when --debug is
used.

Looks like there was one stray trailing space in unrelated code that my
editor deleted. Better this way.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen f60c9cc1e9 gl-renderer: implement output capture
This services output capture tasks for the 'framebuffer' and 'full
framebuffer' pixel sources.

Both pixel sources come from the same source: the EGLSurface. The only
difference is the area. The EGLSurface contains the borders used for
output decorations, hence 'full framebuffer' is possible to capture.

We use GL_ANGLE_pack_reverse_row_order extension to make glReadPixels
return the image data in the layout we need for wl_shm buffers directly.
Without the extension we have to flip manually.

Another extension to the same effect is MESA_pack_invert, but this is
not specified for GL ES. It also uses a different token value, so it
cannot be directly substituted even if supported.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen 0c8c2c4016 pixman-renderer: implement output capture
This services output capture tasks for the 'framebuffer' and 'blending'
pixel sources.

Just like the old screenshooting path, the 'framebuffer' pixel source is
the hardware buffer, whether a shadow is used or not. This may not be
the best for performance, but you do get the real framebuffer contents.
Maybe it's rgb565, or even less.

When the shadow buffer is used, I realized it is effectively the same as
the intermediate blending buffer in GL-renderer when color management is
used. Pixman-renderer does non-linear blending only, so the shadow
buffer is in the blending space. The shadow buffer is also always 8 bpc
regardless of the hardware framebuffer, so the read-back may be
different from the hardware framebuffer. Read-back from the shadow is
optimal for performance, but not what the hardware gets.

'full-framebuffer' source cannot yet be implemented, because backends do
not tell Pixman-renderer about the margins where the wayland-backend
blits the output decorations. The target "hardware" buffer handed to
pixman-renderer does not allow accessing the decorations area.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen c7f5de6d63 libweston: add pixel_format_get_shm_format()
This will be useful for client code that wants to create a wl_shm buffer
with a DRM format code.

The test suite will be using this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen 3700c78131 libweston: implement new screenshooting protocol base
This implements the basics of the new screenshooting protocol. The
actual pixel operations will be implemented separately in the renderers
and DRM-backend.

See the previous commit "protocol: new screenshooter protocol" for why.

If DRM-backend needs more from weston_capture_task when it implements
writeback screenshooting, it will be easy to add user_data or expose
weston_capture_task::link for the backend to use. Those were not added
yet because it is uncertain what is actually needed.

The DRM-backend no-damage optimization requires special handling here as
well. See also 7f1a113c89 .

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen d0eca43b9b protocol: new screenshooter protocol
This is a completely new screenshooting protocol designed to support:
- color management testing by adding the "blending" source
- KMS testing by adding the "writeback" source
- output decorations testing by adding the "full_framebuffer" source
- proper buffer size negotiation instead of guessing from wl_output
- compositor chosen pixel format, primarily for "blending" source
- proper indication of screenshot failure
- dmabuf target buffers, linear only

This new protocol should be good enough to publish as a Weston public
extension. Hence install it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Derek Foreman ca6f30d5de libweston: Fix comment
We now depend on the matrices in weston_view being correct even when the
transform isn't enabled.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-28 10:32:44 +00:00
Derek Foreman 2952ea6379 matrix-transform-test: Add additional tests
Add tests to validate that weston_matrix_to_transform() works properly
on the matrices generated by weston_surface_build_buffer_matrix() and
weston_output_update_matrix()

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman fb20fe9b03 compositor: Cache filtering decision in paint node
Instead of basing this on simple checks, we can test the matrix. This
should result in more opportunistically picking fast nearest neighbour
filtering when it won't result in visible distortion.

For now we only use this in the gl renderer, as paint nodes aren't
plumbed into the pixman renderer yet.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman 021fdf4244 backend-drm: Analyze transformation chain to check if it's supported
Instead of bailing based on our loosely tracked matrix "type" (that won't
recognize when an operation is reversed by its inverse) use the new
weston_matrix_to_transform to determine if the matrix reasonably matches.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman d14753e80c libweston: Add function to create a view's buffer to output matrix
This can be helpful in testing if a paint node needs linear vs nearest
neighbour filtering, or if a view can be placed on a plane.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman 92a9860e1d libweston: Add function to find the output transform of a matrix
When we build up a matrix from a series of operations, it's very useful
to know if the combined operations still result in something that matches
a wl_output_transform.

This adds a function to test if a matrix leads to a standard output
transform, and returns the transform if it does.

Tests are provided that check if complex series of operations return
expected results - the weston_matrix_needs_filtering function is tested
at the same time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman 0e2136df7b libweston: Add a function to test if transformed images need filters
If a transformation matrix causes a scale, a rotation not a multiple of 90
degrees or a non-integral translation then textures rendered with
it would benefit from bilinear filtering.

This test is done in a lazy fashion by examining elements of the matrix
to check for a simple pattern that indicates these conditions are met.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:25:53 -06:00
Derek Foreman 061c2b7382 desktop-shell: Update view transform when resizing windows
After commit 2dc8680d71 this started crashing. We need to update the
view transform here too.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-24 15:59:26 -06:00
Philipp Zabel 133417b016 backend-vnc: Add user authentication
Let VNC clients authenticate using the local username and password of
the user weston is running as. To avoid transmitting the password in
cleartext, make TLS security mandatory.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2022-11-23 16:58:48 +01:00
Philipp Zabel 0733c8f571 libweston: Add user authentication support via PAM
Add user authentication support for remote backends via PAM.
This requires a configuration file /etc/pam.d/weston.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2022-11-23 16:58:48 +01:00
Philipp Zabel 1a027e63cb backend-vnc: enable TLS support
Add TLS key and certificate parameters to enable encryption support.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-11-23 11:04:19 +01:00
Derek Foreman 9a386f5de5 fullscreen-shell: Use center_on_output helper
Simplify code a tiny bit by using the existing shell-helper function.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-22 12:25:19 +02:00
Derek Foreman 0108f979d1 libweston: Add more asserts for dirty transform
A couple of additional assert()s for transforms being dirty in places
where it could lead to unexpected results.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-17 15:36:23 -06:00
Derek Foreman d347e37be4 libweston: change div by 0 behaviour in coordinate conversion
Let's simplify this code by asserting, and letting it explode naturally
(return Inf, possibly SIGFPE depending on external factors) if compiled
NDEBUG, instead of a contained explosion (safely returning 0).

If this actually happens it's Really Bad, so we'd like to catch is ASAP,
especially in CI.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-14 16:05:46 -06:00
Derek Foreman 8bf90010dd libweston: always use the transform matrix for coordinate conversion
We always set it up correctly, even if transforms are disabled. The code
is simpler if we always use the matrix instead of having two cases.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-14 16:05:46 -06:00
Derek Foreman 2dc8680d71 libweston: assert when transforming for views with dirty transforms
If the view transform is dirty it might be incorrect. Also, we normally
set up the view transform matrix properly regardless of whether the
transform is enabled or not - but if we've never run
weston_view_update_transform() it will be all zeros.

This is a step towards removing view->transform.enabled checks and just
using the transform matrix in all cases.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-14 16:05:46 -06:00
Derek Foreman d611ab24fd libweston: Update view transforms more often
These places all eventually lead to calling weston_view_to_global_float()
or weston_view_from_global_float() on a view with a dirty transform.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-14 16:05:46 -06:00
Derek Foreman d3b74daabd data-device: Fix coordinate conversion
I inverted the direction of this transform when I stopped doing it from
weston_compositor_pick_view()

Fixes 4d141a788

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-10 09:01:20 -06:00
Derek Foreman bbd707d9bc input: fix surface jump test
There are two problems here, one is that the surface jump logic only makes
sense if the view remains the same.

The more important fix is that pointer coordinates are in global coordinates
and we want view coordinates, so this test was always wrong and led to an
xdg ping storm due to spurious focus changes.

Fixes 4d141a788

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-10 09:00:26 -06:00
Derek Foreman 9b7402ece9 input: Don't test uninitialized variables
weston_pointer_move() can change the pointer->focus, so we have to ensure
we're only testing old_sx and old_sy if we had a focus set before that
point.

Fixes 9b5a525a3d

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-10 08:12:53 -06:00
Marius Vlad bf0c99f519 libweston/desktop, desktop-shell: Add getters for pending state
This introduces a few getters to retrieve the pending state from
libweston-desktop, now just libweston, and makes use of it,
specifically get_pending_maximized to avoid sending invalid
dimensions to the client in the particular use case
set_maximized/unset_fullscreen.

These pending state getters are useful to query/poke a not-applied
yet state, and could be useful where we don't have a buffer attached
where the client might be set-up as maximized, but internally libweston
hasn't yet applied that pending state.

Fixes #645

Suggested-by: Morgane Glidic <sardemff7+git@sardemff7.net>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-10 13:06:07 +02:00
Tran Ba Khang(MS/EMC31-XC) 91750cdbd4 hmi-controller: switch to listening the shell destroy signal
Listening the shell destroy instead of compositor destroy signal.
This show how to in case the controller depends on shell resource.
The order destroying had changed in this commit, the controller
is destroyed first now

Signed-off-by: Tran Ba Khang(MS/EMC31-XC) <Khang.TranBa@vn.bosch.com>
2022-11-10 11:47:05 +02:00
Tran Ba Khang(MS/EMC31-XC) 9fa161ed09 hmi-controller: add missing removals of surface listeners
The surface listeners must remove when hmi-controller destroying.
To avoid to use after free.

Suggested-by: Marius Vlad <marius.vlad@collabora.com>

Signed-off-by: Tran Ba Khang(MS/EMC31-XC) <Khang.TranBa@vn.bosch.com>
2022-11-10 11:46:58 +02:00
Tran Ba Khang(MS/EMC31-XC) dea53c33ea ivi-shell: add new signal to notify ivi shell destroying
In the case the controlelrs are depended on ivi-shell resource,
it must be destroy before the ivi shell destroy. To do this,
add new ivi shell destroy signal on ivi shell, emit it on
the begining of the shell destroying

Suggested-by: Harsha M M <harsha.manjulamallikarjun@in.bosch.com>
Suggested-by: Michael Olbrich <m.olbrich@pengutronix.de>
Suggested-by: Marius Vlad <marius.vlad@collabora.com>

Signed-off-by: Tran Ba Khang(MS/EMC31-XC) <Khang.TranBa@vn.bosch.com>
2022-11-10 11:46:56 +02:00
Simon Ser f6cbb6678c releasing: use the Wayland release script
See [1] for the motivation.

[1]: 7cdc20cee6

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-11-10 11:22:54 +02:00
Marius Vlad fb57ce17ef shared/cairo-util: Release any fontmap laying around
This is particularly useful when using the weston-editor which seems to
cause an issue with cairo_debug_reset_static_data(), as that still seems
to find out there are references laying around, causing a crash when
exiting:

 ../../../../src/cairo-hash.c:217: _cairo_hash_table_destroy: Assertion
 `hash_table->live_entries == 0' failed

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-10 11:07:12 +02:00
Marius Vlad cfe35b591f shared/cairo-util: Re-use the PangoContext for layout creation
Rather than creating a new PangoContext each time the menu redraw
handler is triggered re-use it if one was created previously.

All toytoolkit clients do create a layout (and implicitly a
PangoContext) but only those that have menu redraw
handler installed will create a new layout for each redraw of the menu,
effectively creating a new PangoContext each time.

Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-10 11:07:12 +02:00
Marius Vlad 60b307e3ce shared/cairo-util: Zero out the memory when creating a new theme
Having the memory zeroed out just works better and avoids any possible
illegal access.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-10 11:07:12 +02:00
Marius Vlad f8a9ce3f55 shared/cairo-util: Do not save/restore the cairo context twice
We are already doing that before calling theme_render_frame() so no need
to do it again in layout creation.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-10 11:07:12 +02:00
Marius Vlad b749138758 libweston: Send name,description, update wl_output to ver 4
These have been in wayland a while back with version 1.20.0.

We also need to update the test client helper with this bump, as
those bind to version 4.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-10 10:57:43 +02:00
Pekka Paalanen f3bed68100 backend-drm: do not print head info twice
Before this patch, when a new head is found its information is printed
first as "updated" and then as "found" in the log.

The reason is that drm_head_create() calls drm_head_update_info() which
printed the head as "changed". Then drm_head_create() itself prints it
as "found".

This fixes it to print only once as "found".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-08 16:57:51 +02:00
Derek Foreman 771bd8acff libweston: Use weston_log_paced for unmapped surface or view warning
Copy the existing behaviour with the new paced logging mechanism.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-08 08:32:26 -06:00
Derek Foreman 6428fd13b7 pixman-renderer: Use paced logger for overdraw warning
Mimic the existing behaviour of logging once, but make it once
per output instead of per run.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-08 08:32:26 -06:00
Derek Foreman 805c7c4814 compositor: Use paced logger for unknown scroll source
Mimic the existing behaviour of logging 5 times, with no reset, but
change it so it's per device instead of using a static variable.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-08 08:32:26 -06:00
Derek Foreman a82cb25108 libweston: Use paced logger for presentation clock read failure
The current code only prints this once, and this is a probably a sensible
thing to do, as a clock read failure is probably not a condition that will
correct itself.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-08 08:32:26 -06:00