Commit graph

180 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
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
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
Olivier Goffart
0a2144bbc3 swrenderer: Fix panic when scaling an image so much that it cannot be seen
Fixes #8230
2025-04-22 16:01:48 +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
Sam Cristall
c4a4913ce5 Experimental Software Renderer: fix texture offset for partial draws when hwaccel 2025-03-31 14:46:21 +02:00
Simon Hausmann
7a25256050 Fix wrong rect being used for target pixel buffer calls 2025-03-31 14:46:21 +02:00
Simon Hausmann
a5bc428509 Fix TargetPixelBuffer functions being called with regions not clipped against the dirty region
This got lost in the rebase/squash session of https://github.com/slint-ui/slint/pull/7685
2025-03-31 14:46:21 +02:00
Olivier Goffart
36a89aeff8 Software renderer: fix drawing background of rotated screen
We need to draw the background over the rotated rectangle otherwise we
don't fill the whole background.

Regression from https://github.com/slint-ui/slint/pull/7685

(also cleanup a useless blend that was leftover from the same change)

Adapt the screenshot test to have at least one non-square "window" so
that we catch the problem in the future
2025-03-06 00:09:35 +01:00
Simon Hausmann
bd80829a44 Clean up and speed up rectangle fill fallback
Match on the composition mode only once per call and compute the fill color only once.
2025-02-24 17:02:10 +01:00
Simon Hausmann
16dce125ca Simplify y range iteration 2025-02-24 17:02:10 +01:00
Simon Hausmann
b6721e172a Simplify foreach_ranges by re-using foreach_region 2025-02-24 17:02:10 +01:00
Simon Hausmann
aced301f4d Simplify RenderToBuffer declaration 2025-02-24 17:02:10 +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
247074b5e7 Simplify accelerated texture and rectangle fills
There's no need to split the areas to span lines.
2025-02-24 17:02:10 +01:00
Simon Hausmann
5518720391 Fix docs about fixed point format for source texture offsets 2025-02-24 17:02:10 +01:00
Simon Hausmann
9e515710ed Expose screen rotation in the TargetPixelBuffer's draw_texture as integral angle 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
Sam Cristall
491cb2f911 Add span_y to draw_texture to fix partial texture draws 2025-02-24 17:02:10 +01:00
Sam Cristall
3855cf6b9c Add draw_texture/process_texture and use accelerated fill_rectangle for background draw 2025-02-24 17:02:10 +01:00
Simon Hausmann
543ed39058 WIP: Add plumbing for acceleration pixel blending operations on target buffers in a synchronous way 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
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
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
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
Olivier Goffart
ff8aff6ab4 swrenderer: Fix drawing of tiled svg
This fixes drawing the background of the live preview with the software
renderer.

The problem was that when a svg image is tiled (and the svg is not
pre-rendered), we would render the svg in a duffer the size of the
target. But that's not the size at which it should be rendered as it is
going to be tiled over this surface.

Too big images are not supported by the software renderer, it would
panic in overflows in diverse places. So this also fixes panics
2024-12-05 16:57:54 +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
9683b67576 swrenderer: intersect the dirty region with the screen rectangle
When rounded out, the dirty region might end up bigger than the size
of the screen, which would then result in panic while trying to draw a
pixel out of the screen.

Fixes #6932
2024-11-28 17:35:26 +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
Olivier Goffart
f8f6282a05 swrenderer: Fix drawing of clipped VectorFont
That code was touched recently while doing the signed distance field
rendering. The offset is now within the source rectangle.
So the SharedBufferCommand's source_rect must include the whole pixmap.

Unfortunately, VectorFont are not covered by the screenshot tests
2024-11-13 22:14: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
7b1e8b4e12 Fix division by zero in distance field rendering
if the width or hight is one pixel, then the delta don't matter since we
will just draw one pixel anyway
2024-10-29 15:54:48 +01:00
Olivier Goffart
1340a4902e
swrenderer: Always use an offset in the image when rednering glyphs (#6673)
Instead of using the trick of taking a sub-slice and pretending the
image was smaller than it is.
Then this is more uniform with all the other rendering path.
And this should prevent the panic in #6643

Fixes #6643
2024-10-28 14:37:00 +01:00
Olivier Goffart
9e2576bc5c swrenderer: Small fixup in distance field
- include the ' ' char that doesn't have a bounding box but need to be
   included for the advance_x
 - Fix an off by one in rendering where the last pixel was missing
2024-10-24 08:12:13 +02: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
Olivier Goffart
d7e76c36cb Software renderer: Don't panic when rotation is used
Instead, just ignore the rotation.

(Rotation is currently used in the live-preview to show the collapsed
items. It shouldn't cause a panic even if rotation is not showning)

CC: #3068
2024-10-07 12:25:40 +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
256ff1a5f5 software renderer: PhysicalRegion::iter to be non-overlapping rectangles 2024-07-10 10:58:27 +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