Commit graph

1368 commits

Author SHA1 Message Date
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
Olivier Goffart
16985a349d Add dispatch_pointer_event to the public API 2022-08-17 18:28:12 +02:00
Olivier Goffart
a62a5cbd19 Rename MouseEvent pos to position 2022-08-17 18:28:12 +02:00
Olivier Goffart
61739dcb81 Remove the Mouse prefix from enum value of the MouseEvent enum 2022-08-17 18:28:12 +02:00
Olivier Goffart
a1724602e6 Skia: Cache the Skia image in the core image cache
Because re-generating the Skia image is slow and there is no point
storing both the image buffer and the SkiaImage in the cache as it
is basically the same information.
2022-08-16 11:22:11 +02:00
Simon Hausmann
151ea2bdd0 Revert "janitor: move code for backspace and delete key shortcut recognition"
This reverts commit 49ea24c44a. This made
DeleteForward and DeleteBackward dead code because move_mod is always
true. Not worth the refactoring IMO.
2022-08-16 09:49:16 +02:00
Simon Hausmann
cca64bf29f Fix build 2022-08-16 09:47:44 +02:00
Simon Hausmann
49ea24c44a janitor: move code for backspace and delete key shortcut recognition
... into the section that checks move_mod, since the code now depends on it.
2022-08-16 09:35:57 +02:00
Simon Hausmann
81ca8f54c2
Add missing shortcuts for delete word forward and backwards (#1483)
* Add missing shortcuts for delete word forward and backwards

Fixes #1467
2022-08-16 08:24:56 +02:00
Simon Hausmann
686df50e9f Revive support for rotation of elements
The rotation-angle/rotation-origin-x/y properties are lowered to an
injected Rotate element, that we already had.

This needs further fixes for transforming input events and an
implementation of rotation in Skia.
2022-08-11 10:34:41 +02:00
Simon Hausmann
b0697352a1 Fix no_std build 2022-08-10 13:07:07 +02:00
Simon Hausmann
351a1b6448 Move set_rendering_notifier from the (to be public) PlatformWindow to the (private) Renderer trait 2022-08-10 13:07:07 +02:00
Simon Hausmann
0ee361d994 winit: Remove unused existing_size field
This field duplicates the winit window's inner size. It is set on a
WindowEvent::Resized(), after which
`winit:🪟:Window::inner_size()` returns the same value.
2022-08-09 13:16:52 +02:00
Simon Hausmann
fa956aca2d janitor: Fix nightly doc warnings about unused parentheses 2022-08-05 09:25:31 +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
Simon Hausmann
27bf9348e6 Rename the backend-gl crate into backend-winit 2022-07-26 17:43:51 +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
793974ce9f Make just one function to fire both timers and animations
Also simplify the Qt backend since only the paint event will
query the animated properties that should then cause a refresh
one frame later
2022-07-26 15:13:07 +02:00
Simon Hausmann
df99b95a0b Don't export DEFAULT_FONT_SIZE into slint_internal.h 2022-07-26 11:21:40 +02:00
Simon Hausmann
fe3d4b7177 Bump MSRV to 1.60 2022-07-26 09:20:52 +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