Commit Graph

2335 Commits

Author SHA1 Message Date
Michael Olbrich ef175c8ed4 backend-drm: handle commit failures correctly
Currently only the return value of the last backend that implements
repaint_flush() is actually used. That only works because the drm backend is the
only backend that implements repaint_flush().
In the drm backend only the return value of the last device is used. And if a
failure is actually detected, then all repainted outputs of all backends are
reset. This can trigger asserts:
weston_output_schedule_repaint_reset() (or _restart()) will change the state of
the output but the backend that did not cause the failure will still call
weston_output_finish_frame().
The same thing can happen with multiple devices in the drm backend. Or outputs
get stuck if an error is dropped.

Since the drm backend is the only one that implements repaint_flush() anyways,
move the failure handling into the backend and make it device specific.
This way only the outputs that need it are reset.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 15:35:30 +02:00
Michael Olbrich e8166e854d backend-drm: skip building atomic state and logging for "empty" repaints
With multiple backends or devices repaint_begin/repaint_flush may be called even
if no outout of a device will be repainted. This results in an "empty" drm state
without any output.
The actual commit to the kernel is already skipped but the drm-backend log is
still filled with "Beginning repaint"/"repaint-flush" messages and the scene
graph.

Use the new prepare_repaint() callback to determine if a backend needs to be
repainted and only create the pending_state if necessary.
Exit early in repaint_flush()/repaint_cancel() when no pending_state was created.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 15:35:30 +02:00
Michael Olbrich a1f8c49d5b compositor: repaint backends separately
When a repaint is triggered then not all backends may have outputs that need to
be repainted.
Check which outputs will be repainted first and then repaint only the backends
that need it.
This way unnecessary repaint_begin() and repaint_flush()/repaint_cancel() can
be skipped and errors are handled for each backend separately.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 15:35:30 +02:00
Philipp Zabel 060f010c35 compositor: access correct weston_buffer union field according to type
Stop writing weston_buffer::shm_buffer when weston_buffer::type is not
WESTON_BUFFER_SHM. Instead, explicitly write to the union field
that corresponds to the buffer type.
Also add a comment why we clear the shm_buffer/dmabuf/legacy_buffer
pointer here.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2024-06-20 14:18:50 +00:00
Derek Foreman c3321d5819 rdp: Use current_scale instead of scale for input translation
current_scale appears to be the only one of the two updated on mode switch.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-20 06:28:37 -05:00
Marius Vlad 3184f5a2df backend-drm: Print out planes IDs that have been excluded
Makes things clearer which planes we have been skipped due to fmt/modifier.
All other debug sites print out the plane id, and the assumption might
be that we retried the same plane when it fact is a different one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-20 13:26:23 +03:00
Jeffy Chen 3b7cfdb561 renderer-gl: Support more shm RGB formats
Some applications, e.g. Chromium browser, may provide ABGR format buf.

Tested with gstreamer 1.22.8:
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=RGB' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=BGR' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=ARGB' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=xRGB' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=ABGR' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=xBGR' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=RGBA' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=RGBx' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=BGRA' ! waylandsink
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=BGRx' ! waylandsink

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-06-19 15:42:59 +08:00
Jeffy Chen be43297679 gl-renderer: Support NV24 shm format
Some HDMI input devices may provide NV24 images.

Tested with:
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=NV24' ! waylandsink

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-06-19 15:41:20 +08:00
Jeffy Chen a073f93aba renderer-gl: Support NV16 shm format
Tested with:
gst-launch-1.0 videotestsrc ! 'video/x-raw,format=NV16' ! waylandsink

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-06-19 15:38:52 +08:00
Pekka Paalanen c4a403b2a6 color-lcms: print ICC profile class on error
Gives a better idea what's wrong.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-06-19 07:40:08 +00:00
Derek Foreman 83b37c0ac4 renderers: pull dmabuf initial setup out of attach
With attach only being called at render time, the dmabuf can be deleted
along with its private data before we attach for the first time.

Let's move the first-time logic into its own callback to call at
buffer setup time instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-18 08:45:43 -05:00
Pekka Paalanen 2b6fe57e81 gl-renderer: fix texcoord in shader desc
Seems like a typo, found by reading shader debug scope logs and
wondering why "!?!?" is there, e.g.:

Deleting shader program for: !?!? SHADER_VARIANT_XYUV
SHADER_COLOR_CURVE_IDENTITY SHADER_COLOR_MAPPING_IDENTITY
SHADER_COLOR_CURVE_IDENTITY -input_is_premult -green

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-06-18 11:33:53 +03:00
Leandro Ribeiro 2c44a4ea4a color: introduce API to create color profile from parameters
Add API to create color profiles from parameters. It is a public API
that should be used by the frontend and also by the color management
protocol implementation.

Currently our protocol implementation does not support clients that want
to create color profiles from parameters, and this is a step towards
supporting that.

As warned in "color: add get_color_profile_from_params() to color
managers", we still do not fully support creating color profiles from
parameters. This just creates a boilerplate color profile that we're
planning to extend later.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00
Leandro Ribeiro 141f466a03 color-lcms: move ICC profile data to nested struct
No behavior change. Move ICC profile data to nested struct to keep
the code more organized.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00
Leandro Ribeiro 0b9565e859 color-lcms: avoid destroying cprof without rofile
In cmlcms_get_color_profile_from_icc(), if we fail to create the
ro_anonymous_file we end up calling cmlcms_color_profile_destroy() with
a cprof whose cprof->prof_rofile is NULL.

For now that's alright, because cmlcms_color_profile_destroy() checks
if this field is NULL. But in the future we'll drop this check, so
the idea of this patch is to avoid an issue in the future.

Reorganize cmlcms_get_color_profile_from_icc() to avoid destroying a
cprof without a ro_anonymous_file.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00
Leandro Ribeiro 93d086f068 color: add get_color_profile_from_params() to color managers
Add function to color managers to create color profiles from parameters.
This will be used by the parametric color profile builder that we'll add
in the next commit.

WARNING: we still do not fully support creating color profiles from
parameters. This just creates a boilerplate color profile that we're
planning to extend later.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:40 -03:00
Leandro Ribeiro 89a57c7b10 color: keep track of supported primaries and transfer functions
In the next commits we'll start support clients that want to create
image descriptions through params using the CM&HDR protocol extension.

In order to do that, we'll have to expose the primaries and transfer
functions that the color manager supports. So keep track of that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:40 -03:00
Leandro Ribeiro 9707a3320d color: add WESTON_TF_POWER
Up to now we had support only for transfer functions with pre-defined
parameters in struct weston_color_tf_info. Add support for the first
parameterized transfer function (a function whose params are not
pre-defined).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:49:09 -03:00
Leandro Ribeiro 1c54ad7fd6 color: make some color struct's and enum's public
In the next commits we are going to introduce a public API to libweston
to allow creating color profiles from parameters. This should be used
by both the frontend and by the color protocol implementation.

This API require some color struct's and enum's that are currently
defined in libweston core, so move them to a public header.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:15:26 -03:00
Marius Vlad 8288cead93 timeline: Fix order with sub-surface clients
This corrects the order in which the parent ID surface is higher
than that of the sub-surface.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-14 11:41:13 +00:00
Leandro Ribeiro cf59ed0ebe shared: remove load_image()
We have a single user of load_image(), and that can be easily replaced
by the new and more flexible weston_image_load() function.

So replace and drop load_image() from the code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:13:18 -03:00
Derek Foreman 984d36aaca compositor: Move censor/direct checks into paint node update
By moving this here we can use the information to disable damage tracking
for placeholder surfaces, as well as render them entirely opaquely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 8c26480c09 gl-renderer: Use pnode is_opaque when drawing
We test if the surface is fully opaque during paint node updates, and
store that information. Now that we've refactored the blended calculations
a little bit, we can easily use this test to make paint_node->is_opaque
override the blend calculation entirely.

This is preparation for future patches that will override is_opaque
when performing content censoring or fallback rendering of solid colors
for weston_direct dmabufs.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman b80d4f4c8d gl-renderer: Use calculated opaque region instead raw opaque region
These should effectively be the same, thought the one we've calculated
may be clipped with the scissor. The end result of the math should be
identical.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 3538466083 gl-renderer: Calculate opaque region before blended
Just moving things around for now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 38487ec7e5 compositor: Dirty paint nodes when output protection changes
We'll be doing censoring via the paint node update code shortly, so
let's make sure we notice when protection changes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 290301882f renderers: Pass a paint node to the attach callbacks
Since we only call this from the paint node update code now, we can pass
the paint node directly.

A bit of internal refactoring is required to support copy_content.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman c08a6ff8bd compositor/renderer: Only attach buffer to renderer in repaint
Instead of doing this in several places, just do it when we're updating
the paint nodes in the repaint loop, or when we're about to copy
content via weston_surface_copy_content().

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman da6622f1d6 compositor: Add PAINT_NODE_BUFFER_DIRTY
In the future we'll use this, but for now just add the tracking.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman e2763565b6 compositor: Pass a mask to weston_surface_dirty_paint_nodes
For now we're just continuing to make the view dirty, but there will be
more dirt in the future.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 71079ffd1a renderers: Make flush_damage take a weston_paint_node
Currently we're passing in a surface, a buffer, and an output. All of
these things are available in the paint node.

Further, if we pass in the paint node directly, we don't have to walk
a list of paint nodes to figure out if the texture is used in the
upcoming repaint.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 39d9e67b08 gl-renderer: Don't flush damage on surface create
We'll flush this during repaint eventually, so there's no need to do it
now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 14599d0607 gl-renderer: Rename surface_flush_damage to paint_node_flush_surface_damage
And in doing so, pass the paint node instead of a surface and a buffer.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 101e270f9b gl-renderer: Use pnode->surface directly instead of pnode->view->surface
We don't need the view, so let's skip the extra indirection.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 4a8e8f5e83 gl-renderer: Stop returning bools for things that can't fail
None of these can fail, so let's not return anything from them.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 4be5e79f8d gl-renderer: Don't check zalloc return in gl_render_attach_shm
We don't always check allocation failures, so why bother here?

Removing this allows simplifying some code in a further patch.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Derek Foreman 41ff97a0d9 gl-renderer: Rename maybe_censor_override
This doesn't just handle censoring protected content anymore, fix the name
and the comments.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-11 09:23:27 +00:00
Lukasz Czechowski 05e5405651 vnc: Allow neatvnc in version 0.8.0
Neat VNC 0.8.0 does not introduce any changes that breaks API used
by VNC backend, so it is safe to extend compatibility.

Signed-off-by: Lukasz Czechowski <lukasz.czechowski@thaumatec.com>
2024-06-07 12:57:54 +00:00
Marius Vlad f2486c8b96 compositor: Remove layer_entry_remove/layer_entry_insert
There are no longer users of these two function. With the
weston_view_move_to_layer() helper being capable of doing this it is time
to retire these entirely to avoid users using them.

Release notes should mention that migrating to the newer helper will be
required when bumping to Weston 14.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-07 11:59:25 +00:00
Marius Vlad 904811100e libweston/desktop: Use the weston_view_move_to_layer helper
Rather than using layer_entry_insert, use the
weston_view_move_to_layer().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-07 11:59:25 +00:00
Ray Smith e79600483f backend-drm: always create gem_handle_refcnt hash table
Devices created via drm_device_create have this hash table, but those
created via drm_backend_create don't.

Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2024-06-07 11:27:27 +00:00
Ray Smith 80f096d9d2 backend-drm: don't leak gem_handle_refcnt in drm_destroy
Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2024-06-07 11:27:27 +00:00
Ray Smith 433f648adb backend-headless: Don't try to finish frame if it was cancelled
When multiple outputs are present, a failure in one's repaint will
cause any repaints of all other outputs to be cancelled. If this
happens during the headless "frame" time, the assertion on
repaint_status in weston_output_finish_frame fails.

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

Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2024-06-07 11:00:25 +00:00
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