Commit graph

431 commits

Author SHA1 Message Date
Pekka Paalanen
6f6a5dd2c8 libweston: remove weston_screenshooter_shoot()
Unused.

This was using the old way of getting screenshots: hooking to
weston_output::frame_signal and calling weston_renderer::read_pixels().
This old way stalled Weston until the GPU work was complete, and
supported only wl_shm buffers.

At this time there is no libweston API for frontends/plugins to ask for
a screenshot, but there is a protocol interface in
weston-output-capture.xml.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-17 14:53:38 +02:00
Pekka Paalanen
9b177e381a libweston: store format modifier name in weston_buffer
This should cut the cost of debug_scene_view_print_buffer() in half on
ARM A55 CPU. Debug printing is quite expensive on such platform.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Pekka Paalanen
664e882415 libweston: add weston_log_scope_stream()
Printing directly into an stdio stream and hooking up to the flush (the
write callback) avoids having to allocate+free a temporary buffer on
every printing call. The FILE uses a permanent buffer for storing the
text, and once it fills up or a newline is detected, it is flushed out.

It is fine to mix the new and the old APIs, since the old API flushes
the stream.

The buffer size of 3 kB is just a guess.

The man-page for fopencookie() recommends setting _FILE_OFFSET_BITS to
64. Even though this patch does not strictly need it (we don't implement
seek or take the address of fopencookie()), I think it's good to follow
anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Leandro Ribeiro
32d0bd3d0e compositor: add grayscale output color effect
This adds a new output color effect: grayscale. It takes RGB color as
input and computes a gray pixel color using the luminance formula for
linear sRGB:

Y = 0.2126 * R + 0.7152 * G + 0.0722 * B

Just like the other color effects we have, this only works for sRGB and
are not enabled when color-management is on.

Note: although the technique is designed to be applied in linear, it's
costly to convert to linear and then back to electrical. As doing the
conversion in electrical still gives a reasonable result, we do it this
way. When we add support for color effects with color-management on,
we'll apply the effect in linear.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-04 13:11:56 -03:00
Derek Foreman
77156786f0 compositor: Remove weston_compositor_stack_plane
It's been a long time since the core has cared about plane z-order. Remove
this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-03-04 13:17:49 +00:00
Derek Foreman
313ea43f35 compositor: Remove x,y co-ordinates from weston_plane
Turns out nothing actually uses these anymore.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-03-04 13:17:49 +00:00
Pekka Paalanen
4232db2864 shell-utils: delete weston_shell_utils_surface_get_label()
Unused. Replaced earlier by weston_desktop_surface_make_label().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 09:40:32 +02:00
Pekka Paalanen
eefcd97e2a libweston: delete weston_surface::get_label as unused
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 09:40:32 +02:00
Marius Vlad
128a88d1a8 shell-utils: Add labels for curtain created surfaces
struct weston_curtain_params is changed to match the new
weston_surface_set_label() API. For now, I did not bother hooking up the
static label flavor.

Part of migration away from get_label().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 07:28:49 +00:00
Marius Vlad
4011de1e22 desktop-shell: set the new surface label field
To update the surface label based on client-controllable fields like
app_id and title we need to use a listener and update the label
accordingly using weston_surface_set_label() added previously.

The added weston_desktop_surface_make_label() will eventually supersede
weston_shell_utils_surface_get_label() by having a more fluent API.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 07:28:49 +00:00
Marius Vlad
2e61633b32 libweston: Use a string for storing surface label
This is an alternative to using set_label_func to avoid using get_label()
callback. get_label() is inconvenient to set up and to call. It incurs
the cost of creating the string every time it is needed. During
debug logging, the string is needed much more often than it changes.

The new label field simply stores the string, making it easy and cheap
to use. As the trade-off, components that set the label string must
re-create the string when it changes, whether it is needed or not.

For the migration to the new label field, get_label_member callback is
used. It will be deleted once the migration is done.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 07:28:49 +00:00
Pekka Paalanen
f02c628ee0 libweston: drop a copy in debug_scene_graph_cb()
Doing

	weston_log_subscription_printf(sub, "%s", str);

would malloc a new buffer, copy str into it, flush it our to the
subscriber, and free the buffer before returning.

Using weston_log_subscription_write() instead there is no malloc and
copy. Only open_memstream() has a malloc'd temporary buffer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-03 15:59:39 +02:00
Pekka Paalanen
bf513a362a libweston: add weston_color_gamut_from_protocol()
Reduce 4 copies of a piece of code into one. Usable for both client and
server side.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-03 07:41:27 +00:00
Rainer Bayr
efa71a250e add NLA support an the nla-ntlm-db option
Signed-off-by: Rainova <rainer.bayr@outlook.com>
2026-02-23 13:30:29 +02:00
Pekka Paalanen
cfecdce2f5 libweston: give weston_views a simple name
Views did not have any identification of their own, except the memory
address "%p" (not human-readable) and very likely assumption that a
surface would have only one view (but we support multiple views).

For trace and debug print purposes, give views nice names like we just
added for surfaces. The owning surface is apparent from the view name.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +02:00
Pekka Paalanen
a209e13526 libweston: give weston_surfaces a simple name
So far we have had two ways of identifying a weston_surface: by its
memory address "%p", and by its get_label function. The memory address
is not human-friendly and can get recycled. get_label() is not unique,
and in some cases it is client-controllable.

Oh, we also have the protocol object ID, but that does not exist for
internally created weston_surfaces.

We also have weston_surface::s_id, damage_track_id and flow_id. These
are used by some Perfetto instrumentation. s_id comes from a
compositor-wide counter rather than per-client counter, the others are
probably not what I'm looking for.

None of these are really nice for trace and debug prints for identifying
surfaces for human reading. Therefore, let's add one more ID, and with
it, a nice name for each surface.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +02:00
Pekka Paalanen
df622cbb20 libweston: track clients
This adds the framework to track clients with custom data. The first use
is to associate an ID with each client. The ID is much better suited for
debug printing than a pointer value.

The string representation is stored so that it can be overridden if
desired for compositor forked clients like Xwayland or shell helpers.

Change to a struct in the public header forces a major version bump for
this development cycle.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:20:39 +02:00
Derek Foreman
87515a6874 compositor: Add REPAINT_DEFERRED repaint_status
Backends can end up in indeterminate/invalid state and be unable to
process updates.

Add a way for the backend to tell the core to stop scheduling repaints,
and a way for the backend to schedule all the repaints that should have
taken place during the invalid state period.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-02-03 09:12:07 +00:00
Leandro Ribeiro
3de7c52942 libweston: collapse CVD correction into single matrix multiplication
CVD correction is composed by a linear transformation, so we should be
able to collapse it into a single matrix multiplication:

Y = M * X

Where Y is the result, X is the original color, and M is the CVD
correction matrix.

As we need to perform CVD correction for every pixel, this can be
beneficial for limited hardware.

In this patch we do that, updating the libweston core code and also the
GL-renderer and its fragment shader.

Suggested-by: Christopher Healy <healych@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-01-22 18:24:29 +00:00
Leandro Ribeiro
d3fee82090 gl-renderer: do not skip output color effect for solid color buffers
When repainting a paint node, if the buffer is a solid color buffer we
may skip the rendering pipeline and directly call glClear() with the
solid color, for optimization purposes.

Currently there's a bug where if the output has an output color effect
set, it is skipped when we have a solid color buffer (as we don't go
through the rendering pipeline, where the effects are implemented).

When we have color-management and the paint node contains a color xform,
we've opted for skipping this optimization and going through the
rendering pipeline for now. However, output color effects are simple,
so let's add the logic to apply them on CPU when we have a solid color
buffer.

Reported-by: Christopher Healy <healych@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-01-12 12:55:49 +00:00
Robert Mader
32f6148afd libweston: Implement color-representation protocol
For now limited to coefficients and ranges that are typically
supported by KMS drivers. We notably leave out alpha modes and
chroma locations for now.

The protocol initialization is guarded by the WESTON_CAP_COLOR_REP
backend capability and thus not enabled anywhere yet.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-12-19 17:08:29 +01:00
Derek Foreman
a3f0e97a71 compositor: Support the commit-timing protocol
Introduce support for the commit-timing protocol to allow applications
to attach a presentation time to a content update.

We use the repaint timer to schedule content updates in advance of
the frame time when they should be displayed.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 10:58:01 -06:00
Derek Foreman
37acb0c0fd compositor: Directly use a timerfd instead of a wl_event_source
In the near future commit-timing + VRR combined will want to have better
than the 1ms precision we're allowed now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 10:58:01 -06:00
Derek Foreman
01b7e9d015 compositor: store frame flags from finish frame
These are used to determine if the previous frame was displayed with
tearing, which is useful in determining when the next frame time should
be.

Store these as a step towards breaking the frame time calculations out
of output_finish_frame into a separate function.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 10:21:43 -06:00
Derek Foreman
f1bcedd089 compositor: Track repaint time and expected presentation time
For the upcoming commit-timing protocol, we're interested in when a
scheduled repaint will be displayed, so let's keep track of both the
repaint time and the anticipated presentation time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 10:21:43 -06:00
Olivier Fourdan
0126a5b4fc backend-headless: Add an option to enable a fake seat
When running headless, weston will not expose a wl_seat.

This was removed with commit a1046adc ("compositor-headless: do not
create a seat").

However, some applications, namely GTK3 based, will log a warning when
there is no wl_seat:

 | gdk_seat_get_keyboard assertion GDK_IS_SEAT(seat) failed

While this is arguably a bug in GTK3 which should not complain with a
legit setup, that breaks the CI of those projects when using Weston,
while most of the other Wayland compositors will create a fake seat when
running headless, making weston the odd ball there.

This changes adds a new option "--fake-seat" that will instruct weston
to create a seat when running headless. The default remains not to
create a seat though, so backward compatibility is preserved.

This partially reverts commit a1046adc66.

See-also: https://gitlab.freedesktop.org/ofourdan/xwayland-run/-/issues/12
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2025-12-08 11:44:27 +01:00
Derek Foreman
cb97abd4f7 compositor: Add the fifo-v1 protocol
Add support for the fifo protocol, which allows an application to submit
a content update that can only be applied after the previous content
update has been active for a display refresh.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-04 14:03:13 -06:00
Derek Foreman
f50296d4e9 compositor: Add a deferred content update framework
Now that we have surface-state application streamlined, it's fairly easy to
add a framework for deferring content updates.

This will be used soon for fifo and commit timing. For now, the
weston_surface_state_ready() call that makes any of this do something
will always return true.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-04 14:03:10 -06:00
Derek Foreman
61134fa151 compositor: Track view and surface visibility per output
Keep track of whether a view has any unoccluded pixels on an output,
use this information to add a weston_surface_visibility_mask() function
that we'll use later.

Since the visibility information is calculated at repaint, and invalidated
by some (but not all) state updates, we'll keep track of when the previous
repaint's status is still valid by watching surface status bits.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-04 13:55:20 -06:00
Derek Foreman
e4be014f93 compositor: Add an explicit latch point
Latch is the moment when the compositor considers updates for an upcoming
redraw. Nothing that takes place after an output latches for repaint can
change what will be repainted.

This needs a more explicit treatment now that upcoming transactional
protocols require things to happen immediately after the latch (ie:
when it's too late to change the upcoming render).

Add an explicit latch point, a signal to tap for testing, and some asserts
to make sure nothing can violate the inevitability of the current render
state.

Note that currently latch is tied to repaint such that we only claim to
have latched when a repaint will happen. In a future commit this will lead
to forcing the repaint loop to fire without damage when the fifo protocol
needs something to happen after a latch. This could be an area for
future improvement.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-04 12:38:17 -06:00
Derek Foreman
b700c7cbee compositor: Add flow id into surface state
We're going to be adding protocols (commit-timing, fifo, syncobj) that
allow deferred surface content updates.

It makes sense to start the perfetto flow ids from the surface state so
we can track a flow from creation (ie:commit) to presentation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-04 12:38:17 -06:00
Marius Vlad
9215a537e0 compositor: Move repaint_status out of weston_output
To accommodate some future CI bump to Trixie (doxygen/breathe issue)
move out the anonymous enum out of weston_output object.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-12-02 17:25:14 +02:00
Derek Foreman
b44cf1b6af animation: Change how we seed the initial time
With the addition of the weston_output_set_ready() call, the shell fade
animation is now started during the very first repaint. The first repaint
doesn't have an accurate frame_time for the previous repaint, as none has
occurred yet.

Since we set the time base for an animation based on the output's frame
time the second time the animation is run, we end up setting the shell fade
start time to 0, and the first real repaint advances the timer to the real
time, generating a warning and truncating the animation.

Instead of tracking the number of animation frames, let's just continue to
reset the time base until we finally get a non-zero time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-11-24 12:29:15 -06:00
Marius Vlad
881ac6a5cf compositor: De-couple paint node ordered list from the view build list
This de-couples the compositor view build list from the paint node
ordered list to allow a more finer grain over what lists we need to
rebuild upon repaints.

As a consequence to that this avoids a trip over from the compositor
when paint nodes are destroyed and no longer re-created upon rebuilding
the view list.

Fixes: #1070
Fixes: abfe874a ("core: Don't rebuild view list on surface-local changes")

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-11-19 15:47:13 +02:00
Derek Foreman
0bfcb700b9 compositor/shells: Require shells to flag outputs as ready to allow repaint
We've added a curtain to the shells so at startup we have something to
render, but this causes a flicker if someone is trying to have a seamless
transition from boot to weston.

Add a ready flag that allows the shell to indicate repaints are safe, so
we can remove the curtains and have no wasted frames at startup.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-27 05:55:51 +00:00
Derek Foreman
6070dd8069 compositor: Add a WESTON_PAINT_NODE_BUFFER_PARAMS_DIRTY
This already existed for surface, so it is trivial to add.

This will let the upcoming plane state reuse code notice a format change.

This is handy because a client might respond to dmabuf feedback by changing
formats, with the expectation that doing so would land content on a plane.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-23 16:22:00 +01:00
Pekka Paalanen
120b88aa0a color: run vec3 through weston_color_curve_sample()
Future development will need to evaluate pipelines with curves and
matrices. Such pipelines naturally operate on vec3, as matrices cannot
be operated one channel at a time. Make weston_color_curve_sample()
operate on arrays of vec3.

Its currently only caller, weston_color_curve_to_3x1D_LUT(), is modified
to employ a temporary array for the API impedance mismatch. This
workaround will be removed later as weston_color_curve_to_3x1D_LUT()
itself will be converted to operate on vec3 arrays.

weston_v3f_array_to_planar() documentation was generated with AI.

weston_color_curve_sample() is restructured a little bit, attempting to
make it simpler to read.

color-operations.h gets the #includes needed to make it self-standing.

Assisted-by: Github Copilot (Claude Sonnet 3.5)
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-21 14:23:37 +03:00
Elliot Chen
bef29b8774 libinput: support ignoring all libinput-based input devices by configuration
For some cases such as remote control, need to disable the interaction
between input device and the weston. It will not affect the use of input
device by other modules or applications.

Signed-off-by: Elliot Chen <elliot.chen@nxp.com>
2025-10-21 12:54:42 +03:00
Derek Foreman
2c7fd792b5 frontend: Add support for forcing a color format
Allow dictating which color format we'd like to use. This introduces the
front-end side and the core parts, leaving the EDID parsing and DRM
connector property for later patches.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-10-18 14:02:16 +01:00
Daniel Stone
0664d5bdc1 output: Record paint_node_changes during repaint
When we're going through assign_planes and repaint, give the backend an
opportunity to see what's changed during this repaint.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-17 13:51:05 -05:00
Daniel Stone
7f8c5f984e paint-node: Expose weston_paint_node_status
Expose the dirty status as public API so we can use it as a part of
weston_output.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-17 13:51:04 -05:00
Pekka Paalanen
360eef9663 color: add weston_color_profile_param_builder_set_target_primaries_named()
The protocol does not carry target primaries by enumeration, but in
weston.ini I want to be able to use a name rather than raw values.
Adding this API makes that possible.

main.c cannot look up the enumeration itself, because color-properties.h
is private. As it should be.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-09 16:17:57 +00:00
Pekka Paalanen
fe85ed48fc shared: implement weston_parse_space_separated_list()
This will be useful for parsing config file entries that have several
items on key, like x,y coordinates or a list of flags. Code reading
custom color profiles from weston.ini will use this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
d7030571c5 frontend,color: print details of the set color profile
It is nice to see the numbers of a parametric color profile when created
from CTA or EDID or just to cross-check with weston.ini.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Robert Mader
07a5ec8157 output-capture: Add output_get_writeback_formats helper
And implement it in the DRM backend. This will be used by the next
commit.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 11:26:21 +02:00
Leandro Ribeiro
6fe0cfc2b8 color: introduce output color effects
Output color effects are applied to the whole output scenegraph. It
depends on color-management being disabled, as the color effects are
applied in sRGB content.

For now we added only a few accessibility options: color inversion,
deuteranopia, protanopia and tritanopia CVD correction.

Note that surfaces presented on outputs that contains a color effect
can't be used for direct scanout (i.e. bypass composition and offloading
to KMS overlay planes). The color effect is applied in our GL-renderer.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-18 12:32:13 -03:00
Elliot Chen
b268b3827c backend-pipewire: support frame rate configuration
Signed-off-by: Elliot Chen <elliot.chen@nxp.com>
2025-09-15 08:20:52 +00:00
Derek Foreman
eac3d78bc6 compositor: Remove view->visible
This is not what any sensible person would expect it to be. It was updated
by a walk of all the paint nodes on the output most recently repainted,
so if a view spanned outputs the visible region would only make sense
within the most recently painted output's region.

It's basically a scratchpad for a mid-repaint operation. Instead of making
it a view member, put it in the paint node, which are always per-output.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 15:23:08 -05:00
Derek Foreman
ed1edb7b5c compositor: replace surface_state->buffer with a buffer_ref
Use a buffer_ref here to allow us to remove the subsurface
cached_buffer_ref and keep it in the surface state struct instead.

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