Commit graph

194 commits

Author SHA1 Message Date
Marius Vlad 19d32da742 shell-utils: Integrate shell-utils into libweston
These shell utils functions are potentially useful to other shells as
well, so make them widely available.

Renamed all functions to weston_shell_utils namespace.

No functional change, copied ad litteram.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-01-09 22:13:07 +00:00
Philipp Zabel 746a03068e libweston, backends: store backend pointer in struct weston_head
Compositor code can use opaque pointer comparison to determine whether
a head belongs to a given backend. Store a backend pointer in struct
weston_head to enable the compositor to select the correct backend
specific output configuration code.

This also allows to use the backend pointer instead of the opaque
backend_id pointer to check whether a head belongs to a backend, so
replace the checks in all to_xyz_head() functions and drop backend_id.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 15:21:16 +01:00
Philipp Zabel dfa845b1dd libweston: add missing struct weston_renderer forward declaration
struct weston_renderer is defined in libweston-internal.h, which is not
included from libweston.h. Add the missing forward declaration for the
renderer pointer stored in struct weston_compositor.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-09 17:04:01 +01:00
Pekka Paalanen 3746e163ab backend-headless: add option for output decorations
When the new option is enabled, headless backend will draw decorations
around its outputs. This makes the actual "framebuffer" larger by the
thickness of the decorations to keep the video mode area free for
clients.

This will be needed for a future test, that will ensure that GL-renderer
will paint the output decorations correctly.

The output title is deliberately NULL, because text rendering is
unpredictable and depends on e.g. what fonts are installed in the
system. Therefore screenshot testing of any text would be really
painful, so let's avoid that.

The decorations setup code is mostly copied from wayland-backend.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00: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 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 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 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
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
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
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 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 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 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
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
Michael Olbrich 5448580111 input: send touch frame event after up event
Currently the frame event gets lost: The touch focus is removed in the 'up'
event. So the focus is gone when the frame event arrives so it is never sent to
the clients.

To avoid this, keep the touch focus until the frame is handled.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-09-24 13:54:57 +02:00
Derek Foreman bb8ef7d271 libweston: Refactor point in output test
This is arguably a little nicer without calling the pixman functions
directly.

In the future when we have different datatypes for coordinates in different
spaces, this test will only be valid on global coordinates, so this change
is also a precursor to stronger type validation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 12:08:34 +00:00
Derek Foreman 5c352b8f4f compositor: Remove output dirty bit
This was actually introduced as part of desktop zoom. We no longer have
use of it.

This makes a subtle functional change - the output's matrices will now be
up to date immediately in cases where previously that update could have
been deferred.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 12:04:00 +00:00
Derek Foreman 3a61976af7 matrix: Make matrix const in weston_matrix_transform
This function doesn't need to change the matrix, so we might as well
enforce that.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 12:00:59 +00:00
Marius Vlad eaf2de3441 compositor: Use weston_load_module
Except the module dir path, they're one and the same. This change
warrants a libweston version bump, if it hasn't been done already.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:47:40 +00:00
vanfanel 3240ccc69d Don't change the max_bpc connector prop if mode=current.
As things are, even when mode=current is specified on the .ini file,
a full modeset is needed (and done), which causes a very noticeable
screen blinking. That is because setting the max_bpc on a connector
needs full modesetting.
The idea here is that if mode=current on the .ini, no modesetting
should be done, so the current max_bpc is programmed into the
connector.
But if a custom max-bpc=... is specified, that will be used instead,
even if mode=current on the .ini

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/660

Signed-off-by: vanfanel <redwindwanderer@gmail.com>
2022-09-23 11:05:34 +00:00
Marius Vlad 1b4def3c48 libweston/desktop: Migrate libweston-desktop/libweston-desktop.h
With commit 'Move libweston-desktop into libweston' we've moved out
libweston-desktop DSO into libweston.  Move also the header to
libweston/desktop.

This removes removes the libweston-desktop pc file and bumps libweston
major version to 12.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 13:57:26 +03:00
Pekka Paalanen b966fd07ea libweston: change read_format to struct pixel_format_info
Everywhere we are standardising to drm_fourcc.h pixel format codes, and
using struct pixel_format_info as a general handle that allows us to
access the equivalent format in various APIs. In the name of
standardisation, convert weston_compositor::read_format to
pixel_format_info.

Pixman formats are defined CPU-endian, while DRM formats are defined
always little-endian. OpenGL has various definitions. Correctly mapping
between these when the CPU is big-endian is an extra chore we can
hopefully offload to pixel-formats.c.

GL-renderer read_format is still defined based on Pixman format, because
of the pecualiar way OpenGL defines a pixel format with
GL_UNSIGNED_BYTE. That matches the same Pixman format on big-endian but
not the same drm_fourcc.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-08-03 14:33:48 +03:00
Jonas Ådahl 5ffa1962a5 compositor: Add support for wl_surface.offset()
This allows for setting a buffer offset without having to make it part
of the wl_surface.attach request. This is useful for e.g. setting a DND
surface icon hotspot offset when using Vulkan; or doing the same with
EGL without having to use wl_egl_window_resize().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-07-26 17:43:01 +00:00
Daniel Stone a8048c5c1c libweston: Properly namespace solid_buffer_values
It's exported by libweston, so shouldn't leak unprefixed types.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-26 11:52:24 +01:00
Daniel Stone 28caa08be6 Implement wp_single_pixel_buffer_v1 protocol
This protocol allows clients to create single-pixel RGBA buffers. Now
that we have proper support for these buffers internally within Weston,
we can expose them to clients.

This bumps the build container version, as we now depend on
wayland-protocols v1.26.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-26 10:26:55 +03:00
Daniel Stone f52231660e tests: Use memstream for config-parser test
Using real files is unnecessarily heavy and error-prone. Fixes timeouts
seen on CI with ASan.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-05 10:15:49 +01:00
Michael Olbrich 48e8c158ea compositor: only reflow the outputs if the shell did not move them
weston_compositor_reflow_outputs() assumes that all output are positioned from
left to right with no gaps in the same order in which they where created.

If the shell moves an output with weston_output_move() then this assumption is
no longer true. So stop reflowing the outputs in the case. The shell is now
responsible for positioning all outputs as needed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-06-23 18:02:00 +00:00
Daniel Stone f962b48958 compositor: Only create paint nodes for mapped surfaces/views
If a surface or a view is not mapped, then we should not be trying to
paint it. Check if this is the case and ensure that we only insert
paint nodes for mapped surfaces & views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: #621
2022-06-16 12:17:15 +03:00
Daniel Stone 0c69688aa2 libweston: Add weston_surface_map() wrapper
Change all instances of surface->is_mapped = true, to a specialised
function.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-16 12:17:15 +03:00
Daniel Stone 13ead893e2 Add weston_surface_has_content()
Just a trivial wrapper to tell you whether or not the surface has valid
content.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-16 12:17:15 +03:00
Pekka Paalanen d24adbbe25 backend-drm: set connector max bpc
"max bpc" property is meant for working around faulty sink hardware.
Normally it should be set to the maximum possible value so that the
kernel driver has full freedom to choose the link bpc without being
artificially forced to lower color precision.

The default value is 16 because that is a nice round number and more
than any link technology I've heard is using today which would be 12.

Also offer an API set the value, so that weston.ini could be used in the
next patch for sink workaround purposes.

Closes: https://gitlab.freedesktop.org/wayland/weston/-/issues/612

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-15 12:58:38 +00:00
Philipp Zabel c6e47d177a libweston: consolidate weston_compositor_create_output(_with_head)
Add a struct weston_head parameter to weston_compositor_create_output()
and fold weston_compositor_create_output_with_head() into it.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-06-10 09:27:43 +00:00
Philipp Zabel aab722bb17 backend-drm: prepare virtual output API for heterogeneous outputs
Stop plugins from overwriting the struct weston_output::destroy vfunc,
as that will be used by backends to recognize their outputs.
Instead, pass a plugin-specific destroy callback when creating the
virtual output.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-06-10 09:27:43 +00:00
Philipp Zabel 54d7682ee8 libweston: add opaque backend_id pointer to struct weston_head
As a first step towards heterogeneous outputs, add an opaque pointer
weston_head::backend_id that will be used by backends to identify
their own heads.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-06-10 09:27:43 +00:00
Pekka Paalanen 8bbd1a995b libweston: remove UNIT_TEST
This #define was used only by the matrix-test program, which was removed
in the previous commit.

Remove it as unused and fold away MATRIX_TEST_EXPORT.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-31 12:26:09 +00:00
Pekka Paalanen 8ebebb20ef drm-backend: add color_outcome / HDR metadata serial
Output color profile may be changed in flight. Output basic color
characteristics and EOTF mode cannot yet be changed in flight, but it is
reasonable to assume they could in the future. Therefore the color
outcome data may change in flight as well, which is the basis for HDR
metadata, which needs to be updated as well.

Track the changes to color outcome data with a serial number.
DRM-backend checks the serial number to see if it needs to re-create the
HDR metadata blob. This allows the changes to propagate all the way to
KMS.

The code added here is more of a reminder of what should happen than a
tested path.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen cea53a90d4 libweston: add HDR metadata to weston_output
This adds hdr_meta field in weston_output_color_outcome. This field is
intended to be set by color manager modules, and read by backends which
will send the information to the video sink in SMPTE ST 2084 mode a.k.a
Perceptual Quantizer HDR system.

Such metadata is essential in ST 2084 mode for the video sink to produce
a good picture.

The validation of the data and the group split is based on the HDR
Static Metata Type 1 definition in CTA-861-G specification.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen 3696d9b6a1 libweston: add basic output color characteristics API
This adds color_chracteristics field in weston_output. This field is
intended to be set by compositor frontends and read by color managers.
Color managers can use this information when choosing the output color
space and dynamic range, particularly when no ICC profile has been set.

This is most useful for HDR outputs, where the HDR static metadata for
PQ mode or the display luminance parameters for HLG mode can be based on
color_characteristics.

The fields of weston_color_characteristics mirror the information
available in EDID. However, using EDID information as-is has several
caveats, so the decision to use EDID for this is left for the frontend
and ultimately to the end user.

There are no defined ranges or validity checks for this data. The color
manager will have to validate the values against whatever it is using
them for.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Derek Foreman c8db957a0b rdp: Add audio support
Allow the front end to register audio setup and teardown functions. These
functions should use FreeRDP's rdpsnd_server_context or
audin_server_context and set up their own handler threads.

The backend remains mostly ignorant to any audio details beyond setting up
and tearing down.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-05-26 19:06:19 +00:00
Daniel Stone 8b167a1703 gl-renderer: Store EGL buffer state in weston_buffer
Introduce a renderer_private hook for weston_buffer, and use this to
store a copy of the gl_buffer_state for EGL buffers (i.e. non-dmabuf, via
EGL_WL_bind_wayland_display).

As part of this, we create the EGLImage along with the weston_buffer
information, and just take a reference to it each time it is attached.
If you have bisected a failure to update surface content to this commit,
it very likely means that your EGL implementation requires images to be
recreated rather than only rebound in order to have their content
updated, which is contrary to specification.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 8544a4d09b weston_buffer: Move direct_display out of gl-renderer
Just make it a generic buffer attribute, not hidden away in GL.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 0c65b23848 libweston: Move renderer interface to internal header
No-one should be implementing an external renderer, so move the
interface out of the public header.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Marius Vlad bd8314078d libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.

Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.

Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().

The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well.  This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).

If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.

Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.

A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:34 +03:00
Marius Vlad 0d8e94af61 libweston: Rename weston_surface_destroy() to weston_surface_unref()
Make it obvious that weston_surface has a reference counting happening
and destruction of the weston_surface happens when the last
weston_surface reference has been accounted for.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:46:31 +03:00