Commit graph

730 commits

Author SHA1 Message Date
Derek Foreman
54a25720c6 compositor: Give paint nodes their own flow id
Since a paint node is a combination of surface, view, and output, using
the surface flow in paint node functions can make a confusing twisty mess.

Perfetto flows have in/out degree of one, so we can't properly express the
1 surface to multiple paint nodes relationship with flows.

So for now let's break up the surface and paint node flows, but in the
future we'll have better ways to map multiple flow starts to the same
function via INSTANT events, and we'll be able to better link surface
content update to paint node render.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-29 10:10:08 -05:00
Leandro Ribeiro
e0c5b8a26b compositor: emit sleep signal
A few custom shells want to know when the compositor is going to sleep.
This adds a new sleep signal and emits it when DPMS is going off.

To showcase the feature, this adds a sleep signal listener to
desktop-shell whose handler logs a message.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-04-22 17:44:29 +03:00
Pekka Paalanen
35527e6eed frontend,libweston: remove color_characteristics
Since the commit "color-lcms: extract HDR static metadata from profile"
this was all dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-16 13:46:22 +00:00
Derek Foreman
22bcfead57 compositor: Add a weston_coord_global_to_surface_for_paint_node and use it
Add compositor code to handle this so the gl-renderer can reference just
the paint_node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
1ec218026a compositor: Store view alpha in the paint node
This is one of the few things backends and renderers still need to grab
from the view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
6f09ba42bd compositor: Add cursor layer status to paint nodes
Store this in the paint node so we don't have to look it up in the view
in the backends.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
febd93e4da compositor: Replace view_has_valid_buffer with paint_node_had_valid_buffer
Backends should be relying on paint nodes for their information, not
views.

Since we always have a paint node when we want to pass a buffer, we can
pass that instead of a view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:39:58 -05:00
Pekka Paalanen
528566527e libweston: allow calling weston_compositor_exit() early
Assertions are the usual way of failing tests in the compositor code,
but it means the test program cannot continue further. It would be
better to save an error exit code and run the compositor to the finish,
and then continue with the next test fixture.

I want to force some paths in GL-renderer output initialization for a
test, and fail otherwise. Calling weston_compositor_exit_with_code()
crashes there though, because the frontend has not installed the exit
handler yet.

Skip the exit handler if it's not there. The error exit code is still
saved, and will eventually bubble out of the compositor.

While at it, let's document these.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Marius Vlad
d59e58bb79 compositor: Pass the length to opem_stream for one shot scene-graph
Rather than passing a NULL use sizeloc to pass the size. Otherwise
fflush(3) and fclose(3) would die out crashing in libc.

Use size also when printing out to a subscriber.

Fixes: e9665ef36

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-04-04 08:11:04 +03:00
Pekka Paalanen
f324d30024 doc: Doxygen group for client
Fix the following error:

Generating doc/sphinx/weston-doc-breathe with a custom command
FAILED: [code=1] doc/sphinx/weston
doc/sphinx/run_doxygen_sphinx.sh
/home/pq/git/weston/libweston/compositor.c:10001: error:
Found non-existing group 'client' for the command '@ingroup',
ignoring command (warning treated as error, aborting now)

Fixes: df622cbb20

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-03 09:05:42 +03:00
Derek Foreman
b88695e3d5 compositor: Update transform in weston_coord global converters
I added these assert()s and have regretted it ever since. I'm sorry.

They've led to a bunch of places that just cargo-cult call
weston_view_update_transform() immediately after dirtying the transform,
as well as a lot of very carefully chosen places that took far too long to
sort out.

weston_view_update_transform() is an immediate return if the transform
isn't dirty, so let's just update them here instead of making everyone
think really hard about when to call weston_view_update_transform().

This should let us remove a few transform updates, and should
make the weston_coord functions a little easier to use.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-02 15:29:55 +03:00
Derek Foreman
1f7bdea5c4 compositor: Fix rotated opaque surfaces
When a paint node is drawing rotated content, it's treated like its axis
aligned bounding box. Even if it only contains fully opaque content,
the parts of the axis aligned bounding box outside of that content
are not opaque.

We need to ensure we don't claim a paint node that isn't axis aligned
is fully opaque, or we'll improperly update regions outside of the
really opaque content.

Fixes 485e1796af

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 08:07:35 +03:00
Derek Foreman
bec568f002 compositor: Update transforms before opacity checks
It makes more sense to update the transform than to bail.

These functions are sort of hints - they have to be correct when true, so
the previous code isn't really buggy. But they make more sense at a glance
this way.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-01 08:07:35 +03:00
Daniel Stone
d532ac0452 surface: Mark surface as dirty from attach_solid()
As weston_surface_attach_solid() can change quite a lot about a surface,
we need to mark it as dirty.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2026-04-01 08:01:44 +03: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
d993f783b0 libweston: add internal weston_buffer_destroy()
Two lines open-coded in two places was not much a problem, but I'm going
to add a new member to weston_buffer that needs freeing, and I want to
do it in just one place.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Pekka Paalanen
9d1320b8fb libweston: use fputs() in scene-graph printing
Use fputs() as much as possible. My theory is that since fprintf() needs
to scan through the format string to find any formatting codes, it must
be less efficient than fputs() that does not scan.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Marius Vlad
cba56affdc libweston: Add a bits_to_str_stream() equivalent variant
This is useful for cases where we already have an open stream which we
can pass straight in and use it when printing node information.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-03-10 16:40:40 +02:00
Pekka Paalanen
e9665ef36f libweston: print scene-graph into FILE
Being able to print the scene-graph straight into a FILE removes one
temporary memory allocation that used to be mandatory. That memory
allocation is now gone from the DRM-backend debug log. It has moved into
the scene-graph log scope. In the case of
weston_log_subscription_printf() it shouldn't matter, because it is only
used when new subscribers appear.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Marius Vlad
f8b39037ad libweston: Track weston_compositor_print_scene_graph
For logging performance profiling.

Signed-off-by: Marius Vlad <marius.vlad@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
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
78d15a6f95 libweston: do not call weston_surface::get_label()
Use the new label field instead. The code becomes much simpler.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 09:40:29 +02:00
Marius Vlad
286f58c3d2 libweston: Use the new label infra for subsurfaces
Subsurfaces labels do not have dynamic fields that change so we can just
use it as is.

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
03a081f2c8 libweston: ensure weston_surface::get_label is non-NULL
On the quest to delete the get_label() vfunc completely, a temporary
default get_label implementation needs to be plugged in. This would
affect all the code that checks whether the get_label vfunc is NULL.

Let's make get_label vfunc non-NULL always intentionally first. We can
delete all the code that checked for NULL, and the bespoke label
replacements in that case. Now all those different "no label" cases are
unified.

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
Derek Foreman
b61898fecd compositor: Initialize output vrr_mode
weston_output_init() should be setting all members to a default value,
it can't assume anything is already 0.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-02-23 11:02:02 +00:00
Derek Foreman
0a0ed0653b compositor: return paint node from weston_output_damage_flush_for_plane
Right now, any non-renderer plane only has a single paint node on it. It
can be useful to know what paint node that was after the damage flush.

This will be used shortly to simplify cursor handling in the drm backend.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-02-19 14:35:53 -06:00
Pekka Paalanen
42cf94143c libweston: give paint nodes internal_name and use it
Makes it much easier for humans to track paint nodes through debug logs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +02:00
Pekka Paalanen
ccce888a68 libweston: two more view %p to change
Use the internal name here as well, to match the scene-graph and for
easier reading.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +02:00
Pekka Paalanen
b9a8c4d80c libweston: reword FAILURE_REASONS_NO_COLOR_TRANSFORM
I found it confusing to read:

[view] view 3-2-1 will be placed on the renderer: no color transform

The view definitely has a color transform. What this means is:

[view] view 3-2-1 will be placed on the renderer: cannot off-load color transform

I hope that's more clear.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +02:00
Pekka Paalanen
f87b1afbc4 libweston: do not pass NULL role_name to fprintf
Makes the print-out a little bit tidier. Passing NULL for "%s" is
handled by glibc gracefully, but I'm not sure what standard requires it
if any.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +02:00
Pekka Paalanen
9c2ea5c11f libweston: use view internal_name in scene-graph prints
We have a consistent and more human-friendly name for views. Use it
instead of pointer values, view_idx, and protocol object ID. This makes
the scene-graph print more readable.

I presume the view_idx was just an ad hoc human-readable addressing for
views. It was stable only as long as the scene-graph didn't change. The
view internal_name is always stable and unique.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-19 16:21:19 +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
Robert Mader
35f23903cd compositor: Add helper to get the opaque region from a pnode
To make use of recent optimizations for the is_fully_opaque
calculation, not only relying on the opaque region any more.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-02-13 10:50:32 +01:00
Derek Foreman
d16955a873 compositor: Fix deferred repaints
When we switch to the deferred state, we want to complete all outstanding
repaints first - even ones started from the idle handler immediately
after we called weston_backend_set_deferred().

Fixes #1090
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-02-09 15:10:21 -06: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
Arnaud Vrac
b28e6f8836 compositor: recompute paint node properties when solid state changes
The paint node is_fully_opaque and is_fully_blended properties are overriden
when the paint node is censored or used to clear a hole for an underlay plane,
in which case the paint node is forced to be a solid color.

Those properties need to be recomputed when the paint node solid state changes,
that is:
- when the view becomes uncensored
- before assigning planes; if the paint node was overriden late in the repaint
  loop to clear a hole for an underlay plane, those properties need to be reset
  early in the next repaint loop to properly compute the visibility of
  underneath views.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2026-02-02 10:29:09 +01: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
Marius Vlad
03686c9f89 libweston: Adjust order for tracking dirty paint nodes
Commit 008884f28 ("compositor: Move dirty buffer handling to paint node
early update") makes the dirty paint node bit being
cleared in the update early function which makes t too late to check in
the paint node update late where we used to accumulate painted frames.

Just move it before the early update to make we still have a way to
print painted frames counter.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-01-22 18:14:36 +00:00
Derek Foreman
2543ec3f54 compositor: Add paint_node_changes for paint node removal
When moving the views between two outputs, the view's paint node is
removed from an output's z order list, but no paint_node_changes are set.

The drm-backend uses paint_node_changes to determine if it can reuse state,
so could leave a stale image behind on a plane until something else
triggered new state generation.

Make z_order_link removal dirty the paint node changes to prevent stale
state reuse.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-01-07 10:44:27 -06:00
Marius Vlad
be98923898 compositor: Skip logging scenegraph at compositor start-up
Users might start the compositor with the scene-graph debug scope which
requires having the clock set-up as implicitly one of the backends needs to be
loaded.

Just avoid doing that until we have one the backends loaded to prevent
a start-up crash.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-01-06 08:45:13 -06:00
Derek Foreman
1f642c8c10 compositor: Fix failure to start with multiple outputs
The change in 65227cb7d4 is actually destructive, as it causes multiple
drm-backend heads to no longer be repainted at the exact same time at
startup.

This frequently leads to a failure to flip when only one head is properly
set up and others have stale state.

Force stampless finish_frame to skip any time adjustments to restore proper
behaviour.

Fixes: 65227cb7 (compositor: Round repaint times down to possible presentation times)
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-01-06 08:39:21 +00:00
Derek Foreman
ba008fea76 compositor: Fix paint node debug print for new views
Make sure we check if a paint node has been assigned to a view before
trying to dump its contents.

The scene graph dump from the repaint loop should always be ok, but if
we're using weston-debug we could race with the repaint for a new view
and try to print the scene graph before the node is created.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-01-05 15:58:28 -06: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