Commit graph

668 commits

Author SHA1 Message Date
Olivier Goffart
715090c8f6 MCU: remove the Devices trait and all common code 2022-08-24 14:58:08 +02:00
Olivier Goffart
348fae8672 MCU: port the STM32h to the PlatformAbstraction API 2022-08-24 14:58:08 +02:00
Olivier Goffart
ec85ea777d Pico: Get rid of the thread_local WINDOW 2022-08-24 14:58:08 +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
9b6188b3d7 MCU: remove the simulator
Now that the winit backend can do software rendering
2022-08-23 14:45:49 +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
4edd0b27c1 Janitor: Some code reformating 2022-08-22 14:41:50 +02:00
Olivier Goffart
ecd80059c3 Use new timer api in winit backend 2022-08-22 14:41:50 +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
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
Olivier Goffart
f7ed7cc3fc Fix crash in Qt backend
we were casting to the wrong type
2022-08-19 15:07:27 +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
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
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
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
c900b2f604 winit backend: use the Window::set_size form the resize event 2022-08-18 09:39:25 +02:00
Olivier Goffart
02c60e5389 Refactor the way the backend sets the window size 2022-08-18 09:39:25 +02:00
Olivier Goffart
d56a33cc53 Pico: don't go to sleep after a touch event
Regression introduced in commit 0b06f97cfb
(there was an else)

Otherwise there are noticable delay after a touch as we go to sleep
instead of redrawing
2022-08-17 19:00:34 +02:00
Olivier Goffart
0b06f97cfb pico: handle the pointer event using 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
Simon Hausmann
a134b7e7a1 Remove support for scale factor in the pico backend
This is is not really working anyway and relies on private API. The constant optimization could be
done perhaps as an option in the sw
renderer later, if it's still worth it.

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-08-17 12:38:04 +02:00
Simon Hausmann
6dc86ae4fc Move the NEEDS_REDRAW global into PicoWindow
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-08-17 12:38:04 +02:00
Olivier Goffart
962af55fbe MCU: port the PICO code to use the Backend trait directly 2022-08-17 10:17:35 +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
Olivier Goffart
ff1400ab6b Skia: Fix drawing of images with source clip, but no colorize
Colorize property with transparent value means no coloration is applied

CC #1445
2022-08-15 12:41:36 +02:00
Simon Hausmann
40ab058b5e Fix build with --all-features on Windows
Remove the renderer-skia-opengl "dev" feature again, as on Windows with a
--all-features build in the CI it'll cause
Skia to be built from source. That's not possible in the CI due to long paths as the skia submodule is checked out.
2022-08-12 16:07:42 +02:00
Simon Hausmann
65acadd14a Add support for rendering with Skia and Direct3D on Windows 2022-08-12 16:07:42 +02:00
Simon Hausmann
cc49ee1824 Add support for rendering with Skia and Metal on macOS
Fixes #1470
2022-08-12 08:17:03 +02:00
Simon Hausmann
7b50e38e53 Skia: Implement rotation support 2022-08-11 13:32:40 +02:00
Simon Hausmann
3b9309a0dd Skia: Simplify OpenGL setup
Avoid re-creating a glow context every time we resize the context/window. Instead query
framebuffer info once (it's 0 anyway...) and keep it around.
2022-08-10 17:02:15 +02:00
Simon Hausmann
48b7054254 winit: simplify shutdown logic
Remove release_graphics_resources() as it's always connected to dropping
the entire renderer's canvas. That one in turn is already prepared, i.e.
for femtovg it makes sure that the context is current.
2022-08-10 17:02:15 +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
6a1bc23321 winit: Clean up rendering notifier handling
Move the rendering notifier into the Renderer. This duplicates a little bit of code, but it

   (1) Allows for avoiding the flush of femtovg/skia if no rendering notifier is
   registered
   (2) Paves the way of gracefully handling the situation where the renderer doesn't support this yet
2022-08-10 13:07:07 +02:00
Simon Hausmann
7314fa0953 Attempt to clarify the reasoning behind windows_with_pending_property_updates 2022-08-10 11:34:30 +02:00
Simon Hausmann
6209af1c9a Remove unnecessary into_iter() call on the Vec's drain 2022-08-10 11:34:30 +02:00
Simon Hausmann
6446a28fd6 winit: fix jitter on macos again when resizing windows
Commit 0ee361d994 regressed on
https://github.com/slint-ui/slint/issues/1269 as the inner_size()
returned at the time during event processing is already the future
value, that will change again when processing the resize event.

Instead of storing the last received value, process the event at the
appropriate MainEventsCleared stage.
2022-08-10 11:34:30 +02:00
Simon Hausmann
9ec6fdc18a winit: fix error messages in console when resizing a window
Make sure the glutin context is current before calling resize.
2022-08-10 09:44:07 +02:00
Simon Hausmann
f4ddfa5ef6 winit: separate rendering from surface resizing
Resize the glutin context when we receive a resize event from winit.
This is the approach recommended by glutin/winit's documentation.

This approach also avoids jitter when rendering with metal (not
implemented yet, but tested locally :)
2022-08-09 16:20:53 +02:00