Commit Graph

9691 Commits

Author SHA1 Message Date
Loïc Molinari bc2d30050b gl-renderer: Only update y2 when merging damage rects
No need to update x1, x2 and y1 when merging a damage rect into a
previous one because they don't change. Melt merge_rect() into the
band compression routine as it's quite short now and convert the
boolean-based for/else construct to a more concise goto-based one.

Describe the compression logic to give a bit more context.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
Loïc Molinari 7ba16ef264 gl-renderer: Prevent programming errors on damage regions
transform_damage() expects a non-empty damage region. Remove
compress_bands()'s run-time handling of errors and use asserts to
prevent programming errors.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
Loïc Molinari 946bb51a2a gl-renderer: Test axis alignment once per paint node
The axis alignment test is part of the damage transformation routine
executed for each damage rect. Extract it in order to compute it once
per paint node.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
Loïc Molinari 445e83c417 gl-renderer: Transform damage rects once per paint node
Previous commit ensured damage rects compression (first step) happens
just once when a paint node both has an opaque and a translucent
region. This one makes sure that the damage rects transformation to
surface space (second step) happens just once.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
Loïc Molinari 2170caade0 gl-renderer: Compress damage rects once per paint node
Before rendering a surface, its visible region is intersected with the
damage region in global space. The resulting region is compressed
(first step) and transformed to surface space (second step) for
clipping. These steps sometimes happen twice when a paint node both
has an opaque and a translucent region. This commit makes sure the
first step happens just once.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
Loïc Molinari 2d71347397 gl-renderer: Move functions to ease next commit review
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
vanfanel 90664b0f3b libweston: enable pointer constraints for fullscreen surfaces.
Signed-off-by: vanfanel <redwindwanderer@gmail.com>
2024-03-04 12:45:07 +01:00
Witold Lipieta 215cceb45d desktop-shell: shell: Capture input on fade animation curtain
Shell fades out and in depending on user interactions. When screen
is faded out, first interaction wakes up the shell from idle and screen
fades back in. However, this first interaction is applied to whatever
is "behind" faded screen and it may trigger unwanted actions (first
touch or mouse click on active GUI elements). Behavior is the same for
both idle and lock screen (because unlock dialog is created after the
first interaction).

Update fade animation curtain creation function to capture inputs in
order to prevent unwanted interactions within faded or locked shell.

Fixes issues #147 and #569.

Signed-off-by: Witold Lipieta <witold.lipieta@thaumatec.com>
2024-02-29 15:29:23 +01:00
Pekka Paalanen 7e22c28444 color: declare cm_image_desc_info
Fixes compiler warnings about the declaration in function signatures not
applying outside of the functions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 61b3ae335a color-lcms: clean up context in init failure
This is not strictly necessary, because if init fails, then
weston_compositor_backends_loaded() fails, main.c will
weston_compositor_destroy() -> weston_compositor_shutdown() ->
cmclcms_destroy() which will free this. But that is very hard to track
down, so let's make the code obviously more correct.

We must also avoid cmsDeleteContext(NULL), because it will then do
something to the default cms context rather than bail out.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 80c0d5e643 color-lcms: create log scopes in cmlcms_init()
This does not change any behaviour, but creating complex dynamic things
was intended to be done in init() rather than color_manager_create().

Create is called from weston_compositor_load_color_manager() before
loading backends, and init is called from
weston_compositor_backends_loaded() after loading backends.

Now we assert instead of check that scope creation succeeded, because
the only way it could fail is to have small memory allocations fail, or
internal code error.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 3e9f8402ad color-lcms: move two functions up in file
No changes to the functions at all. This makes them available for use in
cmlcms_init() for the next patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen dcaff175b4 libweston: assert that color manager supports perceptual
This is required by the protocol spec.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen bdea44919b shared: add weston_assert_bit_is_set()
Will be used in the next patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen d9a7b3795a libweston: move color-management protocol init call to core
This reverts commit 188a3ebd5e.

Call weston_compositor_enable_color_management_protocol() after
compositor->color_manager has been set, and so allows to check if the
color manager supports the features mandatory in protocol. The check is
added in the next patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 35a580dab6 color-lcms: rename get_cprof_or_stock_sRGB to to_cprof_or_stock_sRGB
"Get" could imply increasing reference count, and color transform
objects indeed are reference counted, but this function does not do
that. Rename it to reduce confusion.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 4f796a52e1 color: rename get_stock_sRGB_color_profile to ref_stock_sRGB_color_profile
This makes it more explicit that this indeed is increasing the reference
count, rather than just returning a pointer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen ce51a04013 color-lcms: rename get_xform() to to_cmlcms_xform()
"Get" could imply increasing reference count, and color transform
objects indeed are reference counted, but this function does not do
that. Rename it to reduce confusion.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 6fe294c18a color-lcms: rename get_cprof() to to_cmlcms_cprof()
"Get" could imply increasing reference count, and color profile objects
indeed are reference counted, but this function does not do that. Rename
it to reduce confusion.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen 952f3ef61d color-lcms: rename get_cmlcms() to to_cmlcms()
"Get" might easily imply reference counting, but there is none here.
"to" is more descriptive for a cast.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:39 +02:00
Pekka Paalanen f19b15e373 color-noop: rename get_cprof() to to_cmnoop_cprof()
"Get" could imply increasing reference count, and color profile objects
indeed are reference counted, but this function does not do that. Rename
it to reduce confusion.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:46:33 +02:00
Pekka Paalanen de1db83e04 color-noop: rename get_cmnoop to to_cmnoop
"Get" might easily imply reference counting, but there is none here.
"to" is more descriptive for a cast.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-23 16:31:40 +02:00
Leandro Ribeiro ffe08c4344 libweston: create/destroy color profile id generator in a safe point
Currently we create the color profile id generator in
weston_compositor_backends_loaded() and destroy it in
weston_compositor_shutdown().

If something goes wrong and Weston does not start properly, we end up
calling weston_compositor_shutdown() for a struct weston_compositor
whose color profile id generator is NULL, crashing.

This fixes that, creating/destroying the id generator in
weston_compositor_create()/destroy().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-23 11:50:23 +00:00
Wujian Sun 042d02f422 libweston-desktop: Fix weston crash when lost the shsurf
The shell_surface may disappear when keyboard lost focus,
then the shsurf will be NULL.
Have an ahead check for shsurf before calling the callback
in weston_desktop_surface_foreach_child.

Fixes #811

Tested-by: Erkai Ji <erkai.ji@nxp.com>
Signed-off-by: Wujian Sun <wujian.sun_1@nxp.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-02-23 10:14:42 +08:00
Loïc Molinari 31a9a4831f tests: Only wait for frame callback when necessary
Some tests don't need to wait for the frame callback when a surface is
moved. This commit renames the move_client() helper function to
move_client_frame_sync() so that tests which need synchronisation must
explicitely request it. This allows to get 4 more tests using
repaint only on capture and to speed up runtime.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-22 14:26:32 +00:00
Loïc Molinari 5791bdf6ec backend-headless: Improve documentation
Add a section about the headless backend to the main Weston manual
page and describe the current CLI options as well the new
`--refresh-rate` one.

Fix the incorrect list of supported transforms in the CLI usage.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-22 14:26:32 +00:00
Loïc Molinari 343adb2acd tests: Speed up runtime using immediate repaint on capture
The test suite is throttled by the headless backend repaint
timer. This commit uses the headless refresh rate option to speed up
runtime by using the immediate repaint-only-on-capture mode by
default. Tests which don't support that mode yet override the refresh
value to use the highest rate possible.

Fixes #682

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-22 14:26:32 +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
Loïc Molinari 6caeba699d backend-headless: Add support for custom refresh rates
Custom headless refresh rates can be useful to instrument clients
matching different screen configurations. This commit adds support for
that to the headless backend and exposes it to the frontend with the
"--refresh-rate" CLI option. The default refresh value is still 60 Hz.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-22 14:26:32 +00:00
Leandro Ribeiro 6da5b8a5a5 color-noop: avoid assert hit in cmnoop_destroy()
When we are destroying the color manager, the components referencing
color profiles should have already been destroyed. We have an assert
in cmnoop_destroy() to make sure that the stock profile has refcount
equal to 1.

But we currently have an issue in Weston. While shutting down with
client surfaces alive, we may leak them. So we try to destroy
the color manager with surfaces still alive, and they may be
referencing color profiles.

We already have a workaround for this in our LittleCMS color plugin,
but we've missed that in color-noop. This fixes that, so now we don't
hit the assert anymore.

As we are already dealing with asserts in color-noop, I took the
liberty to replace the last usage of assert with our own wrapper
in this file.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-22 11:38:22 +00:00
Arnaud Vrac 238d5274a2 fullscreen-shell: do not crash when presenting a null surface
The protocol allows presenting a null surface, in this case we would crash. This
can be reproduced with weston-fullscreen and pressing 'o'.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2024-02-21 18:14:18 +02:00
Arnaud Vrac 373ee4df45 fullscreen-shell: restore focus when output is created
Keyboard focus is lost when the first output is created after a default surface
is picked. This can also happen after all outputs disappear and a new one is
created.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2024-02-21 18:14:18 +02:00
Arnaud Vrac acb1d6721e fullscreen-shell: handle output resize and move signals
Outputs are rendered incorrectly after they are resized or moved, so monitor
those events to reconfigure the output and schedule a repaint in this case.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2024-02-21 18:14:18 +02:00
Arnaud Vrac ccb6413aa1 fullscreen-shell: unregister output created listener on shell destroy
Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2024-02-21 18:14:18 +02:00
Jeffy Chen 9406664a54 backend-drm: Cleanup output's disable head list when destroying it
Avoid memory use-after-free when the trying to remove entries from an
already freed list later.

Also add missing removal in drm_output_detach_head() and drm_head_destroy().

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-02-21 11:14:23 +00:00
Diego Nieto 1db0da8c8d compositor/main: warn pipewire-output and remote-output
These warn let to recognize what can be the issue whether
pipewire-output or remote-output has been set but its
mode it is not. Without this log, if mode is not set,
the init just exits

Signed-off-by: Diego Nieto <diego.nieto.m@outlook.com>
2024-02-21 09:49:23 +00:00
Paul Pu 4eee3c816d Fix segfault when using fullscreen when just hotplugging the display
Set the fullscreen_output to NULL when output gets destroyed. Otherwise,
a use-after-free case can happen, which result in a SEGFAULT crash.

Fixes #766

Signed-off-by: Paul Pu <hui.pu@gehealthcare.com>
2024-02-21 17:22:31 +08:00
Diego Nieto 4261892d77 clients/simple-damage: fix exiting message
Signed-off-by: Diego Nieto <diego.nieto.m@outlook.com>
2024-02-20 10:04:57 +00:00
Leandro Ribeiro 0ade70fb6c tests: add tests for the color management protocol implementation
Exercise the color-management protocol mechanics.

This lacks a few test cases that are a bit harder to have, e.g. testing
that a bad ICC file gets rejected. In the future we plan to add them.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-14 12:13:04 -03:00
Leandro Ribeiro 67c6d39634 tests: allow to expect protocol errors from unknown objects
wl_display_get_protocol_error() takes a pointer to interface as
parameter and may set it to NULL when the error comes from an unknown
interface.

That can happen when the client destroys the wl_proxy before calling
this function. So when the wl_display.error event comes, it will refer
to an object id that has already been marked as deleted in the
client's object map. So the protocol error interface will be set to
NULL and its id to 0.

In our test suite, expect_protocol_error() ignores such case, and
asserts that a interface != NULL is set. This commit fixes that, and
now callers are able to call expect_protocol_error() when they expect
errors from unknown objects.

In the next commit we add the color-management protocol implementation
tests, and that requires such case to work.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-14 12:13:04 -03:00
Leandro Ribeiro 39ada71cb3 gitlab-ci: build and install LittleCMS version 2.16
When using some features from LittleCMS in our CI, we are seeing some
crashes on the address sanitizer. Bumping the LittleCMS version fixes
that. So build and install a more recent version of LittleCMS on our CI.

We chose version 2.16 because it introduces the function
cmsGetToneCurveSegment(). We already make extensive use of that in our
codebase, so it is a good idea to have that on our CI as well.

Now color-curve-segments.c will start to get build on the CI, as
HAVE_CMS_GET_TONE_CURVE_SEGMENT will be true. So we also fix a minor
issue in which we were comparing int with uint in this file, what was
caught after experimenting bumping the LittleCMS version.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-14 12:13:04 -03:00
Leandro Ribeiro 188a3ebd5e libweston: expose color management support
In this patch we enable the color-management protocol support, as long
as the color-manager plugin in use supports it.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-14 11:15:35 -03:00
Leandro Ribeiro 5706d7e5d2 color: add support to the color-management protocol
In this MR we add support to the majority of the interfaces from the
color-management protocol.

That means that we are able to advertise output's images descriptions to
clients, preferred surface images descriptions, and so on. We also
support clients that wants to create ICC-based images descriptions and
set such descriptions for surfaces.

We still don't support the interface to allow clients to create
image descriptions from parameters, but that should be addressed
in the near future.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-14 11:15:35 -03:00
Leandro Ribeiro c7d33edd01 color: add color properties helper
Similar to pixel-formats.c, but for color properties. This helper
aggregates the same color properties from different APIs into tables,
and introduce functions to use that.

The idea is that we only use that internally in our libweston struct's,
and pick the specific API value only when necessary.

Preparation for the CM&HDR protocol extension implementation.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-13 14:15:31 -03:00
Leandro Ribeiro 01b43e5294 protocol: add color-management-v2.xml
This does not implement the protocol, it will simply run the scanner
on the xml to generate the .c and .h files.

This is a variant of the color-management protocol that still didn't
land upstream on the wayland-protocols repository.

We are using that to experiment with the protocol, but we'll
completely drop this eventually, when the official protocol
lands.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-13 14:15:31 -03:00
Leandro Ribeiro a84806a88e libweston: add unique id generator
This is preparation for the CM&HDR protocol implementation. It requires
us to give a unique id to each color-profile, so let's do that.

In this commit we introduce a generic id generator to libweston, and
its first user: the color-profile.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-13 14:08:38 -03:00
Leandro Ribeiro ba1561946f shared: include missing header to weston-assert
We forgot to include stdbool to weston-assert.h, but this was not
causing issues because callers of weston_assert_true() themselves
include stdbool.

Add stdbool to weston-assert, as this is the right thing to do.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-13 08:59:57 -03:00
Leandro Ribeiro a2f99828fe color: always set HAVE_LCMS when LittleCMS dependency is found
Up to now, HAVE_LCMS would be set only when users would build Weston
with the deprecated cms-static enabled. But we'll start using this in
libweston in the next commits, independently of cms-static being enabled
or not. So always set HAVE_LCMS when the LittleCMS dependency is found.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-13 08:59:57 -03:00
Leandro Ribeiro bac9060d54 tests: make use of helpers to create unique filenames
Start to use the helpers introduced in "tests: add helpers to create
unique filenames".

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>

Pekka: Dropped program name from output_filename_for_test_case() calls
as it is already added automatically.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-12 14:10:44 +00:00
Leandro Ribeiro d29f904bec tests: add helpers to create unique filenames
With such helpers we are able to create unique filenames for a test
program, a fixture or specific test cases.

This help us to avoid accidents related to using files from other
tests or overriding them.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-12 14:10:44 +00:00