Commit graph

244 commits

Author SHA1 Message Date
Simon Hausmann
3101104f5c Switch from WGPU 24 to WGPU 25
- Use a version of FemtoVG that uses WGPU 25
- Rename the unstable-wgpu-24 feature and wgpu_24 module
- Fetch bevy from a revision on master branch that switches to WGPU 25
- Move the bevy example out of the common workspace: That way users of the repo don't get bevy pulled from git, unless they want to build the bevy example.
2025-07-09 11:30:05 +02:00
Olivier Goffart
526c5da24c Don't use the extended debug of the DisplayHandle in the error message
Keep the error message in one line.
Error such as

```
Error: Error creating OpenGL display (Ok(
    DisplayHandle(
        Wayland(
            WaylandDisplayHandle {
                display: 0x00005641c528e590,
            },
        ),
    ),
)) with glutin: not found
```

Are not easy to parse because of all the new lines
2025-06-25 15:06:21 +02:00
Simon Hausmann
bd0a486da8 Clean up cfgs for Apple operating systems
Replace ios specific cfgs with "apple but not macOS", dubbed
ios_and_friends, so that we also cover iPadOS, etc.. What those have in
common is that they don't have user-resizable windows. (We might want to
add visionOs in the future)

Also, simplify a few macos or ios cfgs with just target_vendor =
"apple", for what applies to all the operating systems.
2025-05-09 20:54:47 +02:00
Simon Hausmann
1c73144b09 Winit: Implement the "resume protocol"
In future versions of winit, it'll only be possible to create windows
when the active event loop signals availability. To upgrade to the latest
accesskit version as well as to run on iOS, we're going to implement support
for this earlier and stop using the deprecrated create_window() function
on the regular (not running) EventLoop.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-05-09 09:36:37 +02:00
Simon Hausmann
302926edfa
Skia: Improve multi-window rendering resource consumption (#8304)
Share Vulkan instance as well as Metal device and command queue across windows.
2025-04-29 18:58:09 +02:00
Simon Hausmann
33581182ef backend-selector: Add the ability to configure WGPU
The `require_wgpu_24` function accepts either a fully setup WGPU, or one
can configure individual aspects such as features/limits.

The wgpu_texture example uses this to add push constants to the required
features and thus eliminates the need for uniform buffers.
2025-04-29 17:46:57 +02:00
Simon Hausmann
da5e7d5b22 WGPU: Add support for using WGPU textures in Slint
This adds a `unstable-wgpu-24` feature that exposes WGPU types in the
GraphicsAPI enum, adds `require_wgpu_24()` to the backend selector,
and adds a conversion from `wgpu::Texture` to `slint::Image`.

The `require_wgpu_24()` function in the selector will be extended in the
future (before the next release) to permit specifying additional aspects
of the WGPU configuration.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-29 17:46:57 +02:00
Simon Hausmann
a50b8f8793
FemtoVG: Add support for WGPU based rendering (#8268)
Enable via the `renderer-femtovg-wgpu` feature flag.

cc #171
2025-04-25 14:37:32 +02:00
Simon Hausmann
98dc4a8657 FemtoVG: Abstract the rest of the FemtoVGRenderer type to be independent from OpenGL
The main visible external change is that FemtoVGRenderer is now a generic type, but in the public Slint API the type alias that uses the OpenGL backend is re-exported under the old name. This looks a little different in rustdoc
but appears to be source compatible.
2025-04-25 10:08:38 +02:00
Simon Hausmann
6595aee73c
Replace use of Rc<winit:🪟:Window> with Arc (#8257)
In preparation for wgpu usage, where the wgpu API requires the window
handle to be send, i.e. Arc<dyn HasWindowHandle>.
2025-04-24 13:28:51 +02:00
Simon Hausmann
fe56fdd5e4 Minor cleanup
Reduce access to CURRENT_WINDOW_TARGET thread-local
(via renamed with_event_loop function) from the renderer adapters.
2025-04-11 09:37:03 +02:00
Yuri Astrakhan
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +01:00
Yuri Astrakhan
61de4d56b0 Fix all format arg inlining
Ran this command:

```shell
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2025-02-06 10:16:20 +01:00
Simon Hausmann
0d36f88152 Revamp BackendSelector API
Based on API review, PlatformBuilder becomes BackendSelector with
a slightly smaller API surface but more options, such as selecting
Metal or Vulkan rendering.
2024-12-16 13:06:05 +01:00
Simon Hausmann
bfdf0e275f Clean up Apple cfg's
Use target_vendor = "apple" where to cover all Apple OS, and exclude ios for event pumping.
2024-12-13 11:03:44 +01:00
Simon Hausmann
37f66789c5 macOS: Replace use of old apple creates with modern objc2 replacements 2024-11-28 10:00:24 +01:00
Ian Hattendorf
3cc44dc670 Add version to OpenGLAPI 2024-10-23 11:13:49 +02:00
Ian Hattendorf
ac9b85049a Add PlatformBuilder API to allow selecting OpenGL API
Right now this just allows selecting between OpenGL and OpenGL ES.
2024-10-23 11:13:49 +02:00
Simon Hausmann
d74e49e71f Skia renderer: Remove unnecessary scale factor argument / function 2024-09-10 10:24:07 +02:00
Simon Hausmann
0be2d4521e API Review: Remove suspend/resume related functions from FemtoVG renderer
This could've been `set_opengl_context` taking an `Option`, but it turns
out that makes for an awkward interface when wanting to pass None,
because that also then requires a dummy type for the OpenGL context even
though none is wanted.
2024-07-08 12:23:56 +02:00
Simon Hausmann
49df131625 Fix slint::Window::hide() on Wayland with winit
On Wayland hiding a window requires destroying the surface, which
means destroying the winit window as well as the underlying graphics
surface. The latter is tricky as we have to keep the renderer around,
as our WindowAdapter trait's `renderer()` function returns a `&dyn
Renderer` and that also has to work without a window (to obtain text
metrics).

Fixes #4225

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-07-03 14:22:30 +02:00
Simon Hausmann
862b1e1dfe winit software: remove unneccessary winit_window rc field
We can obtain that from the softbuffer surface.
2024-07-03 14:22:30 +02:00
Simon Hausmann
d7670d4feb Fix visibility warning with Rust 1.73 2024-06-18 17:48:17 +02:00
Simon Hausmann
7e7a3f72f0 Fix wasm build 2024-06-18 17:48:17 +02:00
Olivier Goffart
dc9f1d5bf1 WIP: upgrade accesskit and accesskit_winit 2024-06-18 17:48:17 +02:00
Simon Hausmann
4c888bf1ae Port the Skia renderer to rwh06 and the new softbuffer
... by accepting an Rc<dyn Has*Handle> in the interface. This is required for softbuffer use.
2024-06-18 17:48:17 +02:00
Simon Hausmann
40f2833bac Fix macOS build of glutin setup code used for FemtoVG renderer in winit backend 2024-06-18 17:48:17 +02:00
Olivier Goffart
865e3e940d WIP: update winit, glutin, raw-window-handle 2024-06-18 17:48:17 +02:00
Simon Hausmann
0e67654431 Fix jitter when resizing a window on macOS
Commit 1e450abc9c originally fixed this. Meanwhile, after many refactorings, this doesn't work anymore for the FemtoVG renderer. That's because the contents placement (or layer's contents gravity) is set before the hidden layer NSOpenGLContext creates is associated with the view.

For the Skia GL surface that already works, but for clarify the code is moved into the same location.

For Skia Metal rendering, apply the same on the metal layer (through the view). For this to work the contents scale also needs to be applied. To avoid further visual effects, the scale needs to be applied as early as possible, so apply it right after creating the
surface and latest at rendering time.

Fixes #5258
2024-06-06 08:34:58 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Simon Hausmann
93142bf417 winit: Always make skia-opengl available
The Skia OpenGL renderer is portable and sometimes esp. on Windows produces better results, so make it always available as an open if `renderer-skia` is enabled. `renderer-skia-opengl` continues to select the GL renderer as default.
2024-01-24 18:20:04 +01:00
Simon Hausmann
f5bf6e5dc0 Skia: Clean up pre present notify callback API
Move this back out of render() again and make it stateful in the renderer. Reduces the amount of book-keeping required and it's always the same callback anyway.
2024-01-04 10:35:09 +01:00
Simon Hausmann
3069e8e503 Add support for frame throttling on Wayland
Use winit's pre_present_notify() API to allow for the compositor to throttle rendering.

Fixes #4200
cc #1695
2024-01-04 09:21:53 +01:00
Simon Hausmann
f941357337 Upgrade to glutin 0.31.1 to fix window transparency on macOS
Fixes #3760
2023-10-30 08:58:25 +01:00
Olivier Goffart
3deb620953 Skia: disable skia software renderer for android
softbuff doen't compile on android
2023-10-26 14:52:07 +02:00
Simon Hausmann
9884b14ee0 Make GL rendering work again on macOS
Disable transparency support to work around https://github.com/rust-windowing/glutin/issues/1640
2023-10-25 08:43:42 +02:00
Simon Hausmann
30c810be00 winit: Propagate errors when winit fails to initialize the event loop
For the backend selector, this means that when a backend is selected explicitly,
and initialization fails, don't try `create_default_backend()` but
propagate the error.

For the Rust code generator, propagate the first ensure_backend()
errors. Any subsequent onces (unlikely, since the first thing any
public new() calls is ensure_backend) will unwrap.
2023-10-24 15:47:08 +02:00
Olivier Goffart
58e5d62a02 Winit port: Fix wasm build
Port everything from instant to web-time
2023-10-23 14:22:48 +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
3855de0794 winit: Add support for selecting Skia's software renderer directly
That might be useful for debugging
2023-10-23 13:55:23 +02:00
Simon Hausmann
f7d666b948 winit backend: clean up renderer creation
Pass around a factory function to create the renderer,
instead of a factory function that creates the window adapter. The adapter is
always the same anyway, and this way the WinitWindowAdapter's new
also doesn't have to be generic.

This also prepares for adding a second skia renderer
constructor later to select a specific variant.
2023-10-23 13:55:23 +02:00
Olivier Goffart
4446a17b24 Skia renderer: reset the surface when the app is resumed on android
Part of #3430
2023-09-21 17:23:08 +02:00
Simon Hausmann
fd123b27bd Default to vsync for OpenGL rendering
Fixes #3516
2023-09-20 12:00:04 +02:00
Olivier Goffart
46ec7875ed Software renderer: partial rendering with winit and fix non-opaque background
Implement the partial rendering with winit and our software renderer.

When the background is not opaque, we must still initialize all the
pixel with 0 otherwise we blend over the previous frame.
(That wasn't visible before because the buffer was always empty)
2023-09-13 16:08:57 +02:00
Olivier Goffart
6e1132726a winit-sw: Loop over the buffer instead of using indices
It is possible that softbuf allocate a larger buffer than in needs?

Prospective fix for #3406
2023-09-06 16:04:03 +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
Simon Hausmann
65f9e6f1eb Move the OpenGLInterface back to the FemtoVG renderer
At the moment it's only needed there, so let's
have it there and move it to core later if the need arises.
2023-08-28 13:33:15 +02:00
Simon Hausmann
6dd60113f1 Add some information about the display handle when glutin::display::Display::new() fails
The error from glutin is just a string.

cc #3312
2023-08-21 17:16:55 +02:00