Commit graph

123 commits

Author SHA1 Message Date
Simon Hausmann
2b2afaf7d8 Work around gbm display not working on Vivante gbm drivers
gbm.rs' lock_front_buffer calls has_free_buffers before calling the underling C lock_front_buffer function on the gbm surface. This has_free_buffers() check succeeds the first time but always fails after that.

However apart from this check, everything else appears to be working perfectly fine. Projects like weston, ksmcube, Qt, or mutter don't do this check beforehand either, so this patch works around gbm.rs by skipping this.

Unfortunately this requires going to gbm-sys directly and implementing the drm traits that require calling the various gbm_bo_get_* functions to retrieve the buffer details for posting to DRM.
2024-02-29 15:18:14 +01:00
Simon Hausmann
367af4fdf4 Align rotation between software renderer and LinuxKMS backend
As discussed a few days ago, let's define rotation to be always
clockwise, as it is done in other graphics frameworks as well as our
own image rotation. This means changing the definition for the
software renderer. Also fixed docs for the enum in the linuxkms backend
that was wrong.
2024-02-07 11:21:59 +01:00
Olivier Goffart
daa376becd Fix linuxkms compilation and warnings when no features are enabled
Remove a lot of error in rust-analyzer when opening the slint workspace
2024-01-26 13:47:14 +01:00
Simon Hausmann
5e23dbe765 Fix reuse compliance check
Current versions of the reuse tool don't allow inline copyright and licsense information in SVG and CSV files anymore. Move those into the dep5 file.
2024-01-18 15:11:43 +01:00
Simon Hausmann
199c761583 LinuxKMS: Fix animations using the wrong start time when invoked from invoke_from_event_loop
The event loop roughly loops like this:

loop {
    update_timers_and_animations();
    render();
    sleep_or_dispatch_events();
}

sleep_or_dispatch_events() will wake up when we receive a queued callback from invoke_from_event_loop, and we would
run the callback right away. If that callback sets animated properties, the start time for animations would be incorrect, as we haven't called update_timers_and_animations() yet.

So instead, let's keep track of any received callbacks per sleep cycle, update the animation tick, and then invoke the callbacks.
2024-01-15 18:30:49 +01:00
Simon Hausmann
9c247553e1 LinuxKMS: Tweak the output shown after SLINT_{DRM,VULKAN}_{MODE,OUTPUT,DISPLAY}=list to mention the environment variable in question
As suggested by Olivier, this makes it much clearer what the next steps
are.
2024-01-12 17:32:56 +01:00
Simon Hausmann
4d23bcdd97 LinuxKMS: Replace the use of panic with eprintln/std::process::exit
As suggested by Olivier, That's a little cleaner than panicing. There's
no reason to panic, this is normal :-)
2024-01-12 17:32:56 +01:00
Simon Hausmann
2b699c2189 LinuxKMS: Add support for selecting display modes with DRM output 2024-01-12 17:32:56 +01:00
Simon Hausmann
bf7a4095ad LinuxKMS: Not only print the name of the renderer, also print the resolution 2024-01-12 16:07:29 +01:00
Simon Hausmann
4d58c9877d LinuxKMS: Remove set_event_loop_quit_on_last_window_closed implementation
This is now handled in i-slint-core.

Amends 9ff13faee8
2024-01-12 10:05:02 +01:00
Simon Hausmann
e1c5f4ff03 linuxkms: Fix support for "refresh_full_speed" in SLINT_DEBUG_PERFORMANCE
We trigger update_timers_and_animations() every time the event loop wakes up.
If there's a real animation in the UI going on, that'll also trigger a
request_redraw() call and all will be well.

But when the only source of animation is set_has_active_animations() from
RenderingMetricsCollector, then we might end up in a situation where the event
loop is woken up before the rendered frame is on the screen, which means we
invoke update_timers_and_animations(), but we won't render because the
previous frame isn't shown yet. When it is shown and our presentation callback
is invoked, has_active_animations() is false again.

So instead, remember if we need to re-render once after rendering()
and use that to decide if we need to re-render in the presentation callback.
2024-01-11 11:23:18 +01:00
Simon Hausmann
a7d1ab89d7 Minor cleanup
Merge two functions that had only one call site.
2024-01-08 09:56:14 +01:00
Simon Hausmann
982b4c806f LinuxKMS: Add initial support for software rendering with Skia
This is the initial implementation based on DRM dumb buffers,
which cleans up various things at the same time:

 - DRM output is separate from GBM and DRM dumb buffer displays.
   The latter two re-use the former.
 - The timer refresh for the Vulkan KHR Display rendering lives
   now with the KHR display code, in hope to be replaced with a
   better mechanism in the future.

What's missing still is support for partial updates as well as
rendering with our own software renderer.
2024-01-07 11:54:29 +01:00
Simon Hausmann
8193d4d064 LinuxKMS: Clean up internal page flip callback API
Remove the hack of calling present() from our swap_buffers() forwarder (and let it really only forward),
and instead call it explicitly through the shared egl_display member.
The way we can pass along the callback instead of storing it separately.
2024-01-04 10:35:40 +01:00
Simon Hausmann
6b6fd91035 linuxkms: Move the fallback timer based animation driver code into a separate helper type 2023-12-19 16:59:35 +01:00
Simon Hausmann
0b21d8bfce linuxkms: Don't use a 16ms timer for the animation frame callback after the first buffer was posted
We don't need to wait 16ms, we could render right away. In theory this could also use invoke_from_event_loop, but then
the callback needs to be sync, which is an unnecessary
complication.
2023-12-19 16:59:35 +01:00
Simon Hausmann
2d0f2a52e6 linuxkms: Simplify drm event handling code a little bit
Less code nesting :)
2023-12-19 16:59:35 +01:00
Simon Hausmann
0ccc334de7 linuxkms: remove home-grown fd event source with calloop's generic even source
That's less boiler plate for us and better error handling (note how the receive_events()
call on the DRM device now propagates the error). And this also unregisters automatically
on drop.
2023-12-19 16:59:35 +01:00
Simon Hausmann
208a1e24ac linuxkms: replace 16m timer for animations with page flip driven rendering (if possible) 2023-12-19 16:59:35 +01:00
Simon Hausmann
4f0ad4c15b linuxkms: remove page flip specific bits from the calloop event loop
This belongs encapsulated inside the egldisplay code.
2023-12-19 16:59:35 +01:00
Simon Hausmann
b998f94ad6 linuxkms: Avoid keeping the EGL display around for too long
Don't keep a strong reference to the EGL display, we don't need that. If the display is removed but there are pending events, just ignore them.
2023-12-19 16:59:35 +01:00
Simon Hausmann
388661cc53 linuxkms: Fix firing of timers while animations are running
Merge the 16 redraw timer with other timers, which might fire sooner.
2023-12-19 16:59:35 +01:00
Simon Hausmann
b40b629e11 linuxkms: don't blockingly read on the drm fd after issuing a page flip request
... instead pass the fd into the calloop event loop and change state when we receive activity on it.

This improves performance slightly, and is a necessary to be able to implement refresh rate throttled rendering (in the next commits).
2023-12-19 16:59:35 +01:00
Simon Hausmann
11df315c54 linuxkms: Clean up file descriptor handling (part 2)
File can be converted into OwnedFd, so we can replace the
use of a dyn with the concrete Rc<OwnedFd>.
2023-12-19 16:59:35 +01:00
Simon Hausmann
e98a029293 linuxkms: Clean up file descriptor handling (part 1)
We don't need Arc for the file descriptors that remain in the same thread.
2023-12-19 16:59:35 +01:00
Simon Hausmann
3b51c8e30a
LinuxKMS: Add support for synthetic display rotations (#4166)
This patch adds support for the `SLINT_KMS_ROTATION` environment
variable, that instructs the Skia/FemtoVG renderers to rotate
the scene before rendering.
2023-12-18 17:49:05 +01:00
Simon Hausmann
8d19426723
linuxkms: decouple event loop from window adapter (#4144)
- Allow for the event loop to run before creating the window adapter
- Keep the loop running if requested
2023-12-12 13:06:36 +01:00
Simon Hausmann
c1841fdfbe Add support for compiling the linuxkms backend without libseat support 2023-12-11 17:36:17 +01:00
Simon Hausmann
cb51fdfe81 janitor: bump xkbcommon dependency 2023-11-14 16:00:56 +01:00
Simon Hausmann
269b327cff janitor: bump calloop dependency 2023-11-14 15:56:24 +01:00
Simon Hausmann
58f9cf5d36 Port to new vulkano
This might fix the issue with resizing causing swapchain re-creation
errors, because "Swapchain creation no longer returns an error when the
swapchain extent doesn't match the current surface extent."

cc #3850
2023-11-13 12:39:59 +01:00
Simon Hausmann
0118363bec Fix build with only backend-linuxkms
Activate the kms feature of softbuffer correctly, when building without
default features.
2023-11-13 11:14:03 +01:00
Olivier Goffart
1864257f29 Silence error when rendering SVG in an 0x0 size
Make the size argument to svg::render optional to mean that it is the
default size of the image.
Otherwise, passing None as the size to ImageInner::render_to_buffer
would not render the image which is possible in some backend (eg: the
button image icon with the qt backend)

And if the image is really rendered on an empty because of layouting or
so, we don't need to show a warning anyway.

Fix #3790
2023-11-02 11:09:20 +01:00
Simon Hausmann
11ce7a2d59 Don't compile glutin twice
Use the same glutin version everywhere
2023-10-25 08:43:42 +02:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Simon Hausmann
60901a27ff skia: Fall back to software rendering if GPU accelerate rendering fails to initialize
At the moment this is only supported for the winit backend and the C++
API. linuxkms uses a different SkiaRenderer constructor.
2023-10-23 13:55:23 +02:00
Simon Hausmann
d9672c5a21 linuxkms: Initialize xkb lazily
This has two benefits:

- It improves start-up time for device that are touch-only because
  the xkb parsing is delayed until a keyboard is attached and key is
  pressed
- It fixes #3678 by working around the situation where xkb would
  crash if the xkbcommon data files (in /usr/share/X11/xkb) aren't
  there. Sadly, no error is reported in that case (that we could
  handle), instead just crashes.
2023-10-16 19:03:10 +02:00
Simon Hausmann
0d35e01724 Revert "linuxkms: Update drm and gbm dependencies"
This reverts commit 17afe1aa8a.

This causes

 thread '<unnamed>' panicked at 'assertion failed: (has_modifier && modifier.is_some()) || (!has_modifier && modifier.is_none())', drm-0.10.0/src/control/mod.rs:324:9

when running on qemu-virgl.
2023-10-13 15:21:15 +02:00
Simon Hausmann
17afe1aa8a linuxkms: Update drm and gbm dependencies 2023-10-13 08:54:59 +02:00
Olivier Goffart
40cbdd17f3 Janitor: linuxkms: slint-ui.com -> slint.dev 2023-10-11 08:28:31 +02:00
Simon Hausmann
1c37a7ed60 linuxkms: Prospective fix for touch input when SLINT_SCALE_FACTOR is set
When supplying logical touch coordinates to the slint::Window, scale
them to the logical screen size, not the physical one.
2023-10-09 16:47:37 +02:00
Simon Hausmann
b31d6c464a linuxkms: Add support for motion pointer events with absolute coordinates
When using qemu we receive these, for example.
2023-10-09 12:12:04 +02:00
Simon Hausmann
186c3ef3cb Simplify filter/map expression
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-10-07 11:26:17 +02:00
Simon Hausmann
b6b3dfc9c0 linuxkms: Prospective fix for failing crtc setup
If the chosen connector doesn't have a current encoder (who's crtc we could use), fall back to the algorithm described in

    https://manpages.debian.org/testing/libdrm-dev/drm-kms.7.en.html#CRTC/Encoder_Selection

for selecting the crtc (minus the usage check, since we drive only one connector).
This is also the same logic as in kmscube.
2023-10-07 11:26:17 +02:00
Simon Hausmann
3a56bcd2a4 Fix build of linuxkms backend on Yocto
We enable libseat's custom_logger feature by default, which redirects
log output from libseat into the Rust log facade. That's nice, but as
part of the implementation of this feature unfortunately libseat's
build.rs unconditionally adds /usr/local/include to the list of the
search include paths when compiling the log_handler.c file. That breaks
the Yocto build, rightly so:

warning: cc1: error: include location "/usr/local/include" is unsafe for cross-compilation [-Werror=poison-system-directories]

We can do without this feature, so let's not enable it.
2023-10-04 22:17:02 +02:00
Tobias Hunger
85e1c6020b janitor: Use workspace dependnecies for the slint crates
This moves most of the version information we need to update into one
place.

Note that the workplace dependency features are in *addition* to any
feature set when using the workspace dependency. So we have all
workspace dependencies defined with `no-default-features = true`.
2023-09-25 16:34:16 +02:00
Tobias Hunger
d6695c55cb Janitor: Use cargo workspace package data more 2023-09-25 16:34:16 +02:00
tronical
b8b9db4e42 Bump version number to 1.3.0 2023-09-05 15:46:36 +02:00
Olivier Goffart
95b6eda10b Make sure PLatformError is Send+Sync as it is needed for anyhow 2023-08-31 20:52:10 +02:00
Olivier Goffart
4ad5b1f6d6 Remove the pin of nix 0.26.2 since nix 0.26.4 was released 2023-08-29 18:42:30 +02:00