Commit Graph

9673 Commits

Author SHA1 Message Date
Jeffy Chen 296b5975f3 backend-drm: Don't try to prepare a non-cursor view in renderer-only mode
Doing this might cause unnecessary DRM importing, which might result in
an error when the DRM's memory address mapping is nearly full.

Return before attempting to create drm_fb to avoid that, since it will
fail in the later check anyway.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-07-03 10:22:45 +00:00
Marius Vlad cc3542b574 desktop-shell: Use the correct link iterator
Mistakenly used weston_seat as opposed to shell_seat when iterating over
the shell seats. This unfortunately takes down the compositor upon switching
back.

Fixes: 4c100ca1d7 ('desktop-shell: Add session listener')

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 10:16:05 +00:00
Marius Vlad a7dad91d8f backend-drm: Do not create a head for invalid blacklight values
This most likely is a driver fail, as we shouldn't be getting a zero
value for max_brightness. Later on, this will be used to compute a
normalized brightness which would trip a with a division by zero.
Rather than fixing that up, just don't enable backlight support and
reportat that to the user that we have an invalid max_brightness value
and not backlight support.

Fixes: #878

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 09:57:49 +00:00
Derek Foreman 08c7015a32 pixman-renderer: Check if the shm_buffer is gone during attach
Moving attach to the render loop in c08a6ff8bd
caused this to crash if the shm buffer is destroyed between being committed
to a surface and being rendered.

Since we don't keep a reference to the buffer pool anyway, we might as well
just skip the attachment here.

Fixes: #922

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-03 09:53:12 +00:00
Michael Olbrich 08386229ad compositor: don't try to repaint while offscreen or sleeping
weston_output_schedule_repaint() already checks the compositor state but
idle_repaint() is called asynchronously so the state may have changed.

Check the state again and abort if necessary.

Without this the DRM compositor might execute a modeset in
drm_output_start_repaint_loop() which should not happen while sleeping or
offscreen.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-07-03 09:34:45 +00:00
Marius Vlad c6aa8c9b17 backend-pipewire: Nuke band-aid
With commit a1f8c49d5b 'compositor: repaint backends separately'
we will be repainting outputs independently so there's no need to keep
this band-aid on. Further more, the comment was most likely wrong.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 09:30:08 +00:00
Marius Vlad e271b2ed99 backend-headless: Nuke band-aid
With commit a1f8c49d5b 'compositor: repaint backends separately'
we will be repainting outputs independently so there's no need to keep
this band-aid on.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 09:30:08 +00:00
Marius Vlad 52354f159f kiosk-shell: Don't assume a valid output
Turns out kiosk_shell_output_set_active_surface_tree() requires having a
valid output which as seen in the wild might not be case. Prevents
an illegal dereference on an invalid shoutput.

Fixes: #920
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-02 15:32:49 +03:00
Loïc Molinari 4566eae245 gl-renderer: Improve wireframe rendering
Render wireframe within paint nodes instead of drawing lines in a
second pass. The wireframe is blended over the node in a single draw
call. This slightly simplifies the logic by removing the computation
of a second set of indices and enables wireframe anti-aliasing using
Celes and Abraham's "Fast and versatile texture-based wireframe
rendering" paper from 2011.

Celes and Abraham use a one-dimensional set of texture coords for each
triangle edge, 1.0 for the 2 vertices defining the edge and 0.0 for
the other vertex, which basically define barycentric coords. Texture
mapping and the mip chain is then exploited to give a constant-width
edge. The main drawback of the technique is that contour edges of
node's damage mesh are drawn half as thick as interior lines since
each triangle draws half of each line's thickness.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-27 20:40:37 +00:00
Loïc Molinari 0729ffbdb8 build: Add generic compiler builtins support
Wrap compiler builtins into shared functions with proper generic
implementations. __builtin_clz() isn't wrapped for now because its use
by screenshooter is pretty specific. It will be properly wrapped in
the next commit which needs a round up to the next power of 2
function.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-27 20:40:37 +00:00
Daniel Stone de669aeb60 doc: Tie Sphinx -W to Werror configuration
Only pass -W (warnings are fatal) to Sphinx if we've set Werror in
Meson.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Closes: wayland/weston#917
2024-06-25 17:45:37 +00:00
Michael Olbrich f843ba34d1 drm-backend: limit reset/restart to output of a failed commit
When a commit fails, then only the outputs that where part of this commit should
be reset or restarted.

Otherwise an unrelated output that has another successful pending commit may be
restarted incorrectly. Then the output is in an inconsistent state and will
trigger an assertion:

weston: ../libweston/backend-drm/state-propose.c:627: drm_output_propose_state: Assertion `!output->state_last' failed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 21:39:32 +02: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 e8166e854d backend-drm: skip building atomic state and logging for "empty" repaints
With multiple backends or devices repaint_begin/repaint_flush may be called even
if no outout of a device will be repainted. This results in an "empty" drm state
without any output.
The actual commit to the kernel is already skipped but the drm-backend log is
still filled with "Beginning repaint"/"repaint-flush" messages and the scene
graph.

Use the new prepare_repaint() callback to determine if a backend needs to be
repainted and only create the pending_state if necessary.
Exit early in repaint_flush()/repaint_cancel() when no pending_state was created.

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
Derek Foreman e5318af755 shared: Add some EGL extensions
We're now using EGL_EXT_present_opaque and EGL_EXT_surface_compression
in weston-simple-egl, but this breaks the build for people that don't have
them in their system headers.

Pull them in from the khronos headers.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-21 13:28:41 +00:00
Marius Vlad 4c100ca1d7 desktop-shell: Add session listener
And use it to perform keyboard activation on the currently focused
window. Similar to what kiosk-shell does, with the note that we go
over all seats in the system rather than picking the first one
available.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-21 13:21:27 +00:00
Marius Vlad 5b2f010c03 kiosk-shell: Add session listener
And use it to perform keyboard activation on the currently focused
window.

Fixes: #910

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-21 13:21:27 +00:00
Marius Vlad e70d9d47fc frontend: Use simple_heads_changes for head enablement
Similarly to all the other back-ends do the same for the RDP one.

With this change the remote output will be placed, similar to the
VNC/PipeWire on the right side from the native one, when both backends
are loaded.

But ultimately this patch is about having all backends share the same
code path.

Fixes: #820
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-21 12:43:55 +00:00
Philipp Zabel 060f010c35 compositor: access correct weston_buffer union field according to type
Stop writing weston_buffer::shm_buffer when weston_buffer::type is not
WESTON_BUFFER_SHM. Instead, explicitly write to the union field
that corresponds to the buffer type.
Also add a comment why we clear the shm_buffer/dmabuf/legacy_buffer
pointer here.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2024-06-20 14:18:50 +00:00
Derek Foreman c3321d5819 rdp: Use current_scale instead of scale for input translation
current_scale appears to be the only one of the two updated on mode switch.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-20 06:28:37 -05:00
Marius Vlad 3184f5a2df backend-drm: Print out planes IDs that have been excluded
Makes things clearer which planes we have been skipped due to fmt/modifier.
All other debug sites print out the plane id, and the assumption might
be that we retried the same plane when it fact is a different one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-20 13:26:23 +03:00
Louis-Francis Ratté-Boulianne 1703d76822 clients: add support for surface compression in simple-egl
When option "-c <bpc>" is specified, the application uses
EGL_EXT_surface_compression extension to compress the window
surface to the given bitrate (bits per component).

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
2024-06-20 07:57:38 +00:00
Pekka Paalanen 3908e3e345 frontend: remove useless if (section)
If section is NULL, weston_config_section_get_*() will assign the given
default value and return -1 with ENOENT. Hence, checking for NULL
section is unnecessary.

This cleans up only the simple cases.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-06-19 17:57:38 +00:00
Jeffy Chen 3b7cfdb561 renderer-gl: Support more shm RGB formats
Some applications, e.g. Chromium browser, may provide ABGR format buf.

Tested with gstreamer 1.22.8:
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=RGB' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=BGR' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=ARGB' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=xRGB' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=ABGR' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=xBGR' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=RGBA' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=RGBx' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=BGRA' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=BGRx' ! waylandsink

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-06-19 15:42:59 +08:00
Jeffy Chen be43297679 gl-renderer: Support NV24 shm format
Some HDMI input devices may provide NV24 images.

Tested with:
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=NV24' ! waylandsink

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-06-19 15:41:20 +08:00
Jeffy Chen a073f93aba renderer-gl: Support NV16 shm format
Tested with:
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=NV16' ! waylandsink

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-06-19 15:38:52 +08:00
Pekka Paalanen c4a403b2a6 color-lcms: print ICC profile class on error
Gives a better idea what's wrong.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-06-19 07:40:08 +00:00
Derek Foreman 2819cb51c6 clients/constraints: Fix up buffer handling
Clear the selected buffer pointer immediately before the array walk to
pick a new buffer so we don't accidentally re-use the attached buffer
when it's already in use.

Set the buffer used bit only when we attach and commit a buffer - this way
we don't accidentally consume all our buffers with no way to have them
released.

Clean up buffers based on wl_buffer presence instead of used at end of
run.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-18 16:43:33 +00:00
Derek Foreman 83b37c0ac4 renderers: pull dmabuf initial setup out of attach
With attach only being called at render time, the dmabuf can be deleted
along with its private data before we attach for the first time.

Let's move the first-time logic into its own callback to call at
buffer setup time instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-18 08:45:43 -05:00
Pekka Paalanen 2b6fe57e81 gl-renderer: fix texcoord in shader desc
Seems like a typo, found by reading shader debug scope logs and
wondering why "!?!?" is there, e.g.:

Deleting shader program for: !?!? SHADER_VARIANT_XYUV
SHADER_COLOR_CURVE_IDENTITY SHADER_COLOR_MAPPING_IDENTITY
SHADER_COLOR_CURVE_IDENTITY -input_is_premult -green

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-06-18 11:33:53 +03: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 141f466a03 color-lcms: move ICC profile data to nested struct
No behavior change. Move ICC profile data to nested struct to keep
the code more organized.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00
Leandro Ribeiro 0b9565e859 color-lcms: avoid destroying cprof without rofile
In cmlcms_get_color_profile_from_icc(), if we fail to create the
ro_anonymous_file we end up calling cmlcms_color_profile_destroy() with
a cprof whose cprof->prof_rofile is NULL.

For now that's alright, because cmlcms_color_profile_destroy() checks
if this field is NULL. But in the future we'll drop this check, so
the idea of this patch is to avoid an issue in the future.

Reorganize cmlcms_get_color_profile_from_icc() to avoid destroying a
cprof without a ro_anonymous_file.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00
Leandro Ribeiro 93d086f068 color: add get_color_profile_from_params() to color managers
Add function to color managers to create color profiles from parameters.
This will be used by the parametric color profile builder that we'll add
in the next commit.

WARNING: 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.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:40 -03:00
Leandro Ribeiro 89a57c7b10 color: keep track of supported primaries and transfer functions
In the next commits we'll start support clients that want to create
image descriptions through params using the CM&HDR protocol extension.

In order to do that, we'll have to expose the primaries and transfer
functions that the color manager supports. So keep track of that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:40 -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 8288cead93 timeline: Fix order with sub-surface clients
This corrects the order in which the parent ID surface is higher
than that of the sub-surface.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-14 11:41:13 +00:00
Marius Vlad 538146380a gitlab-ci.yml: Always run container jobs to allow page deploy to work
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-11 18:34:52 +03:00
Leandro Ribeiro 5e84f9167c clients/image: log some information only if verbose mode is set
This patch adds a new CLI option to weston-image: verbose.

It uses that to decide if we should log some info when the image
contains an ICC file embedded.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:15:42 -03:00
Leandro Ribeiro 5933af7a1d clients/image: allow clients to choose rendering intent
Commit "clients/image: use embedded ICC profile to present image" added
the support to present images with embedded ICC profiles being taken
into account. But the rendering intent was hardcoded to perceptual.

In this patch we allow end users to choose other rendering intents
through command line options.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:15:42 -03:00
Leandro Ribeiro d76643ee47 clients/image: print program usage
Add function to print program usage. For now this is kind of useless,
but in the next commit we'll add more functionalities to clients/image
command line options.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:15:42 -03:00
Leandro Ribeiro 576680c780 clients/image: use embedded ICC profile to present image
For image files that have an embedded ICC profile, use the CM&HDR
protocol extension to present taking that into account.

We use the CM&HDR extension to create an image description based on the
ICC profile. Also through the CM&HDR extension we take this image
description and set it to be the surface image description of the
surface in which we present the image.

For now, the rendering intent is hardcoded to be perceptual. In the next
commits we'll allow end users to choose the rendering intent through
command line options.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:15:42 -03:00
Leandro Ribeiro dbdcae9801 clients: add widget_set_image_description_icc()
This function takes an ICC fd, creates an image description for that and
sets the widget surface image description to this one.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:15:40 -03:00
Leandro Ribeiro cf59ed0ebe shared: remove load_image()
We have a single user of load_image(), and that can be easily replaced
by the new and more flexible weston_image_load() function.

So replace and drop load_image() from the code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:13:18 -03:00
Leandro Ribeiro e015081f5d shared: make load_cairo_surface() also load the embedded ICC profile
Instead of loading only the pixman image through load_image(), load both
the pixman image and the ICC profile with weston_image_load().

It also sets the struct weston_image as the cairo surface user data and
adds a function so that users can retrieve this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:13:18 -03:00
Leandro Ribeiro 312efb2acb shared: allow to get ICC profile from JPEG using weston_image_load()
Follow up of "shared: allow to get ICC profile from PNG using
weston_image_load()". This adds the support to get ICC profiles from
JPEG files.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:13:18 -03:00
Leandro Ribeiro d3f393031f shared: allow to get ICC profile from PNG using weston_image_load()
This introduces the functionality to also load the embedded ICC profile
from an image. For now, this only supports PNG files, but in the next
commit we add the support for JPEG as well.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:13:18 -03:00
Leandro Ribeiro 1b0f8693c6 shared: add weston_image_load()
In the next commits we plan to add support to load ICC profiles that are
embedded in images. So we need something more flexible than
load_image().

This patch introduces a new function that, for now, does the same as
load_image(). For now we keep load_image() as well, but the plan is
to drop it later.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:13:18 -03:00