Commit Graph

69 Commits

Author SHA1 Message Date
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
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
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
Marius Vlad 93e4f4e01f backend-x11: Fix error shutdown path for x11
Another fix for 14c52a942b, 'backend-x11: enable multi-backend support'.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-11-20 16:31:26 +02:00
Marius Vlad 8d85c43355 backend-x11: Move back-end removal to the destroy function
Otherwise we end up with an invalid backend on the shutdown path of the
compositor. This mimics what the wayland back-end does.

Fixes 14c52a942b, 'backend-x11: enable multi-backend support'.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-10-23 20:10:19 +03:00
Derek Foreman cec0ab7d23 libweston: Make better use of global coord helpers
Use wesotn_coord_sub/add() in many more places.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Philipp Zabel 14c52a942b backend-x11: 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 X11 backend can only be loaded as primary backend.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-09-28 14:02:04 +00:00
Philipp Zabel b7fb70630a backend-x11: Use weston_output_finish_frame_from_timer()
Replace the finish frame handler logic with a call to the
weston_output_finish_frame_from_timer() helper function that
does the same.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-27 12:37:09 +03:00
Philipp Zabel fd10c92d69 backend-x11: Use weston_output_arm_frame_timer()
Replace the finish frame timer arming logic with a call to the
weston_output_arm_frame_timer() helper function that does the same.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-27 12:37:09 +03:00
Philipp Zabel d9a8073568 backend-x11: fix output repaint timing
Copy the output repaint timing code from the PipeWire backend.
This evens frame pacing under varying render time and allows
to actually reach 60 fps.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-18 20:41:51 +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 d46b491c83 backend-x11: 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 others renderer in the future.

Also makes sure that weston --backend=x11 --renderer=noop fails
with an error message instead of starting with the GL renderer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-30 11:02:28 +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 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 f154fbba97 libweston: consolidate 'Using GL/Pixman renderer' log message
Consolidates the 'Using GL/Pixman renderer' message emitted by the
PipeWire, RDP, VNC, and X11 backends by moving the weston_log() into
weston_compositor_init_renderer(). Only print the message after
initializing the renderer has succeeded.

This effectively adds the message to the DRM, headless, and Wayland
backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-05-04 14:47:49 +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
Derek Foreman 4a2e7c9f1f backend-x11: use weston_coord to store previous pointer position
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-24 18:44:19 +00:00
Derek Foreman 69908000e3 input: Convert weston_pointer_motion_event to weston_coord
This struct has a lot of members that can be converted to weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-09 12:12:40 +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 7c1492216e backend-x11: split x11_output_get_pixel_format out of x11_output_init_shm
Split x11_output_get_pixel_format() out of x11_output_init_shm() so the
pixel format can already be known when calling pixman->output_create().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-02-07 09:32:31 +00:00
Philipp Zabel a222ce03c7 backend-x11: create renderbuffer when pixman output state already exists
Reorder pixman renderer output state and SHM renderbuffer creation and
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 918ec64f6a backend-x11: 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 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 116c234703 pixman-renderer: add pixman_renderbuffer specialization
Add a private struct pixman_renderbuffer that derives from struct
weston_renderbuffer and move the pixman renderer specific image and link
fields into it.

Add a pixman_renderbuffer_get_image() helper for the backends that need
to access the contained pixman image, RDP and X11.

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 ce6c8e8fd6 backend-x11: store backend on struct x11_output
To avoid retrieving the backend from the compositor all the time, store
a pointer to the x11 backend on its x11_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 53a32e7888 backend-x11: 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 915d8e8cdf build: simplify dep_egl a bit
Make sure dep_egl is always a valid dependency object, even if not
found. Ensure it is not found when not wanted, to avoid linking when
found but not wanted.

Using a not-found dependency in Meson is defined to be a safe no-op, so
use that to simplify the backend dependencies.

libweston/meson.build already errors out if renderer-gl is enabled and
EGL is not found, so the same checks can be removed from the backends.

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 06eb28ba62 backend-x11: drop use_pixman from x11_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
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
Pekka Paalanen 8c4f75f0ea backend-x11: use resize_output with GL-renderer
We get rid of unnecessary GL-renderer output state destroy and create,
meaning we don't destroy and create an EGLSurface either.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-23 12:42:05 +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 84b5d0eb4b backend-x11: use resize_output with pixman-renderer
Now that resize_output() exists and is implemented for Pixman-renderer,
use it.

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
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
Derek Foreman c12ec7a2e5 compositor: Remove weston_transformed_region
Replace all uses of weston_transform_region with
weston_matrix_transform_region, then remove the function completely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +00:00
Marius Vlad d6ab6da988 libweston/backend-x11: Tracking previous events over multiple calls
Rather than doing it with a local variable, track any previous events by
hanging it out of the x11 backend and use it to handle keymap notify
events.

In this way we avoid corrupting the surface destroy signal list, in
notify_keyboard_focus_out(), ultimately leading to a crash.

Fixes #649, #650

Suggested-by: Daniel Stone <daniel.stone@collabora.com>
Reported-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-02 15:45:11 +03:00
Pekka Paalanen aac8eefc44 backend-x11: use shorthand for current_mode
Pure refactoring to reduce statement lengths.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-29 08:54:21 +00:00