Commit Graph

1426 Commits

Author SHA1 Message Date
Pekka Paalanen 1e9b1a1047 backend-headless: support all EOTF modes
The headless backend does not display to anything, so it doesn't care
what the EOTF mode is. To allow testing compositor internal behavior,
claim to support all EOTF modes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen 5f9b68d68f libweston: introduce weston_eotf_mode
This is the switch to turn HDR mode on.

The values in the enumeration come straight from CTA-861-G standard.
Monitors advertise support for some of the HDR modes in their EDID, and
I am not aware of any other way to detect if a HDR mode actually works
or not. Different monitors may support different and multiple modes.
Different modes may look different. Therefore the high-level choice of
how to drive a HDR video sink is left for the Weston frontend to decide.

All the details like what HDR metadata to use are left for the color
manager.

This commit adds the libweston API for backends to advertise support and
for frontends to choose a mode. Backend and frontend implementations
follow in other commits.

The frontend API does not limit the EOTF mode to the supported ones to
allow experimentation and overriding EDID.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Marius Vlad 69a59359fa pixman-renderer: Unref the pixman image when wl_shm_buffer is gone
Even if the weston_buffer_reference is still alive in situations like
when we have closing animations, the underyling buffer (wl_shm_buffer)
is no longer available. Call the appropriate destroy handler to
invalidate the pixman image and avoid touch the shm_buffer.

Fixes: #613

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-04-29 11:48:08 +03:00
Hideyuki Nagase b6fc6b2a8d rdp: sync keylocks on synchronize event
Synchronize events carry keylock status, so we should update it.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase 6515df1333 rdp: Support using Japanese layouts with US keyboards
When RDP indicates that a Japanese keyboard layout is used without
a Japanese 106/109 keyboard (keyboard type 7), use the "us" layout,
since the "jp" layout in xkb expects the Japanese 106/109 keyboard
layout.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase 5d939bc636 rdp: Korean keyboard support
Korean keyboards are keyboard type 8:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeyboardtype

While type 8 is not explicitly mentioned in the RDP documentation,
it can be sent over the wire. Let's support the variants we can.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase 4d5605b3a0 rdp: refactor xkbRuleNames code
This code will eventually be used by RAIL as well, so let's
split it out now.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase a29bcb7031 rdp: change japanese keyboard input from kana to alphabetical
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase e3a4552ecc rdp: Fix Farsi keyboard map
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase 08f5edfe78 rdp: Fix Brazilian keyboard map
Use the common abnt2 variant, instead of the niche nativo one.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Hideyuki Nagase d2a8165bb6 rdp: Add Persian keyboard map
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 15:33:57 +00:00
Derek Foreman 2eb5912960 rdp: Don't bother trying to pick an optimal keyboard model name
Nothing actually cares about this string, and pc105 will do just
fine.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-28 13:19:10 +00:00
Hideyuki Nagase 806e824809 rdp: Add horizontal scroll support
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 12:39:35 +00:00
Hideyuki Nagase 4e907a67e5 rdp: Add high precision scrolling
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 12:39:35 +00:00
Hideyuki Nagase ce09c7835c rdp: refactor scrollwheel code
We move this into a function for when we add horizontal wheel support
later.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 12:39:35 +00:00
Hideyuki Nagase cf5ddd05cb rdp: Allow configuring the refresh rate
We currently hardcode a 60Hz update rate for the rdp backend.

In some cases it may be useful to override this to increase the rate
for a faster monitor, or to decrease it to reduce network traffic.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 07:35:57 -05:00
Hideyuki Nagase bd214edf26 rdp: Calculate frame times from mode refresh rate
Instead of hard coding a 16ms refresh interval, use the refresh rate
from the current mode to determine when the next frame should be.

Currently, we still hard code the refresh rate, so this will end up
with roughly the same value we've been using, but in the future
we'll allow setting it via command line.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 07:35:04 -05:00
Brenton DeGeer 2f9319cef6 rdp: Allow specifying a listener fd on the command line
We already have a way for a single RDP client connection to be
passed from a parent process to a child using a combination
of environment variable (RDP_FD) and env var (--env-socket)

This patch allows a bound socket fd (as opposed to a client
connection) to be established in a parent process and provided
to the rdp backend. WSLg uses this to set up an AF_VSOCK
socket for communication between a Windows RDP client and a
weston compositor running under a hypervisor.

Co-authored-by: Hideyuki Nagase <hideyukn@microsoft.com>
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-28 12:27:56 +00:00
Hideyuki Nagase 13e62c9d18 rdp: validate button state
Discard and log duplicate release or press events. Log and discard
invalid button ids.

This prevents buggy clients from causing problems in weston's internal
state - like breaking idle inhibition button counting.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-27 13:57:42 +00:00
Hideyuki Nagase 873ec15412 rdp: Fix up xf_extendedMouseEvent
These events carry the 4th and 5th mouse buttons, so
we should propagate them. We also need to use pointer
frames to ensure the buttons are properly paired with
the pointer co-ordinates.

Unfortunately, there is no way in RDP to determine if
a mouse event and an extended mouse event should be in
the same pointer frame, so this is the best we can do.

We also enable extended mouse events so they'll be used.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-27 13:57:42 +00:00
Hideyuki Nagase 7f10997d92 rdp: add mouse input debug
Add extremely verbose mouse input debugging.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-27 13:57:42 +00:00
Daniel Stone b5605ccd26 libweston: Remove weston_surface_set_color
Don't do this; instead, create a solid-colour buffer and attach it to
the surface explicitly.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 4d426ab6b1 shell: Explicitly use solid weston_buffers
Rather than punching through to set the surface as a solid colour,
attach an actual weston_buffer to it instead.

This becomes the first user of attaching non-client-generated buffers
to a weston_surface. As a result, it is necessary to introduce a
function which will allow compositors and shells to attach a buffer to a
surface. weston_surface_attach_solid() is therefore introduced as a
special-purpose helper which will attach a solid buffer to a
weston_surface.

It is not intended as a general-purpose mechanism to allow compositors
to attach client-generated buffers to surfaces, as doing so would have
unknown effects on this core part of the compositor itself.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 82b646728c backend-drm: Handle solid-colour buffers in state propose
When we're checking to see if a view is suitable to go on a plane, check
for (and reject) solid-colour buffers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone b38b735e20 backend-drm: Remove Pixman conditional for keep_buffer
The Pixman renderer keeps its own reference to buffers when attached to
surfaces, through its surface state: just use that instead.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 493a4c013e noop-render: Allow solid-color buffers
Refactor the buffer-type check slightly so we can handle solid-color
buffers, which we do exactly nothing with.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone d82d74e713 pixman-renderer: Support solid-colour weston_buffers
Just implemented via the same mechanism as surface_set_color.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 465f4a250c gl-renderer: Support solid-colour weston_buffers
Same as surface_set_color.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 43715ff0c0 weston_buffer: Add solid buffer type
Currently solid-colour displays (e.g. the background for fullscreen
views) is implemented by a special-case weston_surface which has no
buffer attached, with a special punch-through renderer callback to set
the colour.

Replace this with a weston_buffer type explicitly specifying the solid
colour, which helps us eliminate yet more special cases in renderers and
backends.

This is not handled yet in any renderer or backend, however it is also
not used by anything yet. Following commits add support to the renderers
and backends.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 7a27f6cbe4 compositor: Downgrade rather than drop buffer reference when copied
When the renderer/backend indicate that they do not need a surface's
buffer content to be preserved, most often because they have copied it,
simply downgrade the buffer reference to 'will not access', rather than
drop the buffer reference altogether.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone a42908204f weston_buffer: Separate buffer release from lifetime
In the original conception, a weston_buffer_reference indicated that the
underlying contents of the wl_buffer would or could be accessed, so
wl_buffer.release must not be sent until the last reference was
released, as the compositor may still use it.

This meant that renderers or backends which copied the buffer content -
such as the GL renderer with SHM buffers - could only send a buffer
release event to the client by 'losing' the buffer reference altogether.
The main side effect is that `weston-debug scene-graph` could not show
any information at all about SHM buffers when using the GL renderer, but
it also meant that renderers and backends grew increasingly exotic
structures to cache information about the buffer.

Now that we have an additional buffer-reference mode (still referring to
the weston_buffer/wl_buffer, but not going to access its content), we
can allow the weston_buffer_reference and weston_buffer to live as long
as the buffer itself, even if we do send a release event.

This will enable a bunch of backend and renderer deduplication, as well
as finally making scene-graph more useful.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone fdc7b9c352 weston_buffer: Add mode to weston_buffer_reference
Add a mode argument to weston_buffer_reference which indicates whether a
buffer's storage may/will be accessed, or whether the underlying storage
will no longer be accessed, e.g. because it has been copied. This will
be used to retain a pointer to the weston_buffer whilst being able to
send a release event to the client.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 7e90433079 weston_buffer: Hold lifetime for resource/backend usage
Keep the weston_buffer alive for as long as at least one of the
underlying wl_buffer or a backend usage exists.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone d2a858e879 gl-renderer: Prepare for buffer to outlive resource
Make sure we don't die if we're asked to flush the damage on a SHM
buffer which has subsequently been destroyed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 7b3efabd88 weston_buffer: Prepare for buffer to outlive resource
We currently allow a weston_buffer to outlive the underlying wl_buffer
iff the renderer/backend has cached it. Currently the 'is this buffer
valid?' test relies on looking for the validity of the weston_buffer
itself; shift these tests to looking at the validity of the underlying
resource.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone e9c792ed64 backend-drm: More failure reasons
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 231a67ff8c drm-backend: Refactor unpleasant keep_buffer if tree
Break a giant if statement out into a more legible grouping.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 2dcfe723be backend-drm: Make use of weston_buffer format and type
Just pull it from the structure rather than pulling it in externally.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 1d9c62b50d weston_buffer: Print more buffer information in scene-graph
Try to print out as much information as we can about the buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 0a8802404c scene-graph: Use weston_buffer's format/modifier info to print
Now that we have this generically available, use it rather than calling
into per-buffer getters.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 7506cf5240 gl-renderer: Simplify surface->is_opaque
We already have the format; no need to go chasing it again.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 4f88b2655e weston_buffer: Change y_inverted to explicit origin enum
y_inverted meant that the buffer's origin was (0,0), and non-inverted
meant that the buffer's origin was (0,height). In practice, every buffer
was 'inverted' into our natural co-ordinate space that we use
everywhere.

Switch to using an explicit origin enum to make this more clear.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 6dcf3eac1f weston_buffer: Add pixel format and modifier info
Promote these to weston_buffer rather than burying them in the renderers
and backends.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone fef8bb275c weston_buffer: Make use of weston_buffer->type
Rather than calling accessors (wl_shm_buffer_get etc) to figure out
which type our buffer is, just look in the structure.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 34cd0d114f weston_buffer: Add type field
Rather than open-coding various resource -> type accessors, just stick a
type enum in the buffer struct.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 1d5f8af82e gl-renderer: Add hook to fill weston_buffer for EGL
Rather than only filling weston_buffer information when we first come to
use it, add an explicit hook so we can fill the dimensions the first
time the buffer's attached.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone f49d6f47f3 gl-renderer: Reject unknown-format dmabufs
Make sure we only import dmabufs where the underlying pixel_format is
known: if we can't reason about the buffer content, we're not entirely
likely to be able to display it well.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone ca9bb01fe6 renderers: Set buffer properties earlier
When we first see a buffer attached, we create a weston_buffer for it.
The weston_buffer doesn't contain any useful information in and of
itself; that's left to renderers to populate later.

Switch this to doing it in the core at the first opportunity, at least
for SHM and dmabuf buffers; EGL buffers will follow in the next commit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone fec0400886 gl-renderer: Drop unnecessary NULL check
All the callers of flush_damage guarantee we'll have a buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone 12675ed19f renderer: Add buffer to flush_damage
We already have the buffer in the caller, and every no-op implementation
will want to access the buffer. So might as well pass it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone f8ac6f940f gl-renderer: Remove outdated comment
The comment about needing to have destroyed images is somewhat less true
now that we actively avoid doing so.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: 0b51b02c5e ("gl-renderer: Don't re-import dmabufs")
2022-04-25 14:27:08 +00:00
Daniel Stone efd6aae915 gl-renderer: Remove unnecessary dmabuf conditional
We can't try to attach a dmabuf that we never imported.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Hideyuki Nagase 6129cbd880 rdp: Improved rdp logging infrastructure
Add some logging helper functions along with two log scopes for debug
and extremely verbose debugging information.

Also add tangentially related logging for the synchronize event, so
the debug stream isn't empty right now. The vast majority of verbose
usage will come later.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-21 07:33:27 -05:00
Derek Foreman 04e0558327 rdp: Allow disabling RemoteFX codec
There are currently compatibility issues between FreeRDP's implementation
of the RemoteFX codec and Microsoft's implementation.

Perhaps this will be fixed in the future and this option can go away,
but for now it's necessary to have a way to disable the codec if the
windows client is going to be connecting to a weston server.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-21 07:20:59 -05:00
Marius Vlad 3bedb70454 touch-calibration: Clean-up if touch calibrator has been enabled
Seems that we're still missing layer clean-ups, with the touch
calibrator being one of them. Call the appropriate function when
shutting down the compositor instance.

Fixes: #603

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-04-20 08:27:17 +00:00
Hideyuki Nagase 8fb529bc31 input: Fix bug in idle inhibition
Server generated key repeats are ignored - and they don't generate
matching release events. We early return to avoid generating events
for them.

We also need to push the idle inhibition counting after that early
return to prevent breaking idle inhibition with unmatched events.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-18 12:10:20 +00:00
shierote f2d6d21eec libweston: correct argument name in the handler of wl_data_source.accept
Signed-off-by: Taishi Eguchi <taishi2060@gmail.com>
2022-04-14 12:05:57 +00:00
Hideyuki Nagase 87bded8b54 rdp: split off rdp.h
Refactor some of rdp.c into a header file.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-14 12:02:12 +00:00
Hideyuki Nagase 516d2c0207 rdp: fix leak when listener implantation fails
We've already allocated the listener by the time we hit this failure,
so we must exit through the path that frees it.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-04-14 11:57:29 +00:00
Derek Foreman 0ff4e478cd rdp: Fix comment regarding meaning of 120
This URL has changed

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-12 09:26:13 -05:00
Sören Meier edef874696 libbacklight: Fix backlight never gets initialized
In 913d7c15f7 stricter error checking was
introduced to the strtol call, which broke reading backlight values.
Since every sysfs backlight file ends with a newline.

As noted in a comment in the previous MR to prevent damaged pointers
after calling asprintf, replace every asprintf call with str_printf.

Previous-MR: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/543

Signed-off-by: Sören Meier <soerenmeier@livgood.ch>
2022-04-11 08:38:00 +03:00
Michael Tretter 6ee6e76a0c compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.

There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.

The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.

Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-04-06 12:47:05 +02:00
Michael Tretter c448b938f7 backend-drm: always get pending_state from backend
The pending_state is already stored in the backend and can be directly retrieved
from there.

This avoids involving the compositor in passing state between the repaint
phases for a single backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-04-06 12:47:05 +02:00
Daniel Stone c8a2fb7a40 pixel-formats: Add XYUV8888 format
XYUV8888 support was added to gl-renderer in 30104bd89a, but not to
pixel-formats. Oops.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
nerdopolis cdfe94b105 launcher-logind: Don't check wl->vtnr before returning it.
Signed-off-by: n3rdopolis <bluescreen_avenger@verizon.net>
2022-03-16 13:12:20 +00:00
Pekka Paalanen b3ba1becba libweston: remove fbdev backend
Fbdev backend was deprecated in the Weston 10.0.0 release with
6338dbd581. Before that, I suggested
already in 2019 to remove it, but it was too soon then. Now it seems the
final voices asking for fbdev to be kept have been satisfied, see the
linked issue.

Fbdev-backend uses a kernel graphics UAPI (fbdev) which is sub-par for a
Wayland compositor: you cannot do GPU accelerated graphics in any
reasonable way, no hotplug support, multi-output support is tedious, and
so on. Most importantly, Linux has deprecated fbdev a long time ago due
to the UAPI fitting modern systems and use cases very poorly, but cannot
get rid of it if any users remain. Let's do here what we can to reduce
fbdev usage.

I am doing color management related additions to libweston which require
adding checks to every backend. One backend less is less churn to write
and review.

Libweston major version has already been bumped to 11, so the next
release will be Weston 11, without fbdev. enum weston_compositor_backend
entries change their numerical values.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/581

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-15 11:32:46 +02:00
Robert Mader f81aacdf2f pixel-formats: Add support for 64bbp float RGB formats
These are supported by some other compositors already.
Add them to the list so `weston-simple-dmabuf-feedback`
reports them correctly.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-03-11 13:55:19 +01:00
Marius Vlad c19cf3d684 libweston: Enable logging for libseat launcher
The built-in backend of libseat requires users to enable a logging
level in order for libseat to start writing out log messages.  For that
to happen we split out the info and error log level messages into the
compositor's log scope, while debug level messages go into a dedicated
scope.

With that, this patch brings in a new scope, called libseat-debug, which
users need to explicity create a subscription for it as to retrieve/have
access to debug message coming out of libseat. Note that by default we
have a subscription for the log-scope so any errors/info from libseat
would be displayed to the user.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-03-10 17:13:16 +02:00
Marius Vlad e9fe66a91c weston-log: Extract helper for generating a time stamp
As we might be needing it for other scopes extract the time stamp
genration into a helper.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-03-10 17:11:31 +02:00
Derek Foreman 7cae2a1fb0 backend-wayland: Stop supporting wl_shell
This has been deprecated for a long time, so let's stop supporting
it entirely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-03-08 15:12:56 +02:00
Michael Olbrich 78c94d0719 libweston: explicitly cancel start_drag if no matching input device is found
Otherwise, the client will assume that dragging is in progress and remains in
that state forever.
This can happen when weston processes the mouse up event just before the
start_drag() arrives.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-03-04 11:51:01 +00:00
Derek Foreman 2c91c70250 launchers: Remove --tty option
This doesn't work with any of the launchers we've kept. Remove the option
and all the bits that handle it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-03-03 17:00:15 -06:00
Derek Foreman a96dfc7098 launchers: remove launchers
Moving forward we're going to be supporting libseat and logind as our
only launchers. We're doing this to reduce our maintenance burden,
and security impact.

Libseat supports all our existing use cases, and seatd can replace
weston-launch so we no longer have to carry a setuid-root program.

This patch removes weston-launch, and launcher-direct, leaving only
libseat and logind.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-03-03 16:54:14 -06:00
Vitaly Prosyak 87f2d09f18 color-lcms: Always use cmsContext for LCMS API which has THR suffix
Fix a typo. No CM functional change, just redirect LCMS error
into  created cmsContext which output into weston log.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-03-01 22:49:39 -05:00
Pekka Paalanen e2ee2b56f9 tests: make vertex-clip use WESTON_EXPORT_FOR_TESTS
This is probably the simplest case to demonstrate how to use
WESTON_EXPORT_FOR_TESTS.

Previously, vertex-clip test re-built vertex-clipping.c for itself. Now
it directly links in gl-renderer.so instead as that is where
vexter-clipping.c gets built into for actual use. This probably will not
work for any installed program, but luckily tests are never installed,
so Meson makes sure the DSO is found.

Unfortunately we cannot remove the definition of dep_vertex_clipping
yet, because clients/cliptest.c needs it.

This makes vertex-clip test depend on GL-renderer, but that is where the
code is really used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-01 13:32:15 +00:00
Takuro Ashie 351e6a4b21 Don't send compositor's global key bindings to the input method
Although weston_compositor_run_key_binding() is called when the current
keyboard grab is default_grab or input_method_grab, swallowing the key
event is processed only on default_grab. As a result key events that
should be swallowed are sent to the input method unexpectedly.

For example, when a user press `Super + s` on weston-editor to take a
screen shot, `s` will be unexpectedly entered to the text area.
I confirmed such behaviour with weston-simple-im and fcitx5-5.0.10.
It doesn't occur with weston-keyboard because it doesn't install
keyboard grab.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
2022-02-23 15:40:33 +02:00
Vitaly Prosyak 6099c0e24b color-lcms: LCMS transform for color mapping
Use 3D LUT for color mapping.
For category CMLCMS_CATEGORY_INPUT_TO_BLEND use transform which has
3 profiles: input, output and light linearizing transfer function.
For category CMLCMS_CATEGORY_INPUT_TO_OUTPUT use input and output profiles +VCGT.
For category CMLCMS_CATEGORY_BLEND_TO_OUTPUT use output inverse EOTF + VCGT.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-12 23:19:00 -05:00
Vitaly Prosyak c199aade3f color-lcms: linearization of an arbitrary color profile
Graeme sketched a linearization method there:
https://lists.freedesktop.org/archives/wayland-devel/2019-March/040171.html
Sebastian prototyped there:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/14/commits

Thanks to Pekka for great simplifications in implementation, like the xyz_dot_prod()
Quote: "should help untangle lots of the multiplications and summations by saying
we are computing dot products, etc".

The approach was validated using matrix-shaper and cLUT type of profiles.
If profile is matrix-shaper type then an optimization is applied.
The extracted EOTF is inverted and concatenated with VCGT, if it is availible.
Introduce function cmlcms_reasonable_1D_points which would be shared between
linearization method and number of points in 1DLUT for the transform.
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 13:06:11 -05:00
Vitaly Prosyak 37e0d54cc9 color-lcms: add matches parameters based on category
Use category, intent and output and input profiles
for comparison.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 12:58:02 -05:00
Vitaly Prosyak 19913366e8 color-lcms: add new fields for transform search parameter
Add to search parameter cmlcms_category, input and output profiles,
and render intent for output which would be used for both profiles.
Add common function setup_search_param for every category.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 12:58:00 -05:00
Vitaly Prosyak 19f318692e color-lcms: introduce sRGB stock profile
The stock profile would be used when client or output
do not provide any profile or unaware of color management.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 12:56:57 -05:00
Vitaly Prosyak a92fa34d1d color-lcms: add wrapper API for refcounting cmlcms_color_profile
It is used for convenience when profile is cached.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak 494ff5b23b color-lcms: introduce cmlcms_category, EOTF and INV EOTF
1. The cmlcms_category is used to identify the purpose of transform:
   - CMLCMS_CATEGORY_INPUT_TO_BLEND
   - CMLCMS_CATEGORY_BLEND_TO_OUTPUT
   - CMLCMS_CATEGORY_INPUT_TO_OUTPUT

2. Added following fields to cmlcms_color_profile:

   - output_eotf - If the profile does support being an output profile and it
     is used as an output then this field represents a light linearizing
     transfer function and it can not be null. The field is null only if
     the profile is not  usable as an output profile. The field is set when
     cmlcms_color_profile  is created.

   - vcgt - VCGT tag cached from output profile, it could be null if not exist

   - output_inv_eotf_vcgt - if the profile does support being an output profile and it
     is used as an output then this field represents a concatenation of inverse
     EOTF + VCGT, if the tag exists and it can not be null.

3. Added field cmsHTRANSFORM to cmlcms_color_transform.
   It is used to store LCMS optimized pipeline.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak 93c6180c71 gl-renderer: shaders implementation of color mapping function
The following GL extensions provide support for shaders CM:
 -GL_OES_texture_float_linear makes GL_RGB32F linear filterable.
 -GL ES 3.0 provides Texture3D support in GL API.
 -GL_OES_texture_3D provides sampler3D support in ESSL 1.00.

If abovesaid is supported then renderer sets flag WESTON_CAP_COLOR_OPS
which means that all fields in struct weston_color_transform are
supported, for example, 1DLUT and 3DLUT.

Use GL_OES_texture_3D to implement 3DLUT function which
uses trilinear interpolation for pixel processing or bypass as is.
Quote from https://nick-shaw.github.io/cinematiccolor/luts-and-transforms.html
"3D LUTs have long been embraced by color scientists and are one of
the tools commonly used for gamut mapping. In fact, 3D LUTs are used
within ICC profiles to model the complex device behaviors necessary
for accurate color image reproduction".
Quote from https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/
chapter-24-using-lookup-tables-accelerate-color
is about interpolation: "By generating intermediate results based
on a weighted average of the eight corners of the bounding cube,
this algorithm is typically sufficient for color processing,
and it is implemented in graphics hardware".

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak cda130e4b0 gl-renderer: add declaration of color mapping function
Introduce shader color mapping identity and 3D LUT.
Shader requirements struct uses union for color mapping
to prepare the place for 3x3 matrix.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak 2e2ad02d5c libweston: add definition of color mapping function
Introduce 3D LUT definition as part of Weston
color transform struct. A 3D LUT is a LUT containing
entries for each possible RGB triplets.
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Marius Vlad 0b5c75f540 backend-drm/state-propose: Missing some newlines
It would look much better if the debug is printed separately.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-07 17:58:35 +02:00
Robert Mader 8b04534c76 libweston/compositor: Do not map subsurfaces without buffer
We can end in `subsurface_committed()` in different scenarios
without the surface having an attached buffer. While setting
the mapped state to `true` in that case doesn't matter for
that (sub)surface itself, it triggers its own child subsurfaces
to get mapped when they shouldn't.

Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/426

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-07 12:16:16 +00:00
Derek Foreman 83927bb0e6 launcher-logind: Remove systemd-logind support
Many years ago (2014) systemd-logind was brought into libsystemd.
We've supported old versions of systemd-logind ever since.

Let's remove support for old versions of systemd-logind before the
merge for a tiny code simplification.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-02-03 16:00:26 +00:00
Derek Foreman 66374d48f1 compositor: Remove desktop zoom
Zoom is a neat trick, but in its current form it's very hard to test
and maintain.

It also causes output damage to scale outside of the output's boundaries,
which leads to an extra clipping step that's only necessary when zoom
is enabled.

Remove it to simplify desktop-shell and compositor.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-02-03 15:51:20 +00:00
Robert Mader 933290e6ea libweston/compositor: Cache buffer damage for synced subsurfaces
The spec states:
> Because buffer transformation changes and damage requests may be
> interleaved in the protocol stream, it is impossible to determine
> the actual mapping between surface and buffer damage until
> wl_surface.commit time. Therefore, compositors wishing to take both
> kinds of damage into account will have to accumulate damage from the
> two requests separately and only transform from one to the other after
> receiving the wl_surface.commit.

For subsurfaces in sync mode, arguably the same is the case until the
cached state gets applied eventually. Thus, in order to keep complexity
to a sane level, just accumulate buffer damage and convert it only
when the cached state gets applied.

This mirrors how other compositors like Mutter implement cached damage
and what the spec arguably should demand.

Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/446

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-03 15:44:47 +00:00
Manuel Stoeckl b0ed4a2e3b gl-renderer: add support for (a|x)bgr16161616 shm formats
These formats are useful because they are often easier to produce
on CPU than half-float formats, and abgr16161616 has both >= 10bpc
color channels and adequate alpha, unlike abgr2101010.

The 16-bpc textures created from buffers with these formats require
the GL_EXT_texture_norm16 extension.

As WL_SHM_FORMAT_ABGR16161616 was introduced in libwayland 1.20,
update Weston's build requirements and CI.

The formats also needed to be registered in the pixel format table,
and defined in a fallback path if recent libdrm is not available.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2022-02-02 11:58:58 +00:00
Daniel Stone 30de938624 backend-drm: Add more view-to-plane failure states
Specifically log if there were no suitable planes for us to use, or if
we tried to place it on a plane but were told no by the kernel.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone a2c5709e71 backend-drm: Pass paint node through to plane_state find
This lets us clean up a bit of code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 0ace8b66af backend-drm: Unify overlay/primary view->plane code
There's no real reason for these to be separate now that the eligibility
checks have been moved up so we don't call them unless it makes sense.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 81e74ff334 backend-drm: Don't take buffer-release reference for cursor views
We just copy the SHM buffer straight into a separately-allocated GBM BO,
so no need to take a reference on the buffer itself or keep it from
being released.

All drm_output_try_view_on_plane really does at this point is to call
the prepare_*_view function for the requisite plane type, and take a ref
on the weston_buffer from the client. Given that we don't need to keep
the client buffer alive, we can short-circuit
drm_output_try_view_on_plane, and instead just call
drm_output_prepare_cursor_view directly when we have a cursor plane.

This also makes it easier to just remove drm_output_try_view_on_plane in
following patches when we merge the overlay/scanout plane path into one.
Doing so gives us two clearly-separated paths: one for copying a SHM
client buffer into a cursor, and another for directly scanning out
client content.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 873e32137e backend-drm: Remove unnecessary check for fb
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone e1114228f5 backend-drm: Remove unused enum
At some point this got hobbled, such that NO_PLANES and
NO_PLANES_ACCEPTED became the same thing, so we can just check if the
returned plane_state is NULL or not.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 2dd3af3c22 backend-drm: Move IN_FENCE_FD check to common code
No need for this to be specialised within both overlay and scanout plane
paths.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 1b34c5cd80 backend-drm: Remove unnecessary check in prepare_scanout_view
We already guarantee this from the caller.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 6b828c7b57 backend-drm: Don't try non-fullscreen views on the primary plane
You'd think this would go without saying, but no, we just sort of buried
that.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone dc0de9ee2b backend-drm: Move overlay vs. primary plane check earlier
For views which cover the entire output, we always attempt to place them
on the primary plane, to avoid a situation where we place a fullscreen
view into an overlay plane and then have to disable the primary plane,
which doesn't always work.

Move this check earlier, so we don't consider overlay planes to be
candidates for fullscreen views. This check should be changed in future
to only filter for opaque views, but that's for another time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 5e41b44b10 backend-drm: Change cursor checks to asserts
We shouldn't get down into trying to place a view on a cursor plane if
these checks are not met, so change them to asserts rather than early
returns.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone b3d7df5c3e backend-drm: Move plane-type-specific checks to switch statement
This makes it a bit more clear and easy to follow, rather than diving
through if nesting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 0ecd6c3d33 backend-drm: Move renderer-only vs. scanout_plane test earlier
No point trying to put something on the scanout plane in mixed mode.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone ae60745b61 backend-drm: Move cursors_are_broken test earlier
No point trying to place a cursor buffer on a plane when we can't do
cursor planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone e5ad3c8865 backend-drm: Remove separate zpos_plane list
When we introduced support for variable zpos, we did so by filtering the
list of acceptable planes and then creating a separate zpos-ordered
list. Now that the planes are already zpos-sorted in the backend list,
and we have more early filtering, we can replace this with a single
plane-list walk.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 23257c073f backend-drm: Minor comment rewording
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 26c2f9a65f backend-drm: Don't try cursor buffers for client planes
For better or worse, cursor planes can only be used by uploaded SHM
buffers right now, so ignore them when we're calculating the acceptable
plane mask for client dmabufs.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 9c6a069435 backend-drm: Early-out for non-SHM buffers in renderer-only mode
If we're in renderer-only mode, we can only use the renderer and the
cursor plane. Don't even try to import client buffers as it makes no
sense.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 6aec64b2f7 backend-drm: Early-out for too-large SHM/cursor buffers
We know what our limit is for cursor planes, so don't try to assign a
view which is too large.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone ca4c2865e9 backend-drm: Early-out for cursor plane format testing
If we have a SHM buffer, it can only go into a cursor plane - and only
then if it's of the right format.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 66244856e2 backend-drm: Don't try to import SHM buffers as drm_fb
It won't work.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone d5ec9a1a1d backend-drm: Don't try to steal other-output special planes
Each output is hardcoded to the use of a single 'special' (primary or
cursor) plane; make sure we don't try to steal them from other outputs
which might not be happy to discover that we've taken it off them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 075c4ac286 backend-drm: Don't try to use planes without GBM
GBM is how we import all our client content into DRM FBs, so don't try
anything other than renderer-only without it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone af42fc1e33 backend-drm: Assign plane_idx by plane list order
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 6609840479 backend-drm: Pre-sort plane list by zpos
Rather than constructing a zpos-sorted list every time, just have
plane_list be pre-sorted.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone 7ca7c14553 backend-drm: Rewrite zpos-sorting list insertion
It's possible to write this with a few less twisty special cases. Tested
manually with a randomly-distributed input tree as well as manually
trying to hit special cases around first/last entries.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Kenny Levinsen 834df18ac2 meson: Rename to deprecated-weston-launch
This ensures that users that previously set the option explicitly will also have
a chance to notice the deprecation.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2022-01-27 15:38:38 +00:00
Kenny Levinsen e1491a7236 meson: Print deprecation warning for weston-launch
weston-launch will be removed in a future release as this feature has
been offloaded to libseat and seatd-launch. Print an early deprecation
warning to give existing users time to migrate.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2022-01-27 15:38:38 +00:00
Derek Foreman db7e85d5f8 drm: Fix hang on zoom
Transforming the scanout damage by the zoom will result in rectangles
outside of the display, and some with negative co-ordinates. This makes
at least some drivers unhappy (tested on vmware), and the page flip fails,
and weston hangs indefinitely.

Clip the damage to the output so we don't fall down.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-25 16:33:10 +00:00
Simon Ser 6338dbd581 build: deprecate fbdev backend
Rename the build option to "deprecated-backend-fbdev" so that a
previously configured build dir doesn't retain the old setting.
This is consistent with the existing "deprecated-wl-shell" option.
Make the option default to "false".

Print a warning when fbdev is force-enabled.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/weston/-/issues/581
2022-01-25 16:28:05 +00:00
Pekka Paalanen 26b04f0045 libweston: fix paint node color invariant
The invariant is clearly documented in code comments, but the code
failed to ensure it in all cases. Fix it.

There is one very specific protocol sequence triggered by a development
version of the Wine Wayland driver when Chrome (win64 app) is switched
from window to fullscreen and then back by pressing F11 key. The switch
back triggered

weston: ../libweston/color.c:217: weston_paint_node_ensure_color_transform: Assertion 'it->surf_xform_valid == false' failed

For some reason, that specific protocol sequence causes
weston_compositor_build_view_list() to create a transient second view
for a sub-surface. In the Chrome traces, I have seen that happen twice
per run.  The first time it works, the old view gets immediately
destroyed. The second time (during un-fullscreening) a new transient
view is create and then it fails the invariant check.

The fix is in weston_paint_node_create() which is supposed to ensure the
invariant. However, it went through the (new) view's paint node list,
which will not contain paint nodes from other views. In hindsight this
is an obvious bug, but perhaps all views having exactly one associated
surface each somehow confused the author. Since the invariant is about
surface+output, go through the surface's paint node list instead. That
list contains all the relevant paint nodes by definition.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/568

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-01-25 13:45:15 +00:00
Derek Foreman 713f02327d compositor: Fix opaque regions
Commit 0e4f097d broke opaque regions, and since then weston will waste
time rendering occluded areas.

I think this is because we're taking the intersection of the opaque
and scissor regions even when the scissor region isn't enabled.

An easy test is to turn on triangle fan debugging with the gl renderer,
then run weston-simple-damage and move another opaque application such as
weston-terminal over it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-21 15:44:32 +00:00
Leandro Ribeiro d42fa30d14 launcher: fix leak in launcher_weston_launch_connect()
Leak found running drm-smoke-test with ASan.

Do not forget to free the launcher before returning when we can't open
the launcher fd. Also, just set 'out = launcher' after all error paths,
otherwise we give the caller a stale pointer.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Daniel Stone 37a0544edf backend-wayland: Destroy touch device before seat
weston_touch_destroy(), which is called from weston_seat_release(),
asserts that all its touch devices have been destroyed. The Wayland
backend currently destroys the touch devices ... immediately after
calling weston_seat_release().

Invert the ordering so that touch devices are destroyed first and we
don't trip over the assert.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-15 14:25:40 +00:00
Marius Vlad bb55d86300 backend-drm/drm-gbm: gbm_device_destroy on an invalid gbm device
When EGL initialization fails (failure to create a GLES3 or GLES2
context) we will end up calling gbm_device_destroy() twice, once
in init_egl() and once in the drm_backend_create() error path.

Given that we should also take care of properly destroying the gbm
device when we don't have any inputs for instance, mark the gbm device
as NULL to avoid calling gbm_device_destroy() once more when destroying
the DRM-backend.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-12 13:52:26 +00:00
Marius Vlad f2452d6006 libweston: Convert remaning destroy signals
Replaces potential corruption signal emit call sites with the more safer
weston_signal_emit_mutable().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Marius Vlad 2015dfc325 compositor: Fix removal of an output
This uses the more safer version of signal emission to avoid a potential
crash when the output is destroyed that will follow a surface/view
destruction for which it has a listener attached (to the output_destroy
signal).

Fixes: #734

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Alexandros Frantzis fa48c5ee41 libweston: Use weston_signal_emit_mutable for surface destruction
This avoids crashes due to removal of notification listeners from within
invocations of other listener callbacks in the same signal emission.

Fixes: #415

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-12-14 17:55:06 +00:00
Daniel Stone 57d609a47e backend-drm: Cache fb<->plane format compatibility list
Walking the format/modifier list to try to find out if our FB is
compatible with the plane is surprisingly expensive. Since the plane's
capabilities are static over the lifetime of the KMS device, cache the
set of planes for which the FB is theoretically
format/modifier-compatible when it's created, and use that to do an
early cull of the set of acceptable planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 7d27df4c4c backend-drm: Cache drm_fb for each weston_buffer
When we first create a drm_fb from a weston_buffer, cache it and keep it
alive as long as the buffer lives. This allows us to reuse the gbm_bo
and kernel-side DRM framebuffer, rather than constantly creating and
destroying them at every repaint. The overhead of doing so (e.g. MMU
updates) can be significant on some platforms.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 2ecc38b042 backend-drm: Move fb -> buffer reference to plane state
Currently each drm_fb takes a reference on a client buffer it wraps.
This prevents us from being able to reuse a drm_fb in multiple places
(e.g. two views of the same client buffer) simultaneously, or even back
to back.

Move the buffer reference to the plane state, as preparation for
allowing drm_fb to be cached inside the weston_buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 267f6cc6a1 backend-drm: Move drm_fb reference to state-propose
Currently we take a reference on the underlying client buffer every time
we materialise a drm_fb from a view, and release it when the drm_fb is
destroyed. This means that we need to create and destroy a drm_fb every
time we want to use it, which is pathologically unperformant on some
platforms.

To start working towards being able to cache drm_fb, only take the
reference when we apply it to a plane state.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 9e379db082 backend-drm: Early-out in plane assignment for unimportable buffers
No sense walking the plane list every frame if we can't use it because
it's neither a SHM buffer nor a client buffer we can directly import as
a framebuffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone f508603420 backend-drm: Free scanout format table after use
We were deinitialising the array, but not also freeing the allocation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 61851f5c37 content-protection: Don't leak update timer on shutdown
If we still have a pending idle timer when the compositor is being
destroyed, make sure to free it first.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 8817a5f163 backend-x11: Fix EGL compile warning
EGLNativeWindowType can be a lot of different things, including a
pointer which an XID is not. Explicitly cast it through uintptr_t so we
don't throw build warnings either way.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-27 09:57:46 +00:00
Leandro Ribeiro 5429302e78 backend-drm: add KMS plane's formats to per-surface dma-buf feedback
In commit "libweston: add initial dma-buf feedback implementation" we've
added initial support to dma-buf feedback, but it was not using the
feedback from DRM-backend to add useful per-surface feedback.

In this patch we add this. The scanout tranche of the per-surface
feedback is based on the union of formats/modifiers of the primary and
overlay planes available. These are intersected with the
formats/modifiers supported by the renderer device.

Also, it's important to mention that the scene can change a lot and we
can't predict much. So this patch also adds hysteresis to the dma-buf
feedback. We wait a few seconds to be sure that we reached stability
before adding or removing the scanout tranche from dma-buf feedback and
resending them. This help us to avoid spamming clients and leading to
unnecessary buffer reallocations on their end.

Here's an example of what we want to avoid:

1. We detect that a view was not placed in a plane only because its
   format is not supported by the plane, so we add the scanout tranche
   to the feedback and send the events.

2. A few milliseconds after, the view gets occluded. So now the view
   can't be placed in a plane anymore. We need to remove the scanout
   tranche and resend the feedback with formats/modifiers optimal for
   the renderer device. The client will then reallocate its buffers.

3. A few milliseconds after, the view that was causing the occlusion
   gets minimized. So we got back to the first situation, in which the
   format of the view is not compatible with the plane. Then we need to
   add a scanout tranche and resend the feedback...

This patch is based on previous work of Scott Anderson (@ascent).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:52 -03:00
Leandro Ribeiro 0a7034c0cb backend-drm: keep track of the reason why promoting view to a plane failed
Add enum try_view_on_plane_failure_reasons to help us to keep track of
the reason why promoting view to a plane failed. We also add a variable
to struct weston_paint_node so that we can update this information in
each output repaint.

This will be used in the next commits, in which we add proper surface
dma-buf feedback support.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:21 -03:00
Leandro Ribeiro 8eb8414fcd libweston: add initial dma-buf feedback implementation
This adds the initial dma-buf feedback implementation, following the
changes in the dma-buf protocol extension.

The initial dma-buf feedback implementation gives support to send
default feedback and per-surface feedback. For now the per-surface
feedback support is very basic and is still not implemented in the
DRM-backend, what basically means that KMS plane's formats/modifiers are
not being exposed to clients. In the next commits of this series we add
the DRM-backend implementation.

This patch is based on previous work of Scott Anderson (@ascent).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:14 -03:00
Leandro Ribeiro 18f53ab2d4 libweston: assert that renderer->get_supported_formats() is set
This just documents why we can be sure that
renderer->get_supported_formats() is set in bind_linux_dmabuf().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 10:47:45 -03:00
Leandro Ribeiro 60c7fee48d drm-formats: add weston_drm_format_array_count_pairs()
It simply returns the number of format/modifier pairs in the array. This
will be useful for the next commits, in which we add support for dma-buf
feedback.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 10:47:45 -03:00
Scott Anderson f9787ba482 gl-renderer: query DRM device given an EGLDisplay
Add function to query the DRM device given an EGLDisplay. It is the
device being used by the compositor to perform composition.

This will be useful in the next commits of this series, where we add
support for dma-buf feedback.

Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 10:47:39 -03:00
Marius Vlad e9a0c0648b libinput-seat: Cascade errors and bail out in case of failure
Errors happening to devices being added or removed shouldn't fail
silently so exit if any of that happens.

Sprinkle some debug logs for other cases as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2021-11-25 10:47:04 +02:00
Pekka Paalanen 9a9e6ced1b libweston: add weston_output::color_profile
Add API to set an output's color profile. This new function can also be
called while the output is enabled. This allows changing the output
color profile even at runtime if desired.

color-noop has no way of creating weston_color_profile objects, so it
just asserts that no color profile is set.

color-lcms does not yet implement taking the output color profile into
account, so for now it just fails everything if a profile is set.

weston_surface_color_transform_fini() was previously used only prior to
freeing the struct, but now it is used also to just clear the struct,
hence it needs to reset the fields.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-11-23 09:23:05 +00:00
Pekka Paalanen 9a0aa37edd libweston: refactor into weston_output_set_color_transforms()
Move the code into a new function that either succeeds in setting all
the color transformations or does not change anything. This will be
useful when implementing output color profiles changes while the output
is enabled.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-11-23 09:23:05 +00:00
Pekka Paalanen f45d57623e color: add weston_compositor_load_icc_file()
This function will be useful for Weston to load output ICC profiles from
weston.ini.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-11-23 09:23:05 +00:00
Pekka Paalanen aa6346f274 color: introduce weston_color_profile
Roughly speaking, a color profile describes the color space of content
or an output. Under the hood, the description includes one or more ways
to map colors between the profile space and some standard profile
connecting space (PCS).

This object is not called a color space. A color space has a unique
definition, while a color profile may contain multiple different
mappings depending on render intent. Some of these mappings may be
subjective, with an artistic touch.

When a source color profile and a destination color profile are combined
under a specific render intent, they produce a color transformation.
Color transformations are already preresented by weston_color_transform.

This patch adds the basic API for color profile objects. Everything
worthwhile of these objects is implemented in the color managers:
color-noop never creates these, and in color-lcms they are basically a
container for cmsHPROFILE, the Little CMS object for color profiles.
Color profile objects will not be interpreted outside of the color
managers, unlike color transformations.

For a start, the color manager API has one function to create color
profiles: from ICC profile data. More creation functions for other
sources will be added later.

The API has errmsg return parameter for error messages. These are not
simply weston_log()'d, because CM&HDR protocol will allow clients to
trigger errors and the protocol handles that gracefully. Therefore
instead of flooding the compositor logs, the error messages will
probably need to be relayed back to clients.

Color-lcms is expected to create a cmsHPROFILE for all kinds of color
profiles, not just for those created from ICC profile data. Hence,
color-lcms will fingerprint color profiles by the MD5 hash which Little
CMS computes for us. The fingerprint is used for de-duplication: instead
of creating copies, reference existing color profiles.

This code is very much based on Sebastian Wick's earlier work on Weston
color management, but structured and named differently.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-11-23 09:23:05 +00:00
Manuel Stoeckl 742a0232b0 gl-renderer: add support for (a|x)bgr16161616f shm formats
These formats will be eventually be useful for color managed clients
using wl_shm that wish to submit buffers encoding high dynamic range
images.

While the minimum requirement for linearly filterable half float
textures is GL ES 2.0 + GL_OES_texture_half_float_linear, to keep
the code simple, this commit only enables the new formats when
the requirements for color management (notably including GL ES 3.0
and GL_EXT_color_buffer_half_float) are available.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-11-06 23:52:58 -04:00
Marius Vlad 5b357a4bbb backend-rdp: Correctly tear down the RDP back-end
This fixes the tear-down and the destroying part in case RDP back-end
couldn't be initialized. The first issue is the rdp_output which will
not be created in some circumstances (can't open the socket for
instance) and requires a guard check, and secondly, the
rdp_head being created above of that, wasn't removed and tripped an
assert when destroying the compositor instance.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-03 10:33:21 +02:00
Marius Vlad d6ccc8b025 libweston: Rename weston_view_activate() to weston_view_activate_input()
This way, we try to differentiate between input focus and window/surface
activation.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:04:33 +02:00
Manuel Stoeckl c7fbc97120 gl-renderer: add support for (a|x)bgr2101010 shm formats
Adding these formats makes it possible for clients using wl_shm to
submit buffers with 10 bits per pixel, and thus (if Weston is
configured with an xrgb2101010 frame buffer) display more precise
colors on some computer monitors.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-10-27 09:02:07 +00:00
Manuel Stoeckl 3208ee42cd backend-wayland: clean up wayland_input structs
The struct wayland_input objects tracking the outer compositor's
wl_seats are now properly destroyed when the wayland backend is.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-10-20 00:25:43 -04:00
Manuel Stoeckl ac20d4a293 backend-wayland: replace a nested wl_display_roundtrip call
The wl_display_roundtrip call was originally introduced to let the
display_add_seat function wait until a wl_seat.name event was received.

This change replaces the wl_display_roundtrip call with an
asynchronous, nonrecursive equivalent. Now a wl_display.sync callback
is used to delay the final steps of adding a seat until one protocol
roundtrip has occured/the name has been received.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-10-18 19:21:25 -04:00
Derek Foreman 0b51b02c5e gl-renderer: Don't re-import dmabufs
My reading of the GL spec is that a dmabuf becomes a sibling to the
EGLImage created from it, and that all updates to the dmabuf will be
propagated to the EGLImage.

A rebind is still required every time the dmabuf content changes,
but this should be satisfied by gl_renderer_attach(), which does
a rebind when the buffer is commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-09-29 15:20:30 +00:00
Derek Foreman b47e2cc902 gl-renderer: Add EGL_IMAGE_PRESERVED_KHR to our attributes
So, turns out the GL implementation is allowed to destroy EGLImage
sources if this isn't set. Apparently none we've ever been tested on do
this, but it looks like we should be setting this anyway.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-09-29 15:20:30 +00:00
Derek Foreman b6c891774e launcher-logind: Try the user's primary session if not in a session
If we're not in a session we can fall back to sd_uid_get_display() to
find the user's primary session.

This allows launching weston from an ssh session or as a systemd
user service if a viable session is available.

It also more closely follows how libseat finds the session. The libseat
launcher can already do these things, so this change makes these
features common to both launchers.

Based on a patch by Sjoerd Simons <sjoerd.simons@collabora.com>

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-09-29 14:30:50 +00:00
nerdopolis d2a320d53e Fix TTY switching after failed failed repaint with legacy mode set.
Reported in !179 adding weston_output_repaint_failed resets the output

Co-authored-by: Daniel Stone
Co-authored-by: Julius Krah
Signed-off-by: n3rdopolis <bluescreen_avenger@verizon.net>
2021-09-29 12:17:58 +00:00
Derek Foreman a822afaaef input: fix keyboard focus crash
If two or more clients were running and the one that was focused when
weston itself lost keyboard focus was killed, weston would crash.

This is because commit 85d55540cb changed the way we handle saved keyboard
focus when we lose focus, and did so in such a way that the saved keyboard
focus listener could be removed from the surface destroy signal list
during the emit of the surface destroy signal. This corrupted the list
and led to a NULL pointer dereference.

Fix this by using a boolean flag to determine whether we should obey the
saved keyboard focus. We can set this safely in cases where
removing the listener would cause a crash.

Fixes #138

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-09-28 11:42:04 +03:00
Manuel Stoeckl 8a7f1e2bc0 pixman-renderer: track Pixman formats in pixel format table
Adds a Pixman format field to the pixel format table, and
adjusts the shm format handling code in the Pixman renderer
to use this table.

Pixman formats have been registered only for specific 565, 8888,
and 2101010 layouts, as these have corresponding DRM format codes
and are commonly used.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-09-15 15:00:29 +03:00
Dennis Tsiang a2a8d382e3 gl-renderer: Don't require buffer age when using partial update
EGL_KHR_partial_update can be implemented independently of
EGL_EXT_buffer_age so we handle each case seperately.

Signed-off-by: Ben Davis <ben.davis@arm.com>
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2021-09-07 15:20:25 +00:00
Pekka Paalanen 2ec15ebf3f libweston: fix crash on never used output's tear-down
weston_output_enable() initializes the list, but weston_output_release()
maybe be called even if the output was never enabled, triggering the
assert due to uninitialized (actually NULL) list head.

This can be triggered with a bad weston.ini, for example using an
invalid output transform value.

Check in weston_output_disable() instead, but because it too may be
called for non-enabled output, only if it was actually enabled.

Fixes: 1a4f87dec5
	"libweston: introduce weston_paint_node"

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-09-07 16:42:34 +03:00
Leandro Ribeiro 0750ceae6c drm-formats: remove create() and destroy() from the API
Since commit "drm-formats: save result of intersection in the first
array", every block of code where weston_drm_format_array_create() and
destroy() are being called could use init() and fini() instead.

Remove these two functions from the API to make it leaner. This patch
also modifies the code that depends on these functions to use init() and
fini().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-09-06 12:52:37 +00:00
Leandro Ribeiro c51d4ad9c8 drm-formats: save result of intersection in the first array
In the current API, we have some set operations: join, intersect and
subtract. Both join and subtract receives two DRM format arrays and save
the result in the first one.

For the intersection we have a slightly different approach, what makes
the API weird. We don't save the result in the arguments, instead we
return a new array with the result.

Modify weston_drm_format_array_intersect() in order to make it similar
to the other two set operations.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-09-06 12:52:37 +00:00
Daniel Stone fa6ae44719 backend-headless: Fix pointer vs. int confusion with EGL
EGL's native display type is not particularly well defined; in
gl-renderer we get around this by always treating it as a void *, since
for all the platforms we care about it's a pointer - gbm_device,
wl_display, or Display *.

The surfaceless platform doesn't care what the native display is (since
it doesn't have one by definition), so just use NULL instead of what may
be either NULL or 0 depending on environmental factors.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-08-03 18:42:25 +01:00
Daniel Stone eeaaf6b9b0 gl-renderer: Fix sign confusion in format/modifier query
Signed and unsigned integers are not the same thing.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-08-03 13:13:51 +01:00
Daniel Stone aed8aafdbf drm/vaapi: Fix pointer-size confusion
The API expects uintptr_t (good!), but we're passing an unsigned long
here. Make the conversion explicit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-08-03 11:13:23 +00:00
Marius Vlad 2ab08d8698 libweston/data-device: Don't crash when doing dnd operations w/o a keyboard
pointer/touch drag-n-drop operations could happen if there's no keyboard
hooked up or when it is unplugged.

Fixes: #235

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-07-31 17:19:15 +00:00
Emmanuel Gil Peyrot eff793ab46 Fix indentation all through the project
Fixes a “regression” from 04918f3b0b, but
also other missed pieces.
2021-07-31 15:28:20 +00:00
Link Mauve 48cd15ed44 renderer-gl: Allocate buffer on the stack
This avoids an extra heap allocation for each view.
2021-07-31 17:08:59 +02:00
Marius Vlad eb34f827dd input: Handle correctly failure to compile XKB keymaps
And ultimately, fail to start when there are no input devices on the
system. Patchs adds consistency to touch/pointer initialization to
return -1 in case same thing happens.

Further more, when the device is not created we can't assume to retrieve
a valid one from a libinput_device so guard against it. This takes care of
hot-plugging situations when we couldn't create the (keyboard) device,
or when removing it.

Fixes: #117, #402, #485

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2021-07-31 13:44:47 +00:00
Derek Foreman 74bdb35c85 drm: Ignore timestamp for monitor shut-off
Some graphics drivers (currently at least VMware and AMD) will give a 0
timestamp for the atomic mode flip completion event when turning off
the display. This causes us to trip an assertion in
weston_output_frame_finish() because the clock jumps backwards, which
isn't a condition the presentation feedback code should be dealing with.

This is a good assertion and we'd like to keep it. And there's some
expectation that this is buggy behaviour in the graphics drivers that will
be fixed at some point.

Pragmatically speaking though, there's nothing productive we can do with a
correct timestamp for the display shutdown.  So let's just flag the
event sent for DPMS off as invalid so presentation feedback doesn't have
to worry about it, and the assert doesn't fire.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-07-31 13:39:27 +00:00
Vlad Zahorodnii c2b9747812 libweston/compositor: Drop weston_frame_callback
weston_frame_callback is needed primarily to store the doubly-linked list link,
but it can be also retrieved by using the wl_resource_get_link() function.

This removes an extra heap allocation per every wl_callback object.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2021-07-29 15:33:19 +03:00
Marius Vlad 6f6fd2686d pixel-formats: Add human readable format modifier
Conditionally build support when libdrm is at least 2.4.107 to make use
of it.  Plug it in when printing out the buffer information.

With this in, we add a hard dependecy for libweston to link against
libdrm.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-07-22 22:19:17 +00:00
Marius Vlad 63fc73d1cc gl-renderer: Assume num images the same as the no of planes
Potential failures when creating the EGL image could cause an incorrect
number of num images (num_planes > num_images). With this change
egl_image_unref() requires an additional check to avoid any potential NULL
derefs when cleaning up. We do it straight in egl_image_unref() instead
of adding guards all over the necessary parts.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-07-22 11:33:22 +03:00
Marius Vlad 2a6ea687ba gl-renderer: Avoid destroying an egl image if known import failed
As observed on some platforms, importing known DMA buffers can cause
failures, leading to an attempt of destroyng an EGL image not set. This patch
resets the num_images such that loop becomes inert when destroying the
DMA buffer, and avoids passing an egl image to it.

The initial import doesn't have this issue as it sets the num_images in
case it succeeds.  This also corrects the assumption that the num_images
were 0 at that point which, if the initial import succeded, was actually set
to 1.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-07-19 13:56:27 +03:00
Chen Qi 2f2e5da4c3 backend-wayland: fix incorrect header
The wayland.c actually include 'xdg-shell-client-protocol.h' instead of
the server one, so fix it. Otherwise, it's possible to get build failure
due to race condition.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Daniel Stone <daniels@collabora.com>
[daniels: Found in OpenEmbedded/Yocto source.]
2021-07-13 18:26:38 +01:00
Marius Vlad 7a44ee7f37 backend-drm: Clean-up minor leak when destroying the DRM-backend
Fixes a minor leak due to launcher-libseatd:

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f15664e5037 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xaa037)
    #1 0x7f156305c59f in zalloc ../include/libweston/zalloc.h:38
    #2 0x7f156305c99b in seat_open_device ../libweston/launcher-libseat.c:114
    #3 0x7f1563056341 in weston_launcher_open ../libweston/launcher-util.c:79
    #4 0x7f156302f1e2 in drm_device_is_kms ../libweston/backend-drm/drm.c:2616
    #5 0x7f156302f751 in find_primary_gpu ../libweston/backend-drm/drm.c:2715
    #6 0x7f15630309a5 in drm_backend_create ../libweston/backend-drm/drm.c:2970
    #7 0x7f15630317ab in weston_backend_init ../libweston/backend-drm/drm.c:3162
    #8 0x7f1566025b61 in weston_compositor_load_backend ../libweston/compositor.c:8201
    #9 0x7f156640cb9e in load_drm_backend ../compositor/main.c:2596
    #10 0x7f156641193c in load_backend ../compositor/main.c:3079
    #11 0x7f1566413cc3 in wet_main ../compositor/main.c:3356
    #12 0x562ba484b179 in main ../compositor/executable.c:33
    #13 0x7f156624fcc9 in __libc_start_main ../csu/libc-start.c:308

But also use the launcher interface to actually close the DRM fd, in
mirror to what weston_launcher_open() does.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-06-28 11:44:52 +00:00
Pekka Paalanen 7c13c4a476 color-lcms: use sRGB EOTF
Initialize LittleCMS and use it to generate the sRGB EOTF and inverse
curves. Use these curves to define the blending color space as optical
(linear) sRGB by assuming that both content and output color spaces are
sRGB.

As a consequence, this causes Weston to do "gamma correct blending", as
in, blend in light linear space which should avoid distorting colors in
alpha gradients, when color-lcms is active.

This makes use of the 3x1D LUT support added in gl-renderer earlier, and
shows how the color manager is responsible for re-using existing color
transformation objects.

Co-authored-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen b12d4fcb53 gl-renderer: color transform in blit_shadow_to_output()
Use the blending to output color space transformation when blitting from
the shadow to a framebuffer.

This allows the blending and output color spaces to differ as long as
shadow is used, in case a backend does not off-load the color
transformation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen e7b43ba3b4 gl-renderer: color transform output borders
Use the sRGB to output color space transformation when blitting the
borders (decorations) into an output window (nested compositor).

Nested output does not need to be sRGB anymore, as far as the
decorations are concerned.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen d7eca40787 gl-renderer: color transform censor fill and triangle fan
Use the sRGB to blending color space transformation for the censoring
color fill and triangle fan debug drawings.

This removes the assert that the output's blending space is (non-linear)
sRGB.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen 92f2367e58 gl-renderer: implement 3 x 1D LUT color pre-curve
This makes weston_color_transform object be able to express
three-channel one-dimensional look-up table transformations. They are
useful for applying EOTF and EOTF^-1 mapping, or, gamma curves. They
will also be useful in optimizing a following 3D LUT tap distribution
once support for 3D LUT is added.

The code added here translates from the lut_3x1d fill_in() interface to
a GL texture to be used with SHADER_COLOR_CURVE_LUT_3x1D for
weston_surfaces.

It demonstrates how renderer data is attached to weston_color_transform
and cached.

GL_OES_texture_float_linear is required to be able to use bilinear
texture filtering with 32-bit floating-point textures, used for the LUT.

As the size of the LUT depends on what implements it, lut_3x1d fill_in()
interface is a callback to the color management component to ask for an
arbitrary size. For GL-renderer this is not important as it can easily
realize any LUT size, but when DRM-backend wants to offload the EOTF^-1
mapping to KMS (GAMMA_LUT), the LUT size comes from KMS.

Nothing actually implements lut_3x1d fill_in() yet, that will come in a
later patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen 9a6a4e7032 gl-renderer: implement SHADER_COLOR_CURVE_LUT_3x1D
This adds shader support for using a three-channel one-dimensional
look-up table for de/encoding input colors. This operation will be useful
for applying EOTF or its inverse, in other words, gamma curves. It will
also be useful in optimizing a following 3D LUT tap distribution once
support for 3D LUT is added.

Even though called three-channel and one-dimensional, it is actually
implemented as a one-channel two-dimensional texture with four rows.
Each row corresponds to a source color channel except the fourth one is
unused. The reason for having the fourth row is to get texture
coordinates in 1/8 steps instead of 1/6 steps. 1/6 may would not be
exact in floating- or fixed-point arithmetic and might perhaps risk
unintended results from bilinear texture filtering when we want linear
filtering only in x but not in y texture coordinates. I may be paranoid.

The LUT is applied on source colors after they have been converted to
straight RGB. It cannot be applied with pre-multiplied alpha. A LUT can
be used for both applying EOTF to go from source color space to blending
color space, and EOTF^-1 to go from blending space to output
(electrical) space. However, this type of LUT cannot do color space
conversions.

For now, this feature is hardcoded to off everywhere, to be enabled in
following patches.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen 391f513c36 gl-renderer: fragment shader precision to high
Always when supported, make the fragment shader default floating point
precision high. The medium precision is roughly like half-floats, which
can be surprisingly bad. High precision does not reach even normal
32-bit float precision (by specification), but it's better. GL ES
implementations are allowed to exceed the minimum precision requirements
given in the specification.

This is an advance attempt to avoid nasty surprises from poor shader
precision.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen 4d5b2f3410 gl-renderer: add shader bit input_is_premult
Add a new shader requirements bit input_is_premult which says whether
the texture sampling results in premultiplied alpha or not. Currently
this can be deduced fully from the shader texture variant, but in the
future there might a protocol extension to explicitly control it. Hence
the need for a new bit.

yuva2rgba() is changed to produce straight alpha always. This makes
sample_input_texture() sometimes produce straight or premultiplied
alpha. The input_is_premult bit needs to match sample_input_texture()
behavior. Doing this should save three multiplications in the shader for
straight alpha formats.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Leandro Ribeiro 0157591b34 libweston: do not forget to destroy temporary drm_format_array
Leak found running drm-formats-test with ASan:

==58755==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fae744dbe3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7fae744dbe4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x7fae744dd2a2 in weston_drm_format_array_subtract ../libweston/drm-formats.c:410
    #4 0x55723c67bed5 in subtract_arrays ../tests/drm-formats-test.c:487
    #5 0x55723c67b6bb in wrapsubtract_arrays ../tests/drm-formats-test.c:467
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fae744dbe3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7fae744dbe4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x7fae744dd2a2 in weston_drm_format_array_subtract ../libweston/drm-formats.c:410
    #4 0x55723c67deca in subtract_arrays_modifier_invalid ../tests/drm-formats-test.c:613
    #5 0x55723c67da3d in wrapsubtract_arrays_modifier_invalid ../tests/drm-formats-test.c:593
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fae744dbe3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7fae744dbe4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x7fae744dd2a2 in weston_drm_format_array_subtract ../libweston/drm-formats.c:410
    #4 0x55723c67c9c0 in subtract_arrays_same_content ../tests/drm-formats-test.c:521
    #5 0x55723c67c55b in wrapsubtract_arrays_same_content ../tests/drm-formats-test.c:504
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fae744dbe3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7fae744dbe4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x7fae744dd2a2 in weston_drm_format_array_subtract ../libweston/drm-formats.c:410
    #4 0x55723c67d1b7 in subtract_arrays_exclusive_formats ../tests/drm-formats-test.c:552
    #5 0x55723c67cb23 in wrapsubtract_arrays_exclusive_formats ../tests/drm-formats-test.c:529
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fae744dbe3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7fae744dbe4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x7fae744dd2a2 in weston_drm_format_array_subtract ../libweston/drm-formats.c:410
    #4 0x55723c67d8d5 in subtract_arrays_exclusive_modifiers ../tests/drm-formats-test.c:584
    #5 0x55723c67d31d in wrapsubtract_arrays_exclusive_modifiers ../tests/drm-formats-test.c:561
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 320 byte(s) in 5 object(s) allocated from:
    #0 0x7fae74658279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fae74473bc3 in wl_array_add (/usr/lib/libwayland-client.so.0+0xabc3)
    #2 0x7fae74473c10 in wl_array_copy (/usr/lib/libwayland-client.so.0+0xac10)
    #3 0x7fae744dbfe0 in add_format_and_modifiers ../libweston/drm-formats.c:108
    #4 0x7fae744dd389 in weston_drm_format_array_subtract ../libweston/drm-formats.c:418
    #5 0x55723c67d1b7 in subtract_arrays_exclusive_formats ../tests/drm-formats-test.c:552
    #6 0x55723c67cb23 in wrapsubtract_arrays_exclusive_formats ../tests/drm-formats-test.c:529
    #7 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #8 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #9 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #10 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #11 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #12 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #13 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #14 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #15 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x7fae74473b76 in wl_array_add (/usr/lib/libwayland-client.so.0+0xab76)
    #2 0x7fae744dc19f in weston_drm_format_array_add_format ../libweston/drm-formats.c:166
    #3 0x7fae744dbfb7 in add_format_and_modifiers ../libweston/drm-formats.c:104
    #4 0x7fae744dd389 in weston_drm_format_array_subtract ../libweston/drm-formats.c:418
    #5 0x55723c67d1b7 in subtract_arrays_exclusive_formats ../tests/drm-formats-test.c:552
    #6 0x55723c67cb23 in wrapsubtract_arrays_exclusive_formats ../tests/drm-formats-test.c:529
    #7 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #8 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #9 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #10 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #11 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #12 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #13 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #14 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #15 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x7fae74473b76 in wl_array_add (/usr/lib/libwayland-client.so.0+0xab76)
    #2 0x7fae744dc19f in weston_drm_format_array_add_format ../libweston/drm-formats.c:166
    #3 0x7fae744dd3de in weston_drm_format_array_subtract ../libweston/drm-formats.c:426
    #4 0x55723c67bed5 in subtract_arrays ../tests/drm-formats-test.c:487
    #5 0x55723c67b6bb in wrapsubtract_arrays ../tests/drm-formats-test.c:467
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 128 byte(s) in 2 object(s) allocated from:
    #0 0x7fae74658279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fae74473bc3 in wl_array_add (/usr/lib/libwayland-client.so.0+0xabc3)
    #2 0x7fae74473c10 in wl_array_copy (/usr/lib/libwayland-client.so.0+0xac10)
    #3 0x7fae744dbfe0 in add_format_and_modifiers ../libweston/drm-formats.c:108
    #4 0x7fae744dd389 in weston_drm_format_array_subtract ../libweston/drm-formats.c:418
    #5 0x55723c67bed5 in subtract_arrays ../tests/drm-formats-test.c:487
    #6 0x55723c67b6bb in wrapsubtract_arrays ../tests/drm-formats-test.c:467
    #7 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #8 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #9 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #10 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #11 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #12 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #13 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #14 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #15 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 96 byte(s) in 3 object(s) allocated from:
    #0 0x7fae74658652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x7fae74473b76 in wl_array_add (/usr/lib/libwayland-client.so.0+0xab76)
    #2 0x7fae744dd142 in modifiers_subtract ../libweston/drm-formats.c:384
    #3 0x7fae744dd408 in weston_drm_format_array_subtract ../libweston/drm-formats.c:431
    #4 0x55723c67bed5 in subtract_arrays ../tests/drm-formats-test.c:487
    #5 0x55723c67b6bb in wrapsubtract_arrays ../tests/drm-formats-test.c:467
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x7fae74473b76 in wl_array_add (/usr/lib/libwayland-client.so.0+0xab76)
    #2 0x7fae744dd142 in modifiers_subtract ../libweston/drm-formats.c:384
    #3 0x7fae744dd408 in weston_drm_format_array_subtract ../libweston/drm-formats.c:431
    #4 0x55723c67d8d5 in subtract_arrays_exclusive_modifiers ../tests/drm-formats-test.c:584
    #5 0x55723c67d31d in wrapsubtract_arrays_exclusive_modifiers ../tests/drm-formats-test.c:561
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fae74473bc3 in wl_array_add (/usr/lib/libwayland-client.so.0+0xabc3)
    #2 0x7fae744dc19f in weston_drm_format_array_add_format ../libweston/drm-formats.c:166
    #3 0x7fae744dd3de in weston_drm_format_array_subtract ../libweston/drm-formats.c:426
    #4 0x55723c67d8d5 in subtract_arrays_exclusive_modifiers ../tests/drm-formats-test.c:584
    #5 0x55723c67d31d in wrapsubtract_arrays_exclusive_modifiers ../tests/drm-formats-test.c:561
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fae74473bc3 in wl_array_add (/usr/lib/libwayland-client.so.0+0xabc3)
    #2 0x7fae744dc19f in weston_drm_format_array_add_format ../libweston/drm-formats.c:166
    #3 0x7fae744dd3de in weston_drm_format_array_subtract ../libweston/drm-formats.c:426
    #4 0x55723c67deca in subtract_arrays_modifier_invalid ../tests/drm-formats-test.c:613
    #5 0x55723c67da3d in wrapsubtract_arrays_modifier_invalid ../tests/drm-formats-test.c:593
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fae74658279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fae74473bc3 in wl_array_add (/usr/lib/libwayland-client.so.0+0xabc3)
    #2 0x7fae744dc19f in weston_drm_format_array_add_format ../libweston/drm-formats.c:166
    #3 0x7fae744dd3de in weston_drm_format_array_subtract ../libweston/drm-formats.c:426
    #4 0x55723c67c9c0 in subtract_arrays_same_content ../tests/drm-formats-test.c:521
    #5 0x55723c67c55b in wrapsubtract_arrays_same_content ../tests/drm-formats-test.c:504
    #6 0x55723c67e9a9 in run_test ../tests/weston-test-runner.c:162
    #7 0x55723c67f0af in run_case ../tests/weston-test-runner.c:277
    #8 0x55723c67ee48 in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x55723c67f358 in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x55723c680381 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x55723c6803b1 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x55723c680844 in main ../tests/weston-test-runner.c:661
    #13 0x7fae742c4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x55723c67442d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-06-16 13:36:43 +00:00
Alexandros Frantzis 10937feef8 backend-drm: Clear drm_output cursor_view when view is destroyed
The DRM backend uses changes in the cursor view memory address and
surface damage to detect when it needs to re-upload to a cursor plane
framebuffer.

However, when a cursor view is destroyed and then recreated, e.g., when
the pointer cursor surface is updated, the newly created view may have
the same memory address as the just destroyed one. If no new cursor
buffer is provided (because it was attached, committed and used
previously) when this address reuse occurs, then there also isn't any
updated surface damage and the backend doesn't update the cursor plane
framebuffer at all.

To fix this issue utilize the destroy signal to track when the cursor
view is destroyed, and clear the cached cursor_view value in drm_output.
After clearing the cached value, the next cursor view is always
considered new and thus uploaded to the plane properly.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-06-14 13:31:41 +00:00
Pekka Paalanen f0c6104444 libweston: remove weston_output_set_renderer_shadow_buffer()
This is no longer used.

This was originally added in b5265af620.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen d2cfbff186 gl-renderer: use shadow framebuffer automatically
This creates the FP16 shadow framebuffer automatically if the color
transformation from blending space to output space is not identity and
the backend does not claim to implement it on the renderer's behalf.

That makes the weston_output_set_renderer_shadow_buffer() API and
use-renderer-shadow weston.ini option obsolete.

To still cater for the one test that needs to enable the shadow
framebuffer in spite of not needing it for color correct blending, the
quirk it uses now also forces the shadow.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen 37fe6fde49 gl-renderer: define fragment shader compile_const
Compile time constants play an important role in keeping the shader
programs fast. Introduce an informal annotation to mark compile time
constants to make the shader code easier to reason with.

This will make much more sense once functions with compile time constant
parameters are added.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen 734c2278f9 gl-renderer: require GL ES 3.0 for color management
Trying to support GL ES 2.0 + extensions along with GL ES 3.0 for better
control is becoming too complicated fast. In this patch you see the
GL_RGBA vs. GL_RBA16F and GL_HALF_FLOAT vs. GL_HALF_FLOAT_OES paths.
More such cases will come, e.g. GL_RED_EXT vs. GL_R32F.

Make things simpler and require GL ES 3.0 +
GL_EXT_color_buffer_half_float for all color management related
functionality. If one doesn't have GL ES 3.0, all you lose is color
management.

Also, all extensions needed by color transformation operations are
gathered under one boolean flag instead of having a flag per extension,
again for simplicity.

This makes the GL ES extension handling much easier.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen 401e190913 Revert "gl-renderer: Make dummy surface current after all outputs are gone"
This reverts commit 36d699a164.

A different way to fix this same issue is the previous commit
"gl-renderer: do not unbind the context on output destroy"
which is needed for other reasons.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen 6d0aa8f0e9 gl-renderer: do not unbind the context on output destroy
If we make EGL_NO_CONTEXT current, all following GL calls are
no-ops. This will be a problem when gl-renderer introduces
gl_renderer_color_transform containing GL textures and needs to destroy
them when weston_color_transform is destroyed. Mesa would print the the
warning that glDeleteTextures is no-op.

To fix this, keep our GL context current when destroying a GL output.

In case EGL_KHR_surfaceless_context is not available, we must use
dummy_surface.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen 5e79dd4892 libweston: begin color-lcms plugin
This creates the color-lcms plugin that in the future will be using
Little CMS as the color matching module, processing ICC profiles, and
producing HDR tone mappings.

Right now, this new plugin is functionally equivalent to the no-op color
manager, except it already links to lcms2 and checks that the renderer
supports color operations.

Color-lcms is a libweston plugin that is loaded with explicit
weston_compositor API. This does not currently allow loading alternative
color manager plugins. External color manager plugins might be
considered in the future when the libweston APIs around color management
stabilize.

This libweston plugin uses the same build option as the old cms-static
Weston plugins, as they both need lcms2. The minimum version for lcms2
was chosen by what Debian Buster provides today and for no other reason.

This plugin intends to support the Wayland CM&HDR protocol extension and
hence sets supports_client_protocol to true. This will expose the
protocol extension to clients when it gets implemented.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00
Pekka Paalanen 8fb23ed110 color: add from sRGB to blending color transformation
This is needed when the compositor produces any content internally:
- the lines in triangle fan debug
- the censoring color fill (unmet HDCP requirements)

Solid color surfaces do not need this special-casing because
weston_surface is supposed to carry color space information, which will
get used in gl_shader_config_init_for_view().

This makes sure the internally produced graphics fit in, e.g on a
monitor in HDR mode.

For now, just ensure there is an identity transformation. Actual
implementations in GL-renderer will follow later.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00
Pekka Paalanen cda3951a9a color: add from sRGB to output color transformation
This is needed when drawing anything internal directly to an output,
like the borders/decorations in a nested compositor setup. This makes
the assumption that the internal stuff starts in sRGB, which should be
safe. As borders are never blended with other content, this should also
be sufficient.

This patch is a reminder that that path exists, rather than a real
implementation. To be implemented when someone needs it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00
Pekka Paalanen 1d2eee208c color: add output color transform API
This is the blending space to monitor space color transform. It needs to
be implemented in the renderers, unless a backend sets
from_blend_to_output_by_backend = true, in which case the backend does
it and the renderer does not.

The intention is that from_blend_to_output_by_backend can be toggled
frame by frame to allow backends to react to dynamic change of output
color profile.

For now, renderers just assert that they don't need to do anything for
output color transform.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00
Pekka Paalanen 90a5ffa097 libweston: introduce CMS component architecture
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/467#note_814985

This starts building the framework required for implementing color
management.

The main new interface is struct weston_color_manager. This commit also
adds a no-op color manager implementation, which is used if no other
color manager is loaded. This no-op color manager simply provides
identity color transforms for everything, so that Weston keeps running
exactly like before.

weston_color_manager interface is incomplete and will be extended later.

Colorspace objects are not introduced in this commit. However, when
client content colorspace and output colorspace definitions are
combined, they will produce color transformations from client content to
output blending space and from output blending space to output space.

This commit introduces a placeholder struct for color transforms,
weston_color_transform. Objects of this type are expected to be heavy to
create and store, which is why they are designed to be shared as much as
possible, ideally making their instances unique. As color transform
description is intended to be generic in libweston core, renderers and
backends are expected to derive their own state for each transform
object as necessary. Creating and storing the derived state maybe be
expensive as well, more the reason to re-use these objects as much as
possible. E.g. GL-renderer might upload a 3D LUT into a texture and keep
the texture around. DRM-backend might create a KMS blob for a LUT and
keep that around.

As a color transform depends on both the surface and the output, a
transform object may need to be created for each unique pair of them.
Therefore color transforms are referenced from weston_paint_node. As
paint nodes exist for not just surface+output but surface+view+output
triplets, the code ensures that all paint nodes (having different view)
for the same surface+output have the same color transform state.

As a special case, if weston_color_transform is NULL, it means identity
transform. This short-circuits some checks and memory allocations, but
it does mean we use a separate member on weston_paint_node to know if
the color transform has been initialized or not.

Color transformations are pre-created at the weston_output
paint_node_z_order_list creation step. Currently the z order lists
contain all views globally, which means we populate color transforms we
may never need, e.g. a view is never shown on a particular output.
This problem should get fixed naturally when z order lists are
constructed "pruned" in the future: to contain only those paint nodes
that actually contribute to the output's image.

As nothing actually supports color transforms yet, both renderers and
the DRM-backend assert that they only get identity transforms. This
check has the side-effect that all surface-output pairs actually get a
weston_surface_color_transform_ref even though it points to NULL
weston_color_transform.

This design is inspired by Sebastian Wick's Weston color management
work.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00