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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The headless backend does not display to anything, so it doesn't care
what the EOTF mode is. To allow testing compositor internal behavior,
claim to support all EOTF modes.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.
There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.
The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.
Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
EGL's native display type is not particularly well defined; in
gl-renderer we get around this by always treating it as a void *, since
for all the platforms we care about it's a pointer - gbm_device,
wl_display, or Display *.
The surfaceless platform doesn't care what the native display is (since
it doesn't have one by definition), so just use NULL instead of what may
be either NULL or 0 depending on environmental factors.
Signed-off-by: Daniel Stone <daniels@collabora.com>