Commit graph

27 commits

Author SHA1 Message Date
Olivier Goffart
d582fbce31 Make the LineBufferProvider buffer be only the dirty part of the line
It used to be the whole line, but it is safer to only operate on the
part of the line which will actually be updated.
2022-08-19 17:58:05 +02:00
Simon Hausmann
af86f36157 Invert slint:🪟:WindowInner and PlatformWindow ownership
Previously: Window is an Rc<WindowInner>, which has an Rc<dyn
PLatformWindow> - and weak references the other way around.

Now: Rc<dyn PlatformWindow> is the root of window ownership. The impl
PlatformWindow has a slint::api::Window, which just holds a WindowInner.

This change is incomplete on a few levels, mainly that neither of the
code generators nor the interpreter is ported.
2022-08-19 15:07:27 +02:00
Olivier Goffart
956d24dfdc
swrenderer: Remove the DirtyRegion from the API (#1501)
Instead, put the dirty buffer handling from the previous frame directly
in the SoftwareRenderer
2022-08-19 09:07:02 +02:00
Simon Hausmann
086880f605 Speed up rendering of clipped children
When the renderer does not re-implement visit_clip, we call combine_clip.
Then we're missing out on an optimization the GL renderer does: When the resulting clip region
is empty, we do not need to recurse into children for rendering.

That itself reduces the property dependency chain and avoids unnecessary
updates when invisible (clipped) children change properties.
2022-08-02 11:07:46 +02:00
Olivier Goffart
f6072639d1 Sotfware renderer: Add support for ImageInner::EmbeddedImage
If we want to use the software renderer as a drop in replacement
for the GL renderer, we need to be able to render all images
without the compiler having to pre-render the textures

This was tested by hacking the compiler not to render the texture
with the mcu simulator
2022-07-27 08:31:37 +02:00
Olivier Goffart
8c70cd7f57
Move the fonts out of the Backend trait (#1438)
and remove the `'static`
2022-07-26 16:45:54 +02:00
Olivier Goffart
20d5cb72ed Move the init_dirty_region dirrectly into the Renderer
This means we will query the size of the popup also for the GL backend
even if the backend don't need to be marked dirty, but that should be
alright.
2022-07-25 17:53:15 +02:00
Olivier Goffart
f7637b521f More PlatformWindow trait simplification: Component registation optional
Forward the free graphics resource to the renderer by default
2022-07-25 12:04:34 +02:00
Olivier Goffart
74c041010e Move the text functions out of the Window, into the Renderer trait 2022-07-25 12:04:34 +02:00
Simon Hausmann
f0faa8aaca Simplify code reading properties from the Window item
Use the new getter in WindowInner.
2022-07-23 13:25:44 +02:00
Simon Hausmann
0ab71ec503 Perform resolution of font properties against the window defaults in the core library
This simplifies the renderer handling - the FontRequest arriving there
will always be resolved.

And this reduces the amount of property dependencies: If a Text elements
specifies a font-family, no dependency to the window's
default-font-family is created.
2022-07-22 23:09:08 +02:00
Olivier Goffart
9794a4dfad Simplification of the PlatformWindow trait 2022-07-22 18:12:00 +02:00
Olivier Goffart
c2fe06d82d Use the public api::Window for the interface of the software renderer 2022-07-22 18:12:00 +02:00
Olivier Goffart
29404e3f2c Rename i_slint_core:🪟:Window into WindowInner
We already have `api::Window` and also the Window element (`WindowItem`),
So rename the inner part to avoid confusion
2022-07-22 18:12:00 +02:00
Olivier Goffart
ac4f3e97ad Change slint enum values to be PascalCase in rust
... while still being kebab-case in .slint

Some enums might become public API and we want to have them as
PascalCase to respect the rust conventions
2022-07-22 12:23:52 +02:00
Simon Hausmann
67a2f0ce3f WIP: Make image decoding a feature of the core library
This includes the cache of decoded images, the HTMLImage element support
and the SVG rendering adapter.

The objective is that Image holds an ImageInner, which is not a path
anymore that the backend has to process, but instead always either
decoded image data, a pointer to a static texture or an SVG tree that
can be rendered to the desired size.
2022-07-20 12:57:37 +02:00
Simon Hausmann
9799571396 Make it possible to implement the ItemRenderer trait with a lifetime
The as_any() method returning a `&mut dyn Any` meant that the type has to be
'static. The class solution of returning &()
doesn't work because it has to be a mutable ref. Therefore just return an Option.
2022-07-12 20:37:14 +02:00
Olivier Goffart
4ecc2cd1c0 swrenderer: add a renderer that operate dirrectly on the frame buffer 2022-07-06 17:06:40 +02:00
Olivier Goffart
1b551504a2 swrenderer: Refactor so that we can add a BufferRenderer 2022-07-06 17:06:40 +02:00
Simon Hausmann
3a5c4981de Clarify comment about clipping in the sw renderer's text drawing 2022-06-17 12:59:48 +02:00
Simon Hausmann
27dc1ec1a6 Fix build with --cfg slint_int_coord 2022-06-17 12:59:48 +02:00
Simon Hausmann
2903b1814c swrenderer: clip glyphs to the text element's geometry
This ensures that the partial renderer updates correctly and this also
fixes a panic in the printer demo on the stm32h7 when opening the format
combobox in the scan page:

We would attempt to render the word "JPEG" with a font size of 12 pixels.
The letter J has a height of 12 pixels, like the font ascender reported, but it's
y coordinate is negative.
That would also result in a negative text item relative origin for the glyph (target
rect in physical pixels),
which fails to convert to an usize and panics.
2022-06-17 12:59:48 +02:00
Olivier Goffart
711fa66ca3 rp2040 backend: use DMA to send pixels to the screen via SPI 2022-06-17 09:30:09 +02:00
Olivier Goffart
014c827194 swrenderer: Optimize image drawing by using premultiplied colors 2022-06-14 11:23:02 +02:00
Simon Hausmann
2d2eb70b51 Fix panic about multiple mutable borrows with the software renderer
When using repeaters - like in the slide puzzle - and during renderer a component
gets deleted, we call free_graphics_resources and try to free
the dirty rectangle list in the partial renderer cache. At that point the cache is
already mutably borrowed, which causes a panic.

As remedy, apply the mutable borrow more fine grained and not right when calling
render().
2022-06-10 08:38:34 +02:00
Olivier Goffart
dc7117eeb1 swrenderer: move some computation outside of loop 2022-06-08 16:36:46 +02:00
Olivier Goffart
a72115518d Move the software renderer to core 2022-06-04 13:40:50 +02:00
Renamed from internal/backends/mcu/renderer.rs (Browse further)