Commit graph

100 commits

Author SHA1 Message Date
Olivier Goffart
e04f028c91 Fix default-font-size not working with PopupWindow with the Qt backend
We had code on the window to reset the default-font-size property to the
default from the renderer.
For the Qt backend, the PopupWindow being their own Window, this code
was activated also for the PopupWindow's hidden default-font-size
property, which caused all PopupWindow's font to not follow the
default-font-size

Fixes #8855
2025-07-09 17:08:24 +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
94b257bdd4 Skia: Delegate texture import to the surface trait
This makes it easier to keep cfg'ed code in the cfg' surfaces than cfg'ing in cached_image.rs :)
2025-05-05 15:34:52 +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
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
a0823d8638
Skia: Use software rendering by default on Windows (#7934)
We've had some reports like #7641 . Now that we enable partial rendering by default, let's default to software rendering for Skia on Windows, until perhaps the Skia dawn backend arrives.

Closes #7641

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2025-03-25 10:04:49 +01:00
Yuri Astrakhan
feb7a864df Auto-fixed clippy::useless_format
See https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

```
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::useless_format

cargo fmt --all
```

`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear.
2025-02-07 13:16:50 +01:00
Yuri Astrakhan
6324b35e94 Auto-fixed clippy::needless_borrow
`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear.

See https://rust-lang.github.io/rust-clippy/master/index.html#/needless_borrow

```
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::needless_borrow

cargo fmt --all
```
2025-02-07 09:02:45 +01:00
Simon Hausmann
ac7c2dd791 Enable partial rendering with Skia's software renderer by default 2025-01-30 22:44:57 +01:00
Simon Hausmann
85b91bd325 Reduce size of CachedItemGeometryAndTransform and fix filter_item to respect the bounding rect
Remove the geometry field and merely store the offset/transform. This brings the size down from 40 to 32 bytes on aarch64.

Related, filter_item() now respects the item's bounding rect for the decision whether to draw the item or not.
2025-01-30 10:55:28 +01:00
Simon Hausmann
05e70e8c8b Fix support for Window.background tracking with the partial renderer
Fixes #5219
2025-01-29 16:32:42 +01:00
Simon Hausmann
05a37c0563 Skia: Add a way to log how much of the screen the partial renderer redraws 2025-01-28 21:38:30 +01:00
Simon Hausmann
b863e10e3f Disable partial rendering when the application uses a rendering notifier
If we want to enable partial rendering by default in the future, then we need to do this instead of disabling rendering notifiers. We don't know where the application renders to.
2025-01-24 18:41:46 +01:00
Simon Hausmann
3cb4bd174d Add support for triple buffered partial rendering with Skia 2025-01-23 18:27:01 +01:00
Simon Hausmann
3d90434067 Add support for rotation to the partial renderer
The use of the rotation-* properties creates a hidden Rotate item,
which applyes a rotation to the renderer. This rotation (and translation
by rotation origin) is now also applied when the partial renderer
computes the dirty regions.
2025-01-23 09:17:54 +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
6bd043aede Skia: Remove unnecessary RefCell 2024-11-20 07:25:51 +01:00
Simon Hausmann
3f8084cdc0 When using Skia with softbuffer and partial rendering, report damages to softbuffer
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-19 21:31:04 +01:00
Simon Hausmann
a7e04b7d59 Move the partial rendering state into core
... and use from skia as well as the software renderer.
2024-11-19 21:31:04 +01:00
Simon Hausmann
d706f81773 Add support for partial rendering with Skia behind an environment variable 2024-11-19 21:31:04 +01:00
Simon Hausmann
bdb0be64dd Skia: Reduce indentation and fix rustfmt application
Move the closure passed to `WindowInner::draw_contents()` into a
separate function, so that rustfmt works again.
2024-11-19 21:31:04 +01:00
Simon Hausmann
9fdb420d96 Skia: clean up background drawing
Do gradient and solid color fills in one place, instead of two.
2024-11-19 21:31:04 +01:00
Simon Hausmann
9b7de3f806 Pass the buffer age to the Skia software renderer 2024-11-19 21:31:04 +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
0b028bfb6f
Add support for a font-metrics property to Text/TextInput. (#6452)
The struct held provides access to the design metrics of the font scaled
to the font pixel size used by the element.

ChangeLog: Slint Language: Added font-metrics property to `Text` and `TextInput`.

Closes #6047
2024-10-05 17:00:46 +02:00
Simon Hausmann
d74e49e71f Skia renderer: Remove unnecessary scale factor argument / function 2024-09-10 10:24:07 +02:00
Simon Hausmann
e35d05f6b9 API Review: Remove SharedImageBuffer from public API and rename Window::grab_window() to take_snapshot()
Use SharedPixelBuffer as return value for take_snapshot() and provide counter-parts to from_rgb* in Image as to_rgb*
2024-07-05 20:46:55 +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
98a4325f3f Skia: Fix missing BeforeRendering rendering notifier state invocations
Commit 977b827df2 regressed this by passing `None` as surface, so we'd never try to retrieve the graphics api enum to pass to the notifier.
2024-06-26 15:05:47 +02:00
Simon Hausmann
e932aa1381 Skia: Fix broken rendering notifier invocations, part 1
With the new winit, we end up calling resumed() and thus set_window_handle() multiple times - the first time right in the WinitWindowAdapter constructor. This may lead to the following sequence:

1. resumed() calls set_window_handle() the first time.
2. A frame gets rendered (odd, but yeah), we invoke the rendering notifier with RenderingState::RenderingSetup.
3. winit calls resumed(), we call set_window_handle() once more. We reset the surface.
4. The next time a frame gets rendered, we invoke the rendering notifier with RenderingSetup again.

There are a few things wrong, but first and foremost, in step 3 we should call RenderingTeardown if we've called RenderingSetup before.
2024-06-26 15:04:31 +02:00
Simon Hausmann
977b827df2
Add Rust API to grab the contents of a slint::Window into a slint::SharedImageBuffer (#5445) 2024-06-22 09:33:18 +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
Daniel Stuart
436efaceea renderer: Use TextWrap enum for text_size function 2024-06-17 23:52:04 -07:00
Daniel Stuart
9f63d157d1 Add character wrapping for Qt Backend
This adds a new wrapping mode called `char-wrap`, which allows for wrapping at any character.
Currently, it only supports the Qt backend, with the other backends falling back to `word-wrap` when this option is selected.
2024-06-17 23:52:04 -07:00
Simon Hausmann
72e35ea5f9 Work around Skia OpenGL renderer not working with Wayland on certain vivante EGL drivers
Some versions use the zwp_linux_explicit_synchronization_v1 protocol
and end up re-allocating a synchronization object when initialzing an
EGL context on a surface a second time, causing the process to abort.

As a counter-measure, destroy the entire EGL context/surface/etc. before
creating a new one when on startup we call resume() after commit 518681cc02
2024-06-12 10:47:59 +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
Simon Hausmann
afa295a511 Revert "Skia: Don't use Vulkan by default"
This reverts commit ac53049408.

After b00752514c we should retain the
ability to opt into vulkan renderer by enabling the vulkan renderer
feature.

cc #5188
2024-05-07 13:35:20 +02:00
Simon Hausmann
ac53049408 Skia: Don't use Vulkan by default
The Vulkan backend is sometimes have difficulties, sometimes with window
resizing (swapchain resizing failing). Meanwhile, don't pick it by
default unless explicitly requested - prefer OpenGL.

cc #5188
2024-05-07 11:57:06 +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
J-P Nurmi
20026b14f2 Skia: non-uniform border radius 2024-02-06 18:01:35 +01: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
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
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
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
Olivier Goffart
3deb620953 Skia: disable skia software renderer for android
softbuff doen't compile on android
2023-10-26 14:52:07 +02:00