Commit graph

504 commits

Author SHA1 Message Date
Olivier Goffart
594131a7ea winit: Enforce the min/max size in the WindowBuilder and set size again for wasm
In previous version, we were setting the constraint with wasm after
the window was shown, but this is no longer the case because we delay
the window creation by an iteration of the event loop.
Now should apply the constraint before showing the window.

But on wasm, we also must manually enforce these constraint because the
size given to the WindowBuilder is not applied
2022-09-06 14:23:58 +02:00
ogoffart
05a49da906 Bump version number to 0.3.0 2022-09-06 13:00:22 +02:00
Simon Hausmann
5fe212f459 Make sure that skia_backend_opengl is always set on Linux 2022-09-05 14:07:27 +02:00
Simon Hausmann
3a1817de3f Skia: Make it possible to explicitly select the OpenGL backend of Skia
When opting into the Skia renderer, we default to metal on macOS and D3D on Windows.
However if you want to develop a cross-platform application with Skia and
for example rely on OpenGL to be able to implement an OpenGL underlay or overlay,
then we need the ability to explicitly opt into skia's GL renderer.

cc #1445
2022-09-05 14:07:27 +02:00
Simon Hausmann
3ebdb1b86d Add debug info about the Skia back buffer color depths
Include the number of bits per pixel in the existing output
2022-09-05 13:53:04 +02:00
Simon Hausmann
7323e0b93d Bump Skia version to 0.54
This release upgrades to Skia milestone 105 and  includes binaries for
the new windows-textlayout-d3d-opengl configuration that is available as
opt-in.
2022-09-05 11:27:30 +02:00
Olivier Goffart
3f1324cc61 Allow to run the software backend without the femtovg backend 2022-09-02 16:38:35 +02:00
Simon Hausmann
7e5de3d5d3 Remove use of euclid types and tags for logical/physical position and size in the public API
Instead provide our own types.
2022-09-02 11:05:53 +02:00
Simon Hausmann
85461d380d Remove euclid from the public re-export of the Slint crate 2022-09-02 11:05:53 +02:00
Olivier Goffart
e0f1fdf298 Rgb565Pixel: remove color accessor, add conversion to Rgb8Pixel
Closes #1540

(Went or Rgb8Pixel instead of color, because color can have alpha)
2022-09-01 13:58:38 +02:00
Olivier Goffart
fcca38e0f6 Rename set_event_loop_quit_on_last_window_closed to remove EventLoopQuitBehavior
For the winit backend, also make the function work after a call to run()
2022-09-01 12:08:05 +02:00
Simon Hausmann
c1dbf47d15 Fix appearance of drop shadows with Skia
Similar to commit 957186acb7 we need to take the blur into account in the box shadow image:

We add blur margins around the entire image, but we also need to start drawing at (blur, blur) instead of (0, 0).
The same offset needs to be subtracted again when drawing the cached image.
2022-08-31 11:36:04 +02:00
Simon Hausmann
7fd0af8b63 Fix box shadow not rendering correctly when using scale factors != 1
Despite the blur being an abstract float, in reality in femtovg as well
as Skia it's a pixel radius. Commit
1a8a295e38 removed the scaling to physical
pixels, which was wrong.  This restores it and along with it the same
appearance as before.
2022-08-31 11:36:04 +02:00
Simon Hausmann
9338d31535 Remove the use of euclid types from the software renderer public API
Closes #1538
2022-08-31 09:23:38 +02:00
Olivier Goffart
b9c2dec922 API: seal the WindowAdaptor trait
And hide most of its functions in the sealed trait.
2022-08-30 22:21:24 +02:00
Simon Hausmann
0fe29cd196 Fix preview in online editor not updating when making changes
Creating a new window requires access to an event loop instance. The
winit upgrade prevents us from creating multiple EventLoop instances.
Therefore we have to re-use the existing event loop instance, which is
only accessible from within the event handler.
2022-08-30 16:56:27 +02:00
Tobias Hunger
3430a13bf8 API cleanup: Remove quit behavior parameter from run_event_loop 2022-08-30 08:34:45 +02:00
Tobias Hunger
38350db9a0 Fixes pointed out by Olivier and CI 2022-08-29 16:53:47 +02:00
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
13701b4b3f API cleanup: Rename set_paltrom_abstraction to set_platform 2022-08-29 13:26:36 +02:00
Olivier Goffart
1eaa4e1517 winit with swrenderer: don't call window.draw_contents twice.
The render function of the swrendrer already call that.
2022-08-29 11:42:10 +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
f271ebbf21 Add an env variable to test the line by line renderer
This also test the 16 bit mode on the desktop
2022-08-27 15:05:06 +02:00
Simon Hausmann
4014ff8517 Revert "winit: Simplify GL context creation"
This reverts commit 7f2868b5a0.

This is still causing issues on Windows, as reported by tay64 on
Mattermost. This is a box (no vmware) with an ATI driver.

    Vendor: ATI Technologies Inc.
    Version: 4.6.14761 Core Profile Forward-Compatible Context 21.30.23.04 30.0.13023.4001
2022-08-26 16:49:10 +02:00
Simon Hausmann
e24ceb490f winit: Fix panic when shutting down event loop
If we (or the user) ends up calling hide() on a window after returning from the event loop, our
attempt at posting an event would panic in winit as we
try to create a new event loop instances.

Since Winit 0.27 a panic is raised when creating an event loop instance a second time.
2022-08-25 16:49:59 +02:00
Simon Hausmann
7f2868b5a0 winit: Simplify GL context creation
The bug in glutin for creating the GLES context has been fixed, so we can remove the workaround.
2022-08-25 16:49:59 +02:00
Simon Hausmann
be7947a321 Update winit and glutin 2022-08-25 16:49:59 +02:00
Simon Hausmann
a116f58b0c Decouple our femtovg dependency from glutin
This will allow updating glutin without femtovg
2022-08-25 16:49:59 +02:00
Simon Hausmann
94d5444105 Remove swrenderer feature dependency on i_slint_core from mcu bsp crate
Let `renderer-software` enable the API in `slint::platform::swrenderer` and optionally toggle winit support.
2022-08-25 12:54:52 +02:00
Simon Hausmann
d90b503a1c Move the mcu backend to become a board support helper crate for examples 2022-08-25 12:54:52 +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
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