Commit Graph

80 Commits

Author SHA1 Message Date
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
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
Philipp Zabel bb3b9374aa backend-wayland: 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 Wayland 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
Marius Vlad b51462d001 backend-wayland: Don't signal out resize events for activation
This should avoid spurious signal events received by the shell in order
to resize its buffer.

As we can have resize events being sent even if xdg-shell activation
doesn't happen, make use of the output dimensions to determine if we
need do send out a resize event or not.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-09-26 14:07:25 +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
Daniel Stone daac6fc91d backend-wayland: Free pixel formats on shutdown
We allocated them, we should free them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-12 12:30:53 +01: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 1c262efd70 backend-wayland: Prepare for more renderers, reject no-op
Turn the Pixman/GL if/else conditionals into switch cases to make it
easier to add support for other renderers in the future.

Also makes sure that weston --backend=wayland --renderer=noop fails
with an error message instead of segfaulting.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-06-30 16:36:52 +00: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 fcde7fae66 backend-wayland: use to_wayland_backend
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:47 +01:00
Philipp Zabel 6d699c3f54 libweston: add weston_backend::shutdown callback
Add a weston_backend::shutdown callback to split out the part of
weston_backend::destroy that needs to be done before compositor
shutdown.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:45 +01:00
Philipp Zabel 47180ad253 backend-wayland: fix error path in wayland_backend_create
Destroy the renderer before disconnecting the Wayland display.

Trying to destroy the GL renderer with the Wayland display already gone
crashes in the Mesa Wayland integration.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-26 13:45:59 +00:00
Philipp Zabel 291958682f backend-wayland: track damage on renderbuffers
Track damage on struct weston_renderbuffer and drop the custom damage
region from struct wayland_shm_buffer.

Pass repaint damage to wl_surface_damage() instead of accumulated
renderbuffer damage.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-06-13 15:43:56 +00:00
Derek Foreman e8208d21d7 libweston: Use weston_coord in struct weston_output
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:22 -05:00
Philipp Zabel 2c7dceced7 backend-wayland: fix memory leak in wayland_shm_buffer_attach
Since the pixman_region32_t damage is initialized unconditionally, also
finalize it unconditionally. Otherwise we leak rectangle memory when
sb->output->frame is NULL.

Reported-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-09 09:17:55 +00:00
Michael Olbrich 4ce6b1e498 backend-wayland: fix --fullscreen
Don't forget to transfer the fullscreen setting from the config to the backend.
Without this, weston tries to resize the window with the windowed output API but
that is not registered with new_config.fullscreen == true.

This code was accidentally lost in 0a5bb7acff
("backend-wayland: Use renderer enum type for config selection"). So just
restore it.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-05-30 08:35:23 +02: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 741c9e6a99 backend-wayland: fully release pango and fontconfig
This was not found in the test suite, but if you run wayland-backend
manually with ASan, you see the same leaks as in

  backend-headless: fully release pango and fontconfig

Fix them the same way.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-12 12:34:58 +00:00
Michael Olbrich d29c280867 backend-wayland: allow resizing with xdg-shell
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 14:43:20 +00:00
Michael Olbrich 6b23ffabcf backend-wayland: immediately unref the renderbuffer for use shm buffers
wayland_output_destroy_shm_buffers() is called immediately before
output_destroy() of the renderer is called. And for the pixman renderer all
renderbuffers must be destroyed before the output can be destroyed.
Also, weston_renderbuffer_unref() is not called when the buffer is released
because buffer->output is now NULL, so the renderbuffer would be leaked.

So just unref the renderbuffer immediately. Set it to NULL to avoid unreffing it
again should wayland_output_destroy_shm_buffers() be called again before the
buffer is released. This can happen during an xdg-shell resize.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 14:43:20 +00:00
Michael Olbrich 455f24be9c wayland-backend: split switch_mode to prepare for xdg-shell resizing
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 14:43:20 +00:00
Philipp Zabel 7222171d81 backend-wayland: reuse backend->formats[0] as pixman/cairo/shm pixel format
The pixel format stored in backends->format[0] is effectively looked up
via pixel_format_get_info(DRM_FORMAT_ARGB8888). Reuse that instead of
looking up the same via pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8)
in multiple places.

There are still two instances of hard-coded CAIRO_FORMAT_ARGB32 in
wayland_output_get_shm_buffer() that currently can not be obtained from
pixel_format_info.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-02-16 09:48:55 +00:00
Derek Foreman 8031b9d57f backend: Make input notification functions use weston_coord
Push weston_coord into the notification functions instead of passing
two doubles.

The touch handlers are passed a pointer to a weston_coord, which is
unusual. This is done so we can pass a NULL pointer instead of a
fabricated invalid coordinate when the touch type is TOUCH_UP.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-09 12:12:40 +00:00
Derek Foreman 4d0ce16669 libweston: replace weston_output_transform_coordinate
This creates a global coordinate from a device coordinate.

Replace it with weston_coord_global_from_output_point() which
does the same thing and returns a weston_coord_global.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-09 12:12:40 +00:00
Philipp Zabel 2914f28fd1 backend-wayland: destroy renderbuffer before renderer output state
Reorder pixman renderer output state and SHM renderbuffer removal to
make sure the pixman renderbuffer list is empty when the output state
is destroyed.

Fixes: 4d96635a3f ("pixman-renderer: track damage in weston_renderbuffer")
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-02-03 10:41:08 +02:00
Philipp Zabel 2a6c1afced backend-wayland: fix pixman output state creation
Pixman output state creation requires a valid pixel format to be set for
weston_output_update_capture_info().

Fixes: c67773bc5c ("pixman-renderer: use pixel_format_info instead of pixman_format_code_t")
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-02-03 10:41:08 +02: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 8642a8e8e4 backend-wayland: drop unused pm_image
This pixman image is not actually used anymore, drop it.

Fixes: 89e1831cd7 ("pixman-renderer: add weston_renderbuffer and create/destroy interface")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-26 16:04:32 +01: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 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 edb4ac4bf7 backend-wayland: store backend on struct wayland_output
To avoid retrieving the backend from the compositor all the time, store
a pointer to the wayland backend on its wayland_output structures.

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

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
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 0a5bb7acff backend-wayland: Use renderer enum type for config selection
When we're selecting our renderer, use the enum rather than a boolean to
force Pixman on.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-01-10 10:59:04 +02:00
Pekka Paalanen 212c666ab5 backend-wayland: use gl-borders
Use the gl-renderer border code shared with headless-backend. We can
drop all this open-coded stuff.

In the output disable path, make sure to call this only when gl-renderer
is used. It will also reset the border state in gl-renderer, which is
harmless here, and it's necessary in the resize path.

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 e752c8737f backend-wayland: drop use_pixman from wayland_backend
Now that the renderer type is stored in struct weston_renderer,
use that instead of use_pixman to determine the renderer type.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Philipp Zabel c448819b37 backend-wayland: do not try to release uninitialized seat
Do not call weston_seat_release() if Weston aborts before
weston_seat_init() could be called. This fixes a possible
segfault due to uninitialized list traversal in the error
path.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-11-30 14:11:22 +01:00
Derek Foreman 2ca2eac39a libweston: Split notify_pointer focus into notify/clear
This lets us say what we really mean instead of passing a NULL output
and garbage co-ordinates.

This will help later when manufacturing garbage coordinates becomes much
harder to do.

The clear_pointer_focus() path continues to do nothing, and is just a FIXME
macro, as it has been for a very long time...

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-25 15:58:24 -05:00
Michael Olbrich 631b60b38b backend-wayland: always propagate touch frame event
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-09-24 13:54:57 +02: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
Pekka Paalanen 8636422309 libweston: add weston_renderer::resize_output()
Previously renderers were not told when the output (framebuffer they
need to draw) size changed. Renderers just pulled that information out
from weston_output::current_mode when they happened to need it. This
makes some things awkward, like resizing the shadow or intermediate
buffers. In fact, Pixman-renderer does not even support resizing its
shadow buffer, nor does GL-renderer. DRM-backend has to destroy and
re-create the renderer output state anyway, but rdp, x11 and wayland
backends would be natural users of resizing API.

This commit adds an API for resizing with empty implementations. Actual
implementations will be added in following patches for each renderer
while moving parts of resizing code from backends into the renderers.
No-op renderer needs no implementation.

Only wayland-backend has actual resizing code already, and that is made
to call the new API. Unfortunately, Pixman and GL renderers differ: one
does not blit them while the other does. In order to assert the
functionality of each renderer to keep the API consistent,
wayland-backend needs to lie to pixman-renderer. That's not new, it
already does so in wayland_output_get_shm_buffer() where the 'pm_image'
addresses only the interior area instead of the whole buffer.

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
Derek Foreman 21deaee6a9 libweston: use weston_region_global_to_output more often
Use this anywhere we used weston_matrix_transform_region with an output
matrix.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +00:00