Commit Graph

2343 Commits

Author SHA1 Message Date
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
Leandro Ribeiro bcd76c372b libweston: fix indentation of a few files
Recently I accidentally created a few files using spaces instead of
tabs. This patch fixes that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-04 17:32:39 -03:00
Loïc Molinari 06436d8adc gl-renderer: Define attrib array locations in an enum
This makes the code slightly easier to read and prevents using
incorrect locations now that shader permutations can provide different
vertex streams.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-04 17:24:12 +00:00
Loïc Molinari 26a69cb2f2 gl-renderer: Rename fan debug mode to wireframe debug
There's no fans anymore, so wireframe makes more sense now.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-04 17:24:12 +00:00
Loïc Molinari 23ae2e7f32 gl-renderer: Batch paint node's draw calls in fan debug mode
Index vertices from the damage mesh as lines and emit a single draw
call in fan debug mode. A new shader path and an additional vertex
stream are added in order to filter the color of the solid shader
variant per sub-mesh.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-04 17:24:12 +00:00
Loïc Molinari 22d9b9815f gl-renderer: Use compile-time annotation in vertex shader
Reuse fragment shader's compile-time annotation logic in vertex
shader for consistency.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-04 17:24:12 +00:00
Loïc Molinari f7a14ba0e7 gl-renderer: Batch paint node's draw calls
A paint node with 'n' rects damaged by 'm' quads emits 'n*m' OpenGL
draw calls. This commit batches the 'n*m' clipped polygons into an
indexed triangle strip damage mesh using degenerate triangles. A
single draw call per paint node is emitted to reduce API overhead.

Fan debug mode is disabled for now and will be added back using
batching in the next commits.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-04 17:24:12 +00:00
Loïc Molinari ce1705435f gl-renderer: Do not expose clipper_clip() in header
There is no need to expose it since it can be accessed by passing
non-axis aligned quads. Move existing tests to the quad clipper.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-05-30 09:09:45 +00:00
Loïc Molinari bef1f5fd7d gl-renderer: Remove support for non-quad polygons from clipper
The added complexity is unnecessary, it is limited to polygons of
length less than or equal to 8, there is currently no use for that
feature nor any plans to use it and tests are non-existent.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-05-30 09:09:45 +00:00
Michael Olbrich 5e43ef81ae backend-wayland: don't wait for one frame when starting the repaint loop
The repaint loop is started when a client provides a new frame while the
compositor is idle. This frame should be shown as soon as possible. So it makes
no sense to commit the previous frame one more time before rendering the next
frame.

Just call weston_output_finish_frame() directly to start repainting immediately.

As a side effect, this fixes an issue when the output is resized when no
fullscreen shell is involved: At that point, parent.draw_initial_frame is
already false, so draw_initial_frame() is not called. But when resizing, the old
buffers are removed so the commit happens without a buffer attached to the
surface. So the surface is invisible for one frame until the next one is
rendered.

draw_initial_frame() is not removed here, because it is still needed for the
synchronous resize that happens with the fullscreen shell.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-05-29 13:20:11 +00:00
Naveen Kumar ad039cdfd2 backend-drm: Enable atomic async flip support
Since DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP capability is available in the
mainline kernel, now we should enable back tearing support.

v2:

 - Bump kernel version to 6.9
 - include the fallback definitions

Reviewed-by: Marius Vlad <marius.vlad@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Naveen Kumar <naveen1.kumar@intel.com>
2024-05-28 09:33:51 +00:00
Loïc Molinari d4fe0a42fd gl-renderer: Assume axis alignment using node's valid_transform
Assume axis alignment using node's valid_transform boolean instead of
relying on the transform flags of the weston_view struct. This is more
reliable since matrix flags could erroneously hang around after a
series of transforms. Additionally, nodes with standard output
transforms like translations, flips and rotations by 90° can now take
the fast axis aligned path.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-05-27 16:21:21 +00:00
Marius Vlad b2e6a6438f libweston: Don't add frame callbacks from occluded paint nodes
This changes the callback frame list insertion after paint node late
update takes place in order for to the visibily region to be modified.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-05-27 10:47:33 +00:00
Derek Foreman e169b77430 compositor: Don't lift planes out of scene graph entirely
When we lift planes entirely out of the scene graph, paint node visibility
calculations become "per plane". This means that when we lift something
onto a paint node, anything beneath it will be redrawn in response to
client side damage even if the lower surfaces are occluded.

Instead, keep the scene graph together and make the paint node visible
regions be their visibility within the global scene graph.

This has the side effect of plane motion causing redraws, to update
regions they've been obscuring. My assumption is that moving planes
is less frequent than damage being posted beneath an overlay, and
that we'll be more efficient for normal use cases this way.

An optimization is in place to prevent redraws when moving transparent
planes, as they haven't been occluding updates.

In addition to theoretically removing some wasteful rendering time, this
also simplifies damage accumulation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-05-24 11:13:34 -05:00
Derek Foreman 36c2c4a254 libweston-desktop: Break grabs when a parent surface is destroyed
When a client is killed we don't get a clean dismissal of pop-ups in
construction order. This can lead to a weston_desktop_surface being
destroyed before its child popup is destroyed.

The weston_surface is still alive, so the surface destroy listener can't
save us.

Track grabbed seats in parent surfaces and explicitly break any grabs
that depend on them when the surfaces are destroyed.

Fixes #870

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-05-21 13:21:35 -05: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
Pekka Paalanen 8556059785 backend-drm: set connector property "Colorspace"
Based on what is configured in weston_output, check and set the
colorimetry mode into KMS connector property "Colorspace".

This changes how video sinks interpret the pixels, and should allow
driving e.g. WCG monitors in BT.2020 mode.

This does not alter the pixel values themselves. That is the color
manager responsibility, and ultimately the responsibility of the
frontend and the end user to match the monitor driving mode with the
output color profile they chose.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen 45ae99aff7 backend-drm: get KMS colorimetry modes
Based on KMS "Colorspace" connector property, populate the mask of
supported colorimetry modes on a head.

EDID should be checked too, but it is currently ignored.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen 53493aaddc libweston: add colorimetry_mode API
This API is mostly for use by the DRM-backend. Colorimetry mode is is
the KMS connector property "Colorspace" which defines the video signal
encoding colorimetry. A video sink indicates the supported modes in EDID
or DisplayID.

This patch adds the libweston API that allows backends to indicate the
supported modes for the frontends, and frontends to set the mode to be
used by backends. Colorimetry mode does not directly affect color
management inside Weston, it is only metadata for the video sink. It is
the frontend's responsibility to set up an output color profile that
agrees with the colorimetry mode. (That API has not been implemented
yet.) eotf_mode will be the same.

There is only one reason to make this a libweston core API instead of
a backend-drm API: when wayland-backend gains color-management protocol
support, meaning it can forward WCG and HDR content correctly to a
host compositor, the supported colorimetry modes can be determined from
the host compositor's supported color-management features, allowing the
guest Weston to pick some other output image description than the host
compositor's preferred image description. This likely allows only a few
other choices from standard colorspaces, so it's possible this isn't
sufficient for that use case.

Either way, it is easy to just copy the eotf_mode API design, and since
colorimetry_mode and eotf_mode go together, let both have the same API
design. It is possible to convert this to backend-drm API later.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen cd622900ee shared: add weston_assert_false()
Complement to weston_assert_true(), to avoid having to use !.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen c310516d1d shared: add weston_assert_legal_bits()
Helper to assert that a value does not have any bit set outside of the
mask. To be used with "all bits mask" of enum types that enumerate bits.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen 74d1700f0b libweston: add TODO to validate EOTF mode
Currently EOTF mode is not validated against the supported mask, to
allow easier experimenting without supplying a modified EDID through the
kernel.

The validation should be added before color management becomes
non-experimental.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen 8f31f172f8 backend-drm: add connector property "Colorspace"
Just the definitions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen cfd6f3ea83 backend-drm: move wdrm enums to separate file
This will allow me to use this header in libweston core to build a
single translation table between core enums, string names, and wdrm
enums.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen fd8acf2148 libweston: bits_to_str() helper
Refactor existing code into a helper, so when I introduce more bit mask
enums, I don't need to copy the whole function.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Pekka Paalanen 161cc8643c libweston: move weston_output_color_outcome to private
Turns out these structures do not need to be in the public header, so
move them into a private header.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-06 10:39:42 +00:00
Leandro Ribeiro c10ca00e10 color: handle image description that are not ready
This patch is for our CM&HDR protocol extension implementation.

When a client requests to create an image description, it can only start
using that after receiving the 'ready' event. The compositor may take
the time it needs to create the backing color profile for such image
description. But nothing guarantees that clients will do the right
thing.

This fixes some issues for not well behaved clients and also documents
how we handle image description that are not ready.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-04-26 12:11:17 +00:00
Leandro Ribeiro 29e3af7ba2 color: handle image description whose creation gracefully failed
This patch is for our CM&HDR protocol extension implementation.

When we gracefully fail to create an image description, we send the
'failed' event and the client can only destroy such image description.
But nothing guarantees that clients will do the right thing.

This fixes some issues for not well behaved clients and also documents
how we handle image description whose creation gracefully failed
internally.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-04-26 12:11:17 +00:00
Leandro Ribeiro 4ee612253e color: explain why we don't unset surface image description
There's a comment with a TODO that would be super simple to implement,
but we preferred to wait at the moment. But there are discussions on the
upstream CM&HDR protocol MR that would change that. This patch documents
that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-04-26 12:11:17 +00:00
Derek Foreman b3f115dfc0 libweston: Move plane stack/release for output primary_plane
It doesn't make sense to stack the plane before it's useful - so only
put it in the compositor's plane list on output_enable. The opposite of
weston_output_enable is weston_compositor_remove_output, so release the
plane there.

This stops a crash when closing one of multiple windows for a nested
backend results in the output being freed while the plane is still on the
compositor's plane list.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-04-23 09:50:14 -05:00
Derek Foreman 25d8eb6b5a libweston: Destroy paint nodes when releasing a plane
Previously we assigned any paint node to the primary_plane of the output
it was on and marked it dirty.

This doesn't make sense if we're releasing the primary_plane.

Let's just delete the paint nodes and force a view list rebuild, which
will recreate them appropriately.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-04-23 07:28:22 -05:00
Pekka Paalanen abe3e20e1f color-lcms: switch default rendering intent to perceptual
This should produce the best results on average for all kinds of apps on
any kind of display.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-04-19 12:19:36 +00:00
Pekka Paalanen 7d38e044dd gl-renderer: consolidate powlin sampling GLSL
This is pure refactoring.

Ease readability by reducing code duplication between pre and post curve
powlin handling.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-04-18 14:56:53 +00:00
Pekka Paalanen 044379f66a gl-renderer: consolidate linpow sampling GLSL
This is pure refactoring.

Ease readability by reducing code duplication between pre and post curve
linpow handling.

While at it, define symbols for the counts. This patch converts only
linpow. Powlin are converted in follow-up.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-04-18 14:56:53 +00:00
Pekka Paalanen 8fc5e0a333 gl-renderer: consolidate pre and post curve LUT GLSL
This is pure refactoring.

Ease readability by reducing code duplication between pre and post curve
LUT handling.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-04-18 14:56:53 +00:00
Marius Vlad 2d3cca3d3e libweston: Add paint node destruction into weston_layer_entry_remove()
This prevents a potential crash where users of
weston_layer_entry_insert/layer_entry_remove() would see when moving
views into a NULL layer (effectively unmapping the surface/view).

Users that have migrated to the weston_view_move_to_layer() are immune
to this issue because that takes care of paint node destruction.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-04-11 10:16:40 +03:00
Derek Foreman 527bc8aeb3 gl-renderer: apply output transform before readback in repaint
When reading back for the remote backends we need to convert the extents
of the damage (which is in global coordinates) to output coordinates
to read back the correct region.

We were doing this in a bespoke fashion by adding the output coordinates.
Instead, use weston_matrix_transform_rect() to transform the extents by
the output transform - which includes the scale factor.

This fixes output scale on RDP with the gl renderer.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-04-10 19:03:04 +00:00
Leandro Ribeiro 9002667aa0 color: add support to parametric curves in weston_color_curve
Until now, all the curves would be represented with 3x1D LUT's. Now we
support LINPOW and POWLIN curves (arbitrary names that we've picked).
We can use these curves to represent LittleCMS curves type 1, 4 and
their inverses -1, -4. The reason why we want that is because we gain
precision using the parametric curves (compared to the LUT's);

Surprisingly we had to increase the tolerance of the sRGB->adobeRGB MAT
test. Our analysis is that the inverse EOTF power-law curve with
exponent 1.0 / 2.2 amplifies errors more than the LUT, specially for
input (optical) values closer to zero.

That makes sense, because this curve is more sensible to input values
closer to zero (i.e. little input variation results in lots of output
variation). And this model makes sense, as humans are more capable of
perceiving changes of light intensity in the dark.

But the downside of all that is that for input values closer to zero, a
little bit of noise increases significantly the error.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-03-26 11:23:26 +00:00
Leandro Ribeiro d9e2eca13f gl-renderer: move lut_3x1d curves to union
In the next commit we'll add support for more color curves. So move
lut_3x1d to an union.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-03-26 11:23:26 +00:00
Leandro Ribeiro aee3e313c6 color-lcms: add function to get params from parametric curvesets
Given a certain curveset, get_parametric_curveset_params() returns true
if the curveset contains parametric curves. Also, it returns the
parameters of the curveset (for each curve) and if the input should be
clamped or not.

This is not a generic function, it will specifically work for some well
behaved curveset. E.g. we return false if there are more than 3 curves
(one per color channel).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-03-26 11:23:26 +00:00
Leandro Ribeiro aff6029da2 color-lcms: add translate_curve_element_LUT()
Currently in translate_curve_element() we always translate the curve
into a LUT. But in the future we'll be able to translate the curves to
parametric ones.

So move the current code to a new function
translate_curve_element_LUT(), so that in translate_curve_element() we
are able to call one of the two functions (_LUT() or _parametric()).

No behavior changes, just preparation for the upcoming patches.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-03-26 11:23:26 +00:00
Leandro Ribeiro 80d97db856 color-lcms: changes to the parameters of translate_curve_element()
Not a behavior change, but this allow us to decide what function pointer
to use within this function (instead of forcing callers to decide that).

In the following commits this will be helpful. We'll add more curves
besides 3x1D LUT's and, depending on the curve, the function pointer
signature may differ.

Also, we now pass the xform directly to the function, and it can select
the curves depending if it is being called for a pre or a post curve.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-03-26 11:23:26 +00:00
Pekka Paalanen efec55cf62 color-lcms: print transformation id instead of pointer
Pointer values are hard to track for humans, being long numbers. Now
that we have unique id for each color transformation, print that instead
of the pointer. It is a small number easy to track for humans.

Transformation id numbers do get re-used aggressively, so you have to
keep track of what is being destroyed and created over time when reading
logs. Pointers had the same caveat, just a lot more random.

The prefix 't' indicates "transformation".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-20 12:58:12 +00:00
Pekka Paalanen aef9404b1d color: generate id for color transformations
Just like with color profiles, generate an ID for color transformations
as well. This is not needed by protocol or anything, it is just for
debugging purposes. A small ID is easier for humans than a long pointer
value.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-20 12:58:12 +00:00
Pekka Paalanen b0224c4752 color-lcms: print profile id instead of pointer
Pointer values are hard to track for humans, being long numbers. Now
that we have unique id for each color profile, print that instead of the
pointer. It is a small number easy to track for humans.

Profile id numbers do get re-used aggressively, so you have to keep
track of what is being destroyed and created over time when reading
logs. Pointers had the same caveat, just a lot more random.

The prefix 'p' indicates "profile", just in case we use another id space
for some other thing similarly.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-20 12:58:12 +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
Marius Vlad b93335a741 backend-pipewire: Move region initialization at the start
Failure to do so, might cause a crash if the output repaint happens
before the pipewire pipeline started -- calling pixman_region32_fini on
a uninitialized region.

Fixes 2abe4efcf7, "libweston/backends: Move damage flush into backends"

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-03-11 12:31:55 +00:00
Loïc Molinari 4861b19f3d gl-renderer: Enable async output capture support for OpenGL ES 2
Plug async read back support to OpenGL ES 2 implementations using
GL_NV_pixel_buffer_object, GL_OES_mapbuffer extensions and
GL_EXT_map_buffer_range.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-08 13:12:13 +00:00
Loïc Molinari b5553cb5dd gl-renderer: Use fence sync to listen for async capture completion
Using a fence sync triggered on read back completion allows to
precisely know when it completed. The timeout path is kept as a
fallback when fence syncs aren't available.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-08 13:12:13 +00:00
Loïc Molinari f1f921b8cf gl-renderer: Validate SHM stride in common output capture path
SHM buffer stride validation is duplicated in sync and async output
capture paths. Move it into a common path to avoid duplication.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-08 13:12:13 +00:00
Loïc Molinari b9be532b27 gl-renderer: Add OpenGL ES 3 async output capture support
ReadPixels() implies a synchronous read back of the render buffer to
return pixel data. OpenGL ES 3 adds asynchronous read back support by
writing the pixel data into a dedicated buffer object. This commit
adds asynchronous read back support to the output capture code. It
spawns a read back request and schedules a timeout a few frames later
in order to store the pixels into the client SHM buffer.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-08 13:12:13 +00:00
Pekka Paalanen 5223b8430e color-lcms: move 3D LUT vs. blend-to-output assert
There is no reason why cmlcms_fill_in_3dlut() would not work for
blend-to-output category, so the assert is a little misplaced.

However, there would be a bug if 3D LUT was used for blend-to-output,
because we should never fail to optimize that chain. Put the assert
where it belongs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 4b9fa23ec6 color-lcms: stop hard-coding blend-to-output transformation
Stop special-casing the blend-to-output category, and pass it through
the same mechnisms and optimizations as all other transformations. In
the future, more curve types will be added to weston_color_transform,
meaning that blend-to-output does not always have to be a LUT. It could
become a parametric curve, which is more efficient and more precise to
compute, when VCGT does not exist.

Drop the special crafting of output_inv_eotf_vcgt LUT and replace it
with inv_eotf cms profile. inv_eotf will be combined with vcgt cms
profile as a chain as needed instead.

Blend-to-output transformations do not use a render intent, but we have
to tell cmsCreateMultiprofileTransformTHR() something, so arbitrarily
pick ICC-Absolute render intent for it.

Now all color transformations go through xform_realize_chain(), where
the documentation is improved.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 98454720be color-lcms: convert VCGT curves to lcmsProfilePtr
We need it as a cms profile, so let's make it one to start with. We even
gain non-datal error handling.

This will also be useful in rewriting output_inv_eotf_vcgt next.

The type change of vcgt_curves is required to be able to call
cmsCreateLinearizationDeviceLinkTHR(), even though everything about
vcgt_curves should be doubly const. The curves are populated on demand
and cached in cmsHPROFILE, so we also must not explicitly free them.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen fd63243c02 color-lcms: convert output eotf from curves to lcmsProfilePtr
We need it as a cms profile, so let's make it one to start with. We even
gain non-fatal error handling.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 236ee19ed4 color-lcms: wrap cmsHPROFILE type
cmsHPROFILE is a typedef of void *.

This means you can change the type of pointer variable to or from
cmsHPROFILE, and the compiler will not see any difference. The compiler
is happy to implicitly cast any pointer type to cmsHPROFILE and back.

In order to bring some type safety for future refactorings that will be
doing such type changes, introduce a wrapper struct. The wrapper being
an actual unique type will not allow implicit casting.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 570b348f45 color-lcms: replace comments in ensure_output_profile_adds_icc()
I did not understand the old comments. The new comments explain what
happens here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 547dc2738a color-lcms: improve ensure_output_profile_extract() error reporting
Return an error string so we can report the cause in more detail.

For consistency, add checking for VCGT dup failure, so we can report
that too. Leaking partial VCGT array on VCGT dup failure is fixed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 3488e2403f color-lcms: refactor into ensure_output_profile_extract()
Refactor and rename retrieve_eotf_and_output_inv_eotf().

Refactoring to make the calls more convenient to read, and preparation
for changing the object types for the curves.

ensure_output_profile_extract() reserves a place for another function
that works on parametric profiles instead of ICC profiles.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 7ccb9736b3 color-lcms: move output-only fields from cmlcms_color_profile
Refactoring to allow the next patch, no functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 5d6e7115a9 color-lcms: make identity_pipeline comment more detailed
This perhaps better explains what the issue here is.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen e6551ef41f color-lcms: remove stale comments about eotf_mode
The plan is to have the frontend decide on the EOTF mode and colorimetry
mode, but also the frontend is responsible for setting up a color
profile that matches the chosen modes. Therefore we don't need to care
about the modes explicitly here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 07eeed8f90 color-lcms: simplify getting render intent
Render intent does not depend on the output (profile), so drop that
argument. Render intent does not apply in blend-to-output category in
our design, so make it NULL there. Then, we only need to check the
surface for a render intent from a client.

The assert is dropped, because we don't need to advertise to clients all
the rendering intents we support internally. Even though we do.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Pekka Paalanen 0d3fa81840 color-lcms: handle NULL render intent
The clean-up following this patch will set the render intent field to
NULL when it does not apply (blend-to-output transformation). Make sure
we handle it.

In the search param string, fix a typo, and stop claiming we get a
render intent from a profile; we never do.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-03-07 14:50:47 +00:00
Loïc Molinari bc2d30050b gl-renderer: Only update y2 when merging damage rects
No need to update x1, x2 and y1 when merging a damage rect into a
previous one because they don't change. Melt merge_rect() into the
band compression routine as it's quite short now and convert the
boolean-based for/else construct to a more concise goto-based one.

Describe the compression logic to give a bit more context.

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

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

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

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

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
Loïc Molinari 2d71347397 gl-renderer: Move functions to ease next commit review
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-03-05 11:48:17 +00:00
vanfanel 90664b0f3b libweston: enable pointer constraints for fullscreen surfaces.
Signed-off-by: vanfanel <redwindwanderer@gmail.com>
2024-03-04 12:45:07 +01:00
Pekka Paalanen 7e22c28444 color: declare cm_image_desc_info
Fixes compiler warnings about the declaration in function signatures not
applying outside of the functions.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #811

Tested-by: Erkai Ji <erkai.ji@nxp.com>
Signed-off-by: Wujian Sun <wujian.sun_1@nxp.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-02-23 10:14:42 +08:00
Loïc Molinari 7b2eddf022 backend-headless: Add support to repaint only on captures
Damages and captures both trigger repaints of outputs. Some
configurations don't care about damages and use headless only for
captures. This commit adds a new feature to libweston that lets
outputs repaint only on captures, not on damages. The headless backend
enables that new feature when given a special refresh rate of 0 mHz.

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

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

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

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

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

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-22 11:38:22 +00:00
Jeffy Chen 9406664a54 backend-drm: Cleanup output's disable head list when destroying it
Avoid memory use-after-free when the trying to remove entries from an
already freed list later.

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

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-02-21 11:14:23 +00:00
Leandro Ribeiro 39ada71cb3 gitlab-ci: build and install LittleCMS version 2.16
When using some features from LittleCMS in our CI, we are seeing some
crashes on the address sanitizer. Bumping the LittleCMS version fixes
that. So build and install a more recent version of LittleCMS on our CI.

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

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

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

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

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

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

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

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

Preparation for the CM&HDR protocol extension implementation.

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

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

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-13 14:08:38 -03:00
Morgane Glidic 0de497f868
libweston/desktop: Update my Copyright
Signed-off-by: Morgane Glidic <sardemff7+git@sardemff7.net>
2024-02-11 19:07:39 +01:00
Loïc Molinari 5516527f2b tests: Add box32 quad clipper tests
Add a few tests ensuring the box32 quad clipping wrapper works as
expected.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari e82ce8032c gl-renderer: Fix quad clipper non-zero area check
The non-zero area check of clipper_quad_clip() is incorrect for quads
initialized with a polygon starting with a vertical edge. In order to
handle polygons starting with an horizontal edge and polygons starting
with a vertical one, it must check opposite vertices for equality.

The test previously described as "Box intersects entire smaller
aligned quad" is now described as "Clockwise winding and top/left
initial vertex". This test keeps the same values as before but all
combinations of winding order and first edge orientations are
also tested. The QUAD() macro isn't used anymore to do so.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Loïc Molinari 1f9637ec8e tests: Add quad clipper tests
Add quad clipping tests checking intersections at all edges and
corners of axis-aligned and unaligned quads with negative and positive
values.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-06 09:21:11 +00:00
Pekka Paalanen f880732004 backend-drm: rename eotf_list to str
I want re-use this variable for printing the colorimetry mode list as
well in a future patch, so a generic name is less confusing.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:22:33 +02:00
Pekka Paalanen fc0a74a4c9 backend-drm: skip EDID parsing if no change
Performance-wise this is moot, but since we are detecting if the raw
EDID data changed, might as well use it.

Now we have a path where the head's device_changed is almost guaranteed
since EDID changed, and that's useful for the next patch.

We can only do this, because the core initializes a head with values
that we would be setting anyway when EDID is missing, e.g. disconnected
head on compositor start-up.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:22:27 +02:00
Pekka Paalanen 2c0a9c064a backend-drm: store EDID data
Store the EDID data as-is, so that we can tell when the EDID blob has
changed. This is not too useful yet, because all the weston_head_set_*()
API raises the device_changed flag only if the information actually
changes. However, I want to expose the libdisplay-info di_info structure
through weston_head, and those cannot be (as) easily compared.

We need to know when the EDID blob changes, so we can call
weston_head_set_device_changed() appropriately when updating di_info.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:20:04 +02:00
Pekka Paalanen 4a028ade32 tests: conditionally skip part of alpha-blending
One of the three fixture setups of alpha-blending test requires
color-lcms.so. If color-lcms.so is not built, that fixture fails.

Make it skip as necessary, making the test suite pass with
color-management-lcms=false build option.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-26 14:31:35 +02:00
Dylan Aïssi 0f260b4f78 backend-rdp: fix typo: chunck -> chunk
Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
2024-01-25 21:42:49 +01:00
Robert Mader e34e027515 backend-drm: Sort planes by faked zpos
Just like we already do for planes with proper zpos. Otherwise we'll
often end up choosing the primary plane instead of an overlay one
in `drm_output_find_plane_for_view()`.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-01-22 17:16:19 +01:00
Ray Smith 885c616589 backend-drm: fix confused fallback format handling
This seems to think formats needs to be NULL terminated, but it doesn't
and gl_renderer_get_egl_config asserts that all formats_count elements
are not NULL.

This happens when EGL_KHR_no_config_context is not supported.

Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2024-01-22 09:29:01 +00:00
Robert Mader e37454a262 linux-dmabuf: Add support for protocol version 5
It adds the followig paragraph:
```
Starting from version 5, the invalid_format protocol error is sent if
all planes don't use the same modifier.
```

We already assumed this in some places and, most importantly, it's
required by the kernel. Thus alter `dmabuf_attributes.modifier` to make
it clear that different modifiers for multi-planar dmabufs were never
supported.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-01-19 18:59:22 +01:00
Jeffy Chen e454de5af3 renderer-gl: Fix segfault when reading pixels
We should use the actual stride to create tmp pixmap.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-01-16 22:18:30 +08:00
Jeffy Chen 623c7b5202 renderer-gl: Fix wrong stride error when reading pixels
The gl_renderer_do_read_pixels() is expecting stride in bytes.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-01-16 22:18:30 +08:00
Derek Foreman e74f2897b9 libweston: Clip damage to paint node visible region
commit 79212ba9ad fixed a bug by
introducing a new one.

Before that point we could clip paint node damage to stale
visibility data. After that point we post damage for occluded
views, leading to large amounts of pointless drawing.

Add back the clip to visible region, in
weston_output_flush_damage_for_plane(), where we have up to date
visibility region information.

fixes 79212ba9ad

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-01-15 14:03:41 +02:00
Chao Guo 8e0e75999e compositor: improve viewport source validity check
If client changes the buffer transform or size and re-commit the surface
before surface dirtys buffer (weston_surface_attach), the viewport
source validity check may fail. Because the width_from_buffer and
height_from_buffer cannot be updated based on new buffer transform.

Therefore, add the situation of size dirty (WESTON_SURFACE_DIRTY_SIZE) to
source validity check, width_from_buffer and height_from_buffer can be
updated in time when the buffer transform and scale change.

Signed-off-by: Chao Guo <chao.guo@nxp.com>
2024-01-12 13:44:03 +00:00
Zhou Liang b288e662d6 backend-drm: fix deinit unexpected connector
The `drm_output_deinit` should use the drm device passed by the
function, should not use the `b->drm` device.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Zhou Liang 66aaa41074 backend-drm: fix drm add connector to unexpected drm device
If both the head and writeback are not found, then we should add
connectors to the drm device passed by the function, not the b->drm
device.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Zhou Liang 8b3becf524 backend-drm: fix drm find wrong connector
In a multi-GPU environment, different cards may contain connectors with the
same ID, and drm_head_find_by_connector just use the connector_id to find
the connector, it may find the wrong connector.
Fix this by find the connector based on the drm device and connector id.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Robert Mader 5a2509ffb1 backend-drm: Don't force non-opaque overlays to primary plane
If a view is non-opaque - such as an overlay over a video - we shouldn't
force it to be on the primary plane, as that's where the underlying
content should be placed, such as the video view.

dc0de9ee already mentioned: "This check should be changed in future to
only filter for opaque views, but that's for another time."

Adding "Fixes" at this is arguably a bug fix:
Fixes: dc0de9ee (backend-drm: Move overlay vs. primary plane check earlier)
Fixes: 2538aacc (backend-drm: Construct a zpos candidate list of planes)

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-01-11 15:57:09 +01: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 04d9f7e738 libweston/animation: Remove weston_fade_run unused argument
And with it, bump libweston to next major version, 14. We seems like
we never used that argument so better just removed it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-01-09 13:15:16 +02:00
Jeffy Chen b074186836 libweston: Avoid double-destroy of animations
The idle_animation_destroy task should be removed when destroying
animations by the other callers such as handle_animation_view_destroy().

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-01-05 09:08:03 +08:00
Khem Raj dbd134ca5a libweston,tools: Include libgen.h for basename signature
Latest musl has removed the declaration from string.h [1] as it only
implements POSIX version alone and string.h in glibc implements GNU
version of basename. This now results in compile errors on musl.

This might be a warning with older compilers but it is error with
Clang-17+ as it treats -Wimplicit-function-declaration as error

Switch the use in backlight_init function to use POSIX version

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-12-18 21:13:52 +00:00
Pekka Paalanen b84ad9e34c libweston: drop weston_output_init() test workaround
This was added in 4def21c196.

0c1ab2ad76 removed all uses of NULL
weston_compositor, making the workaround unnecessary.

Drop the workaround, it's dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-12-15 14:15:22 +02:00
Philipp Zabel b72785e1f6 libweston-desktop: Work around crash when opening popup menu
Fix a crash when right-clicking on a weston-terminal, where
weston_desktop_seat_popup_grab_add_surface() is called with
seat->popup_grab.keyboard.keyboard == NULL in case there is
no keyboard connected.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-12-11 16:58:01 +01:00
Daniel Stone a5c5702112 touch-calibrator: Regularise surface/view mapping
Manually mark the surface as mapped exactly once - in the committed
handler where we have our content, and assert that it's correct when we
want to use the surface by instantiating a view.

The view handling can be made much more simple by simply using the new
view helpers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-12-06 12:16:27 +00:00
Daniel Stone 16825359c7 input: Use surface/view helpers for drag surfaces
Use the helpers we have to map and position drag icons.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-12-06 12:16:27 +00:00
Daniel Stone 7f62fe817a input: Use surface/view helpers to map
Use the helpers to map a weston_surface and weston_view, rather than
manually manipulating the internals.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-12-06 12:16:27 +00:00
Daniel Stone 1f9e0ce9ad input: Use helpers to map surfaces/views
When working on tablet tools, use the weston_surface and weston_view
helpers to manipulate their cursors, instead of manually setting various
members.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-12-06 12:16:27 +00:00
Loïc Molinari 309a546165 gl-renderer: Improve clipper documentation
Add clipper_clip() documentation and improve comments a tiny bit.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari 42205628bf gl-renderer: Prefix clipper API
Prefix and slightly rename the clipper structs and funcs:

  - struct clip_vertex -> struct clipper_vertex
  - struct gl_quad     -> struct clipper_quad
  - clip_transformed() -> clipper_clip()
  - init_quad()        -> clipper_quad_init()
  - clip_quad()        -> clipper_quad_clip()
  - clip_quad_box32()  -> clipper_quad_clip_box32()
  - float_difference() -> clipper_float_difference()

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari 2d0d0175d2 gl-renderer: Add init_quad() to clipper
Extract quad bounding box initialization from the GL renderer and move
it to a dedicated initialization function in the clipper. It's used by
both the renderer and the clipping test client, which further reduces
code duplication.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari f74c5a4102 gl-renderer: Replace clip_transformed() context with a clipping box
Simplify clip_transformed() by replacing its context parameter with a
clipping box parameter. The context struct is still used internally to
pass data around.

Since clip_transformed() doesn't take a context anymore, the clipping
boxes are now declared per test and stored along with the other vertex
data. That prepares the ground to add new tests using different boxes.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari bf222f1897 gl-renderer: Use clip_vertex struct for boxes in clipper API
Carry on the common vertex representation front by making boxes use
the clip_vertex struct.

A new function clip_quad_box32() is added to clearly separate the main
function taking a clip_vertex struct from the utility function taking
a pixman_box32 struct.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari b8063dbb13 gl-renderer: Remove polygon8 struct from clipper API
Pass a clip_vertex struct and a size to clip_transformed() instead of
a polygon8 struct to simplify the clipper API by sticking to a common
vertex representation.

Simmplify vertex-clip test since clip_transformed() now works on a
copy of the polygon (commit edd5d1cc09).

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
Loïc Molinari aac11c8884 gl-renderer: Remove clip_simple() from clipper
clip_simple() isn't used anymore outside of the clipper. This commit
removes it to simplify the clipper API. Its implementation is moved
straight to the axis-aligned quad clipping path of clip_transformed().

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2023-12-05 10:54:39 +00:00
He Yong 98606d6a03 replace weston_signal_emit_mutable with wl_signal_emit_mutable
wayland upstream has introduced wl_signal_emit_mutable
now we can use it

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/208

Signed-off-by: He Yong <hyyoxhk@163.com>
2023-12-04 11:37:17 +02:00
Arnaud Vrac 9c637d70eb gl-renderer: do not use glTexImage3D directly
Resolve the function through eglGetProcAddress instead as it's only defined
starting with OpenGLES 3.0.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2023-11-29 15:13:49 +00: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
Derek Foreman 78657c5ff3 drm-backend: Fix cursor updates with overlapping heads
We can't use the surface damage to determine when to upload new cursor
images because when heads overlap the first repainted head will accumulate
that damage as plane damage.

We can't easily use plane damage either because the plane isn't really
assigned until after an atomic test, which requires the cursor fb to be
current.

Untangle this mess a little by always testing with the first cursor fb,
which is identical to the second in all ways, then replace with the correct
fb in repaint.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-11-10 09:38:41 -06:00
Derek Foreman bbaba601c8 vnc: Fix cursor updates
Now that overlapping outputs are a thing, we have a problem with vnc
cursors.

The surface->damage used to update the vnc cursor might actually be
flushed by a previous output's repaint cycle, leading to a missing cursor
update to the vnc client.

Instead we should use the damage accumulated on the cursor plane to choose
when to update the cursor. This damage is in output coordinates, so let's
be lazy and just use the presence of damage as an indicator that the
cursor needs an update.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-11-10 09:38:35 -06:00
Derek Foreman 0def955a48 libweston: Don't set VISIBILITY_DIRTY on non-primary planes
VISIBILITY_DIRTY is used to apply damage to the plane, but that doesn't
make sense for non-primary planes.

For example, we don't want moving the cursor to result in damage being
registered on the cursor plane.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-11-10 09:37:43 -06:00
Derek Foreman 79212ba9ad libweston: Don't clip damage to paint node visible region
When an output repaints, it calculates visibility for its paint nodes,
accumulates damage for all paint nodes across all outputs, and then
paints.

This means that when it's accumulating damage for all paint nodes in
paint_node_add_damage(), it may be accumulating damage to nodes on other
outputs that haven't had their visible regions updates yet.

This leads to clipping with a stale visibility region, and losing damage.

Let's just drop the clip here for now - there are already other places
where paint nodes have to carry damage outside their visible regions.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-11-10 09:37:43 -06:00
Derek Foreman 8b7597d40f vnc: Remove scanout plane optimization
This is a revert of 72e2da24

The VNC backend will place a single fullscreen surface on a virtual
scanout plane, and send the entire contents of this plane every repaint.

This saves a renderer pass, but moving the mouse over the fullscreen
client results in full screen damage for every mouse motion, similarly
client surfact damage is ignored and every repaint pushes the entire
window content down into Neat VNC.

Due to the way this is implemented, by pushing the scanout plane content
from assign_planes(), the primary plane could post damage and corrupt
the display.

Ideally we could fix this optimization to respect plane damage and do the
scanout plane push from the repaint callback, but since a release is
coming soon let's just strip it out for now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-11-09 11:23:22 -06:00
Leandro Ribeiro cab1992b81 color: do not use NULL as stock sRGB color profile
Stop assuming that NULL represents the stock sRGB color profile. From
now on, query the stock sRGB color profile from the color manager.

This should be internal to libweston (core and the color plugins), and
users of the libweston public API should not be affected by this. They
are still allowed to set an output color profile to the stock sRGB using
NULL.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Leandro Ribeiro afbc729e71 color-lcms: extract color characteristics even when output cprof != NULL
cmlcms_get_hdr_meta() returns early if the output has a color profile
set. That makes sense, because we should be able to get the color
characteristics from the color profiles.

But in the next commits, every output will have a color profile set. To
allow the color-metadata-parsing test, do not return early when
output->color_profile != NULL in cmlcms_get_hdr_meta() anymore.

In the future we'll adjust this function in order to always extract the
color characteristics from color profiles, as output->color_profile
should always be set.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Leandro Ribeiro 977c41a65c color: add get_stock_sRGB_color_profile() to color manager
In the next commit we'll stop using NULL as the stock sRGB color
profile, so add a function to the color manager to allow libweston core
to have access to the stock sRGB profile.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Leandro Ribeiro 154ce42b8c color-noop: add stock color profile
In the next commit we introduce a function to get the stock sRGB color
profile from the color-manager, so mock a stock color profile in the
color-noop.

It has no valid content, but should make callers happy. This is safe to
do because the color profile is opaque, and only color-noop itself
should have access to its content.

color-lcms already has a stock sRGB color profile, so we don't have
to do anything there.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Leandro Ribeiro 33ed93561e color-noop: make use of xalloc helpers
Use xzalloc instead of zalloc, etc.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Leandro Ribeiro 39de0bd988 color-lcms: unref stock sRGB cprof instead of directly destroying it
Directly destroying the cprof is not ideal, because it may hide issues
that we have in the code. If we are destroying a cprof with ref_count
bigger than 1, there's something wrong that we need to fix.

Instead, assert that the stock sRGB cprof has ref_count == 1 when we are
destroying the color manager. And use unref() instead of destroy().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Marius Vlad d18fd64a15 libweston: Ignore subsurface offsets
Ignore any client-supplied offset to subsurface commits to keep the same
consistency we find on other compositor.

Fix: #829
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-10-26 14:46:10 +00: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 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
Derek Foreman e622be7423 input: avoid crash by using surface directly
A constraint always has a surface, but may not have a view - use the
surface pointer directly without trying to get it through the view.

Fixes #823

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-13 07:46:44 -05:00
Derek Foreman e49294b901 libweston: fix output clamp helper
Any coordinate that didn't change during clamping was left uninitialized,
resulting in failures later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-09 08:19:44 +00:00
Derek Foreman 209b7eb56a backend-drm: Fix visibility calculation
Between assign_planes() and pnode_update_late(), the pnode's plane may
not yet be up to date. This leads to the visible region being incorrectly
calculated for paint nodes beneath a paint node that changes planes. Their
visible regions will still contain a cut out for the node that no longer
occludes them.

However, we place damage on nodes beneath a node that changes planes in
order to redraw the region beneath a node that moves from the primary to
non-primary plane.

The gl-renderer clips to a paint node's visible region when rendering it,
so this accidental cut-out masks away all the damage and leaves us with
a mess.

Fix this by using the correct plane in the visibility calculation.

Fixes #821

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-06 12:39:57 -05:00
Derek Foreman 176a413ef0 libweston: Prefer primary backend when assigning outputs to views
If coverage and power status are the same, we should prefer a primary
backend over a secondary one.

Fixes #818

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-06 11:50:50 +00:00
Derek Foreman 305e954f76 libweston: Reconsider view primary output on output power change
When an output power state changes, it may become or no longer be the
best primary output for a view.

Fixes #819

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-06 11:50:50 +00:00
Derek Foreman d3fa809c55 libweston: Consider output power state when selecting primary
If our primary output is turned off, we won't get frame events, so let's
try really hard to prioritize a turned on output with coverage.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-06 11:50:50 +00:00
Philipp Zabel d1df848d94 compositor, backend-vnc: Allow to disable output resizing
In some use cases the VNC client should not be allowed to resize the VNC
output. Add a boolean option "resizeable" in the VNC [output] section to
control this.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-10-05 11:43:12 +02:00
Philipp Zabel 690beab475 backend-vnc: Implement output resizing
Let VNC clients resize the VNC output.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-10-05 11:00:21 +02:00
Philipp Zabel 8895b15f3d ci, backend-vnc: update to Neat VNC 0.7.0
Neat VNC 0.7.0 supports desktop resizing.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-10-05 11:00:12 +02:00
Daniel Stone cae789774a surface: Check parents in weston_surface_is_mapped()
A subsurface is not considered to be fully 'mapped' unless its ancestors
are also mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 2faf491f61 surface: Add weston_surface_is_mapping()
The counterpart to weston_surface_is_unmapping(). This is valid for the
duration of processing the surface commit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 5c75ecccfe surface: Don't re-map already-mapped surfaces
If a surface has already been mapped, just return early out of
weston_surface_map(), rather than firing the map signal and rebuilding
the view list.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Derek Foreman 720421c193 libweston: Add and use weston_coord_surface_add/sub helpers
We already have these for global coordinates, now we have them for
surface coordinates too. In addition to removing some unsightly
unadorned coordinate usage, this also adds appropriate coordinate space
id checks at runtime.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00: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
Derek Foreman 18cce195d3 libweston: Make a common helper for clamping a coord to an output
This is a tricky bit of code and we use it in two places. Let's make a
single implementation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Derek Foreman 71e38cf2ef libweston: Use weston_coord_surface in weston_surface_state
Use this for the buffer attachment offset coordinates.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Derek Foreman 4f17af4691 libweston: Remove dbus helpers
Now that launcher-logind is gone, we don't use any of this anymore.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:58:01 -05:00
Derek Foreman e3b6ed50f1 launcher: Remove launcher-logind
Second try at removing direct logind support. This time more careful
with the documentation, as libseat can still use logind even if we don't
directly use it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:55:32 -05:00
Derek Foreman 3959c90c7c launcher: Drop drm dependency
This was probably only for launcher-direct, and hasn't been required for
a while.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:47:43 -05:00
Derek Foreman 2296781cee launcher-libseat: Rename libseat_dep
Most other dependencies are named dep_* so let's conform.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:47:43 -05:00
Derek Foreman 501e3f193f launcher-libseat: Don't depend on dbus
The libseat launcher doesn't directly use dbus functions.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:47:43 -05:00
Derek Foreman 754562fb52 Revert "launcher: Remove launcher-logind"
This reverts commit 55bf6b5046.

This accidentally removed things that should have stayed - libseat
can still use the logind API, even if weston doesn't directly use
it.

Note that the logind-launcher does not actually build anymore
because breaking changes landed before this revert.

Since we're removing it again right away, I've not taken care to
fix that.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:46:48 -05:00
Philipp Zabel c93a54ece3 libweston: add explicit weston_compositor::primary_backend pointer
This avoids spreading around the knowledge that the primary backend is
the first backend on weston_compositor::backend:list.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Philipp Zabel a4f0666659 libweston, compositor: let weston_compositor_load_backend return backend
Let weston_compositor_load_backend() return a backend pointer and remove
the backend pointer from struct weston_compositor.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Michael Olbrich 44f36b9b55 libweston: don't return buffers early with multiple backends
Releasing the buffer reference here works because the backend has seen the
surface and has updated keep_buffer if necessary. With multiple backends
the assumption breaks. The same surface may be visible (now or later) on an
output from another backend. This backend has not seen the buffer yet so it
cannot update keep_buffer.
As a result, the reference is released to early. A surface that is rendered
on a secondary backend first can no longer be placed on a plane on a DRM
backend.

To avoid this, always keep the buffer reference until it is replaced when
multiple backends are involved.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Philipp Zabel 6d3fa71d7b libweston: drop workaround for multi-backend incapable backends
All backends add themselves to weston_compositor::backend_list now.
Drop the workaround that catches unconverted backends that still set
weston_compositor::backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +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 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
Philipp Zabel c857042b45 backend-vnc: 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.

To stay backwards compatible, the VNC backend can be loaded as primary
backend. It also supports being loaded as secondary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Philipp Zabel f014009419 backend-rdp: 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.

To stay backwards compatible, the RDP backend can be loaded as primary
backend. It also supports being loaded as secondary backend.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-09-28 14:02:04 +00:00
Philipp Zabel 308d5cf367 backend-pipewire: 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.

To stay backwards compatible, the PipeWire backend can be loaded as
primary backend. It also supports being loaded as secondary backend.

Co-authored-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +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 281aa0a4d7 backend-drm: 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 that the backend is capable of being loaded simultaneously
with other backends.

The DRM 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 20c5b4527c libweston: allow loading multiple backends
Before loading a backend, clear the weston_compositor::backend pointer
to check whether the backend supports multi-backend operation and adds
itself to the weston_compositor::backend_list.

Keep weston_compositor::backend pointing to the last loaded backend
either way, to allow the calling compositor code to store it away for
later, to check whether a head belongs to a given backend in the output
configuration code. This workaround can be removed after all backends
are converted to be multi-backend aware.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Philipp Zabel 3d50069afc libweston: intersect all backends' supported presentation clocks
In preparation for multi-backend support, determine the presentation
clocks that are supported by all backends.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-09-28 14:02:04 +00:00
Philipp Zabel 183c309b85 libweston: use weston_compositor::backend_list instead of ::backend
In preparation for multi-backend support, start/flush/cancel repaint on
all backends by looping over the weston_compositor::backend_list.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Philipp Zabel 76372375ab libweston: store backends in a list
In preparation for multi-backend support, add a list of backends to the
weston_compositor structure. Until backends are converted, this list
just contains the single weston_compositor::backend. Keep that pointer
for now, until the conversion is complete.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Leandro Ribeiro 08018d3a28 linux-dmabuf: replace assert with the new weston-assert
Make use of the new weston-assert in linux-dmabuf.c

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-09-28 06:52:24 +00:00
Derek Foreman 55bf6b5046 launcher: Remove launcher-logind
This has been deprecated and non-default for a full release cycle, so
we're going to remove it now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-28 06:47:06 +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 8888777b26 backend-rdp: 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.

This makes finish_frame_handler() return more exact timestamps
calculated from the previous frame time if the timer callback
was not delayed too much.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-27 12:37:09 +03:00
Philipp Zabel 98cd2e9f97 backend-vnc: 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 2fc6a8bbd2 backend-pipewire, libweston: Extract weston_output_finish_frame_from_timer()
Extract the finish frame timestamp code and the call to
weston_output_finish_frame() into a new helper function
weston_output_finish_frame_from_timer() that can be reused
by the other timer driven backends sharing the same logic.

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 6fb3443ff4 backend-vnc: 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 b7400c614e backend-rdp: 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 eec50e5aac backend-pipewire, libweston: Extract weston_output_arm_frame_timer()
Extract pipewire_output_arm_timer() into libweston so it can be reused
by the other timer driven backends that use the same delay logic.

Call the shared function weston_output_arm_frame_timer().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-27 12:37:09 +03: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 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