Commit Graph

6848 Commits

Author SHA1 Message Date
Pekka Paalanen 20b092d8b4 backend-x11: need libdrm headers in build
9ddb3bc315 started using drm_fourcc.h but forgot
to add libdrm headers to the dependencies.

This fixes the build for build-native-meson-no-gl-renderer when a future patch
reduces the dependencies pulled in by the libweston dependency object.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen d2332b8bba build: link libdl explicitly to DRM backend
In the future libweston will stop providing it for its users, since it's not
part of libweston API.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen 5e734ba308 build: link libm explicitly
In the future libweston will stop providing it for its users, since it's not
part of libweston API.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen 71ff95a544 build: separate deps for int and ext libweston users
We have two kinds of libweston users: internal and external. Weston, the
frontend, counts as an external user, and should not have access to libweston
private headers. The shell plugins are external users as well, because we
intend people to be able to write them. Renderers, backends, and some plugins
are internal users who will need access to private headers.

Create two different Meson dependency objects, one for each kind.

This makes it less likely to accidentally use a private header.

Screen-share is a Weston plugin and therefore counts as an external user, but
it needs the backend API to deliver input. Until we are comfortable exposing
public API for that purpose, let it use internal headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen 17389d63fd gitlab-ci: fix pages
This hopefully fixes a failure introduced in
5a0706b238987bf3dcf7dde54556850ee88ccdba:

cp: cannot stat '/builds/wayland/weston/prefix-weston-build-native-meson/share/doc/weston/*': No such file or directory

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 12:48:43 +03:00
Stefan Agner 5a0706b238 gitlab-ci: add build configuration without gl-renderer
Building without gl-renderer seems to fail rather often. Introduce a
specific build job which tests this configuration.

Make use of the Folded Block Scalar in YAML to concatenate the build
option string with spaces. This will make diffing build option
changes very readable.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-24 09:09:33 +00:00
Stefan Agner 88c8f69a2f clients: avoid build error without gl-renderer
Make sure gl-renderer is enabled when building the EGL and EGL
dmabuf clients. This avoids missing declaration warnings and
linking errors such as:
  ../clients/simple-dmabuf-egl.c:1142: undefined reference to `weston_check_egl_extension
  ...
  ../clients/simple-egl.c:206: undefined reference to `weston_check_egl_extension'

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-24 09:09:33 +00:00
Stefan Agner 70e6356415 backend-headless: fix build issue without gl-renderer
If the gl-renderer is disabled build fails with:
  ../libweston/backend-headless/headless.c:394:9: error:
  ‘EGL_PLATFORM_SURFACELESS_MESA’ undeclared (first use in this function)

Fix this by including shared/weston-egl-ext.h.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-24 09:09:33 +00:00
Emmanuel Gil Peyrot deae98ef45 shared: Use memfd_create() when available
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>
2019-10-24 07:32:17 +00:00
Marius Vlad 23d01c67a3 doc/sphinx: Add some documentation about timeline points
Use doxygen ingroup command as to show the symbols in the sphinx
documentation.

Include some basic comments and document the exported functions from
timeline.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad a66d2c87cc libweston: Remove timeline-object and clean-up
Removes timeline-object header and what is left of the older
timeline part.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad 5de9297df2 libweston: Notify timeline of object modification
We notify the timeline of the fact that the object suffered
modifications through the 'set_label' function. Remove the old
refresh variable.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad 3203ff68ad libweston: Convert timeline points to use the timeline scope
With the timeline scope being created it is time to convert TL_POINT()
to use the timeline scope through the compositor instance.

This patch removes the global variable allowing to run the new timeline
code.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad da104ebe5b libweston: Create the 'timeline' scope
With everything now in place, it is time to create the timeline scope.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad fb10ed768b libweston: Introduce timeline subscription and timeline subscription object
An object based on 'weston_timeline_subscription' will be created for
each subscription created. It contains the next object ID and list of
'weston_timeline_subscription_object'.

It will automatically be cleaned by the logging framework when the
subscription gets destroyed, or use the object destroy signal to trigger
the destruction of the timeline subscription (@pq), when the object
itself is being destroyed.

This class will hanged-off the subscription, such that we can
retrieve it when going over all the subscriptions.

An object based on 'weston_timeline_subscription_object' will help
maintain the state of the objects seen and will be created when a new
object will be emitted for a particular 'weston_timeline_subscription'.

Adds wrappers for ensuring the timeline subscription object is created
or has to be searched in order to be found, as to avoid duplicated code.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 21:41:09 +03:00
Marius Vlad 2a1b7865dd libweston: Clean-up timeline to make room for a new approach
With it this removes the parts responsible for creating the file,
timeline_log class, removes the debug key binding when creating the
compositor instace, keeping only what can be re-used.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad d0d89d0d5f weston-log: Add a subscription iterator
Helper to retrieve next available subscription as to avoid exposing the
subscription, which is an opaque (internal) class of the logging
framework.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad 410d0bc0b2 weston-log-internal: Allow to hang-off data over the subscription
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad 9bb1c3a3c2 weston-log: Add 'destroy_subscription' callback for the subscription
As 'new_subscription' can create additional objects, 'destroy_subscription'
will be needed when cleaning up.

As this requires a libweston_major bump (noticed by @pq), bump it up to
8.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad 0c7beb0b67 weston-log: 'new_subscriber' is actually 'new_subscription'
The callback is executed when the subscription is created, so it doesn't
really have a proper name.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:54 +03:00
Marius Vlad 413cda58d6 libweston: Fix rename of weston_compositor_destroy() reference
Commit 284d5345ad introduced a new tear_down function for the
compositor, it seems we missed a comment reference for it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:54 +03:00
Marius Vlad f51dc3444c weston-log: s/scope/sub, leftover from the logging framework
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:54 +03:00
Adam Jackson 3cfd297f2c tests: Fix undefined left shift in internal-screenshot-test
../tests/internal-screenshot-test.c:60:18: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
2019-10-16 16:07:47 -04:00
Adam Jackson ad0fe6b6f9 image-loader: Fix undefined left shift in premultiply_data
../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.
2019-10-16 16:06:06 -04:00
Adam Jackson 3c3f3b1cc3 libweston: Fix integer underflow in weston_layer_mask_is_infinite
ubsan doesn't like what we were doing here:

../libweston/compositor.c:3021:21: runtime error: signed integer overflow: -2147483648 + -1 cannot be represented in type 'int'

Rather than try to be clever in invoking weston_layer_set_mask, just build the
maximal mask explicitly.
2019-10-16 16:02:59 -04:00
Loïc Yhuel 267b16e8f4 libweston: fix possible crash after a view is removed the layer
weston_compositor_build_view_list can reconstruct the view_list without a view which was
previously in it. The existing pointers in view->link are left unchanged, which could
lead to corruption or access to released memory in wl_list_remove, depending of the
order of destruction of the views.

This can happen at least with the black view created by the desktop shell for fullscreen
surfaces, when it is hidden in lower_fullscreen_layer.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
2019-10-16 14:10:35 +00:00
Pekka Paalanen c57a8cccd3 compositor: add use-gl option to headless
This will allow one to run the headless backend with GL-renderer.

Implements: https://gitlab.freedesktop.org/wayland/weston/issues/278

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 5104d7b2af headless, gl-renderer: support pbuffer outputs
Use the surfaceless platform in the headless backend to initialize the
GL-renderer and create pbuffer outputs. This allows headless backend to use
GL-renderer, even hardware accelerated.

This paves way for exercising GL-renderer in CI and using the Weston test suite
to test hardware GL ES implementations.

Relates to: https://gitlab.freedesktop.org/wayland/weston/issues/278

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 209187491b noop-renderer: zero-initialize struct
This ensures that all function pointers we do not fill in will be NULL.

I had a crash in the Xwayland test with
https://gitlab.freedesktop.org/wayland/weston/merge_requests/274 without this,
because import_dmabuf was garbage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen ecdf50d38e gl-renderer: add EGL surfaceless platform support
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>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 53b7fd70b8 gl-renderer: document output_window_create
Even if it is internal, it is a non-trivial interface and deserves
documentation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 0010f8380a gl-renderer: document display_create
Some of this is a little convoluted to figure out from the code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 411a7cfe67 gl-renderer: display_create needs surface type
In case the base EGLConfig is needed, gl_renderer_display_create() needs to
know it should use EGL_WINDOW_BIT or EGL_PBUFFER_BIT.

The PBUFFER case is added for when the headless backend will grow GL-renderer
support.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Stefan Agner 24756a8965 backend-rdp: don't use shadow buffer for the RDP backend
Since the RDP backend allocates regular memory already as hw buffer
anyway, a shadow buffer is not required. The read_pixels interface
anyway renders directly into the hardware buffer, hence this does
not make a performance difference in practise. It avoids allocating
an unnecessary buffer.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-09 21:44:58 +00:00
Pekka Paalanen 7b679772e3 xwm: no need for compositor/weston.h
The xwayland plugin (XWM) is a libweston plugin, so it has no business using
Weston things. Luckily its not, this was just a left-over include. Remove it to
reduce confusion.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 17:14:22 +03:00
Pekka Paalanen 4f5e360180 build: simplify include_directories
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>
2019-10-04 17:14:22 +03:00
Pekka Paalanen c232f8d934 Unify the include style of shared/ headers
When all shared/ headers are included in the same way, we can drop unnecessary
include seach paths from the compiler.

This include style was chosen because it is prevalent in the code base. Doing
anything different would have been a bigger patch.

This also means that we need to keep the project root directory in the include
search path, which means that one could accidentally include private headers
with

	#include "libweston/dbus.h"

or even

	#include <libweston/dbus.h>

IMO such problem is smaller than the churn caused by any of the alternatives,
and we should be able to catch those in review. We might even be able to catch
those with grep in CI if necessary.

The "bad" include style was found with:
$ for h in shared/*.h; do git grep -F $(basename $h); done | grep -vF '"shared/'

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 16:04:48 +03:00
Pekka Paalanen acf84fd29f xwm: dnd does not need cairo-util.h
Turns out dnd.c does not actually need cairo-util.h. This was found when
unifying the include directives of all shared/ headers. Removing this makes one
less place to fix.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 15:56:19 +03:00
Pekka Paalanen b6c7a3020c build: use dependency for matrix.c
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>
2019-10-04 15:55:55 +03:00
Pekka Paalanen 03eacfa618 build: shells do not need matrix.c
Do not build matrix.c into the shell plugins. The matrix functions are exported
by libweston.so and the shell plugins links to it.

Found by inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 15:53:29 +03:00
Pekka Paalanen 2f83c02e88 gl-renderer: use EGLConfig printer for window outputs
Replace the old config printer with the new fancy one: less duplicate code,
more details logged.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:18:11 +03:00
Pekka Paalanen f2aa6408ea gl-renderer: print detailed EGLConfig list
Print details of all available EGLConfigs in case none match what we are
looking for. This helps debugging.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:18:11 +03:00
Pekka Paalanen 6aadac7144 gl-renderer: improve get_egl_config errors
Listing exactly what we were looking for but did not find should help debugging
failures.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 7ba4c515a3 gl-renderer: prefer the base EGLConfig
If configless_context is not supported, we pick one EGLConfig as the "base
config" because we have just one GL context and different configs between the
context and EGLSurfaces might not work. Until now, we did not actually make
sure to pick the base config.

If the base config matches the requirements, prefer it. Only if it doesn't
match, go looking for another config.

This should give better chances of success on systems where configless_context
is not supported by relying less on eglChooseConfig().

Cc: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 88e5fcb55a gl-renderer: pbuffer config for non-surfaceless
If we don't have the surfaceless_context extension, we create a pbuffer as a
dummy surface to work with. If we also don't have configless_context, then it
is possible the config used for creating the context does not support pbuffers.
Therefore, if both conditions apply, we need to pick a config that supports
both window and pbuffer surfaces.

This makes the "base" config compatible, but it does not yet guarantee that we
actually pick it again when creating the pbuffer surface. Fixing that is
another patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 5d6d2b10af gl-renderer: configs for pbuffers too
Fold more code into the common config choosing, the pbuffer path this time.
Simplifies code and allows gl_renderer_get_egl_config() to grow smarter in the
future to guarantee config compatility in the absence of configless_context
extension.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 7cb7a6781f gl-renderer: remove EGLConfig attributes from API
Now that all backends pass in a list of acceptable DRM formats, that is used to
determine if the EGLConfig has an alpha channel or not. Therefore the
opaque_attribs and alpha_attribs are now useless, and we can remove the whole
config_attribs argument from the API.

gl_renderer_get_egl_config() uses an internal attrib list that matches at least
the union of the opaque_attribs and alpha_attribs matches.

Overall, behaviour should remain unchanged.

The new attribute array becomes variable in the future, so it is left
non-const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 9ddb3bc315 backend-x11: use DRM formats for EGLConfig
Define a specific DRM format for the GL-renderer to render in. It goes through
fuzzy matching in egl-glue.c which ensures we get exactly the number of bits
for each channel, but does not require an exact format match.

This ensures we get the bit depth we expect instead of the first arbitrary
EGLConfig.

This should not change the current behaviour, because Mesa EGL takes care to
order the configs as apps expect.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen ed20b4d983 backend-wayland: use DRM formats for EGLConfig
Define a specific DRM format for the GL-renderer to render in. It goes through
fuzzy matching in egl-glue.c which ensures we get exactly the number of bits
for each channel, but does not require an exact format match.

This ensures we get the bit depth we expect instead of the first arbitrary
EGLConfig.

This should not change the current behaviour, because Mesa EGL takes care to
order the configs as apps expect.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 7cbafec8ae gl-renderer: fuzzy EGLConfig matching for non-GBM
Implement fuzzy EGLConfig pixel format matching, where we ensure that R, G, B
and A channels have the expected number of bits exactly. This is used on EGL
platforms where the EGLConfig native visual ID is not a DRM format code. On EGL
GBM platform, the old exact matching of native visual ID is kept.

As only the DRM backend uses a DRM format list for picking a config, this patch
should not change any behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00