Commit graph

10517 commits

Author SHA1 Message Date
Derek Foreman
ae9b99352c compositor: move some prototypes
In a future commit, we'll need weston_subsurface_parent_commit sooner,
so just move both of these prototypes earlier in the file.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
8479772d2d compositor: drop has_cached_data subsurface bit
We don't use it anymore, we just casually commit and expect that
applying clean state is harmless.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
3db7d41642 compositor: Don't check for cached data in synchronized_commit
It really doesn't matter if we do a little extra work here,
weston_subsurface_commit_from_cache() is harmless if called on clean state.

If this turns out to waste some cycles we can add some more dirty bits
later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
26625a4928 compositor: Don't pass parent sync status to subsurface_parent_commit
We called subsurface_parent_commit with a flag to indicate whether we're
committing from a synchronized parent or not - this was used for
determining if a subsurface was effectively synchronized.

Now that we know whether a subsurface is effectively synchronized, we
can drop the parameter.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
c0053057db compositor: Simplify weston_subsurface_commit
Just bouncing everything through the cache makes for a much
simpler flow.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
b5970e6e68 compositor: remove weston_subsurface_is_synchronized
This was used to check if a subsurface was effectively sync,
and we now have a bool to check for that instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
1326428f41 compositor: track subsurface effective sync status
Keep track of subsurface effective sync status when it changes instead of
figuring it out when we need to know it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
4afd8961fc compositor: Create a common path for applying surface state
Create a common weston_surface_apply() for both subsurface and normal
surfaces to push state through, as this will let us remove a bunch of
common code in the future.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
2deb5e1dfd compositor: use early return in set sync/desync
Trivial change for clarity.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
3674d9665b compositor: rename commit_subsurface_order to apply_subsurface_order
Continuing to make a split between "commit" and "apply" in preparation
for a future where the application happens later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
a84db969f4 compositor: Rename weston_surface_commit_state
We'll eventually have a hard split between the commit and the application
of state, so rename this function to better indicate what it does.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
ee90650c8c compositor: Make subsurface->synchronized a bool
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Jonas Ådahl
ed6beb1dbf compositor: Make surface state caching reusable
Intended to be used by other inter surface synchronization mechanisms
than subsurfaces.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2025-09-05 10:01:42 -05:00
Robert Mader
ccce6cfdda clients: screenshot: Use shared client-buffer utils
In preparation for dmabuf support.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-05 11:47:18 +02:00
Robert Mader
4d43e63ab5 clients: screenshot: Sort imports
In preparation for more additions.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-05 11:47:18 +02:00
Robert Mader
106beccc91 weston-test-client-helper: Use shared client-buffer utils
For now just wrap the existing buffer struct around the new shared one.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-05 11:47:18 +02:00
Robert Mader
af834d1419 tests/client-buffer: Use shared client-buffer utils
Use the shared helper in order to avoid duplication. This will also
ensure that any format added to the test will also be usable by other
tests and clients.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-05 11:47:18 +02:00
Robert Mader
6951ff578b shared: Add client-buffer helpers
Factor out client-buffer creation into a helper library in order to
avoid duplication. This notably allows clients and tests to easily reuse
the dmabuf and yuv logic.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-05 11:47:18 +02:00
Derek Foreman
bf311ff232 screenshooter: Don't fail the first time an output won't capture
Historically, weston-screenshooter attempts a capture on all
wl_outputs, and if any output fails to capture it exits immediately.

These days it's possible to set up the pipewire backend to mirror
a drm backend output. This leads to surprising behaviour if one
tries to screenshot while no pipewire client is in use. Since the
pipewire backend has no buffer to render into at this point, the
screenshot fails. The drm screenshot is then dropped on the floor
because one of the wl_outputs failed to capture.

Avoid this for now by just continuing in the case of such
"graceful failures". Though maybe in the future we should allow
picking a wl_output by name, or have a command line switch to
decide whether to stop after a failure or not.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
724d3707ec pipewire: Shoot down unsatisfiable capture tasks
If there's no running connection, we can't capture, so just burn down any
waiting tasks so we don't assert later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
c54c421d21 gl-renderer: Listen to capture destroy signals
Listen to the capture destroy signal so we can prevent the async fd
source from causing a UAF.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
263290c677 gl-renderer: Move destroy_capture_task
Simple code motion to help with a later commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Derek Foreman
d2bab8a5ee libweston: Add an output capture task destroy listener
An output task may be destroyed by a client disconnect. This causes
problems for our drm backend's asynchronous capture task handler, which
currently has no way to notice this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-04 08:54:52 -05:00
Pekka Paalanen
48cc12cfc5 color-lcms: return cmsHTRANSFORM from xform_realize_chain()
No functional change.

This will help to keep the code more straightforward when
parametric<->ICC color transformations are added, and they need more
operations than just the cmap_3dlut for the 3D LUT.

Particularly, there will be a new flag telling if cmap_3dlut is
populated, and the flag is best set in init_icc_to_icc_chain() instead
of xform_realize_chain().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
13e7a3addb color-lcms: renames in_prof/out_prof
Shorter shorthands are nicer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
4e286bd297 color-lcms: add mask for allowed steps
When crafting an ICC to ICC color transformation, all the steps in
weston_color_transformation are at disposal. In the future also
parametric<->ICC color transformations will be crafted using the same
ICC chain machinery. However, there some steps must be reserved for
additional operations.

Add a bit mask that tells which color steps can be used by
xform_realize_icc_chain().

Unfortunately the mask is most conveniently stored in struct
cmlcms_color_transform. The LittleCMS context user data is the only good
way of passing our own bits into the factory code, but the user data
cannot be reset without destroying the context. It is probably not safe
to destroy the context as long as we have any LittleCMS objects alive
and created in that context. Hence, the user data must out-live the
LittleCMS context.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
dfea094772 color-lcms: prefix color_transform_step values
I will be adding a MAPPING value, and it would look odd without any
prefix. This adds a bit of namespacing.

The definition is moved to the header, because I will be needing it in
struct cmlcms_color_transform.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
0974359b8f color-lcms: split into xform_realize_icc_chain()
Split init_icc_to_icc_chain() into two parts:
- init_icc_to_icc_chain() is specific for ICC to ICC transformation
- xform_realize_icc_chain() can process any chain of cmsHPROFILEs

xform_realize_icc_chain() will be used by ICC-to-parametric and
parametric-to-ICC transformations in following commits.

No changes to functionality. 'extra' local variable is lost as unused.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Pekka Paalanen
9500bbe844 color-lcms: rename xform_realize_chain to init_icc_to_icc_chain
I will be splitting this function, and xform_realize_chain() matches the
parts I'm going to split out of it, while the remainder will be specific
to icc-to-icc transformations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-04 10:55:34 +03:00
Leandro Ribeiro
c594aa22cb backend-drm: offload post-blend color transformation to KMS
In this patch we allow offloading the post-blend color transformation
to KMS.

As KMS currently only supports to offload the transformation in a LUT,
this may result in precision issues. So this introduces the config
option "offload-blend-to-output", which is disabled by default.

This option requires "color-management" to be enabled, otherwise it is
ignored.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
996ec58ce3 frontend: avoid unecessary call to get_section()
We already get the core section a few lines above, and no other call
get_section() call are made in between.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
e77ca25a80 color: fail weston_color_curve_to_3x1D_LUT() when !xform->steps_valid
This is a leftover from "color: do not use color steps for non-optimized
pipelines". If a xform don't have valid steps, it shouldn't have curves.
So this function should fail.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
fceb4151a3 color: allow creating LUT from curve even when bad precision may occur
At this point, the DRM/KMS API supports offloading post-blend color
xform only through LUT's. This is not ideal, and an API to improve that
should be proposed in the future.

But we still want to experiment with offloading pre-blend (not post)
color transformation through the colorop API, which is close to being
accepted upstream. But this requires us to offload post-blend as well.

weston_color_curve_to_3x1D_LUT() currently fails if we detect that
crafting a LUT from the color curve may result in bad precision.
Instead, let's add a boolean param to control if we forbid or not bad
precision. This should allow us to offload post-blend xform through
LUT's.

This also improves the error messages in this function.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
6f969623eb backend-drm: do not disable underlay planes based on b->format
Since commit "backend-drm: improve code that chooses output->format", we
changed how b->format (the GBM format from the config file) is used.

There are config options in weston.ini that allow us to ignore the GBM
format set. So what matters to us is which output->format is being used,
and we compute that in drm_output_pick_format_egl() and
drm_output_pick_format_pixman().

So remove these checks that disable underlay planes based on b->format,
keeping only the ones that depend on the output->format selection.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
56c27ea248 backend-drm: improve code that chooses output->format
Instead of picking an arbitrary format, let's first ensure that the
format is supported by the renderer.

Also, start choosing formats with alpha channel if we have b->underlay.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
ed7ceef37e gl-renderer: do not set compositor capabilities on failure
When gl_renderer_display_create() fails, do not change the compositor
capabilities.

The compositor may not abort when that happens, it may simply decide to
fallback to another renderer. So setting anything on failure is wrong.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
c10857df5d gl-renderer: add function to query supported rendering formats
This goes through all formats available in the EGLConfig's that we
get from EGLDisplay and expose them in a struct weston_drm_format.

Currently backends choose a format for their outputs and hope that
GL-renderer is able to find a compatible EGLConfig. This should help
backends to avoid guessing.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
dd5e1f5047 libweston: rename get_supported_formats to get_supported_dmabuf_formats
Let's be more more specific and rename the renderer interface function
that returns the supported dma-buf formats. I.e. if we pass a dma-buf
with one of these formats for the renderer, it should be able to import
it.

Next we'll introduce a function to query the rendering formats from
the renderer, so this distinction is important.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
fba356e44d gl-renderer: log EGLConfig component type
Now that we also support EGLConfig with floating-point, let's log this
information.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
b5ed927960 gl-renderer: properly log EGLConfig vis id
To log vis id, we call:

eglGetConfigAttrib(egldpy, eglconfig, EGL_NATIVE_VISUAL_ID, &value)
p = pixel_format_get_info(value)

The problem is, EGL_NATIVE_VISUAL_ID represents a DRM format only on
GBM platform. So for other platforms we are calling
pixel_format_get_info() with values that are not DRM formats.

Avoid calling pixel_format_get_info() when the platform is different
from GBM, and log only the hex value in such case.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
0c986257f9 gl-renderer: change params of a few functions
No behavior change, just to make things easier for next commits. They
will need struct gl_renderer *gr in print_egl_config_info().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
ec646f34d6 gl-renderer: add support to query EGL configs with float-point formats
Currently when we have a blend-to-output color transformation, we have a
16FP shadow buffer representing the blending space. Then we blit from
that to the primary plane fb, which is a regular buffer (fixed-point,
not 16bpc).

The shadow buffer needs to be 16FP because the blending space is linear
with relation to light. So it needs more bits for encoding.

In the next patches we enable the option to offload the blend-to-output
color transformation to KMS, so we'll need the primary plane fb to be
of a 16FP format. In order to do that, we need to be able to find EGL
configs with float-point formats. In this patch we enable that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Leandro Ribeiro
3cad1c7716 libweston: remove set_gamma()
The plugins cms-static and cms-colord have been deprecated and removed
from our code. They were the only thing holding set_gamma() from being
removed. So remove set_gamma() from the code.

Users can have the same results tweaking the output color profile that
they use.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-02 13:34:00 +00:00
Derek Foreman
6b1b3d167d xwm: Add command line option to disable window decor
Our window decor uses cairo-xcb. cairo-xcb stores xcb_connection_t
internally and uses them as kind of a hash key for internal bookkeeping.
This needs to be torn down with a cairo_device_finish, when the last
cairo surface is destroyed, and we are not properly handling that.

Because of this weston bug, if the Xwayland server dies, is restarted,
and the weston X window manager gets the same xcb_connection_t pointer
value for a new connection that it had for a previous connection,
cairo-xcb will use stale state and crash.

Weston is used in some places (like Mesa CI) where Xwayland crashes are
more common than one might usually expect, and weston needs to be robust
against these failures. It's ok to have no window frames in xwl in these
cases, because nobody is interacting with the windows.

The '--no-xwm-decorations' command line option will now remove
cairo-xcb from use entirely, so this crash can no longer happen.

We should still fix the bugs in our cairo usage, but I think long term
it's still ok to have a way to disable this and reduce complexity.

Ref #1042

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-08-28 14:35:30 -05:00
Pablo Saavedra
98d4438265 screen-share: Guard pixman_image_unref call on shared_output_destroy
Prevent crashes during shared_output_destroy when cache_image is not
initialized.

Signed-off-by: Pablo Saavedra <psaavedra@igalia.com>
2025-08-28 11:17:33 +02:00
Robert Mader
092fe3f7ec tests/client-buffer: Sync dmabufs with DMA_BUF_IOCTL_SYNC
As required by the spec when accessing dmabufs from the CPU, see
https://docs.kernel.org/driver-api/dma-buf.html

While effectively a no-op on amd64, this fixes test failures on various
aarch64 devices, including:
 - rk3588 (Panfrost, Rock5)
 - rk3399 (Panfrost, PineBook Pro)
 - Broadcom BCM2712 (V3D, RPi5)
 - Qualcomm SDM845 (freedreno, OnePlus6)

Fixes: 303d88448 (tests: client-buffer: Add dmabuf support)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-08-25 12:10:10 +02:00
Jaeyoon Jung
e91252a943 desktop-shell: Add scale-fit background type
It is similar to scale-crop but fits to the output so that the image
does not get cropped.

Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
2025-08-18 16:42:26 +09:00
Philipp Zabel
683eabb61e build: Allow libdisplay-info 0.3.0
There are no breaking changes for the high-level API that Weston uses.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2025-08-13 15:36:51 +02:00
Pekka Paalanen
ead6c5b319 frontend: use weston_enum_map for scroll method
Use helpers instead of open-coding.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-08-05 11:51:23 -05:00
Pekka Paalanen
72d2b14e6a frontend: use weston_enum_map for colorimetry modes
Use helpers instead of open-coding.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-08-05 11:51:23 -05:00