Commit graph

628 commits

Author SHA1 Message Date
Derek Foreman
cb49b386f2 compositor: Move paint node validation into a function
We're going to assert on a bunch of stuff, so let's put it in a function
to remove clutter.

For now it's trivial, but I'll be adding more tests shortly.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-16 10:25:42 -05:00
Derek Foreman
59e2a111fa compositor: Remove is_direct from paint node
It's the same as buffer->direct_display essentially 100% of the time,
except maybe if someone set weston_direct on a single-pixel-buffer, but
that's madness.

Just drop it entirely, and let the only existing reader of the variable
get it from the buffer directly.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-16 10:25:42 -05:00
Derek Foreman
1465362e9f compositor: Move paint node censor into early update
Previously I didn't think we needed this set up before assign_planes, but
certainly in the near future we'll want access to these bits for plane
assignment. It should be harmless to move them all now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-10 09:15:07 -05:00
Daniel Stone
c6b519ab12 paint-node: Set draw_solid for single-pixel buffers
Single-pixel buffers are, by definition, a single-colour fill across the
entire paint node. Use the draw_solid path for these where we can.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
e96a970e56 buffer: Don't lose direct-display when censoring output
When we're censoring output due to a content-protection mismatch, we
were setting draw_solid for the placeholder, but losing is_direct for
the original buffer.

There's no real effect with the current renderers, but best to be
consistent and make pnode->is_direct always accurate.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Philipp Zabel
847952b711 compositor: Fix warning on 32-bit architectures
On 32-bit ARM, tv_sec is of type long long int. Cast to int64_t and
use PRId64 from inttypes.h instead of %ld to silence these format
warnings:

  .../libweston/compositor.c: In function 'weston_compositor_print_scene_graph':
  .../libweston/compositor.c:9297:14: warning: format '%ld' expects argument of type 'long int', but argument 3 has type '__time64_t' {aka 'long long int'} [-Wformat=]
  .../libweston/compositor.c:9322:16: warning: format '%ld' expects argument of type 'long int', but argument 3 has type '__time64_t' {aka 'long long int'} [-Wformat=]

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2025-10-09 13:29:01 +01:00
Marius Vlad
bcb7676ed7 backend-drm: Add some further debug message for hot-plug events
And also for connector changes. This would allow tracking hot-plug
events from the udev/kernel and figure out that connector properties
changed.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-09-25 14:07:48 +01: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
Derek Foreman
1a9cf3bfb6 compositor: Fix output reflowing when mirroring is in use
When we have a mirror, it will be at the same x,y position as the output
it's mirroring. On hot unplug, the current logic results in the mirroring
output being moved to the left by the width of its target output. The
mirror will then be destroyed, and the views can be left dangling outside
of usable space when a hot plug restores the outputs.

Subtly change the reflow logic to only reflow outputs to the right of the
removed output by testing co-ordinates, instead of assuming that every
output in the list is to the right of the previous.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-17 11:39:03 +00:00
Derek Foreman
439aea0188 compositor: Track DIRTY_POS properly
For clients using old protocol versions, the WESTON_SURFACE_DIRTY_POS bit
currently gets set on any attachment. It should really only be set if
the attachment is non-zero.

Since it's possible to attach mulitple times, or to invoke
wl_surface.offset multiple times, let's allow clearing the bit so it
stays up to date with the state that will actually be used on commmit().

Currently, this is pointlessly pedantic, as we don't really do much with
the bit, but in a future commit I intend to use it to notice states that
may change visibility/occlusion status of a surface.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-08 08:14:09 +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
ac71d40dec compositor: Add transforms to scene graph debug dump
Add transform information to scene graph debug dumps, which can be
helpful in determining why application surfaces aren't ending up on
hardware planes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:34:18 -05:00
Derek Foreman
cfaa19a292 libweston: Move transform string code into libweston
Pull this out of the frontend.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:34:18 -05:00
Derek Foreman
628e860ffa compositor: Dump some paint node info with the scene graph
For now I've just added plane failure reasons, but more could follow.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:34:18 -05:00
Derek Foreman
6e7b4d63c2 compositor/drm: Move failure reason stringification into compositor
While this is generally drm specific stuff, it's leaked into paint nodes
a little bit already.

Pushing it into the core gives us the ability to print failure reasons
in the scene graph debug text (in a future commit), which can be very
informative.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:34:17 -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
760ca22e8f compositor: Remove unused forward declaration
We don't need to define weston_compositor_build_view_list here, as it's
already defined before it's used.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
0ea8141195 compositor: Move a bunch of surface state handling stuff to another file
compositor.c is too big, let's try to peel off a bit of surface state
handling code into another file.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
72f73f6692 compositor: internally export weston_surface_to_subsurface
I'll want to use this in another file soon, but for now let's just
clean up the extra prototypes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
3b017341b7 compositor: Make weston_surface_commit handle subsurfaces
Push the subsurface vs surface logic into weston_surface_commit so there's
just one function to call from surface_commit to handle both.

This is mostly preparation for splitting off a bunch of surface handling
functions into their own file later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
76dc730d3d compositor: Move region_init_infinite to a header
We've got it in two places, let's share the code.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
e79c9ceee5 compositor: Move cache flush into weston_subsurface_set_synchronized
Do a subsurface cache flush in weston_subsurface_set_effectively_synchronized
instead of in the protocol handler.

This is just so when I move some functions into another file later, I don't
need to expose weston_subsurface_apply_from_cache().

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
b76e6ebd82 compositor: rename surface_commit_from_cache to apply_from_cache
Finish up renaming functions so that committing state and applying state
have their own function names. This will be useful soon when we have a
mechanism to commit state into a queue and apply it later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
98253554c8 compositor: Remove weston_subsurface_synchronized_commit
This is now just a call to weston_subsurface_commit_from_cache, so just
call that directly.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
93ad388414 compositor: Move parent_apply call into weston_surface_apply
To streamline state handling, push the weston_subsurface_parent_apply
calls and list walks into weston_surface_apply().

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
fb7b3e2880 compositor: Make subsurface state application order consistent
We have several places where we apply surface state, then walk the
subsurface list.

In surface_commit() however, we walk the list first then apply state.

Re-order surface_commit() so it's the same as the other sites.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
051f0ac7d9 compositor: Rename parent_commit to parent_apply
Continue renaming "commit" functions to "apply" in anticipation of
a violent split between the two concepts.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
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
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
Derek Foreman
f132462df7 compositor: Don't pass a time to weston_output_repaint()
Nothing does anything with this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-08-01 15:08:00 +00:00
Leandro Ribeiro
3f81d2fd38 compositor: let backends handle output->disable_planes
On weston_output_repaint(), we have:

output_assign_planes(output);
...
output->repaint(output);

output_assign_planes() avoids calling output->assign_planes() when
output->disable_planes > 0. This brings a few complications to backends,
because they can't rely on the repaint loop starting from a certain
function: sometimes it starts from assign_planes(), others from
repaint().

Let's be more consistent: always call assign_planes() and let backends
handle output->disable_planes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-07-18 17:58:45 +02:00
Marius Vlad
feb4fd1386 compositor, frontend: Allow to configure placeholder-color
This is a trivial change to allow passing a user-defined color to
specify the color for the placeholder.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-06-24 16:00:05 +03:00
zhou liang
fc3e3cf653 compositor: prevent weston_surface references a destroyed output
weston_surface retains a pointer to its associated output, but if the
output is destroyed, the pointer becomes invalid. In set_fullscreen(),
weston_shell_utils_get_focused_output may return this stale output via
weston_keyboard, leading to a use-after-free crash.

This change ensures the output reference is cleared when the output is
destroyed, preventing potential crashes.

Signed-off-by: zhou liang <liang.zhou@gehealthcare.com>
2025-06-09 11:23:37 +00:00
Derek Foreman
cf44b691c6 compositor: Add weston_view_move_before_layer_entry
Add a function to move a view in front of a layer entry, so we can easily
add this functionality to lua-shell in a future commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-06-04 15:39:03 +03:00
Derek Foreman
a124b19a01 compositor: Remove weston_view_damage_below()
It has no more callers, and hasn't done what its name implies for a very
long time.

Remove it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-05-30 11:38:47 +00:00
Derek Foreman
cc0edfd13d compositor: Remove weston_view_damage_below from transform add/remove
weston_view_damage_below() does nothing but schedule a repaint, and a
repaint will be scheduled in weston_view_geometry_dirty_internal() anyway,
so remove the extra call.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-05-30 11:38:47 +00:00
Derek Foreman
1683d7a9d2 compositor: Schedule a repaint directly in weston_view_unmap
Instead of calling weston_view_damage_below(), which only schedules a
repaint, call weston_view_schedule_repaint() instead.

The result is the same, but the code is less confusing.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-05-30 11:38:47 +00:00
Derek Foreman
601a72dd8c compositor: Remove weston_view_damage_below calls from update_transform
Update transform only does something if we've called
weston_view_geometry_dirty_internal() previously to set the dirty flag.

weston_view_damage_below() just schedules a repaint, and
weston_view_geometry_dirty_internal() will already have done that.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-05-30 11:38:47 +00:00