Commit graph

84 commits

Author SHA1 Message Date
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
eb825f2e95 Support default-font-* properties in Live-Preview
... by changing the resolution for the `WindowItem` to traverse the
item tree from the current item, instead of going to the window.

This doesn't quite fix #4298 because `rem` resolution is still missing.
That requires the built-in default font size function to be fixed as
well, which is non-trivial.

cc #4298
2025-04-24 09:18:45 +02:00
szecket
ed47d1e70a
matching the math for skia and femtovg renders for radial gradient (#7899) 2025-03-21 10:53:04 -04:00
Yuri Astrakhan
9621cae218 Auto-fixed clippy::needless_lifetimes
`__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_lifetimes

```
__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_lifetimes

cargo fmt --all
```
2025-02-07 09:20:49 +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
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
cf9b515a92 Clean up rendering of component container
Instead of creating a dummy Rectangle with background property, implement a RenderRectangle trait.
2025-01-29 12:39:40 +01:00
Simon Hausmann
52f6178a89 Fix panic when using gradient backgrounds on Window
This regressed with commit 3cb4bd174d, which introduced the draw_rect() hook in ItemRenderer, but unfortunately
it wasn't in the `impl ItemRenderer` section
in the FemtoVG and Skia renderers.

ChangeLog: Fix panic when using gradient backgrounds with `Window`.
2025-01-24 17:14:49 +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
0d723953f9 Add support for line caps in Path Strokes
ChangeLog: Added `Path::stroke-line-cap` property.

Fixes #4676
2025-01-20 22:28:45 +01:00
Simon Hausmann
c764da4aab
Add property to toggle anti-aliasing on Path elements (#7308)
This enables working around bugs in GPU drivers. Especially the GC7000UL
plus its driver on imx8mp has been observed to sometimes horribly degrade in
performance when Skia renders anti-aliased paths (when a function like
`gcoSURF_BlitCPU` shows up at the top of `perf` that's a bad sign).
2025-01-10 10:28:01 +01:00
Simon Hausmann
2ec0522151 Fix panic in FemtoVG and Skia renderers with certain drop shadows
If the effectively drop shadow size would be zero, the FemtoVG and Skia item renderers would panic. The following test-case reproduces this:

```slint
export component Test inherits Window {
    Rectangle {
        drop-shadow-color: black;
        drop-shadow-offset-x: 1px;
        drop-shadow-blur: -0.5px;
        width: 0.5px;
        height: 0.5px;
        background: blue;
    }
}
```

ChangeLog: [Renderers] Fix panic with FemtoVG and Skia renderers for certain drop shadows.
2025-01-06 12:40:44 +01:00
Simon Hausmann
e8f319bd77 Implement translation() 2024-11-19 21:31:04 +01:00
Simon Hausmann
34fc24e4e0 Skia: Fix opacity not being applied to box shadows correctly
When a box shadow is the only child of an opacity item, we don't create an intermediate opacity layer (good). Without the opacity layer, it's mandatory to apply the current opacity though, which commit b5c61fb2f5 did, except
it missed this one draw_image call for the box shadow itself.

Fixes #6359
2024-10-02 07:03:02 +02:00
Simon Hausmann
4c5b7c353a Prospective fix for division by zero in Skia renderer when rendering images
Closes #6280
2024-09-25 14:01:21 +02:00
Simon Hausmann
76388260f6 Simplify oddly complex expression 2024-09-25 12:27:03 +02:00
Simon Hausmann
bc2e97fcef Skia: Improve rendering quality of layers and qt style with fractional translations
Layers and cached pixmaps should be "invisible" in terms of quality,
and they're "designed" to be pixel aligned.
2024-09-18 07:44:29 +02:00
Olivier Goffart
67b82230f7 Skia: fix mixing tiling and colorize
A colorized image is baked by a texture, which needs the context so that
the make_subset don't return None
2024-09-13 17:35:57 +02:00
Simon Hausmann
d6b3e69a7e Fix SLINT_DEBUG_PERFORMANCE="overlay" with Skia
After the FontMgr changes in the previous Skia update we can't default
construct Font anymore. Let's use the same default font we also use for
regular text then.

Fixes #5764
2024-08-06 16:12:15 +02:00
Simon Hausmann
b5c61fb2f5 Skia: Make sure to consistently apply the global alpha
Replace uses of skia_safe::Paint::default() with calls to self.default_paint(), to apply the current global alpha.

Fixes #5706
2024-07-29 13:21:21 +02:00
Olivier Goffart
8b5df70dd0 Make a trait for the Text rendering
So we can Split Text
2024-07-05 12:51:25 +02:00
Walter Kalata
56e6d7b08e Option<(Paint, Option<Shader>)> -> Option<(Paint, Shader)> 2024-06-26 13:16:24 +02:00
Walter Kalata
c04caac5ed Addresses feedback re: tuple return values over closure args 2024-06-26 13:16:24 +02:00
Walter Kalata
aa5e9b99d5 Support dithering gradients in the skia renderer 2024-06-26 13:16:24 +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
Simon Hausmann
b4fc512d5e Skia: Fix quality of control rendering when using cache-rendering-hint: true;
By default, render layers with smooth scaling, just like we do also in `Image` by default.

The easiest way to reproduce the issue is to use `cache-rendering-hint: true;` on an `Image` and then scale it: It'll appear as if `image-rendering: pixelated;` is used, which it shouldn't.

`cache-rendering-hint: true;` on an `Image` doesn't make much sense by itself, but it should be a no-op.
2024-05-15 14:20:11 +02:00
Noah Sweilem
3ae3da3a04 Fix formatting issues 2024-04-26 13:16:19 +02:00
Noah Sweilem
15b8e6c9fa Text stroking: implement hairline stroking when width is zero 2024-04-26 13:16:19 +02:00
Noah Sweilem
f51d91f9f1 Text stroking: check if brush is transparent instead of stroke width to disable rendering 2024-04-26 13:16:19 +02:00
Noah Sweilem
38ed7bed00 Skia text stroke implementation 2024-04-26 13:16: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
Olivier Goffart
881da94737 Move the condition to render the text cursor in TextVisualRepresentation
And add a hack to make the screenshot test pass on Mac
2024-03-21 09:34:52 +01:00
Olivier Goffart
5e66fe9dc8 Fixup cursor color and appearence
On mobile and macOs, the cursor is the selection color.
Also don't show the cursor when there is a selection (all platforms)
2024-03-21 09:34:52 +01:00
Olivier Goffart
9f6b837f7d android: fix cursor and handle color
On android, the handle is the same as the cursor color and the cursor
color is usually the "accent" color.
We can't know the accent color from the native code, but we know the
selection color which is the accent color with a lesser opacity.
2024-03-20 15:06:34 +01:00
Olivier Goffart
06174c16d3 Femtovg&Skia: fix drawing of tiled svg image
We will render them with the final size in the buffer, so account for
that difference when rendering
2024-02-27 19:08:16 +01:00
Olivier Goffart
3910095e4d Tiling for the nine slice images 2024-02-26 12:16:41 +01:00
Olivier Goffart
5e7ddf3a19 Image Tiling
(Doesn't work yet with 9slice)
2024-02-26 12:16:41 +01:00
Olivier Goffart
bb4f2b1581 Implement 9slice with other renderer 2024-02-13 14:46:27 +01:00
Olivier Goffart
ce6c7f5527 Image: add horizontal and vertical alignment 2024-02-08 18:59:26 +01:00
Olivier Goffart
cb92ba1132 Add ImageFit.preserve and de-duplicate the fitting code 2024-02-08 10:10:56 +01:00
Olivier Goffart
b23c605ac1
Refactoring: Use a trait for Item being Images 2024-02-07 13:28:47 +01:00
J-P Nurmi
5e086971c9 Add RenderBorderRectangle trait 2024-02-06 18:01:35 +01:00
J-P Nurmi
031742246c Implement clipping 2024-02-06 18:01:35 +01:00
J-P Nurmi
20026b14f2 Skia: non-uniform border radius 2024-02-06 18:01:35 +01:00
Olivier Goffart
f1f141896f
Fix linear gradiant rendering in non square rectangle
Fixes https://github.com/slint-ui/slint/issues/3730
2024-01-17 17:44:51 +01:00
Simon Hausmann
bdd275811e Bump skia-safe version
This updates to m118. See
https://github.com/rust-skia/rust-skia/releases/tag/0.67.0 for more
details.
2023-10-26 10:45:36 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
J-P Nurmi
6792f6abf1 Skia: fix empty text input cursor alignment 2023-10-04 10:17:30 +02:00