Commit graph

10341 commits

Author SHA1 Message Date
Pekka Paalanen
c0f79189dd shared: add safe_strtofloat()
This is for parsing multiple numbers from one weston.ini key, which
means I cannot use weston_config_section_get_double(). Also going to use
float type, which has less range than double.

Ironically, the tests fill likely fail on locales that do not use
period as the radix character.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-09 16:17:57 +00:00
Daniel Stone
f0be8d94a5 gl-renderer: Use glClear for solid opaque regions
If we have a solid region which is opaque, we don't need to go through
blending: we can simply emit a glClear, which has a pretty big benefit
on tilers in particular.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
af5f2370af gl-renderer: Move pixman_region_to_egl() up
We'll want to use this from earlier code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
1377fdf20d gl-renderer: Ignore transparent paint nodes
Skip these completely during repaint, since they by definition won't
have any effect.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
30a807b86f renderer-gl: Move checks into ensure_surface_buffer_is_ready
Instead of predicating the call to ensure_surface_buffer_is_ready() on
various conditions, move those into early exits from there.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
452f148b6c gl-renderer: Remove copy of buffer colour data
We can just get this directly from the paint node.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
6ffb4358e1 renderer-gl: Merge solid-buffer and placeholder paths
Now that paint nodes handle solid buffers properly, we can use the same
codepath through gl-renderer for all solid buffers, regardless of
whether they're a single-pixel buffer from clients, or a weston_curtain,
or a temporary placeholder due to content-protection or direct-display.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01: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
Daniel Stone
8fc62e9ab8 gl-renderer: Rename prepare_placeholder to generic solid
This is, in fact, the path we'll take for all solid draws.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
b9e31d03ba gl-renderer: Use buffer colour for readback
When we're calling weston_surface_copy_content() from a solid buffer,
use the buffer's solid colour directly instead of our local copy.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Daniel Stone
11d721e748 gl-renderer: Resolve open question
The answer is that no, we do not need to be using the view's opaque
region. If the paint node is marked as fully opaque, that's because the
view itself is also opaque, and as we are dealing with surface
co-ordinates we don't need to be handling the transform here.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 14:01:12 +01:00
Ray Smith
930f768bdb backend-drm: Fix double-free of pending state in error path
drm_pending_state_apply_atomic is supposed to leave pending_state
untouched if called as a test-only and that test fails, as per the docs
for drm_pending_state_test. If it gets as far as doing the atomic test
and it fails, it doesn't free pending_state. However if it fails to even
compile the state for the atomic test (for example, if a particular
property is not implemented in the driver for a particular plane), it
frees pending_state. In this case, drm_output_propose_state will free
the contained drm_output_state again, typically leading to a segfault.

Treat failing to compile the state for the atomic test in the same way
as successfully running the atomic test but it failing.

Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2025-10-09 13:39:23 +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
Philipp Zabel
200f4cf461 weston-log: Fix warning on 32-bit architectures
On 32-bit ARM, tv_usec is of type long long int. Cast to int64_t and
use PRId64 from inttypes.h instead of %ld/%li to silence these format
warnings:

  .../libweston/weston-log.c: In function 'weston_log_scope_timestamp':
  .../libweston/weston-log.c:961:22: warning: format '%ld' expects argument of type 'long int', but argument 5 has type '__suseconds64_t' {aka 'long long int'} [-Wformat=]
  .../libweston/weston-log.c: In function 'weston_log_timestamp':
  .../libweston/weston-log.c:1015:27: warning: format '%li' expects argument of type 'long int', but argument 6 has type '__suseconds64_t' {aka 'long long int'} [-Wformat=]

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2025-10-09 13:29:01 +01:00
Philipp Zabel
de3a3fca1b shell.lua: Fix layer link assertions
Replace two always-true assertions:

        weston_assert_true(wc, &other_shview->view->layer_link.layer);

with what seems to have been the intended check:

        weston_assert_ptr_not_null(wc, other_shview->view->layer_link.layer);

This fixes a build warning:

  .../lua-shell/lua-shell.c: In function 'lua_shell_env_view_move_behind_other_view':
  .../lua-shell/lua-shell.c:1466:1: warning: the comparison will always evaluate as 'true' for the address of 'layer' will never be NULL [-Waddress]
  In file included from .../include/libweston/desktop.h:27,
                   from .../lua-shell/lua-shell.h:27,
                   from .../lua-shell/lua-shell.c:33:
  .../include/libweston/libweston.h:1112:23: note: 'layer' declared here
  .../lua-shell/lua-shell.c: In function 'lua_shell_env_view_move_in_front_of_other_view':
  .../lua-shell/lua-shell.c:1482:1: warning: the comparison will always evaluate as 'true' for the address of 'layer' will never be NULL [-Waddress]
  .../include/libweston/libweston.h:1112:23: note: 'layer' declared here

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2025-10-09 13:45:47 +02:00
Daniel Stone
dc473a4131 tests/color: Increase sRGB->BT2020 matrix tolerance
The average tolerance was very very close on my AMD machine, but not
enough; the maximum tolerance certainly needed to be increased.

Observed on an AMD Radeon 780M with radeonsi from an October 2025 Mesa
build.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-10-09 10:39:31 +01:00
Pekka Paalanen
516f4b9b2f color-lcms: fix transform destroy on error
The error path in cmlcms_color_transform_create() uses
cmlcms_color_transform_destroy() to clean up. cmap_lut3d can be NULL in
that case, and cmsDeleteTransform() chokes on it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
4890cd6a3d frontend: create automatic color profiles from .ini
This introduces a new key for outputs in weston.ini, "color-profile".
For starters, implement a pre-defined sRGB profile and an automatic
profile.

Automatic color profiles are created based on the colorimetry-mode and
the eotf-mode of the output. EDID can also be taken into account, but it
is opt-in due to its potential unreliability.

This feature is documented as not fully implemented, because color-lcms
does not yet handle parametric color profiles together with ICC
profiles. Specifically, the stock sRGB profile is still an ICC profile,
and would not be able to be used together with a parametric output
profile.

Co-authored-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03: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
6ec30279f7 color: weston_color_profile_params_to_str() const
As it should have been. Found, when I temporarily needed to print
'static const struct weston_color_profile_params'.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
e76da2ccd0 color-lcms: shorten parametric profile description
Details are printed separately for logs and debugs, we don't need to
clutter the (short) description with these. The name_part is already
long enough for frontend-created automatic profiles.

Client-created parametric profiles will be indistinguishable from each
other, but we also don't log them anywhere. In debug prints, they are
identified by id numbers and printed in detail.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
e75873d376 color: improve primaries-named builder error
This error gets sent to clients or into the Weston log. Print the name
rather than the meaningless number.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
b8ac69eef1 color: check maxCLL and maxFALL against target lum always
The target luminance range is implied when not explicitly set, so maxCLL
and maxFALL should be checked against target luminances regardless of
whether target luminances are explicit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
a17d5b4eb2 color: validate luminances more
Make sure the given values are finite, positive, and non-zero where
appropriate.

Because these validations are not mandated in the color-management
protocol, they are not immediate failures. They will fail the final
image description creation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
6fbc1376ee color: improve profile builder errors
Statements phrased positive are easier to understand than phrased
negative. Use "must" instead of "should".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
3f150b090b color: fix CIE value validation
The old code checked x for low limit and y for high limit, rather than
checking both for both limits. Fix this.

Check all value pairs rather than the first one four times. Don't stop
at the first error, record them all.

While at it, we might as well print exactly what value was the problem.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
d180517ae4 color: move validate_color_gamut() up the file
This is a simple move of code, no changes. The next patch needs it here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Robert Mader
8e30a7efc7 clients: screenshot: YUV support
If any output uses a YUV format, instead of trying to composite into a
png, write the raw data into .yuv files for each output.

These files don't contain any metadata yet, thus one may want to convert
them into y4m files with e.g. a command like the this:
ffmpeg -s 1024x768 -r 1 -pix_fmt yuv420p -i ~/wayland-screenshot-output-0-2025-08-01_15-58-24.yuv -c:v copy screenshot.y4m

Note that this may only work for certain pixel formats, such as
DRM_FORMAT_YUV4[20|22|44], and not for e.g. DRM_FORMAT_P010.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-07 11:48:33 +02:00
Robert Mader
a9fc1fc0f7 clients: screenshot: Fixup --help command line option
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-07 11:48:33 +02:00
Robert Mader
a09895e907 clients: screenshot: Support dmabuf passthrough for writeback connectors
Instead of relying on the compositor to allocate dmabufs for the
writeback connector and copying the results to the client-provided
shm-buffer, support allocating dmabufs in the client. The compositor
will pass them through to the writeback connector, effectively doing
the equivalent to "passthrough"/"plane-offloading"/"zero-copy".

Based on a patch by Chien Phung Van <chien.phungvan@vn.bosch.com>

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 16:04:18 +02:00
Robert Mader
722f0a2664 tests: drm-writeback-screenshot: Test client dmabuf support
Which is not supported with Pixman, thus test the GL and VK renderers.

This ensures the code-path for directly forwarding client-allocated
dmabufs to the writeback connector works as expected.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 15:53:45 +02:00
Robert Mader
e6b67d2c72 shared/client-buffer-util: Sync for read as well
In the next commit we will need syncing for reading. Thus adapt the sync
helper accordingly. We are not using the helper for performance-critical
tasks yet, thus there's currently no strong reason to allow users to
differentiate between the cases.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
203dbd3393 tests: client-helper: Make client_capture_output() take a client_buffer_type
Using the newly introduced create_buffer(), to which the buffer type is
passed on in order to allow taking writeback screenshots with dmabufs.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
23f396aa30 tests: client-helper: Add create_buffer() helper
Taking the newly introduced client_buffer_type enum, allowing simple
creation of dmabuf buffers.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
e27929e3b3 shared/client-buffer-util: Add buffer type enum
This will be helpful in follow-up commits.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
618bfad1d4 libweston: Get framebuffer from dma buffer in drm backend
If the client requests to take a screenshot using the writeback source
with a DMA buffer, Weston will get the framebuffer from that dmabuf
object and attach it to the writeback connector.

Original commit by Chien Phung Van.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Co-authored-by: Chien Phung Van <chien.phungvan@vn.bosch.com>
2025-10-06 14:06:30 +02:00
Erico Nunes
ad0f4cf94b vulkan-renderer: make dmabuf import dedicated allocation optional
This is not strictly always necessary depending on the implementation,
so the extension requirement can be made optional.
Also improve its usage by first checking whether the dedicated
allocation is preferred/required by the driver, before importing
with dedicated allocation.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-10-02 21:22:45 +01:00
Robert Mader
6cc8f48cd8 clients: Paint desktop-shell color background with single-pixel-buffer
So the buffer has the WESTON_BUFFER_SOLID type, which will make
additional optimizations easier going forward.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-02 17:05:22 +01:00
Marius Vlad
2497377af4 libweston/desktop/xwayland: Add MINIMZE state change
This is identical to MAXIMIZE side where we change the state to
MAXIMIZE, and implicitly go through a state surface check.

For XWAYLAND type of windows (non weston_desktop_surface)
that surface state check will be needed. This is a temporary work-around
to avoid Weston crashing as some X11 Window types will hit this path.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-10-02 08:43:46 +03:00
Derek Foreman
cb17b87a65 xwm: Fix crash when querying position of XWAYLAND windows
windows in the XWAYLAND state are popups and other such things that aren't
managed by libweston-desktop, so we crash if we query their position
with weston_desktop_api.

Query the position for these XWAYLAND windows based on their weston_view
and window geometry.

This should result in synthetic configure notify events no longer crashing.

Fixes #831
Fixes #1019

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-02 07:37:04 +03:00
liang zhou
1560cc3f0b compositor: prevent crash when moving view with popup on first output removal
In a multi-screen setup, removing the first screen triggers `handle_output_move`.
If `weston_view_set_position` is called on an output that has an active popup,
it causes a weston crash due to the view has a parent.

Signed-off-by: liang zhou <liang.zhou@gehealthcare.com>
2025-09-30 13:17:23 +00:00
Marco Felsch
4ba62103a6 backend-drm: set DRM_MODE_ATOMIC_ALLOW_MODESET during head disable
A change in the connector state require a possible full modest depending on the
hardware.

The connector wasn't set to unconnect if the head was detached while the output
is still enabled. Fix this by always checking the disable_head_link list during
drm_output_apply_state_atomic().

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
2025-09-30 15:37:37 +03:00
Marco Felsch
9c67c8c0d8 backend-drm: chek DRM_MODE_ATOMIC_TEST_ONLY before remove from list
DRM_MODE_ATOMIC_TEST_ONLY shouldn't remove the head from the
drm_output::disable_head list else the head is lost for the actual modeset
action.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
2025-09-30 15:36:38 +03:00
liang zhou
0b540ba8d6 desktop-shell: Fix crash when fullscreen surface has no output
The shell_set_view_fullscreen function was dereferencing
shsurf->fullscreen_output without checking if it was NULL first. This
could lead to a crash when a fullscreen surface had no associated
output during display hotplug.

Fix issue: https://gitlab.freedesktop.org/wayland/weston/-/issues/1028

Signed-off-by: liang zhou <liang.zhou@gehealthcare.com>
2025-09-30 12:10:41 +00:00
Robert Mader
5e7835bf2b ci: Bump kernel and Mesa version
1. Bump the kernel version to the drm-misc-next-2025-09-04 tag, fixing
   various issues required for vkms testing.

2. Use /sys/bus/faux/devices/vkms/drm/ instead of /sys/devices/platform/vkms/drm/
   for the card basename.

3. Bump Mesa to the commit needed for vkms+lavapipe. This also needs another
   leak workaround, so the code got a small cleanup.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-26 14:12:04 +02:00
Robert Mader
e187420e38 output-capture: Fix protocol event order
The new formats_done event has to be at the end, triggering warnings
like the following otherwise:

warning: since version not increasing

Fixes: 00902a592 (output-capture: Allow multiple formats and add formats_done event)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 17:53:59 +02:00
Robert Mader
b6c1bc872e output-capture: Fix assertions in pull_capture_task()
Fixes: 9ea205e00 (output-capture: Support writeback connector formats)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 17:51:22 +02:00
Pekka Paalanen
be71b5a094 color-lcms: compare parameters with tolerance
Comparing floating-point values for identity is fragile. Comparaing with
a small tolerance allows for matches that differ only due to numerical
precision of computations.

The tolerance is taken from
weston_color_tf_info_from_parametric_curve().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +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