Commit graph

67 commits

Author SHA1 Message Date
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
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
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
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
Olivier Goffart
865e3e940d WIP: update winit, glutin, raw-window-handle 2024-06-18 17:48:17 +02: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
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
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
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
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
Simon Hausmann
4e7ebdceba Improve zero-size OpenGL surface handling
- Use NonZeroU32 in the OpenGLContextWrapper interface (correct API for the future)
- Don't render zero sized windows with the software renderer and FemtoVG
2023-07-27 16:48:57 +02:00
Olivier Goffart
49485dbf7d SoftwareRenderer: add API to construct and change the buffer type 2023-07-27 14:44:28 +02:00
Simon Hausmann
f15bc6147e Simplify FemtoVG and Skia renderer APIs: remove resize()
We can convey the new physical window size from the run-time
through the private renderer API
when a window resize event is dispatched.
2023-07-25 19:33:26 +02:00
Simon Hausmann
7d136b6568 Remove the window parameter from the render() function of all the renderers
This makes for a slimmer API and instead we can create the renderer <-> window association
behind the scenes ourselves,
in set_component.
2023-07-25 17:28:08 +02:00
Simon Hausmann
507428b03e
Simplify FemtoVG and Skia renderer API (#3153)
Fold show() into the first time render() is invoked,
and hide() into the Drop implementation.
2023-07-25 17:17:40 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Simon Hausmann
a181fe0196 Port to softbuffer 0.3.0 2023-06-22 08:11:16 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Simon Hausmann
879e09922f Begin renderer API cleanup: Remove size argument from WinitCompatibleRenderer::render()
We would pass `physical_size_to_slint(&self.winit_window().inner_size())`, which is
identical to `slint::Window::size()`, which
calls `size()` on the WindowAdapter, which
returns the above.
2023-05-26 10:46:59 +02:00
Simon Hausmann
fe4a434ce4 Remove the WindowAdapter from the renderer constructor
This allows disentangling the native window creation from the renderer
creation, which is rather ugly and complicated on the C++ side.
2023-05-21 14:40:43 +02:00
Simon Hausmann
12e6e322d9 Make the WinitWindowAdapter non-generic
This isn't necessary anymore
2023-05-11 10:42:09 +02:00
Simon Hausmann
c3cee1c3d9 winit: Simplify internal renderer trait
Don't require the creation of an Rc<winit window>, leave
that to the caller.
2023-05-11 10:42:09 +02:00
Simon Hausmann
a3a13c727a winit: Cleanup, move the winit window out of the individual renderers 2023-05-11 10:42:09 +02:00
Simon Hausmann
721e74238f winit: Simplify softbuffer handling
Allocate the softbuffer in the constructor
2023-05-11 10:42:09 +02:00
Simon Hausmann
7df902b53c winit: Create a winit window at renderer creation time
This simplifies the logic for how to apply window related requests as
they can be applied to the winit window immediately.

It also simplifies the state handling in the WinitWindowAdapter, as
there's no more distinction between mapped and unmapped. We always map
now (winit does).

One related change in core is that the window properties are now sent to
the backend before calling show(), instead of after.
2023-05-11 10:42:09 +02:00
Olivier Goffart
98747cd385 Winit software renderer: Fix transparent background
Despite the documentation of softbuffer claiming that the high bits
should be 0, it seems to be interpreted as an alpha value when the
window is actually transparent.
And the values are considered as premultiplied alpha

Also use a Premultiplied aplha for the buffer so we can even have
transparent window with the software renderer
2023-05-03 19:29:51 +02:00
Simon Hausmann
098a078008 Make it possible for the window adapter creation to fail
The creation of the renderer might fail, for example if we tried to
create an OpenGL renderer on a display that doesn't support OpenGL. We
should catch that in the future and fall back to the software renderer.
2023-04-27 17:37:36 +02:00
Simon Hausmann
af8e71dacc Minor cleanup
Replace qualifier with use.
2023-04-27 17:37:36 +02:00
Simon Hausmann
8ffb5131c7
Introduce error handling in the FemtoVG and Skia renderers (#2402)
Avoid unwrap() and expect() and instead propagate errors all the way
down to run_event_loop(), show(), and hide() in the Slint AIP.
2023-03-24 14:18:11 +01:00
Simon Hausmann
c54e1cba43 Fix support on GLX displays with FemtoVG
In order for GLX support to work, we need to create the X11 window with
the same visual as in the GLX configuration. That requires delaying
the creation of the window.

This is done in four parts:

- The window builder is re-introduced in the winit backend create
  internal renderer interface.
- The glcontext helper code for wasm was moved into a separate function
  (less indentation).
- The loop over different display preferences was replaced with a
  preference to the "window system native GL interface" over EGL,
  which should achieve the same as the fix for #2162. Upstream glutin
  defaults to this and so do various downstream projects.
- Use glutin-winit for the actual display selection.

This covers the FemtoVG bits of #2269
2023-03-23 15:36:42 +01:00
Olivier Goffart
a19efc30db
Replace the MAX_BUFFER_AGE const generic with a runtime enum
Having a const generic for that didn't turn to be a good API.
Also made the C++ side more difficult

(Also renamed buffer_stride to pixel_stride)

Closes #2135
2023-02-08 14:44:01 +01:00
Florian Blasius
ed67f3aabb
bump soft-buffer to 0.2 (#2038) 2023-01-09 09:08:59 +01:00
Simon Hausmann
14350a970b Cleanup: consume the original pixel buffer in the conversion for softbuffer 2022-12-13 16:51:26 +01:00
Simon Hausmann
5820db6088 Remove the OpenGL dependency for renderer-winit-software
Use softbuffer to bring pixels produced by the software renderer to the screen.
2022-12-13 16:51:26 +01:00
Simon Hausmann
b2ebac63c2 Remove component_destroyed from winit's internal renderer interface
The default impl of unregister_component in WindowAdapterSealed would call free_graphics_resources
on the rendere. Any re-implementation would have to do the same,
which the winit backend forwarded through
the winit backend specific internal renderer interface.

Instead, the original call site for unregister_component now calls
free_graphics_resources and unregister_component (for accessibility tree dirty notification).
2022-12-09 09:03:27 +01:00
Simon Hausmann
f5bbca9fce Remove default_font_size() from internal winit renderer interface
Replace register_root_component in the WindowAdapterSealed altogether with
a default font size getter on the renderer.

This is overall simpler and allows removing the doc-hidden getter in the software renderer.
2022-12-09 09:03:27 +01:00
Simon Hausmann
06f7f76b69 Reduce the renderer interface further in the winit backend
Move the canvas into the renderer entirely as interior state.

This complicates the implementation but paves the way for an easy-to-use API.
2022-12-09 09:03:27 +01:00
Simon Hausmann
6c22af4247 Wrap the software renderer into a struct
This is in preparation for internalizing the canvas state.
2022-12-09 09:03:27 +01:00
Simon Hausmann
ff119eab4f Minimize the WinitCompatibleRenderer trait a little
Replace the raw-window-handle traits with a winit window. It's okay to
use winit one level into the renderer (the part that lives in this
crate).
2022-12-09 09:03:27 +01:00
Simon Hausmann
307636d652 Remove winit dependency from the renderers
GLWindow (yes, misnomed) is now responsible to creating and owing the
winit:🪟:Window.
2022-12-08 12:12:11 +01:00