Commit graph

11042 commits

Author SHA1 Message Date
Pekka Paalanen
5fa20c75ca coverage: exclude assert branches
Assertions have two branches, and the fail branch must never be taken,
so it does not make sense to count them in branch coverage. Ignore all
branches on lines matching weston_assert_ regular expression.

The RE must match from the beginning of the line, hence allow leading
whitespace. This is a Python 're' module usage thing. Unfortunately it
is impossible to pass a backslash in a meson.build file as an argument
to a command[1], so let's use a configuration file.

[1]: https://github.com/mesonbuild/meson/issues/1564

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
73a57eba64 color: fix sending power TF exponent
Forgot to do the encoding for the wire. Found by a new test in
development.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Daniel Stone
4b67563783 drm-backend: Remove transparent-to-opaque FB substitution
When we want to scan out a transparent buffer, but know from the
view/surface opaque regions that it's in fact fully opaque, we can help
the hardware out by naming the framebuffer as opaque.

Unfortunately this optimisation has been unsound for a while now.

Firstly, drm_fb caching makes the optimisation racy. We need to cache
the drm_fb for performance reasons, because constantly mapping and
unmapping buffers from the display controller IOMMU can be
excruciatingly slow. But caching it means that our selection of format
is invariant across the buffer's lifetime; we can take an alphaful
buffer, see that it is currently opaque and map it to an opaque
framebuffer format. If the view later becomes non-opaque, we'll still
try to reuse the opaque framebuffer, which is wrong.

Secondly, modifiers may invalidate the optimisation. The observation
that XRGB and ARGB can be transposed for all(.a == 1.0) only holds true
for linear buffers. Non-linear formats such as AFBC and DCC may have
completely different representations for XRGB and ARGB, so it's unsound
to just flip between the two.

The fix for modifiers would be to make the optimisation conditional on
modifier == LINEAR, but since the fix to the temporal soundness issue
with caching is to delete what's there and maybe rebuild it differently
later, let's just do that for now.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2026-06-10 14:22:49 +03:00
Pekka Paalanen
ca8ff7acc9 gl-renderer: try to avoid shader swizzle on ES 2
From the bug report:

	We observed a significant performance regression on OpenGL ES
	2.0 hardware (NXP i.MX8M Mini, Vivante GC NanoUltra) after
	upgrading from weston 14 to 15 that glmark2-es2-wayland scores
	dropped by approximately 23%.

	We bisected this to commit be5c662b ("gl-renderer: Add OpenGL ES 2
	support to texture swizzles"). The texture2D_swizzle() function
	introduced in fragment.glsl uses dynamic vector component indexing
	which is very expensive on ES 2.0 GPUs that lack native support
	for it.

When the component re-ordering is identity, avoid the swizzle
index uniform completely by using a shader without it.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/work_items/1120
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 13:44:14 +03:00
Derek Foreman
f3e30e4692 surface-state: Fix assert firing when subsurfaces have no views
I've not been able to reproduce this, but have a report that this fires
when running Chromium on aarch64.

It seems plausible that we can get here when none of the subsurfaces have
views, and thus the flag won't be set.

Let's make the assert conditional on having views.

Fixes 6a280a8f
Fixes #1117

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-08 21:14:26 +01:00
Derek Foreman
54a5c59b09 drm: Display modifiers in the state dump
It can be useful to know what modifier is being used for a plane's content.

This can mostly be inferred from the paint node dumps in the scene graph,
but that still doesn't tell us what modifiers the renderer's buffer uses.

Dump it next to the format.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-08 21:48:56 +03:00
Derek Foreman
c7e8339b7b drm: Keep track of modifier names in drm_fb
Create the modifier name string at bo creation time and free it at end
of life.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-08 21:48:56 +03:00
Leandro Ribeiro
0a3324d0cd tests: add alpha modifier tests
This adds two new test files:

alpha-modifier-smoke-test.c: contains tests exercising the mechanics of
the protocol, expected errors for misbehaved clients, etc.

alpha-modifier-test.c: contains tests to ensure that the visual changes
from an alpha modifier surface are working as intended. It exercises all
renderers.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
c724914260 tests: move surface_commit_color() to test client helper
This function is duplicated all over the test files. This moves it to
weston-test-client-helper.c and removes the duplicated code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
16027db804 compositor: add support for alpha modifier protocol extension
This adds the boilerplate to support the protocol extension and also
the required changes in core compositor, renderers and backends.

Also, the protocol is now advertised to clients.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
7022de417c compositor: do not change status flags if opaque region is the same
surface_set_opaque_region() currently sets the surface->pending.status
WESTON_SURFACE_DIRTY_BUFFER_PARAMS flag, no matter if the newer opaque
region set by client is the same that we have in the pending state.
Instead, let's compare before raising the flag.

This allow us to reduce a chunk of code from
weston_surface_apply_state(), as it would compare the opaque region of
the pending state with the one currently set in surface->opaque before
dirtying views. Now this is not needed anymore.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
99c41d197c compositor: ignore opaque region hint when surface->is_opaque
The opaque region hint set by client can be ignored when whole surface
is opaque. In this case, the opaque region is the whole surface. So
start ignoring the opaque region hint in such case.

Also, this moves the surface->is_opaque calculation from
weston_surface_attach() to weston_surface_apply_state(), to the same
block in which we use the client opaque region hint. This move is safe
because weston_surface_attach() sets WESTON_SURFACE_DIRTY_BUFFER_PARAMS
when it would recompute is_opaque.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
e387b16c14 compositor: rename struct weston_paint_node member view_alpha to alpha
Paint nodes have a member named view_alpha. In the next commits, this
will be combined with the surface alpha modifier factor. So let's rename
it to alpha.

This also renames view_alpha to paint_node_alpha in our renderers.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
83948e138b pixman-renderer: replace view->alpha with pnode->view_alpha
Similar to "compositor: replace view->alpha with pnode->view_alpha".
Instead of relying on view->alpha, draw_node_translated() should use the
view_alpha value cached in the paint node.

For now this is just a cosmetic change, but it will be needed when we
add support for the alpha modifier protocol extension in the next
commits. Paint node view_alpha will be renamed to alpha and will combine
the view alpha and the surface alpha modifier factor.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
0bc8c54144 compositor: replace view->alpha with pnode->view_alpha
Instead of relying on view->alpha, we can use the view_alpha cached in
the paint node in a few functions. These are functions called after
paint_node_update_early(), where view_alpha gets updated.

For now this is just a cosmetic change, but it will be needed when we
add support for the alpha modifier protocol extension in the next
commits. Paint node view_alpha will be renamed to alpha and will combine
the view alpha and the surface alpha modifier factor.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
f2d8571dbc compositor: move view_alpha computation earlier
In function paint_node_update_early() we compute view_alpha late in the
function, and we have function calls earlier that have to access
view->alpha because pnode->view_alpha would still be outdated.

Compute view_alpha earlier and make use of that in these functions.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
180662e7ab compositor: simplify paint_node_update_early()
pnode->is_fully_opaque and is_fully_transparent are being computed in
several places in function paint_node_update_early(). Years of new
additions resulted in a code that works but is hard to read and reason
about.

This restructures the code and adds a few comments, making it clearer.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Robert Mader
c9c0fc745f input: Stop setting keyboard focus to subsurfaces
The wl_subsurface documentation says:
> A sub-surface never has the keyboard focus of any seat.

The previous behavior - a protocol violation - caused subtle
issues in clients such as Chromium >= 144.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-06-08 11:42:24 +02:00
Pekka Paalanen
67066ad887 drm: constify drm_colorop_pipeline_state::pipeline
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

drm_color_pipeline describes the hardware, so most uses of it must be const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
53c346ec12 drm: constify drm_colorop_state::colorop
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

drm_colorop describes the hardware, so most uses of it must be const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
0b87ca022b drm: constify drm_colorop_matrix_blob
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
473b1becbf drm: constify *_add_prop()
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
241c143553 drm: constify drm_colorop_type_to_str()
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
0ecb8faaf1 drm: constify drm_rotation_from_output_transform()
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
50b5fe1b5d drm: constify drm_colorop_clut_blob
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
374ea6afd8 drm: constify drm_colorop_3x1d_lut_blob
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 16:08:19 +03:00
Pekka Paalanen
630c8bbf2a drm: constify KMS property framework
I discovered there are things we can make const, so I decided to do it
all over the place. Having things const has documentary value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-05 13:56:27 +03:00
Derek Foreman
691c03858b compositor/frontend: Set underscan properties from weston.ini
Look up underscan settings in weston.ini, validate them, and pass them on
to the compositor.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
f3ea435320 drm: Set margin properties if available
We'll prefer the margin properties if they're available, and set
them to set up underscan.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
3f501df947 drm: Check for margin caps and set underscan accordingly
For now, we're going to use either margin or underscan properties to
set up a symmetrical underscan - that way we have feature parity no
matter which props the driver supports.

We can orthogonally expose the things margins can do that symmetrical
borders can't later with a centering offset option, if we want to.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
9b26c1ed09 drm: Add the margin properties
These are a more standard way of configuring underscan. Add the properties
for now, we'll hook them up later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
4b2441df98 drm: Set the underscan properties
Grab them from the output and set them if necessary. Since nothing can
set them yet, this will always be off/0 currently.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
0d4ade8b79 compositor/drm: Check heads for underscan capabilities
Add a weston_head_set_supported_underscan and use it in the drm backend.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
f36b439eff drm: Add underscan properties
Add the enums and property names.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-03 09:36:36 -05:00
Derek Foreman
ba1c247096 drm: Don't attempt to reuse failed state
When a flip fails we can't re-use the state, so make sure the forced
rebuild flag is set for all flip failures, not just flip failures that
stem from a reuse.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-02 22:00:19 +01:00
Marius Vlad
b959b90c4a ivi-shell: Convert to wl_signal_emit_mutable
As far as I can tell all these have correspoding tests
in tests/ivi-layout-test-plugin.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-06-02 14:11:37 +03:00
Marius Vlad
425d21a01e kiosk-shell: Convert to wl_signal_emit_mutable
And add a missing handler removal in kiosk-shell-grab.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-06-02 14:08:53 +03:00
Marius Vlad
e8b6334a6a desktop-shell: Convert to wl_signal_emit_mutable
Removes a destroy signal from input-panel as there no users for it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-06-02 14:08:53 +03:00
Benjamin Otte
00a14c4f14 simple-egl/simple-vulkan: fix reported framerate
The code always reports the framerate once the first frame appears
that's 5 seconds or more after the frame we started counting on.
However, this time is not guaranteed to be exactly 5 seconds after we
started counting, yet we were treating it as such.

This patch changes it by updating the start time to 5 seconds after the
last measurement, so that the reported value matches the 5 second
interval and the rest of the time is included in this measurement.

It also restarts counting if too much time has elapsed - likely the
window had been hidden and not received frame callbacks, so the
framerate isn't reliable.

Signed-off-by: Benjamin Otte <otte@redhat.com>
2026-06-02 10:34:57 +03:00
Derek Foreman
16d0015445 trace: Just add some new log points for input
Gives us a better window into where input latency comes from.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-01 08:48:51 -05:00
Derek Foreman
8a501ef1a9 trace: Add a weston_trace_time_since and use it for input events
Adds a time_since typedef and _Generic annotator - we can typecast any
timestamp to a time_since for annotation, and the result will be the time
in microseconds between the timestamp and the current time (ie: the time
the annotations are being commit)

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-01 08:48:51 -05:00
Pekka Paalanen
e36836e64f backend-rdp: fix sprintf compiler warning
This patch seems to fix the following compiler warning (as error) from
GCC 16.1.1:

../../git/weston/libweston/backend-rdp/rdpclip.c: In function ‘clipboard_process_html’:
../../git/weston/libweston/backend-rdp/rdpclip.c:417:31: error: ‘%08u’ directive writing between 8 and 10 bytes into a region of size 0 [-Werror=format-overflow=]
  417 |                 sprintf(cur, "%08u", fragment_start);
      |                               ^~~~
../../git/weston/libweston/backend-rdp/rdpclip.c:417:17: note: ‘sprintf’ output between 9 and 11 bytes into a destination of size 0
  417 |                 sprintf(cur, "%08u", fragment_start);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../git/weston/libweston/backend-rdp/rdpclip.c:420:31: error: ‘%08u’ directive writing between 8 and 10 bytes into a region of size 0 [-Werror=format-overflow=]
  420 |                 sprintf(cur, "%08u", fragment_end);
      |                               ^~~~
../../git/weston/libweston/backend-rdp/rdpclip.c:420:30: note: using the range [0, 4294967295] for directive argument
  420 |                 sprintf(cur, "%08u", fragment_end);
      |                              ^~~~~~
../../git/weston/libweston/backend-rdp/rdpclip.c:420:17: note: ‘sprintf’ output between 9 and 11 bytes into a destination of size 0
  420 |                 sprintf(cur, "%08u", fragment_end);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a false-positive, as the destination is fixed via the hardcoded
HTML header and the offsets into it.

First I thought the problem was with the "region of size 0" and could
not make sense of it. Turns out the warnings were triggered by the
potential of formatting numbers longer than 8 decimal characters.
Ensuring the numbers cannot need more than 8 characters makes the
compiler happy.

If the numbers were more than 8 characters, the header would get
corrupted, and the numbers itself would get corrupted. Hence it seems
prudent to just bail off in that case. Input data is not trusted anyway,
and although unlikely, a 100+ MB blob does seem possible in theory.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-01 14:02:08 +03:00
Pekka Paalanen
4db67f1eac tests: drop the custom ELF section
With DECLARE_TEST_LIST(), there is no need for the custom ELF section.
We can use a plain variable to refer to the list of test functions.

This makes the test harness more reliable as we are no longer relying on
internal compiler behavior on laying out objects in sections. This is
also obvious to memory access checkers that the accesses are valid.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
807245bce6 tests: remove old test listing macros
After the conversion to DECLARE_TEST_LIST(), none of these are used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
dffdcb1757 tests/xwayland-test: migrate to DECLARE_TEST_LIST API
Replace TEST() macros with explicit static functions and
DECLARE_TEST_LIST() registration for better type safety and to
prepare for removing the custom ELF section.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
610a7f9aa7 tests/xdg-shell-test: migrate to DECLARE_TEST_LIST API
Replace TEST() macros with explicit static functions and
DECLARE_TEST_LIST() registration for better type safety and to
prepare for removing the custom ELF section.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
ab605f59e7 tests/viewporter-test: migrate to DECLARE_TEST_LIST API
Replace TEST() and TEST_P() macros with explicit static functions and
DECLARE_TEST_LIST() registration for better type safety and to
prepare for removing the custom ELF section.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
a15c5ef3bb tests/viewporter-shot-test: migrate to DECLARE_TEST_LIST API
Replace TEST() macros with explicit static functions and
DECLARE_TEST_LIST() registration for better type safety and to
prepare for removing the custom ELF section.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
1ee9479b29 tests/vertex-clip-test: migrate to DECLARE_TEST_LIST API
Replace TEST() and TEST_P() macros with explicit static functions and
DECLARE_TEST_LIST() registration for better type safety and to
prepare for removing the custom ELF section.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00
Pekka Paalanen
972368356c tests/touch-test: migrate to DECLARE_TEST_LIST API
Replace TEST() macros with explicit static functions and
DECLARE_TEST_LIST() registration for better type safety and to
prepare for removing the custom ELF section.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-05-28 16:29:56 +03:00