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>
Wayland signals (wl_signal) do not reliably handle changes to the
notification list during signal emission. Such scenarios occasionally
come up and can be difficult to investigate and debug.
This commit introduces the weston_signal_emit_mutable() function which can be
used in place of wl_signal_emit() and safely implements the following
behavior regarding notification list changes:
1. Listeners deleted during a signal emission and which have not already been
notified at the time of deletion are not notified by that emission.
2. Listeners added during signal emission are ignored by that emission.
The implementation of weston_signal_emit_mutable() is copied from the
wlr_signal_emit_safe() function of the wlroots project.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
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>
The "sans" and "mono" aliases for "sans-serif" and "monospace" are
deprecated[1]. Let's standardize on the non-deprecated versions, which were
already in use in some places.
[1]: be453bd159/fonts.conf.in (L33-67)
Signed-off-by: Alyssa Ross <hi@alyssa.is>
asprintf() has the problem that it leaves *strp undefined when it
fails. Here is a simple wrapper that ensures NULL if asprintf() fails,
which is much more convenient to use.
This will be useful in future patches, where one needs to return error
messages from maybe failing functions, and more.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fixes ASan reported leaks:
Direct leak of 256 byte(s) in 1 object(s) allocated from:
#0 0x7f8266f2d330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8266c8589a (/lib/x86_64-linux-gnu/libpixman-1.so.0+0x5089a)
#2 0x7f8266c4ea77 (/lib/x86_64-linux-gnu/libpixman-1.so.0+0x19a77)
#3 0x55fa7818f8e8 in load_png ../../git/weston/shared/image-loader.c:297
#4 0x55fa7819039e in load_image ../../git/weston/shared/image-loader.c:423
#5 0x55fa78187b3e in load_cairo_surface ../../git/weston/shared/cairo-util.c:354
#6 0x55fa7815ff8a in background_draw ../../git/weston/clients/desktop-shell.c:779
#7 0x55fa7817b2c2 in widget_redraw ../../git/weston/clients/window.c:4520
#8 0x55fa7817b831 in surface_redraw ../../git/weston/clients/window.c:4578
#9 0x55fa7817b9a7 in idle_redraw ../../git/weston/clients/window.c:4607
#10 0x55fa78184ea4 in display_run ../../git/weston/clients/window.c:6527
#11 0x55fa781646fb in main ../../git/weston/clients/desktop-shell.c:1556
#12 0x7f826659709a in __libc_start_main ../csu/libc-start.c:308
#13 0x55fa7815c0a9 in _start (/home/pq/build/weston-meson/clients/weston-desktop-shell+0x120a9)
Indirect leak of 8024 byte(s) in 1 object(s) allocated from:
#0 0x7f8266f2d330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x55fa7818f5e7 in load_png ../../git/weston/shared/image-loader.c:275
#2 0x55fa7819039e in load_image ../../git/weston/shared/image-loader.c:423
#3 0x55fa78187b3e in load_cairo_surface ../../git/weston/shared/cairo-util.c:354
#4 0x55fa7815ff8a in background_draw ../../git/weston/clients/desktop-shell.c:779
#5 0x55fa7817b2c2 in widget_redraw ../../git/weston/clients/window.c:4520
#6 0x55fa7817b831 in surface_redraw ../../git/weston/clients/window.c:4578
#7 0x55fa7817b9a7 in idle_redraw ../../git/weston/clients/window.c:4607
#8 0x55fa78184ea4 in display_run ../../git/weston/clients/window.c:6527
#9 0x55fa781646fb in main ../../git/weston/clients/desktop-shell.c:1556
#10 0x7f826659709a in __libc_start_main ../csu/libc-start.c:308
#11 0x55fa7815c0a9 in _start (/home/pq/build/weston-meson/clients/weston-desktop-shell+0x120a9)
from the command
ASAN_OPTIONS=fast_unwind_on_malloc=0,malloc_context_size=50 \
LSAN_OPTIONS=suppressions=/home/pq/git/weston/.gitlab-ci/leak-sanitizer.supp \
./tests/test-viewporter test_viewporter_bad_source_rect
by recording the pixman image as user data so it can be freed when the
surface is destroyed.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
In commit "backend-drm: simplify compile time array copy", the macro
ARRAY_COPY was introduced.
The macro STRING was accidentally introduced in the same commit, and as
it is completely unnecessary, remove it.
Also, memcpy was copying from src to dst, and it should do the opposite.
So fix it.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In drm_fb_get_from_dmabuf() we have some compile time array copies, and
multiple static_assert() calls are needed (for safety). This makes the
code unpleasant to read.
Add ARRAY_COPY macro, to simplify the code.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This header is for sharing fallback definitions for drm_fourcc.h. A new
test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format,
and more new formats will be expected with HDR supports.
Share these fallback definitions in one place instead of copying them
all over.
All users of drm_fourcc.h are converted to include weston-drm-fourcc.h
instead for consistency: have the same definitions available everywhere.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
While the code looks fine, clang 7 memory sanitizer complains about
things like:
==26052==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f4f4d003327 in weston_config_get_section /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:141:2
#1 0x7f4f4cfce11a in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3266:12
==26683==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f09ebd638e2 in config_section_get_entry /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:125:2
#1 0x7f09ebd661c4 in weston_config_section_get_bool /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:310:10
#2 0x7f09ebd2e1e5 in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3269:3
In all cases, the errors point to wl_list_for_each().
Making these allocations use zalloc() avoids these errors. Since using
zalloc() is a good habit in any case, I didn't dig deeper.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fix the following build warning by moving the 'seals' declaration inside the
HAVE_MEMFD_CREATE guard:
../shared/os-compatibility.c: In function ‘os_ro_anonymous_file_get_fd’:
../shared/os-compatibility.c:341:6: warning: unused variable ‘seals’ [-Wunused-variable]
int seals, fd;
^
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
The initial version of os_ro_anonymous_file missed two guards around the
seal logic which leads to a compilation error on older systems.
Also make the check for a read-only file symmetric in
os_ro_anonymous_file_get_fd and os_ro_anonymous_file_put_fd.
Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
Fixes:
../shared/os-compatibility.c:273:25: error: ‘PROT_READ’ undeclared (first use in this function); did you mean ‘LOCK_READ’?
map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, file->fd, 0);
^~~~~~~~~
LOCK_READ
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
When option-parser is confronted with a boolean option, have it write a
bool rather than treating the value as a pointer to an int32.
(lib)weston already heavily uses bool types internally, so this has the
nice side effect of eliminating quite a few local variables which only
existed as integer shadows of internal boolean variables.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Wayland innovated a lot of cool things, but non-binary boolean values is
the great advances of our time.
Make config_parser_get_bool() work on boolean values, and switch all its
users.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Make sure we export the get_full_path() accessor (declared in the
header, used by Weston itself) and the parser's destroy function.
Signed-off-by: Daniel Stone <daniels@collabora.com>
The ro_anonymous_file is an abstraction around anonymous read-only files.
os_ro_anonymous_file_create creates such a file with the contents passed
in data. Subsequent calls to os_ro_anonymous_file_get_fd return a fd
that's ready to be send over the socket.
When mapmode is RO_ANONYMOUS_FILE_MAPMODE_PRIVATE the fd is only
guaranteed to be mmap-able readonly with MAP_PRIVATE but does not
require duplicating the file for each resource when memfd_create is
available. RO_ANONYMOUS_FILE_MAPMODE_SHARED may be used when the client
must be able to map the file with MAP_SHARED but it also means that the
file has to be duplicated even when memfd_create is available.
See also:
weston commit 76829fc4ea
wayland commit 905c0a341ddf0a885811d19e2b79c65a3f1d210c
Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.
It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.
This patch is best viewed with the -w option of git log -p.
It is an almost exact copy of Wayland commit
6908c8c85a2e33e5654f64a55cd4f847bf385cae, see
https://gitlab.freedesktop.org/wayland/wayland/merge_requests/4
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
../shared/image-loader.c:184:14: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
Store each channel in a uint32_t instead of a byte so we compute the shift over
an unsigned type.
This allows passing EGL_PLATFORM_SURFACELESS_MESA to
gl_renderer_display_create(). It is not useful on its own, because the
surfaceless platform has no window surfaces.
This feature will be used by the headless backend.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Define common_inc which includes both public_inc and the project root directory.
The project root directory will allow access to config.h and all the shared/
headers.
Replacing all custom '.', '..', '../..', '../shared' etc. include paths with
common_inc reduces clutter in the target definitions and enforces the common
#include directive style, as e.g. including shared/ headers without the
subdirectory name no longer works.
Unfortunately this does not prevent one from using private libweston headers
with the usual include pattern for public headers.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
matrix.c needs to be built differently for a test program vs. everything else,
so it cannot be in a helper lib. Instead, make a dependency object for it for
easy use which always gets all the paths correct automatically.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fixes the following warn/error when using combination of flags like
building with debug, when disabling optimization and/or when enabling ASAN:
../shared/option-parser.c:61:1: error: control reaches end of non-void function [-Werror=return-type]
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When building without GL renderer the compiler prints the following
warning:
../clients/subsurfaces.c: In function ‘egl_state_create’:
../clients/subsurfaces.c:225:35: warning: passing argument 1 of
‘weston_platform_get_egl_display’ makes pointer from integer without a
cast [-Wint-conversion]
225 | weston_platform_get_egl_display(EGL_PLATFORM_WAYLAND_KHR,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| |
| int
...
Define the fallback implementation of weston_platform_get_egl_display
to take an integer which is the underlaying datatype of EGLenum.
Signed-off-by: Stefan Agner <stefan@agner.ch>
It is a public installed header used by libweston.h.
See "Rename compositor.h to libweston/libweston.h" for rationale.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
It is a public installed header used by libweston.h.
See "Rename compositor.h to libweston/libweston.h" for rationale.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
matrix.h is a public installed header and even used by libweston.h.
See "Rename compositor.h to libweston/libweston.h" for rationale.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
If buttons list isn't empty and title is NULL, SEGV is occured in
pango_layout_set_text(). This patch fixes this problem.
Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
The in-tree clients can access the functions via libshared, but they are
currently not available for external clients, such as custom shell helper
applications similar to weston-desktop-shell or
weston-ivi-shell-user-interface.
The functions to read the content of the config are already exported.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Make it official that libweston will export the weston_config API, as requested
in https://gitlab.freedesktop.org/wayland/weston/merge_requests/29 .
There is no other way third party helper clients could access the API.
The autotools build has been accidentally exporting it all the time, but the
Meson build needed fixing.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Implement the set_acquire_fence request of the
zwp_surface_synchronization_v1 interface.
The implementation uses the acquire fence in two ways:
1. If the associated buffer is used as GL render source, an
EGLSyncKHR is created from the fence and used to synchronize
access.
2. If the associated buffer is used as a plane framebuffer,
the acquire fence is treated as an in-fence for the atomic
commit operation. If in-fences are not supported and the buffer
has an acquire fence, we don't consider it for plane placement.
If the used compositor/renderer doesn't support explicit
synchronization, we don't advertise the protocol at all. Currently only
the DRM and X11 backends when using the GL renderer advertise the
protocol for production use.
Issues for discussion
---------------------
a. Currently, a server-side wait of EGLSyncKHR is performed before
using the EGLImage/texture during rendering. Unfortunately, it's not clear
from the specs whether this is generally safe to do, or we need to
sync before glEGLImageTargetTexture2DOES. The exception is
TEXTURE_EXTERNAL_OES where the spec mentions it's enough to sync
and then glBindTexture for any changes to take effect.
Changes in v5:
- Meson support.
- Make explicit sync server error reporting more generic, supporting
all explicit sync related interfaces not just
wp_linux_surface_synchronization.
- Fix typo in warning for missing EGL_KHR_wait_sync extension.
- Support minor version 2 of the explicit sync protocol (i.e., support
fences for opaque EGL buffers).
Changes in v4:
- Introduce and use fd_clear and and fd_move helpers.
- Don't check for a valid buffer when updating surface acquire fence fd
from state.
- Assert that pending state acquire fence fd is always clear
after a commit.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to just the
renderer.
- Check for EGL_KHR_wait_sync before using eglWaitSyncKHR.
- Dup the acquire fence before passing to EGL.
Changes in v3:
- Keep acquire_fence_fd in surface instead of buffer.
- Clarify that WESTON_CAP_EXPLICIT_SYNC applies to both backend and
renderer.
- Move comment about non-ownership of in_fence_fd to struct
drm_plane_state definition.
- Assert that we don't try to use planes with in-fences when using the
legacy KMS API.
- Remove unnecessary info from wayland error messages.
- Handle acquire fence for subsurface commits.
- Guard against self-update in fd_update.
- Disconnect the client if acquire fence EGLSyncKHR creation or wait
fails.
- Use updated protocol interface names.
- User correct format specifier for resource ids.
- Advertise protocol for X11 backend with GL renderer.
Changes in v2:
- Remove sync file wait fallbacks.
- Raise UNSUPPORTED_BUFFER error at commit if we have an acquire
fence, but the committed buffer is not a valid linux_dmabuf.
- Don't put buffers with in-fences on planes that don't support
in-fences.
- Don't advertise explicit sync protocol if backend does not
support explicit sync.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Remove IN_WESTON in favour of the already defined UNIT_TEST which is
used to modify a compilation unit to expose more functions for unit
tests to prod at.
Originally IN_WESTON meant that compilation unit was being compiled for
use in the Weston compositor, but it probably never really did anything
more than change what WL_EXPORT means in matrix.c.
This patch not only simplifies the logic, but it fixes the Meson build
of test-matrix: IN_WESTON was defined there even when matrix.c was being
built outside of Weston, which caused it to depend on libwayland
headers, which were not included in the Meson build of test-matrix.
Test-matrix has no reason to depend in libwayland in any way, so this
patch fixes that.
Reported-by: Greg V <greg@unrelenting.technology>
Signed-off-by: Pekka Paalanen <pq@iki.fi>
This patchs fixes warnings generated by older toolchains:
shared/image-loader.c: In function 'load_png':
shared/image-loader.c:211:12: warning: variable 'data' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered]
png_byte *data = NULL;
See https://linux.die.net/man/3/longjmp why is this needed.
Signed-off-by: Marius Vlad <marius.vlad0@gmail.com>
Meson is a build system, currently implemented in Python, with multiple
output backends, including Ninja and Make. The build file syntax is
clean and easy to read unlike autotools. In practise, configuring and
building with Meson and Ninja has been observed to be much faster than
with autotools. Also cross-building support is excellent.
More information at http://mesonbuild.com
Since moving to Meson requires some changes from users in any case, we
took this opportunity to revamp build options. Most of the build options
still exist, some have changed names or more, and a few have been
dropped. The option to choose the Cairo flavour is not implemented since
for the longest time the Cairo image backend has been the only
recommended one.
This Meson build should be fully functional and it installs everything
an all-enabled autotools build does. Installed pkg-config files have
some minor differences that should be insignificant. Building of some
developer documentation that was never installed with autotools is
missing.
It is expected that the autotools build system will be removed soon
after the next Weston release.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Pekka Paalanen <pq@iki.fi>
It's a bit surprising that Weston looks different when launched from the root
of the git repo vs from elsewhere.
But it's also technically a security vulnerability: if I launch it from
a directory like /tmp, it might pick up a weston.ini created by another user,
which could then load modules with arbitrary code. Basically, it's the same
problem as including "." in $PATH.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Collect the fallback definitions of static_assert() from desktop-shell
and the test shell, and move them to helpers.h. This allows code
throughout the tree to use static_assert() for build-time assertions,
where it is supported by the compiler.
As GCC goes out of its way to only add static_assert() when C11 has been
explicitly requested - which we don't do - make sure to use the more
widely available _Static_assert() if that is provided.
This will be used in future patches to ensure two array lengths don't go
out of sync.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Now that WESTON_MODULE_MAP supersedes WESTON_BUILD_DIR for libexec
binaries, we don't need to check in WESTON_BUILD_DIR anymore.
There was only one user of weston_config_get_libexec_dir(), so remove
the whole function. There is no reason to export it.
Due to libshared.la being pulled into libweston, this probably was
libweston ABI unintended. Regardless, libweston major has already been
bumped.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Add a helper function to check if two struct timespec values are equal.
This helper function will be used in upcoming commits that implement the
input_timestamps_unstable_v1 protocol.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The cairo surface used for the icon must be completely given to the
frame as soon as said frame has been created. To prevent both the
window and the frame from sharing ownership of the icon, we set
window->icon_surface back to NULL right after creating or changing the
frame, only keeping it there when no frame has been created yet.
Fixes https://lists.freedesktop.org/archives/wayland-devel/2018-January/036655.html
Reported-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Instead of assuming the file prefix contains the path and filename
prefix, give these two items separately.
A NULL or empty string path may still be given to refer to the current
directory.
Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Reviewed-by: Daniel Stone <daniels@collabora.com>