Commit graph

90 commits

Author SHA1 Message Date
Olivier Goffart
a37ec2a3b7 Add a documentation comment about DrawRectangleArgs::alpha
Some checks are pending
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
As mentioned on the chat:
https://chat.slint.dev/public/pl/4dbd4wame7rr7fz6ruf7kqfu5a
2025-06-23 15:42:20 +02:00
Olivier Goffart
e42c4b18c2
swrenderer: interface for hw rendering of rectangle with border or gradients (#8384) 2025-05-06 15:53:53 +02:00
Olivier Goffart
c8138ff1db
swrenderer: rewrite TargetPixelBuffer::draw_texture interface
Instead of using datastructure that are tailored to our line by line
renderer and draw functions, use more generic and future proof data that
are easier to handle by hardware accelerator, and may be easier to
stabilize.

The screenshots from the screenshots test have to be re-done
because the rounding is different

Note: the C++ API DrawTextureArgs is not exposed yet
2025-04-29 23:26:02 +02:00
Olivier Goffart
1c5279032d MinimalSoftwareWindow: fix sizing with scale factor 2025-04-11 22:16:23 +02:00
Simon Hausmann
bdae506fd6 Fixed Fixed multiplication to work with u16 2025-03-31 14:46:21 +02:00
Simon Hausmann
0841c71776 Implement Fixed multiplication via intermediate i64 2025-03-31 14:46:21 +02:00
Olivier Goffart
84261ee01c Avoid overflow in Fixed::mul 2025-03-31 14:46:21 +02:00
Simon Hausmann
54b188b0d7 Fix texture src offset precisions for TargetPIxelBuffer::Draw_texture
Implement Mul<Fixed> for Fixed instead of truncation.
2025-03-31 14:46:21 +02:00
Olivier Goffart
1efe8c8d5f
swrenderer: Don't overflow for font bigger than 256px
Fixes #7936
2025-03-25 15:51:18 +01:00
Simon Hausmann
ce2cd01383 Separate the stm32 independent part of the slint::platform::Platform impl from stm32 specific bits
... by moving them into an embassy backend to be shared in the future
with other board support packages.
2025-03-20 13:51:47 +01:00
Olivier Goffart
754a6bfdef swrenderer: make sure small functions in fixed point are inlined
`cargo bench -p printerdemo_mcu`

Before
```
bench                fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ full                            │               │               │               │         │
│  ├─ Rgb565Pixel    2.919 ms      │ 8.155 ms      │ 4.279 ms      │ 4.326 ms      │ 100     │ 100
│  ╰─ Rgb<u8>        6.139 ms      │ 10.49 ms      │ 7.729 ms      │ 7.826 ms      │ 100     │ 100
╰─ render_only                     │               │               │               │         │
   ├─ Rgb565Pixel                  │               │               │               │         │
   │  ├─ FullBuffer  1.439 ms      │ 4.138 ms      │ 1.597 ms      │ 1.635 ms      │ 100     │ 100
   │  ╰─ LineByLine  1.576 ms      │ 1.765 ms      │ 1.636 ms      │ 1.642 ms      │ 100     │ 100
   ╰─ Rgb<u8>                      │               │               │               │         │
      ├─ FullBuffer  2.016 ms      │ 2.872 ms      │ 2.111 ms      │ 2.128 ms      │ 100     │ 100
      ╰─ LineByLine  2.122 ms      │ 2.995 ms      │ 2.21 ms       │ 2.245 ms      │ 100     │ 100
```

After
```
bench                fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ full                            │               │               │               │         │
│  ├─ Rgb565Pixel    2.187 ms      │ 4.913 ms      │ 3.48 ms       │ 3.505 ms      │ 100     │ 100
│  ╰─ Rgb<u8>        5.489 ms      │ 8.193 ms      │ 6.713 ms      │ 6.723 ms      │ 100     │ 100
╰─ render_only                     │               │               │               │         │
   ├─ Rgb565Pixel                  │               │               │               │         │
   │  ├─ FullBuffer  1.105 ms      │ 1.932 ms      │ 1.225 ms      │ 1.278 ms      │ 100     │ 100
   │  ╰─ LineByLine  1.188 ms      │ 2.052 ms      │ 1.289 ms      │ 1.352 ms      │ 100     │ 100
   ╰─ Rgb<u8>                      │               │               │               │         │
      ├─ FullBuffer  1.505 ms      │ 2.643 ms      │ 1.599 ms      │ 1.669 ms      │ 100     │ 100
      ╰─ LineByLine  1.539 ms      │ 2.058 ms      │ 1.641 ms      │ 1.652 ms      │ 100     │ 100
```
2025-03-06 12:24:54 +01:00
Simon Hausmann
f114ff28dd Rename TargetPixelBuffer::Pixel to ::TargetPixel 2025-02-24 17:02:10 +01:00
Simon Hausmann
910d45a01f Fix window background fill
Don't blend the background but fill it when going through ProcessScene.
2025-02-24 17:02:10 +01:00
Simon Hausmann
4c1b7762bd Separate the target pixel buffer trait and related types into a separate module 2025-02-24 17:02:10 +01:00
Simon Hausmann
df6c99871d Change TargetPixelBuffer's draw_texture function to take a data structure instead of many arguments 2025-02-24 17:02:10 +01: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
Olivier Goffart
c98d234b9e Janitor: Always use `#![no_std] for runtime lib
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
2025-01-27 19:22:00 +01:00
Olivier Goffart
4e7bbcf2ba
Try to improve rendering (positioning) of signed field distance font. (#6868)
* WIP: swrenderer: use fixed point for the pixmap font coordinate

* swrenderer: signed distance field: move the glyph to the middle

* swrenderer: round the advance instead of truncating it in distance field

* swrenderer: actually align the gplyph on the sub-pixel precision

sub-pixel within the source.

* swrenderer: adapt the threshold for signed distance field

sqrt(2) is the distance to the diagonal, seems like this gives sharper fonts

* Fix bug in the elision, and re-upload the screenshort

the screenshot changed because the afvanced is now rounded intead of
truncated
2024-11-30 23:03:31 +01:00
Olivier Goffart
b0c7ac41f0 Add debug statements
to help debugging #6432
2024-11-07 17:24:06 +01:00
Olivier Goffart
446bb4a6bf
swrenderer: signed distance field: properly round the x and y glyph coordinate (#6687) 2024-10-30 18:12:52 +01:00
Olivier Goffart
45976bcf2b
Small polish of the appearence of small glyph with sdf
The trick is that we should have a constant delta, regardless of the
size of the individual glyphs.
2024-10-30 10:43:32 +01:00
Olivier Goffart
d8ab4e4600 Signed DistanceField font rendering in swrenderer
Note that this is still disabled in the compiler with no way to enable
it with public API
2024-10-23 09:12:30 +02:00
Simon Hausmann
20cf304936 Enable support for WASM builds with the software renderer
Everything is already working, just had to play around with a few cfgs. The sharedfontdb module already takes care of including DejaVuSans as default fallback font.
2024-10-17 08:50:25 +02:00
Olivier Goffart
a6ff642da5
refactor: split sofware_renderer.rs in modules 2024-10-11 11:56:46 +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
Olivier Goffart
43b05074e0
Software renderer: fix drawing partialy clipped texture with rotation (#6445)
We were assuming that the extra clip was always on a unrotated image,
the rendering code didn't account for rotated screens

ChangeLog: Software renderer: fix artifact with partial drawing and rotation
2024-10-04 15:16:41 +02:00
Olivier Goffart
c89ea56abb Update a bunch of dependencies
Bigger change is cause by resvg/usvg which now takes the font database
in a Arc, so we must store it in a Arc ourself to cheaply lend it to usvg
2024-06-23 16:47:13 +02:00
Daniel Stuart
436efaceea renderer: Use TextWrap enum for text_size function 2024-06-17 23:52:04 -07:00
Daniel Stuart
bac81bf350 Add character wrapping for software renderer
This adds `char-wrap` functionality to the software renderer.
2024-06-17 23:52:04 -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
Olivier Goffart
f45bab6a3f swrenderer: Support multiple rectangles for the dirty regions
This allow to be much faster in the case two small area of the screen
changes.
2024-04-26 14:45:23 +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
Tobias Hunger
77c85aa703 janitor: fix clippy warnings about "bound is defined in more than one place" 2024-03-14 13:42:38 +01:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Olivier Goffart
5e7ddf3a19 Image Tiling
(Doesn't work yet with 9slice)
2024-02-26 12:16:41 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
424f046416 swrenderer: refactor image drawing algorithm
For tiling, we will need to know the actual source size in addition to
the scaling factor that can be different. So store the scaling factors
in the scene command, as well as an offset where to start.

This is more accurate in case of clipping and rotation.
For rotation that doesn't matter (appart from the fact that the testing
can now be more strict)
But for clipping this prevent glitches with partial rendering where it
would seem like the image are moving a bit by a pixel when it is redrawn
with a different clip
2024-02-15 18:25:47 +01:00
Olivier Goffart
b2920b1714 Software renderer: use 16 bit precision when drawing image
This is important when zooming, and still allow images of 65535 pixel
width or height
2024-02-13 14:46:27 +01:00
J-P Nurmi
1971f598bb SW: non-uniform border radius 2024-02-06 18:01:35 +01:00
今何求
607bdbfcf8
Upgrade to fontdue 0.8
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-11-29 10:52:27 +01:00
Olivier Goffart
277dce6345 swrenderer: Optimize image rendering
Do the match on the format before the loop
2023-11-18 13:21:11 +01:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
J-P Nurmi
6686861523 SW: fix vertical alignment of elided multiline text 2023-10-11 14:35:20 +02:00
Olivier Goffart
b6636b2e94 swrender: Implement window rotation by 180° and 270°
(The tests are still failling)
2023-10-09 18:07:23 +02:00
Olivier Goffart
ec36d46740 WIP: experiment with screen rotation
TODO:
 - Polish the API
 - Most screenshot test are failling because the rotation don't draw the
   rounded rectangle exactly the same (that's because the border
   rectangle algo is not perfect), and also scaled image are not pixel
   perfect

The updated screenshot is because of a small change in the image
rendering algorithm that changes the rounding slightly.
2023-10-09 18:07: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
Simon Hausmann
cd0056ca92 Make it easier to use the software renderer with PremultipliedRgbaColor and Rgb565 in "foreign" environments
Implement rgb::Pod/rgb::Zeroable for PremultipliedRgbaColor and Rgb565
Pixel. This allows for bytemuck::cast_slice(), making it easier to copy
software renderer output into another buffer that's the same format but
Vec<u8> for example.
2023-08-07 11:46:43 +02:00
Olivier Goffart
3a807e46c1
Renderer feature refactor 2023-07-27 19:11:24 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00