Commit graph

489 commits

Author SHA1 Message Date
Tobias Hunger
10c3c9d16d Api cleanup: Rename some remaining platform abstractions to platform 2022-08-29 16:53:47 +02:00
Tobias Hunger
107e3ed2e2 janitor: Fix some typos 2022-08-29 16:53:47 +02:00
Tobias Hunger
88cf874d03 API cleanup: Rename create_window to create_window_adapter 2022-08-29 16:53:47 +02:00
Tobias Hunger
1e6ffeaa0f API cleanup: Rename PlatformWindow to WindowAdapter 2022-08-29 16:53:47 +02:00
Olivier Goffart
344f5c437b swrenderer: Move the DirtyTracking enum into a const generic
Closes: 1541
2022-08-29 14:13:55 +02:00
Tobias Hunger
53053683a1 API cleanup: Rename PlatformAbstraction to Platform 2022-08-29 13:26:36 +02:00
Tobias Hunger
3557e92a84 API cleanup: Fix typos in comments/documentation 2022-08-29 13:26:36 +02:00
Tobias Hunger
259457eff8 API cleanup: Fix typo in variable name 2022-08-29 13:26:36 +02:00
Tobias Hunger
13701b4b3f API cleanup: Rename set_paltrom_abstraction to set_platform 2022-08-29 13:26:36 +02:00
Olivier Goffart
4f0e2608d2 Sofware renderer: keep a Weak of the Window
Closes #1545

Not that `SoftwareRenderer::new()`  takes the Weak by value instead of
by reference, because coercing a reference to a `Weak` to a `&Weak<dyn>`
is not possible, while converting a Weak to a `Weak<dyn>` just works.
2022-08-29 11:07:05 +02:00
Olivier Goffart
4105bafc2f Fix the doc example of SoftwareRenderer::render_line_by_line
If we don't make it compile, it will have so many typo it's useless :-)
2022-08-27 15:05:06 +02:00
Olivier Goffart
d1e3ce4acf Tests for the timers
Tests that timer fires, but also that stopping them within a timer event work
(Test for #1532 and #1533)
2022-08-26 10:16:18 +02:00
tay64
0b1be0316e Fix #1532: Timer::{start,stop} in the timer's own callback
Before the change:

- calling the_timer.start(...) in the_timer's callback resulted in the_timer
keeping the old callback;

- calling the_timer.stop() in the_timer's callback was ignored.
2022-08-26 09:19:10 +02:00
Olivier Goffart
8fba65a282 Rename and expose the unsafe-single-threaded feature 2022-08-25 16:47:53 +02:00
Simon Hausmann
4864bda404 swrenderer: group pub use together 2022-08-25 12:54:52 +02:00
Simon Hausmann
f239f810c8 Remove the use of i_slint_core in the pico and stm32 bsp modules 2022-08-25 12:54:52 +02:00
Olivier Goffart
2ad648ac66 swrenderer: Do not draw the inside of rounder rectangle if it is transparent
No need to blend a slice of transparent color
2022-08-25 12:37:05 +02:00
Olivier Goffart
ab4ce29749 Add a Rgb565Pixel
So we don't have to depend on embedded_graphics just for that
2022-08-25 12:37:05 +02:00
Olivier Goffart
42eb7432de janitor: Move unsafe_single_core module to a file 2022-08-25 10:24:51 +02:00
Olivier Goffart
13c9c3bbab Re-export the platform module as public api in slint::platform
Tweek some documentation
2022-08-24 14:28:51 +02:00
Olivier Goffart
dbd9f00c71 Don't call invoke_from_event_loop in doctests
The test backend can no longer support this.

Because Tests might be called from different thread and the backend with
an event loop can only be set on one thread. So the test backend can't
implement new_event_loop_proxy()
2022-08-24 11:32:21 +02:00
Olivier Goffart
c14e2d41d8 Rename PlatformAbstraction::event_loop_proxy to new_event_loop_proxy 2022-08-24 11:32:21 +02:00
Olivier Goffart
7417422e3c Make the PlatformAbstraction not Send using a EventLoopProxy trait
This changes the way the platform abstraction is initialized
2022-08-24 11:32:21 +02:00
Olivier Goffart
2e5ab86bea Rename backend module to platform
and the Backend trait into PlatfromAbstraction trait
2022-08-23 19:39:49 +02:00
Simon Hausmann
1a8a295e38 Skia/FemtoVG: implement re-use of box shadow textures
When using box shadows in repeaters, we end up creating multiple
distinct textures of the drop shadow. That's a waste of precious texture
memory if they have the same properties.

Instead, when creating box shadows in a frame, see if they can be
re-used across images.  The texture still persistent in the image_cache,
via the explicitly shared skia_safe::Image and Rc<Texture>.

This works well when rendering repeated elements new top-down, but it's
not perfect.  For example if a bunch of repeated elements are in a
flickable, only a portion of them are visible and the view is scroll up,
then the top-down rendering will not find a cache hit for the newly
visible element with drop shadows. Yet this is simple enough to help
with sharing in many cases.
2022-08-23 15:27:34 +02:00
Olivier Goffart
398eb68b9e swrenderer textlayout: fix panic when max_with is 0
Because a single glyph wouldn't fit on a line, it would loop forever
2022-08-23 08:19:25 +02:00
Olivier Goffart
a27806aca8 Add a feature to use the sofware renderer with the winit backend
Currently, you still need to pass some env variable at build time so it
embeds the font.
2022-08-22 19:02:28 +02:00
Olivier Goffart
a326844948 Move the has_active_animation to the window 2022-08-22 14:41:50 +02:00
Olivier Goffart
00e9fcc9dd backend API: polish and move the timer functions to the backend module 2022-08-22 14:41:50 +02:00
Olivier Goffart
2dddce7536 Update atomic-polyfill
Since the new version also depends on the ctirical-section 1.0 crate
we need to enable the relevant API in the cortex-m crate because the
rp2040-hal doesn't have it yet
2022-08-22 13:16:30 +02:00
Olivier Goffart
243df1ed54 Rename blend_buffer to blend_slice 2022-08-22 09:52:56 +02:00
Olivier Goffart
228e2d9a7e Some polishing of the TargetPixel trait 2022-08-22 09:52:56 +02:00
Olivier Goffart
1eb330d1d3 Some documentation for the line renderer 2022-08-19 17:58:05 +02:00
Olivier Goffart
339f2d2656 swrenderer: Use PhysicalLength as the range type 2022-08-19 17:58:05 +02:00
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
1d436778c1 Remove the use of the PlatformWindowRc alias again
and use Rc<dyn PlatformWindow> instead. The alias has to stay with the ffi
functions though and the item vtable definitions,
because we don't have an Rc<> template in C++.
2022-08-19 15:07:27 +02:00
Simon Hausmann
74289deb25 Remove the PlatformWindowWeak alias
... and use Weak<dyn PlatformWindow> directly.
2022-08-19 15:07:27 +02:00
Simon Hausmann
98e1befd0d Port the C++ generator and C++ API to the new window ownership model
One key difference to the Rust way is what `slint::Window` means. In
Rust that holds the `WindowInner` and `slint::Window` is only exposed as
`&slint::Window`. This is possible because the component owns the
`Rc<dyn PlatformWindow>`, which has a function to return the
`&slint::Window`.

In C++ `slint::Window` is also exposed as `slint::Window&` in the
`window()` getter, but there's no way to get a reference to a  C++
wrapper for the Rust `&slint::Window` that the `PlatformWindow` trait
returns. Therefore in C++ `slint::Window` wraps `Rc<dyn
PlatformWindow>`.
2022-08-19 15:07:27 +02:00
Simon Hausmann
fd026a3991 Change itemtable to use &PlatformWindowRc instead of &WindowInner
The former is cbindgen friendly, the latter is entirely Rust internal.
2022-08-19 15:07:27 +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
Simon Hausmann
f88b688fbf Simplify PlatformWindow receivers
For hide() we don't really need Rc<Self>, and for show() we had Rc<Self> because
for example for winit we need a Weak<Self> for the thread-local mapping of
window id to window.

However that can be encapsulated in the PlatformWindow impl using Rc::new_cyclic,
there's no need to expose this in the trait.
2022-08-19 15:07:27 +02:00
Simon Hausmann
e48034d580 Simplify window property and redraw trackers
Store a platform window directly.
2022-08-19 15:07:27 +02:00
Simon Hausmann
3e42ae9838 Replace three more uses of WindowRc with &WindowInner 2022-08-19 15:07:27 +02:00
Simon Hausmann
427cac772b Begin moving the interpreter from WindowRc to &WindowInner 2022-08-19 15:07:27 +02:00
Simon Hausmann
b0b8d8d899 Change the Item vtable to take a &WindowInner instead of &WindowRc
... in preparation for storing an Rc<dyn PlatformWindow> in the component.

This won't compile with C++ yet.
2022-08-19 15:07:27 +02:00
Simon Hausmann
8e84faa2c5 Prepare PlatformWindow API for exposing and (in the future) owning the Window
Move the self_weak of WindowInner into the impl of PlatformWindow. Most implementations already have it anyway.

While right now the method returns a `WindowRc`, at the end of the series
it should return a `&Window`.

From that `&Window` we can get to `&WindowInner` and all receivers there
are `&self`.
2022-08-19 15:07:27 +02:00
Simon Hausmann
262c96af8c Simplify receiver for WindowInner
Use &self consistently, instead of Rc<Self>, so that in the future we can
replace Window(Rc<WindowInner>) with Window(WindowInner).
2022-08-19 15:07:27 +02:00
Lukas Jung
a639cb6d8e seperate text deletion code with move_mod 2022-08-19 13:31:24 +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
Olivier Goffart
02c60e5389 Refactor the way the backend sets the window size 2022-08-18 09:39:25 +02:00