Commit Graph

68 Commits

Author SHA1 Message Date
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
Loïc Molinari 53cc781701 backend-headless: Fix release/debugoptimized build warning with gcc
Fix ‘ret’ used uninitialized.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-03 10:54:34 +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
Ray Smith 433f648adb backend-headless: Don't try to finish frame if it was cancelled
When multiple outputs are present, a failure in one's repaint will
cause any repaints of all other outputs to be cancelled. If this
happens during the headless "frame" time, the assertion on
repaint_status in weston_output_finish_frame fails.

Do the same as the DRM backend does in its equivalent callback
drm_output_update_complete and don't finish the frame.

Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2024-06-07 11:00:25 +00:00
Derek Foreman 27bf066c81 renderer: Move dmabuf setup into renderer init
We've forgotten to set this up in some backends, so let's just do it in
weston_compositor_init_renderer().

The headless backend used to fail out if linux_dmabuf_setup() failed, but
had no reason to do so, so just remove that to make the code common.

Suggested by cwabbott on irc.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-05-10 00:09:35 -05:00
Pekka Paalanen ea91d595dc backend-headless: support all colorimetry modes
The headless backend does not display to anything, so it doesn't care
what the colorimetry mode is. To allow testing compositor internal
behavior, claim to support all colorimetry modes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Jordan Williams 2e6c58fb37
meson: Add missing dependencies on egl
A proper dependency on egl is missing for several backends as well as
for libshared. This dependency is necessary to pull in the correct
include directories from the egl.pc pkg-config file. 

Signed-off-by: Jordan Williams <jordan@jwillikers.com>
2024-03-18 10:27:40 -05: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
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
Derek Foreman 2abe4efcf7 libweston/backends: Move damage flush into backends
Currently we flush damage for the "primary plane" every repaint, but this
is folly.

The drm backend may skip rendering entirely if using an all-planes
composition. This could leave the renderer plane in a messy state if a
surface on an overlay plane disappears.

Instead, let the backends flush the primary plane damage when they know
they need to render.

Fixes #864

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-01-10 14:13:09 -06:00
Derek Foreman e3a509236b headless: Enable use as a secondary backend
Conditionally create the renderer like other secondary backends.

Now that we have multi-backend support and overlapping outputs, an
interesting use case for the headless backend exists.

We can have a high performance steady state on the drm backend with
all content on scan-out planes, bypassing the renderer. Taking a
screenshot of this would ideally use readback, but some hardware is
incapable of readback, or only capable at certain resolutions.

By using the headless backend as a secondary backend, and creating a
headless output that overlaps the drm outputs, we can take the
screenshot on the headless backend without disrupting the plane
layout on the drm backend.

For this to be efficient, other changes need to be made, but this is
a step in that direction.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-16 12:13:21 +00:00
Philipp Zabel baaef12432 backend-headless: enable multi-backend support
Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine whether the backend is capable of being loaded simultaneously
with other backends.

The headless backend can only be loaded as primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Philipp Zabel 1d59530e4b libweston: Set the presentation clock in the compositor
Let backends declare the presentation clocks they can use with a
new bitfield weston_backend::supported_presentation_clocks and set
presentation clock after loading the backend in the compositor.

Make weston_compositor_set_presentation_clock() internal and replace
weston_compositor_set_presentation_clock_software() with an exported
weston_compositor_backends_loaded(), which is called by the compositor
after the backend is loaded.

In the future, this can be extended to determine the subset of clocks
supported by all backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 11:51:56 +03:00
Derek Foreman f07af89f9c libweston: Move output damage subtraction out of backends
Right now every backend clears output damage from the primary plane when
it repaints. Instead of having this same operation spread across all
the backends, just do it in the core instead.

In the future, we want to remove damage tracking from the primary plane
entirely, and this is a small step in that direction.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Philipp Zabel 90c11cf40e libweston: move weston_compositor_shutdown call out of backends
If we want to support multiple backends, the compositor must take care
to call this once, at the appropriate moment, so stop letting the
backends handle compositor shutdown themselves.

Move the weston_compositor_shutdown() calls from the backend::destroy
callbacks into weston_compositor_destroy() and the calls in the backend
creation error paths into weston_compositor_load_backend().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:47 +01:00
Philipp Zabel b1606a9f2c gl-renderer: support automatically downloading FBO renderbuffers
For software backends like VNC, support downloading the FBO renderbuffer
contents via glReadPixels automatically at the end of repaint_output.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-09 15:37:09 +00:00
Philipp Zabel c3d49732de backend-headless: render to FBO instead of pbuffer
Render into an FBO instead of a PBuffer EGL surface.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-09 09:21:31 +00:00
Marius Vlad 44d185138f libweston/backend-headless: Remove cleanup_after_cairo()
In some circumstances (like system load) we seem to be racing with the
threads fontconfig creates and the resource release happening inside
cleanup_after_cairo(), and we would still find a cached entry holding a
font map reference while we are on the compositor exit path --
which happens in cleanup_after_cairo() when calling
cairo_debug_reset_static_data().

This was introduced with commit 823580e070, 'backend-headless: fully
release pango and fontconfig', as a way to have a clean memory leak
report, but due to the fact we can't influence how libraries manage
their threads, the solution (for now at least) would be to just remove
it entirely.

Running it at the end in the test itself, or before calling exit(2),
while it does narrow the window, it still exhibits the cairo crash assert
related to having cached entries in that font map hash table.

Reference: https://gitlab.freedesktop.org/wayland/weston/-/issues/756

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-06-07 13:09:21 +03:00
Philipp Zabel 7d2112c713 libweston: pass backend to weston_windowed_output_api::create_head()
Pass the backend instead of the compositor to the windowed output API
create_head() method and increment the API version.

That way the backend will not have to find the backend pointer from the
compositor. This is trivial now, but in the multi-backend case would
entail iterating over all backends to find the correct one.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-04-17 09:38:50 +02:00
Pekka Paalanen 823580e070 backend-headless: fully release pango and fontconfig
In the color-icc-output test, this fixes the following ASan reports:

Direct leak of 6912 byte(s) in 27 object(s) allocated from:
    #0 0x7f36bf0a9e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f36bd9c2704  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20704)
    #2 0x7f36bd9c2dc8  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20dc8)
    #3 0x7f36bd9c439c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c)
    #4 0x7f36bd9cb24c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c)
    #5 0x7f36bd29c4a9  (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9)
    #6 0x7f36bd29ada7  (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7)
    #7 0x7f36bd29ba59  (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59)
    #8 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0)
    #9 0x7f36bd9c9152  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152)
    #10 0x7f36bd9c956b  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b)
    #11 0x7f36bd9c977c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c)
    #12 0x7f36bd9c9c9e  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e)
    #13 0x7f36bd29c4a9  (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9)
    #14 0x7f36bd29ada7  (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7)
    #15 0x7f36bd29ba59  (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59)
    #16 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0)
    #17 0x7f36bd9c9152  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152)
    #18 0x7f36bd9c956b  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b)
    #19 0x7f36bd9bb507  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507)
    #20 0x7f36bd9bb766  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766)
    #21 0x7f36bd9ad926  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926)
    #22 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6)
    #23 0x7f36ba21caae  (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae)
    #24 0x7f36b9b8a6df  (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df)
    #25 0x7f36b9b88bd9  (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9)
    #26 0x7f36b9db218d  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d)
    #27 0x7f36b9db313b  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b)
    #28 0x7f36b9db39aa  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa)
    #29 0x7f36b9db84c8  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8)
    #30 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702)
    #31 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586
    #32 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071
    #33 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81
    #34 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150
    #35 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165
    #36 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115
    #37 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186
    #38 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267
    #39 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526
    #40 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020
    #41 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431
    #42 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080
    #43 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410
    #44 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534
    #45 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462
    #46 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464
    #47 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682
    #48 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308
    #49 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89)

Indirect leak of 1696 byte(s) in 53 object(s) allocated from:
    #0 0x7f36bf0aa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f36bd9c2d48  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d48)
    #2 0x7f36bd9c439c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c)
    #3 0x7f36bd9cb24c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c)
    #4 0x7f36bd29c4a9  (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9)
    #5 0x7f36bd29ada7  (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7)
    #6 0x7f36bd29ba59  (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59)
    #7 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0)
    #8 0x7f36bd9c9152  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152)
    #9 0x7f36bd9c956b  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b)
    #10 0x7f36bd9c977c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c)
    #11 0x7f36bd9c9c9e  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e)
    #12 0x7f36bd29c4a9  (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9)
    #13 0x7f36bd29ada7  (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7)
    #14 0x7f36bd29ba59  (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59)
    #15 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0)
    #16 0x7f36bd9c9152  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152)
    #17 0x7f36bd9c956b  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b)
    #18 0x7f36bd9bb507  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507)
    #19 0x7f36bd9bb766  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766)
    #20 0x7f36bd9ad926  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926)
    #21 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6)
    #22 0x7f36ba21caae  (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae)
    #23 0x7f36b9b8a6df  (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df)
    #24 0x7f36b9b88bd9  (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9)
    #25 0x7f36b9db218d  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d)
    #26 0x7f36b9db313b  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b)
    #27 0x7f36b9db39aa  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa)
    #28 0x7f36b9db84c8  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8)
    #29 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702)
    #30 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586
    #31 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071
    #32 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81
    #33 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150
    #34 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165
    #35 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115
    #36 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186
    #37 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267
    #38 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526
    #39 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020
    #40 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431
    #41 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080
    #42 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410
    #43 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534
    #44 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462
    #45 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464
    #46 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682
    #47 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308
    #48 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89)

Indirect leak of 537 byte(s) in 52 object(s) allocated from:
    #0 0x7f36bf057817 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:452
    #1 0x7f36bd9c1fa4 in FcValueSave (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1ffa4)
    #2 0x7f36bd9c2d5d  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d5d)
    #3 0x7f36bd9c439c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c)
    #4 0x7f36bd9cb24c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c)
    #5 0x7f36bd29c4a9  (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9)
    #6 0x7f36bd29ada7  (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7)
    #7 0x7f36bd29ba59  (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59)
    #8 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0)
    #9 0x7f36bd9c9152  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152)
    #10 0x7f36bd9c956b  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b)
    #11 0x7f36bd9c977c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c)
    #12 0x7f36bd9c9c9e  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e)
    #13 0x7f36bd29c4a9  (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9)
    #14 0x7f36bd29ada7  (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7)
    #15 0x7f36bd29ba59  (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59)
    #16 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0)
    #17 0x7f36bd9c9152  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152)
    #18 0x7f36bd9c956b  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b)
    #19 0x7f36bd9bb507  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507)
    #20 0x7f36bd9bb766  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766)
    #21 0x7f36bd9ad926  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926)
    #22 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6)
    #23 0x7f36ba21caae  (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae)
    #24 0x7f36b9b8a6df  (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df)
    #25 0x7f36b9b88bd9  (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9)
    #26 0x7f36b9db218d  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d)
    #27 0x7f36b9db313b  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b)
    #28 0x7f36b9db39aa  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa)
    #29 0x7f36b9db84c8  (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8)
    #30 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702)
    #31 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586
    #32 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071
    #33 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81
    #34 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150
    #35 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165
    #36 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115
    #37 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186
    #38 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267
    #39 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526
    #40 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020
    #41 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431
    #42 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080
    #43 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410
    #44 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534
    #45 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462
    #46 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464
    #47 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682
    #48 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308
    #49 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89)

SUMMARY: AddressSanitizer: 9145 byte(s) leaked in 132 allocation(s).

We do the clean-up unconditionally because xwayland plugin may also need
it, but cannot easily do it itself. This reduces reported leaks in
xwayland test too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-12 12:34:58 +00:00
Philipp Zabel ad38c41a50 gl-renderer: use pixel_format_info instead of drm fourccs
Use struct pixel_format_info pointers instead of uint32_t drm fourcc
values at the API surface for output and image creation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-29 14:47:03 +01:00
Philipp Zabel c67773bc5c pixman-renderer: use pixel_format_info instead of pixman_format_code_t
Use struct pixel_format_info pointers instead of pixman_format_code_t
values at the API surface for output and image creation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-28 12:59:16 +00:00
Philipp Zabel 14533cdd25 libweston: make weston_renderbuffer refcounted
Add weston_renderbuffer_ref/unref() functions and use them to
eventually destroy the weston_renderbuffer. Drop the explicit
renderbuffer_destroy vfunc from the pixman renderer interface.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-27 16:52:14 +01:00
Philipp Zabel e4538a7647 pixman-renderer: rename create_image_no_clear to create_image
Given that pixman_image_create_bits_no_clear() is asked to allocate the
buffer on its own, the _no_clear part is not important. Drop it.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-26 12:50:09 +01:00
Philipp Zabel a782040368 pixman-renderer: update capture info on output creation
Move the call to weston_output_update_capture_info() from the headless
backend into pixman_renderer_output_create(). For this, add an
uint32_t drm_format parameter to struct pixman_renderer_output_options.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-23 20:05:21 +00:00
Philipp Zabel af5acbc9cb libweston: let weston_output_update_capture_info() take drm_format
Let weston_output_update_capture_info() take a uint32_t drm_format
parameter directly instead of const struct pixel_format_info *format.
No other fields apart from the format were used from this structure.

Without this, callers may have to unnecessarily look up the pixel
format info in cases where the DRM fourcc is already available.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-23 20:05:21 +00:00
Philipp Zabel eb9a740c20 libweston: move pixman_renderer_init() into weston_compositor_init_renderer()
Stop calling pixman_renderer_init() from backends directly.
Call it via weston_compositor_init_renderer() instead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-23 20:05:21 +00:00
Philipp Zabel 4d96635a3f pixman-renderer: track damage in weston_renderbuffer
Add a damage region to struct weston_renderbuffer and use it to replace
the previous_damage tracking in the drm backend.

Keep renderbuffers on a list in struct pixman_output_state and use it
to accumulate damage on all renderbuffers during repaint_output.
Now renderbuffers have to be created when pixman output state already
exists.
Reorder renderer output state and renderbuffer creation accordingly.

With this, pixman_renderer_output_set_hw_extra_damage() can be removed.

This can not yet replace the external damage tracking in the VNC
backend, which needsto know the accumulated damage that is not returned
from repaint_output.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 6757bae0f3 pixman-renderer: set renderbuffer via new repaint_output parameter
Add a struct weston_renderbuffer parameter to repaint_output and make
backends set the pixman image renderbuffer through this parameter
instead of using pixman_renderer_output_set_buffer()

Turn pixman_renderer_output_set_buffer() static.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 89e1831cd7 pixman-renderer: add weston_renderbuffer and create/destroy interface
Add a create_image_from_ptr vfunc to struct pixman_renderer_interface,
which wraps weston_renderbuffer creation for the pixman renderer via
pixman_image_create_bits(), as well as a renderbuffer_destroy vfunc
to dispose of the pixman image renderbuffer.
Also add create_image_no_clear using pixman_image_create_bits_no_clear()
instead.

Make the backends create and destroy their pixman image renderbuffers
through this interface.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 32c7629516 pixman-renderer: add pixman_renderer_interface
Add a struct pixman_renderer_interface with output_create and
output_destroy vfuncs and store a pointer to it in struct
weston_renderer.

Make all backends access the pixman_renderer_output_create/destroy
functions through this interface and turn them static.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel fc8d260ce3 libweston, backends: move GL renderer interface into weston_renderer
Move the struct gl_renderer_interface pointer from the backends into
the weston_renderer structure. The interface struct only contains
function pointers that never change, so make it const.

Load and initialize the GL renderer in libweston instead of in the
backends, using the new weston_compositor_init_renderer() function.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-16 20:40:34 +01:00
Philipp Zabel 39aebcabcb backend-headless: store backend on struct headless_output
To avoid retrieving the backend from the compositor all the time, store
a pointer to the headless backend on its headless_output structures.

This will be useful once the compositor contains more than one backend.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-16 17:11:08 +01:00
Philipp Zabel 6f977640e6 libweston, backends: pass backend parameter to weston_backend functions
Passing the backend as a parameter to the weston_backend function
pointers seems more natural and will be very useful once there can be
more than one backend.

Since all backends already store a pointer to the compositor instance,
replace the compositor parameter with the backend in all functions.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-13 18:55:59 +01:00
Daniel Stone b846c26d97 backend-headless: Use renderer enum type for config selection
When we're selecting our renderer, use the enum rather than two
mutually-exclusive booleans to not use the no-op renderer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-01-10 10:59:04 +02:00
Daniel Stone e1da6c6615 libweston: Add WESTON_RENDERER_AUTO type
Add an 'auto' or unspecified renderer type, so we can use enum
weston_renderer_type during the configuration stage, where the target
renderer may be unspecified or unknown.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-01-10 10:59:04 +02:00
Pekka Paalanen e619a65b09 libweston: move gl-borders code into helper lib
Move this code from headless-backend to a helper library, so it can be
shared with wayland-backend.

gl-renderer.h was missing #pragma once, which made the build fail.

Unfortunately gl-borders needs gl-renderer.h which will attempt to
include EGL headers if gl-renderer is enabled in the build, so we must
get the EGL build flags too, just for the headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen c57112a40a backend-headless: refactor into weston_gl_borders
Refactor this code into two backend-agnostic functions, that in the next
step can be moved into code shared between backends.

Pure refactoring, no changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen 5522f73559 backend-headless: clean up gl border data pointer
GL-renderer keeps the pointer for the border image data for later use.
When we destroy our cairo_surface, that data gets freed. Therefore,
reset the pointer stored by GL-renderer too, to ensure use-after-free
cannot happen.

This is not really necessary in this particular case, because the
renderer output is destroyed immediately after, so there is no chance of
UAF.

However, this is needed for code sharing purposes. Wayland-backend will
do exactly this when an output is resized. To share this code with
wayland-backend, we also need to reset the pointers. It's harmless and
more correct in the output disable path.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen f47ed7894c backend-headless: use a loop in update_gl_border
Replace a bunch of copied code with a loop over a simple array. This
makes the code easier to read, and allows further refactoring.

This is pure refactoring, no changes to results or behavior.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Philipp Zabel 746a03068e libweston, backends: store backend pointer in struct weston_head
Compositor code can use opaque pointer comparison to determine whether
a head belongs to a given backend. Store a backend pointer in struct
weston_head to enable the compositor to select the correct backend
specific output configuration code.

This also allows to use the backend pointer instead of the opaque
backend_id pointer to check whether a head belongs to a backend, so
replace the checks in all to_xyz_head() functions and drop backend_id.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 15:21:16 +01:00
Philipp Zabel 51c8882991 libweston: move headless_backend::renderer_type to weston_renderer::type
Move the renderer type from struct headless_backend into struct
weston_renderer to store the chosen renderer type in a unified manner.
This will later allow secondary backends to determine the renderer type
chosen by the primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Pekka Paalanen 3746e163ab backend-headless: add option for output decorations
When the new option is enabled, headless backend will draw decorations
around its outputs. This makes the actual "framebuffer" larger by the
thickness of the decorations to keep the video mode area free for
clients.

This will be needed for a future test, that will ensure that GL-renderer
will paint the output decorations correctly.

The output title is deliberately NULL, because text rendering is
unpredictable and depends on e.g. what fonts are installed in the
system. Therefore screenshot testing of any text would be really
painful, so let's avoid that.

The decorations setup code is mostly copied from wayland-backend.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00:00
Pekka Paalanen 7886cbe4b9 gl-renderer: pass initial output area explicitly
This changes the GL-renderer interface to pass the initial framebuffer
size and compositing area explicitly. All backends are changed to
provide the correct parameters.

GL-renderer mostly does not yet use these values, but later patches
will. The pbuffer path uses it already, because they replaced the
existing fields.

All this is to make GL-renderer aware of the different sizes, so it can
implement the future revision of the screenshooting API.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-23 12:42:05 +00:00
Pekka Paalanen f4559b0760 pixman-renderer: pass initial size explicitly
In a journey to decouple renderer from weston_output, pass the initial
framebuffer size to Pixman-renderer explicitly.

Now Pixman-renderer will never look into weston_output::current_mode.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-23 12:42:05 +00:00
Marius Vlad eaf2de3441 compositor: Use weston_load_module
Except the module dir path, they're one and the same. This change
warrants a libweston version bump, if it hasn't been done already.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:47:40 +00:00
Pekka Paalanen 8b6c3fe0ad backend-headless: choose pixel format by drm_fourcc
Pixman image formats are CPU-endianess dependent while drm_fourcc are
not. Standardise around drm_fourcc because DRM-backend uses them anyway.

This also makes Pixman-renderer use the same format as GL-renderer will
prefer on headless.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-29 08:54:21 +00:00
Pekka Paalanen dd706d5953 backend-headless: let pixman allocate the image
No need to manually allocate the storage, Pixman can do that.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-29 08:54:21 +00:00
Philipp Zabel 5159af0607 backend-headless: check that outputs and heads are in fact ours
As a first step towards heterogeneous outputs, ignore other backends'
heads and outputs. This is done by checking the destroy callbacks for
heads and outputs.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-06-10 09:27:43 +00:00