Commit Graph

729 Commits

Author SHA1 Message Date
Loïc Molinari 42205628bf gl-renderer: Prefix clipper API
Prefix and slightly rename the clipper structs and funcs:

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

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

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

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

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

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

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

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

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

Signed-off-by: He Yong <hyyoxhk@163.com>
2023-12-04 11:37:17 +02:00
Leandro Ribeiro 0c1ab2ad76 tests/color-metadata-errors: add mock stock sRGB color profile
In the following commits, we'll create the stock sRGB color profile for
outputs in weston_output_init(), and destroy it in
weston_output_release().

We already have a mock color manager in the tests, but we still need
to add the functions to create/destroy a mock stock sRGB color profile.
This should avoid crashes in the following commits.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-10-30 11:47:35 +00:00
Derek Foreman cec0ab7d23 libweston: Make better use of global coord helpers
Use wesotn_coord_sub/add() in many more places.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Pekka Paalanen d2b70d2fa9 shared: add weston-assert
Add yet another flavor of assertion macros.

Unlike libc assert.h assert(), these cannot be easily disabled by the
build. They also print both the implied expression and the compared
values.

Unlike ZUC macros, there is much less framework code and it can handle
also floating-point types.

The function custom_assert_fail_ can be redefined, meaning that
different compilation units can do different things on failure.

Also the 'compositor' parameter was added to the new macros because we
plan to use these asserts in our log infrastructure, and we want to
print the "failure" messages in the right log scopes. Having the
compositor already in the macros will avoid double work.

Another future possibility is to write specific asserts for the test
suite. So we would be able to write a test suite failure function that
just print what "failed" without aborting.

There is also limited support for custom types.

These are actually pretty similar to libinput's litest macros.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-09-28 06:52:24 +00:00
Derek Foreman d62c1b7f7b shell-utils: Use weston_coord in curtain params
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 9e12250707 shells: Use weston_coord for shell API
Replaces a lot of x, y pairs with weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 8eed64c7df libweston: Add weston_view_set_position_with_offset
There are many times when we want to set a global position with a surface
offset added.

It's a fairly nasty operation, and most places in the code currently do
it naively, ignoring the painful existence of freeform window rotations
and other complex transforms that could be in play (but probably aren't)

Add a helper for this and convert existing usage.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Daniel Stone 43cc77d4e9 tests: Check that test-surface unmaps on NULL
Make sure that committing a NULL buffer to a test-surface results in a
paint node disappearing.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-11 15:27:28 +00:00
Daniel Stone caac97be6a tests: Don't remap surfaces with NULL buffer
On attaching a NULL wl_buffer, weston_surface_attach() will unmap the
surface. Don't immediately remap it within committed() if we don't have
a buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-11 15:27:28 +00:00
Daniel Stone 5b14a094e7 tests: Use weston_view_move_to_layer()
Use the helper, don't mark stuff as mapped ourselves. Set the position
before the view, so when it's marked as mapped, it's already in
position.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-11 15:27:28 +00:00
Daniel Stone e61d15dd76 tests: Move surface mapping earlier in surface-shell
The surface needs to mapped before a view can be mapped. Fix this.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-11 15:27:28 +00:00
Derek Foreman 4def21c196 tests: prevent tests from breaking when they use invalid weston_compositor
The color-metadata-errors test inits outputs with a NULL compositor, and
makes a compositor that's entirely 0s except for the bits it's interested
in.

This makes a mess in a future where the primary_plane is split up per
output, as initializing the primary plane tries to add it to the
compositor's plane_list.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Daniel Stone 0189bfac9f surface: Add test for recursive subsurface unmapping
Make sure that in a 1 -> 2 -> 3 -> 4 parent->child subsurface nesting,
destroying surface 2 also immediately unmaps 3 and 4.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 17e4a77831 tests: Initialise breakpoint list for all test types
The list of client breakpoints was used for both client tests and plugin
tests - anything that uses the weston-test module - but was only
initialised in the client-test path. Make it unconditional.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: efde2fa0b1 ("tests: Add client<->compositor breakpoint support")
2023-07-03 22:39:38 +01:00
Daniel Stone ce113969e3 tests: Add paint-node test
This is a very simple test, mostly intended as a demonstration of the
new client<->compositor breakpoint infrastructure. It ensures that for a
simple test surface, a paint node has been created in the output's
paint-node list, reflecting the properties of the attached buffer.

This is an example of properties which are not observable by regular
clients.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00
Daniel Stone efde2fa0b1 tests: Add client<->compositor breakpoint support
Add support for clients to request the server insert breakpoints at
various points in its processing. These breakpoints are handled
internally by semaphores (visible to tests through helpers): when the
server reaches the specified point, it will pause execution until the
client allows it to restart.

A weston_compositor pointer returned at each breakpoint allows the
client to reach across the thread boundary and access the server's
internal data structures. This can be used to, for example, inspect
paint nodes, internal damage, or any other work which is not necessarily
client-visible.

The majority of tests will not need to use this infrastructure; it is
only intended for tightly-coupled tests which can very specifically
dictate and anticipate the server's execution flow.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00
Daniel Stone 68cfc121dc tests: Track weston_outputs in weston-test plugin
Keep a tracking set of every weston_output created by the compositor,
and use this to listen to the repaint signal.

This currently does nothing, but will later be used to listen to repaint
signals as a client breakpoint type.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00
Daniel Stone fec581ab7a tests: Pass wet_testsuite_data to test runs
Make sure every test handler now gets a copy of wet_testsuite_data,
which we'll later use for client<->compositor synchronisation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00
Daniel Stone ae2c47045f tests: Remove single case for device destroy test
Currently we have some device tests which run in a single iteration
once, then in lots of iterations after that.

The single-iteration case is useless, so remove it, which has the happy
side effect of not breaking when we change the test signature.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00
Leandro Ribeiro 9486740d21 tests: add color pipeline optimizer tests
This will help us to debug our color pipeline optimizer without the
need to craft special ICC profiles for that. In this initial patch,
we are able to add matrices and curve sets to the pipeline and assure
that the optimizer is doing the right thing.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-29 11:08:40 +00:00
Derek Foreman 14220a5f80 tests: Don't wait for frame callbacks when a surface is on no outputs
The event-test moves a client off of all the outputs to check for an
output leave event, but our move_client() code waits on a frame callback
to continue.

The fact that weston currently generates this frame callback is not
something we should enforce in a test, as it could (should) change in
the future.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-28 11:30:07 -05:00
Daniel Stone 0a4d74c60d weston-test-desktop-shell: Use weston_view_move_to_layer()
Simple patch, negative LoC, cleanliness win, correctness win.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Daniel Stone 249f68adb0 build: Run tests with leak-sanitizer suppressions
cf. the never-ending saga of how we can't neuter the fontconfig leaks,
also pass our CI leak-sanitizer suppression file when running tests
locally. This makes it easier to run with ASan enabled in your local
environment.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-22 14:31:57 +01:00
Daniel Stone 42f071e881 tests/drm: Fix leaks in drm-writeback-screenshot-test
We were leaking a couple of buffers (both input and output), and also a
couple of filenames.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Daniel Stone f360818960 tests/xwayland: Ensure $DISPLAY is correctly set
We rely on the Xwayland launcher setting $DISPLAY to connect to our own
X server. Make very sure in the tests that we're actually getting that
set properly.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Sergio Gómez 65740ca9a7 tests: Add basic testing for pointer constraints protocol
Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-06-14 10:27:14 +03:00
Sergio Gómez 34269c4708 tests: Add a button binding to weston-test-desktop-shell
We need this so that Weston can update the "click to activate" serial, so
that we can then use the constraints protocol (see
maybe_enable_pointer_constraint() in libweston/input.c).

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-06-14 10:27:14 +03:00
Derek Foreman e8208d21d7 libweston: Use weston_coord in struct weston_output
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:22 -05:00
Derek Foreman 244dc963b9 libweston: use weston_coord for weston_view_set_position
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:19 -05:00
Loïc Molinari 49053a2aa2 gl-renderer: Store clipped vertices directly into the vertex buffer
Move vertex clipper back to single-precision floating point
intermediates. Since positions are sent down the graphics hardware as
single-precision values, this prevents useless conversions between
single and double precision values and lets compilers fit twice as
much data into vector registers. It also removes a copy by letting the
clipper store vertices directly into the vertex buffer.

This is mostly reverting the conversion to double-precision that
happened along with the switch to the weston_coord struct for vertex
coordinates (commit 10e70bf23c).

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Leandro Ribeiro cf64fbe784 tests: assert that capture info was received before trying screenshot
If the source is not supported, we won't receive the capture
information. So the capture info (size/format) will be zeroed, and we
fail while trying to create a buffer for the screenshot with size/format
zeroed.

With this patch we fail if we don't receive the capture info, what makes
the failure reason more explicit.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-05 07:51:27 +00:00
Marius Vlad 4bc7bd73d7 libweston/weston-log: Add a iterator helper for debug scope
This adds three new helpers: one to iterate over all debug scopes
created/added and other two are for simpler getters for the scope name
and the description.

Included with this change is also a simple test to retrieve them.

This is an alternative to using the debug scope list advertised when
using the weston-debug private extension. libweston users can use this
directly to know which scopes they can subscribe to, and there's no need
to have a client implementation for the weston-debug protocol.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-05-30 11:05:14 +00:00
Marius Vlad 9e1c2056cf tests/meson.build: Add missing dependency for xcb-client-helper
This fixes the following build issue:

[    6s] cc -Itests/libtest-xwayland-client.a.p -Itests -I../tests -I. -I.. -Iinclude -I../include -Iprotocol -I/usr/include/pixman-1 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall
-Winvalid-pch -Wextra -Wpedantic -std=gnu99 -Wmissing-prototypes -Wno-unused-parameter -Wno-shift-negative-value -Wno-missing-field-initializers -Wno-pedantic -Wundef -fvisibility=hidden -O2
-Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fPIC -MD -MQ
tests/libtest-xwayland-client.a.p/xcb-client-helper.c.o -MF tests/libtest-xwayland-client.a.p/xcb-client-helper.c.o.d -o tests/libtest-xwayland-client.a.p/xcb-client-helper.c.o -c
../tests/xcb-client-helper.c
[    6s] ../tests/xcb-client-helper.c:39:10: fatal error: wayland-client.h: No such file or directory

Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-05-18 19:23:58 +03:00
Leandro Ribeiro 8c9dd4febb tests/color-icc-output: add ICC VCGT tests
There are some ICC profiles that contain something named VCGT tag. These
are usually power curves (y = x ^ exp) that were loaded in the video
card when the ICC profile was created. So the compositor should mimic
that in order to use the profile.

Weston already has support for that, but our ICC profile tests were
missing this case. This adds such tests.

For testing purposes, we have added tests with different exponents per
color channel.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-04-27 10:37:38 +00:00
Leandro Ribeiro 722d7f8c3f tests/color-icc-output: assert that dimension is not zero when creating clut
Without that we may crash when trying to create a PTYPE_CLUT ICC profile
with dimension zeroed. This would be wrong, so with this change we are
basically validating the test case arguments.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-04-27 10:37:38 +00:00
Leandro Ribeiro 7ea4075d77 tests/color-icc-output: differentiate test name based on ICC profile type
For now we have some tests with the same name. Differentiate them based
on the ICC profile type that they build: CLUT vs matrix shaper.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-04-27 10:37:38 +00:00
Daniel Stone d0301c9a82 tests/xwayland: Don't leak XCB reply
Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-04-19 10:17:19 +01:00
Michael Olbrich c30da2aa32 tests: ivi-shell: prepare for API simplification
The return values for most of the API functions will be removed and replaced by
asserts. So checking return values will no longer work and passing invalid
arguments will trigger asserts. Modify and remove the tests accordingly.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-04-19 09:38:09 +03:00
Daniel Stone c7a29b5196 tests: Allow DRM fixture setup to cleanly skip
Move our DRM test fixture setup later, where we already have a bunch of
per-backend splits, so we can choose to skip our tests at the right
time.

Doing this allows us to skip DRM tests with no memory leaks.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-04-12 10:52:57 +00:00
Daniel Stone 3ae62c208c tests: Move prog_args_save() later
This allows us to append to the arguments later on.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-04-12 10:52:57 +00:00
Leandro Ribeiro a62cb45b6e tests/color-icc-output: make use of color debug scopes
Now that we have color profile, transformation and optimizer debug
scopes, make use them in this test.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-04-12 10:03:32 +00:00
Pekka Paalanen 21f2fb99d5 tests: do not leak renderer argument
Noticed by ASan. The strdup() is not necessary, str_printf() returns an
allocated string.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-11 17:43:14 +03:00
Marius Vlad 06b57e1dda tests/xwayland-test: Also print out Weston log messages
We don't accumulate log scopes with was previous set internally so
enable the "log" scope (explicitly) for the xwayland-test to see what
Weston prints out.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-03-31 09:06:24 +03:00
Marius Vlad 14ca04609a tests/xwayland: Enable xwayland XWM debug log scope and more debug
We're still timing out with our basic xwayland test in CI, so this
enables the XWM logging scope, and enables some further print debugs we
have available in our helper library, in an attempt to further
investigate and determine why we're still timing out.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-03-28 12:45:13 +03:00
Leandro Ribeiro 89d05db0b7 tests: add writeback sreenshooter test
This adds a test to ensure that the DRM-backend writeback screenshooter
is working properly.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Marius Vlad 640a3c7165 xcb-client-helper: Add a XCB client helper for tests
This patch introduces a small library wrapper around XCB to be used in
Xwayland tests.

It's being designed such that we do not advance without accounting for
all X11 events when changing the window state.  It adds a fence that
waits for all events to be processed, and only after all the events have
been accounted for, to proceed further, resuming execution of the
tests.

This works by keeping a tentative_state list for the client and a
window state that gets applied when the event we waited for has been
received.

This is useful in test clients, which could verify at the end after
receiving all events that the correct state has been applied. Acts as a
way to verify that the we never get or have a different state than the
one we expect.

With it, this converts test-xwayland to using libxcb (together with
xcb-cursor-dev) rather than using Xlib, and with it it removes any Xlib
dependency we might have in the tests.

This only adds support for map/unmap/create/destroy/property notify.
A follow-up would be to expand this library to track window movement
and resizing.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-03-03 08:30:46 +00:00