Commit Graph

1540 Commits

Author SHA1 Message Date
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
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
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
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
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
Derek Foreman
f9b57c5234 libweston: Use paced logger for bad repaint delays
Ideally we'd like to see this more than just a single time, but we'd also
like to prevent it from triggering endlessly. Let's also make this happen
per output.

While we're here, use the word "abnormal" instead of "insane"

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-08 08:32:26 -06:00
Derek Foreman
8e661b3c93 libweston: Add weston_log_paced()
We have a few places where we log messages only the first time they occur.
Provide a log throttling implementation so we don't have to open code this
in all the places that need it.

Instead of just logging a single time, allow some finer control. We allow
logging of a specified number of events. Additionally, we have an optional
timeout after which the event count is reset so we can log at most N
events in M ms.

The first new event printed after the timeout expires will also include a
count of suppressed events.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-08 08:32:26 -06:00
Emmanuel Gil Peyrot
1c5ce4c2cc DRM: Add support for HDMI content type
Some monitors expose a selector for the kind of content that will get
displayed, allowing them to optimise their settings for this particular
content type.

I got access to such a monitor, sadly even setting it to game mode
didn’t lower its atrocious latency, but drm_info[1] reports it to be set
correctly so hopefully it’ll work better with other monitors.

[1] https://github.com/ascent12/drm_info

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2022-11-03 15:40:00 +00:00
Derek Foreman
de306e4601 input: make sure pointer->focus is set before trusting pointer->sx,sy
We're just going to crash at weston_view_from_global_fixed() anyway if
this is untrue, but we have a similar assertion elsewhere already.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
9b5a525a3d input: Be more careful with pointer surface coordinates
Whether these coordinates are "invalid" (set to an unlikely sentinel value)
or not is based purely on whether pointer->view is valid.

Check pointer->view before using these values every time, and stop
using an "invalid" value entirely.

The reason for this is that in the future we're reworking how 2D
coordinates are handled, and removing the dubious conecept of an invalid
coordinate simplifies things a little.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
4d141a7881 libweston: Don't return coordinates from weston_compositor_pick_view
Sometimes callers don't want them, and sometimes (when view is NULL) the
coordinate is invalid.

Waste a tiny bit of time calculating them as needed in the callers
instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
9409ce7024 input: Don't test bogus coordinates in surface jump logic
sx and sy are meaningless (-1000000) when view is NULL. The case this
is meant to catch is when the surface coordinates change while the
global coordinate doesn't, (eg: max/unmax a window with a keyboard
shortcut) - in that case view will always be set.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
eed00f679e input: Don't pass surface coordinates to weston_pointer_set_focus
We're always passing pointer->x, y converted to surface coordinates, or
garbage if view is NULL. Let's just stop passing those coordinates
entirely and calculate them in the function.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
2995bc981d input: Complain if we focus a surface with a coordinate outside it
Not all callers of weston_pointer_set_focus use weston_compositor_pick_view
to get their coordinate, so let's log something if the coordinate doesn't
make sense.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
e2e0a73335 compositor: Factor out check if a view takes input for a point
Make this into its own function so we can use it for sanity checks later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-02 10:25:15 +00:00
Derek Foreman
160a4ba3ad data-device: Split set_focus and clear_focus
Removes the need to fabricate a fake coordinate pair when calling
weston_drag_set_focus to clear focus.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 12:17:51 -05:00
Derek Foreman
c754847d68 data-device: Refactor grab and touch grab focus handlers
Reduce a tiny bit of code duplication.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 11:31:08 -05:00
Derek Foreman
5079f0b2f9 helpers: Add a u64 from 2 u32 helper
We do this enough that having a single implementation for it is probably
a win.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 08:13:30 +00:00
Derek Foreman
2ca2eac39a libweston: Split notify_pointer focus into notify/clear
This lets us say what we really mean instead of passing a NULL output
and garbage co-ordinates.

This will help later when manufacturing garbage coordinates becomes much
harder to do.

The clear_pointer_focus() path continues to do nothing, and is just a FIXME
macro, as it has been for a very long time...

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-25 15:58:24 -05:00
Philipp Zabel
2f0be4b4d0 backend-vnc: use configured keymap
Use the keymap rules/model/layout configured in the weston.ini [keyboard]
section.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-10-18 16:06:13 +02:00
Philipp Zabel
5cd87ff801 backend-vnc: implement direct key code handling
Allow clients that support the QEMU Extended Key Event Message to send
keycodes directly.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-10-18 16:06:13 +02:00
Stefan Agner
12f7665310 backend-vnc: add VNC support using Neat VNC library
This adds basic VNC protocol support using the Neat VNC library
(https://github.com/any1/neatvnc). Neat VNC depends on the AML main
loop library. The backend makes use of AML's integrated epoll backend
and connects AML via file descriptor with the Wayland event loop.

This implementation does not support authentication and hardcodes the
pixel format currently.

Co-authored-by: Philipp Zabel <p.zabel@pengutronix.de>
Co-authored-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Stefan Agner <stefan@agner.ch>
[r.czerwinski@pengutronix.de:
 - use new (as of 0.5.0) Neat VNC buffer API, with a buffer pool]
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
[p.zabel@pengutronix.de:
 - transform repaint damage to output coordinates
 - transform pointer coordinates into global space
 - check that outputs and heads are in fact ours, see aab722bb1785..060ef82d9360
 - track damage across multiple frame buffers
 - choose pixel format by drm_fourcc, see 8b6c3fe0ad
 - enable ctrl and alt modifiers
 - fix frame timing to achieve a constant repaint rate
 - pass initial size explicitly, see f4559b0760
 - use resize_output with pixman-renderer, see 55d08f9634e8..84b5d0eb4bee
 - allow configuring the refresh rate]
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-10-18 07:31:42 +02:00
Simon Ser
722f211518 build: deprecate launcher-logind
Deprecate launcher-logind and disable it by default.

launcher-libseat supports logind, so this shouldn't cause any
regression.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/weston/-/issues/488
2022-10-10 13:58:09 +02:00
Paul Kocialkowski
0afd3428dc screenshooter: Add SHM buffer destroy listener to avoid invalid memcpy
This adds a destroy listener on the SHM buffer provided by our client.
It will unregister the frame notify listener in case our buffer is
destroyed before the frame signal is emitted and thus avoid a memcpy
to invalid memory.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2022-10-03 16:52:16 +02:00
Vitaly Prosyak
6678f8150c color-lcms: add support for matrices
This patch adds the essential LittleCMS color pipeline optimizations and
analysis that is necessary for extracting matrices from pipelines
correctly. When we can extract a matrix and 1D curve sets, we can use
those with GL-renderer without needing an inherently heavy and imprecise
3D LUT. This should improve color transformation precision and
performance when a 3D LUT is not necessary.

The core of the optimization and analysis is a custom plugin for
LittleCMS. The optimization step comprises of repeatedly merging
sequential matrices and sequential curve sets into one and eliminating
identity elements which may allow for more merging. The analysis step
takes the optimized LittleCMS pipeline and attempts to fit all of its
elements into the weston_color_transform model. If it fits, we have an
optimized color transformation and do not need a 3D LUT. If it does not
fit, we use a 3D LUT as before.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-28 10:28:28 +00:00
Pekka Paalanen
1874f4db92 color-lcms: add cmlcms_category_name()
This will be used by debug logging and error reporting.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-28 10:28:28 +00:00
Vitaly Prosyak
f3277a4fa5 color-lcms: drop locals in cmlcms_color_transform_create()
Restructing cmlcms_color_transform_create for readibility.

Also dropped zalloc() check in favor of xzalloc() as per the recent
Weston development policy.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-28 10:28:28 +00:00
Pekka Paalanen
40e06794ad color-lcms: restructure xform_set_cmap_3dlut()
Right now this function only creates a CMM pipeline and produces a 3D
LUT from it, but in the future it can produce other types of
transformations. The function is renamed to xform_realize_chain()
because it creates a chain of profiles, forms a multi-profile-transform
from them, and fits that into weston_color_transform.

The further refactoring supports the future changes, and attempts to
make the code more readable.

There is provision for easily adding more profiles into the chain.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-28 10:28:28 +00:00
Pekka Paalanen
711b27797d color-lcms: relax cmlcms_fill_in_output_inv_eotf_vcgt()
Relax the types of color transformations categories where this function
can be used. Yes, it is only useful for BLEND_TO_OUTPUT, but that is for
the user of this function to take care of. This function always works as
named regardless. The only condition is that output_inv_eotf_vcgt has
been populated, so fill_in_curves() may as well assert that.

While at it, make the code a little more concise. The 'len' assertion
belongs in fill_in_curves() because that is where the problem would
appear if the assertion failed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-28 10:28:28 +00:00