Commit graph

411 commits

Author SHA1 Message Date
Pekka Paalanen
98becedfcd libweston: publish eotf and colorimetry mode to string
Frontend wants to print these sometimes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-03 17:49:20 +03:00
Pekka Paalanen
3fefb5ba44 libweston, clients, tests: implement weston_matrix in terms of weston_mat4f
This converts weston_matrix and weston_vector to use linalg-types
internally. All direct accesses to members had to be converted
everywhere, mostly in the simplest form possible which leaves some
trivially reducable code around.

The intention is that we can now gradually migrate away from
weston_matrix in the future.

Look like one trailing space got accidentally annihilated in
compositor.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-01 15:59:54 +03:00
Pekka Paalanen
e8b7ade58b libweston: add linalg-3.h
3x3 matrices, a straight-forward copy of libalg-4.h.

Useful for color computations and 2-D geometry.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-01 15:59:54 +03:00
Pekka Paalanen
f0567654d6 libweston: introduce linalg.h
linalg-types.h can be used from e.g. libweston.h so that structures can
embed linalg types but without forcing every user of libweston.h to
compile all the inline functions.

weston_mat4f implements most of weston_matrix, and some more. This is
just for starters. Implementing weston_mat3fwill be essentially a copy
of all this.

The matrix inversion is a copy from weston_matrix with a little bit of
clean-up.

The goal is to create a more intuitive libear algebra API, that is easy
to extend to 3x3 matrices and 3-vectors, eventually superseding all
existing matrix code: weston_matrix, calls to LittleCMS matrix
routines (plugin API), and ad hoc matrix code in tests/.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-01 15:59:53 +03:00
Marius Vlad
1a2c25116b libweston: Rename LED_* to WESTON_LED*
This is required to avoid a namespace collision for LED_COMPOSE key
code and was introduced with c112760368, "input: Add support for
LED_COMPOSE and LED_KANA".

If not already done this requires a libweston major version bump.

Fixes: #997
Fixes: c112760368, "input: Add support for LED_COMPOSE and LED_KANA
USB HID LEDs"

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-03-07 14:30:20 +00:00
Marius Vlad
5f1c43de29 fontend: Arm the surface counter timer only when using debug
Rather than having this timer always fire up & running, do it when we actually
enable debug, with the `--debug` cmd line argument.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-03-06 16:09:42 +02:00
Marius Vlad
bbe0b74ebd libweston: Add also painted frame rate counters
Rather than using wl_surface::commit to count the frame rate, use the
painted frames for each paint node, and implictly the surface.

This happens in the output repaint paint node list parsing, and includes
also a perfetto counter to display it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-03-06 16:09:39 +02:00
Marius Vlad
e850e97ab7 libweston: Add frame commit frame rate counting
This is a continuation of work from
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/24

This patch adds a surface callback frame rate counter to the scene-graph
debug scope.

The timer interval is set by default to 1 second. This use a timer to
periodically compute the current frame callback commits in that interval
as the surface frame rate per timer interval.  Note that is solely based on
wl_surface::commit call.

Together with this, this patch also adds perfetto counter that stores
the same computed frame rate. This means the counter will be updated on
the next interval timer when the timer is armed/fired such that that
perfetto drawings will show up in a window period of time (interval).

Helpful to identify what frame rates clients achieve to debug
performance issues as to provide an objective common group. Using the
debug-scope aggregates all surfaces at the same place. This is not based
on the GPU whatsoever so it can also work on SHM type of buffers.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Changwoo Cho <changwoo.cho@lge.com>
2025-03-06 15:14:12 +02:00
Marius Vlad
ad3957ddf8 timeline-perfetto: Store disambiguator globally
This way we can use the same ID when for perfetto counters to allow
to identify clients much easier.

Also, renamed "surface" with "unlabelled surface" when get_label function
is not set.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-03-06 15:14:12 +02:00
Derek Foreman
77dcbe381f libweston: Add shell_private data
Shells need to find their own internal structures for weston_outputs.
Let's make that process trivial instead of a list walk.

Add a getter and setter for this private data and use it from the kiosk
shell.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-03-04 12:30:51 +00:00
Robert Mader
9124a98aec color: update color-management protocol to wp-v1
For a list of changes that got squashed into this commit see
https://gitlab.freedesktop.org/rmader/weston/-/commits/color-management-protocol-wp-v1-bkp

Co-authored-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-02-26 10:09:43 -03:00
Derek Foreman
8e26bf1ce9 libweston: Add VRR capabilities
Add functions to query output VRR capabilities and set the current VRR
mode.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-02-21 06:49:42 +00:00
Derek Foreman
85d1ca7fab drm-backend: Set VRR_ENABLED property based on output configuration
Set up the VRR_ENABLED instead of always clearing it to 0.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-02-21 06:49:42 +00:00
Derek Foreman
c321cc3020 drm-backend: Add Variable Refresh Rate modes
Query the vrr_capable property for heads, and expose it to frontends.

Currently we only support game mode VRR, but expose VRR capabilities as
an enum in anticipation of supporting QMS VRR in the future.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-02-21 06:49:42 +00:00
Martin Rys
c112760368 input: Add support for LED_COMPOSE and LED_KANA USB HID LEDs
Also bump up the xkbcommon dependency to a newer, 10 year old version,
to be able to remove very old ifdefs.

Signed-off-by: Martin Rys <martin@rys.rs>
2025-02-12 17:04:06 +02:00
Derek Foreman
0be4403f65 timeline: Add flow ids for surfaces
We add a flow_id when we touch a surface that has no flow id, and clear
it when we flush damage, so a flow line will be drawn connecting any
operations on a surface and terminating in its damage clear.

This is less useful for surfaces that never receive explicit damage after
they're set up, such as background images and the panel, as they might
never show up as a damage track, and have an unterminated flow line.

For surfaces that do show up on a damage track, we can follow them back to
the commit that caused them to update.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-01-24 12:22:13 +00:00
Derek Foreman
485cb4ab12 timeline: Add the TL_POINTs into perfetto data
Try to roughly achieve feature parity with WESGR by processing the same
timepoint data and feeding it into perfetto, with output and surface
specific tracks.

We can't match the way WESGR draws this information, because perfetto has
a different display paradigm, but we can try to at least make sure all the
same information is visible in an understandable way.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-01-24 12:22:13 +00:00
Leandro Ribeiro
9dcc5f20f8 color: adjust a few error codes in our parametric creator API
If a certain feature is unsupported, return UNSUPPORTED instead of
BAD_TF, BAD_PRIMARIES, etc.

Also, up to now cm->get_color_profile_from_params() would return
UNSUPPORTED. But this is different from the other UNSUPPORTED usages, so
return a new error.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
0ed8294881 color: add weston_color_profile_param_builder_set_primary_luminance()
This follows a recent change in the CM&HDR protocol (more specifically,
v4 of the experimental version). Now users of the API can set luminance
parameters for the primary color volume.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
9ae0a7ec05 color: accept max_fall and max_cll even for tf different from PQ
The CM&HDR protocol extension spec relaxed the requirements for the
max_fall and max_cll setters. Now we accept such values even when the
transfer function is not PQ.

This also fixes an issue in which we'd not accept target_luminance
for transfer function different from PQ, which was not on the spec.

INCONSISTENT_SET is not being used in any other errors, so remove that
from enum weston_color_profile_param_builder_error.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
1082ef328a color: rename luminance to target luminance
In the experimental color-management protocol v3
(xx-color-management-v3), we had only the luminance parameters that were
defining the luminance range targeted by the image description. But in
v4 a way to specify luminance parameters for the primary color volume
has been added.

In order to avoid confusion, rename existent luminance variables to
target luminance.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Marius Vlad
43f7b7b3bb windowed-output-api.h: Provide ARRAY_LENGH() for windowed-output-api
We need this common helper as we don't have access to shared helper, so
just define one in-situ.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:28 +02:00
Marius Vlad
207fed2710 Revert "shared/helpers.h: Migrate helpers.h to libweston"
This is problematic as we don't have namespacing for these and some of
the macros can interfere with other defines.

This reverts commit 8634c7e349.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:26 +02:00
Marius Vlad
dae61f3321 windowed-output-api.h: Do an explicit cast to avoid C++ build failure
Address the following build issue:

error: invalid conversion from ‘const void*’ to ‘const
weston_windowed_output_api*’ [-fpermissive] return
weston_plugin_api_get(compositor, api_names[type],
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
const void* sizeof(struct weston_windowed_output_api));

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-11-25 11:26:35 +00:00
Marius Vlad
8634c7e349 shared/helpers.h: Migrate helpers.h to libweston
As weston_windowed_output_get_api needs ARRAY_LENGTH() move helpers to a
libweston/ so other users can re-use that instead of re-defining these
all over. Easier for other front-ends to make use of them.

With this change windowed-output-api.h also includes the helpers header.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-11-25 11:26:35 +00:00
Marius Vlad
a501acd291 libweston/matrix: Fix narrow conversion with C++
Fixes the following C++ narrow conversion:

/include/libweston-14/libweston/matrix.h: In function ‘weston_coord
weston_coord_truncate(weston_coord)’:
/include/libweston-14/libweston/matrix.h:212:39: error: narrowing
conversion of ‘(int)in.weston_coord::x’ from ‘int’ to ‘double’
[-Werror=narrowing] 212 |         return (struct weston_coord){
	(int)in.x, (int)in.y };
      |                                       ^~~~~~~~~
/home/mvlad/install-new/include/libweston-14/libweston/matrix.h:212:50:
error: narrowing conversion of ‘(int)in.weston_coord::y’ from ‘int’ to
‘double’ [-Werror=narrowing] 212 |         return (struct weston_coord){
	(int)in.x, (int)in.y };

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-10-18 20:40:56 +03:00
Marius Vlad
68bbc4cf51 libweston: Move weston_get_backend_type after enum declaration
Fix: #951

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-10-10 07:56:59 +00:00
Lukasz Czechowski
58a0abcb58 vnc: Allow to disable Transport Layer Security
Some VNC clients, i.e. noVNC, do not support TLS encryption.
Add new argument "--disable-transport-layer-security" to
explicitly disable activation of TLS.
This will allow to extend VNC clients compatibility.

Signed-off-by: Lukasz Czechowski <lukasz.czechowski@thaumatec.com>
2024-08-14 07:48:09 +00:00
Marius Vlad
75280d2e40 frontend: Disable client resize for RDP remote outputs
Similar to the VNC backend do the same for the RDP backed, as this would
allow to get a matching output, in dimensions, to the one we are
mirroring.

This also re-works a bit the no-clients-resize to be more inline with
VNC one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-08-12 15:50:13 +00:00
Marius Vlad
f43342cf78 frontend: Disable client resize for VNC remote outputs
As we're mirroring other outputs we shouldn't allow clients to resize
the output.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-08-12 15:50:13 +00:00
Marius Vlad
d553333da8 frontend: Share a native output using 'mirror-of' keyword
This would allow to screen-share a particular output like the
following:

[output]
name=vnc
same-as=DP-5

[output]
name=rdp-0
same-as=DP-4

[output]
name=pipewire
same-as=eDP-1

Both 'vnc', 'pipewire' 'rdp-0' remote outputs would then be a
screen-share 'DP-5', respectively, 'e-DP1', or the 'DP-4' DRM output.

Currently, this is intended only for VNC, RDP and PipeWire remote outputs.

This patch exports weston_output_set_position(), and uses that for
overlapping a remote output with a native DRM one, rather than using
weston_output_move() as that has a side-effect when reflowing outputs
from shells.

Further more creating this remote output is driven entirely by compositor
signal events such that enabling an DRM native output would enable the
remote output, while disabling the native would have the same outcome
for the remote one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-08-12 15:50:13 +00:00
Marius Vlad
c4eb15d453 libweston: Keep a local copy of native_mode
This avoids dereferencing a possible stale pointer, and allows
retrieving the modeline/refresh later on when one needs to retrieve
those values. This is a temporary band-aid.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-08-12 15:50:13 +00:00
Marius Vlad
14cfb97949 libweston: Add a helper for retrieving backend type
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-08-12 15:50:13 +00:00
Joan Torres
1b793b7acd color: update color-management protocol to xx-v4
The main differences is the split of cm_surface functionality with
cm_surface and cm_feedback_surface.

There can only be one cm_surface to set, unset image descriptions. When
cm_surface is destroyed, the image description is automatically unset.

There can be multiple feedback_surfaces for one surface though.
Now the "preferred_changed" signal can be an initial event.

Creator params now have a new request: set_luminances.

Signed-off-by: Joan Torres <joan.torres@suse.com>
2024-08-07 13:36:49 +00:00
Pekka Paalanen
39b577e3a6 libweston: add weston_head_get_display_info()
This new public API is intended to deliver EDID etc. information to the
frontend. The use case here is display colorimetry, to help the frontend
craft output image descriptions (color profiles).

The frontend will need to link to and use libdisplay-info to make use of
this. This avoids having to replicate in libweston the high-level API
that libdisplay-info already has. The libdisplay-info API is also likely
to be extended, and it is not nice to play catch-up with it.

As a di_info can only be destroyed by calling into libdisplay-info,
libweston core can only ensure it has already been freed. There is not
enough reason to make libweston core depend on libdisplay-info, only the
DRM-backend is.

It will be up to DRM-backend to ensure display_info is updated and
device_changed is set only when necessary.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-07-25 13:20:52 +00:00
Derek Foreman
0a4f50a072 libweston: Remove output->scale
We've got output->scale, output->current_scale, output->original_scale and
output->native_scale.

output->scale is apparently just a weird temporary variable, and has led
to some confusing bugs.

Remove it entirely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-15 11:50:49 +00:00
Daniel Stone
f5074f261a view: Move psf_flags from weston_view to weston_paint_node
Fundamentally, the flags are a property of each paint node, rather than
each view as such. Move them over there so it gets a little less painful
to work with.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2024-07-12 17:50:21 +03:00
Derek Foreman
376b3952a0 libweston: Store shm buffer stride in weston_buffer
After c08a6ff8 moved attach to the render loop, we have a bad situation
when clients delete an attached shm buffer. We try to query the stride
at attach time, but the shm_buffer has been destroyed, and we crash.

Instead of carefully fixing that, I've instead stored the stride at
buffer creation time (as we already do with buffer width and height).
This lets attach succeed in the gl-renderer, keeping the old texture data
available for any upcoming rendering.

Fixes: #927

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Tested-by: Connor Abbott <cwabbott0@gmail.com>
2024-07-04 13:07:54 +03:00
Michael Olbrich
ef175c8ed4 backend-drm: handle commit failures correctly
Currently only the return value of the last backend that implements
repaint_flush() is actually used. That only works because the drm backend is the
only backend that implements repaint_flush().
In the drm backend only the return value of the last device is used. And if a
failure is actually detected, then all repainted outputs of all backends are
reset. This can trigger asserts:
weston_output_schedule_repaint_reset() (or _restart()) will change the state of
the output but the backend that did not cause the failure will still call
weston_output_finish_frame().
The same thing can happen with multiple devices in the drm backend. Or outputs
get stuck if an error is dropped.

Since the drm backend is the only one that implements repaint_flush() anyways,
move the failure handling into the backend and make it device specific.
This way only the outputs that need it are reset.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 15:35:30 +02:00
Michael Olbrich
a1f8c49d5b compositor: repaint backends separately
When a repaint is triggered then not all backends may have outputs that need to
be repainted.
Check which outputs will be repainted first and then repaint only the backends
that need it.
This way unnecessary repaint_begin() and repaint_flush()/repaint_cancel() can
be skipped and errors are handled for each backend separately.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 15:35:30 +02:00
Leandro Ribeiro
2c44a4ea4a color: introduce API to create color profile from parameters
Add API to create color profiles from parameters. It is a public API
that should be used by the frontend and also by the color management
protocol implementation.

Currently our protocol implementation does not support clients that want
to create color profiles from parameters, and this is a step towards
supporting that.

As warned in "color: add get_color_profile_from_params() to color
managers", we still do not fully support creating color profiles from
parameters. This just creates a boilerplate color profile that we're
planning to extend later.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00
Leandro Ribeiro
9707a3320d color: add WESTON_TF_POWER
Up to now we had support only for transfer functions with pre-defined
parameters in struct weston_color_tf_info. Add support for the first
parameterized transfer function (a function whose params are not
pre-defined).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:49:09 -03:00
Leandro Ribeiro
1c54ad7fd6 color: make some color struct's and enum's public
In the next commits we are going to introduce a public API to libweston
to allow creating color profiles from parameters. This should be used
by both the frontend and by the color protocol implementation.

This API require some color struct's and enum's that are currently
defined in libweston core, so move them to a public header.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:15:26 -03:00
Marius Vlad
619578f62f kiosk-shell, xwayland: Add a new weston_xwayland_surface_api function
Such that shells can retrieve Xwayland's surface WM_CLASS/WM_NAME and use
it to place the corresponding Xwayland surface on the appropriate
output, similar to what xdg_shell::set_app_id does.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-07 12:40:50 +00:00
Marius Vlad
f2486c8b96 compositor: Remove layer_entry_remove/layer_entry_insert
There are no longer users of these two function. With the
weston_view_move_to_layer() helper being capable of doing this it is time
to retire these entirely to avoid users using them.

Release notes should mention that migrating to the newer helper will be
required when bumping to Weston 14.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-07 11:59:25 +00:00
Pekka Paalanen
53493aaddc libweston: add colorimetry_mode API
This API is mostly for use by the DRM-backend. Colorimetry mode is is
the KMS connector property "Colorspace" which defines the video signal
encoding colorimetry. A video sink indicates the supported modes in EDID
or DisplayID.

This patch adds the libweston API that allows backends to indicate the
supported modes for the frontends, and frontends to set the mode to be
used by backends. Colorimetry mode does not directly affect color
management inside Weston, it is only metadata for the video sink. It is
the frontend's responsibility to set up an output color profile that
agrees with the colorimetry mode. (That API has not been implemented
yet.) eotf_mode will be the same.

There is only one reason to make this a libweston core API instead of
a backend-drm API: when wayland-backend gains color-management protocol
support, meaning it can forward WCG and HDR content correctly to a
host compositor, the supported colorimetry modes can be determined from
the host compositor's supported color-management features, allowing the
guest Weston to pick some other output image description than the host
compositor's preferred image description. This likely allows only a few
other choices from standard colorspaces, so it's possible this isn't
sufficient for that use case.

Either way, it is easy to just copy the eotf_mode API design, and since
colorimetry_mode and eotf_mode go together, let both have the same API
design. It is possible to convert this to backend-drm API later.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen
161cc8643c libweston: move weston_output_color_outcome to private
Turns out these structures do not need to be in the public header, so
move them into a private header.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen
aef9404b1d color: generate id for color transformations
Just like with color profiles, generate an ID for color transformations
as well. This is not needed by protocol or anything, it is just for
debugging purposes. A small ID is easier for humans than a long pointer
value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-20 12:58:12 +00:00
Loïc Molinari
f4c69abc57 libweston: Let multiple backends register the Windowed Output API
The windowed output API is implemented by the Wayland, the X11 and the
headless backends. It's currently not possible to create a secondary
headless backend when the primary backend is Wayland or X11 because
the windowed output API would be registered twice. This commit
suffixes the windowed output API names with the backend name in order
to avoid clashes: "weston_windowed_output_api_<backend>_v2".

A use case for Wayland or X11 as primary backend and headless as
secondary is for instance to request output captures on the headless
backend to avoid read backs on the primary backend's render buffers.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-12 18:35:57 +00:00
Loïc Molinari
7b2eddf022 backend-headless: Add support to repaint only on captures
Damages and captures both trigger repaints of outputs. Some
configurations don't care about damages and use headless only for
captures. This commit adds a new feature to libweston that lets
outputs repaint only on captures, not on damages. The headless backend
enables that new feature when given a special refresh rate of 0 mHz.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-22 14:26:32 +00:00