Commit graph

34 commits

Author SHA1 Message Date
Jocelyn Turcotte
041238708f wasm: Prevent wasted redraws with multiple post_events
The previous approach of calling send_event on a timer has the disadvantage
or re-entering the event loop for every queued event. Any requested redraw
after one of those events will end up actually drawing, even if that frame could be
replaced by the next event's redraw without being shown to the user.

winit also doesn't expose publicly its web Runner send_events method that would
allow us to queue the events outside and pass them all together.

We can however queue the events inside winit by putting the event loop in
ControlFlow::Poll mode so that winit batches them itself.
This has the side effect of processing and painting those events using
requestAnimationFrame.

To achieve this we take advantage of winit processing send_event calls
synchronously, possibly while on a native event handler, by entering the
event loop just to send WakeEventLoopWorkaround, set the event loop in
Poll mode, exit, and call send_events again with our event which then
ends up being queue in the web event loop's Runner until the next animation
frame where all queued events are processed and redrawn together.
2022-05-16 11:02:28 +02:00
Simon Hausmann
eb3ceb54bd janitor: Move the GL renderer into a separate module 2022-04-20 17:41:53 +02:00
Simon Hausmann
063a292327 GL backend: add shortcut for zero opacity
If the global opacity is zero, we don't need to paint rectangles, etc.

This shortcut is a compromise between opting out much later on femtovg
level and too early before querying properties of the rectangle.  We
still want to do the latter as somebody might depend on that.
2022-04-07 11:37:51 +02:00
Simon Hausmann
d29f834e57 GL backend: minor optimization for image rendering
When colorizing or drawing images, it's not necessary to apply the extra edge anti-aliasing.
2022-04-06 11:33:18 +02:00
Simon Hausmann
6116bcb35d Minor memory usage optimization for clip layers in the GL backend
If a clipped rectangle transitions from having a border radius to none, then we can
delete the clip layer.
2022-04-06 11:32:57 +02:00
Simon Hausmann
f836322ca1 Speed up rendering of clip elements
When a clip element is enabled and it does not intersect with the current clip region,
then we don't even have to bother rendering any child elements.
2022-04-06 11:32:44 +02:00
Simon Hausmann
e06e99a4b9 GL backend: avoid triangle strip for stroke when filling plain rectangles
Similar to commit a329f052ea, we can apply the same
optimization to rectangles.
2022-04-06 11:32:23 +02:00
Simon Hausmann
a329f052ea GL backend: avoid stroke when blitting textures
When blitting a rectangular texture, we can disable the anti-aliasing on the edges
that femtovg applies by default. That avoids an extra triangle strip for
this stroke to apply anti-aliasing.
2022-04-01 13:32:25 +02:00
Simon Hausmann
033cf3721e Improve performance of opacity rendering
Avoid an opacity layer also in the case where it is applied to an element with no children.
2022-03-25 10:50:02 +01:00
Simon Hausmann
d6a569b8f8 Make rendering_metrics_collector a public module
... instead of pulling it entirely into the graphics module.
2022-03-24 21:20:28 +01:00
Simon Hausmann
f3b1ba6717 Collect statistics about the number of layers created in the GL and Qt renderer 2022-03-24 21:20:28 +01:00
Simon Hausmann
e719357ffa janitor: Remove unnecessary clone 2022-03-24 09:10:29 +01:00
Simon Hausmann
caca532ada Released unused opacity layers 2022-03-23 17:37:27 +01:00
Simon Hausmann
4799ac9ce8 Don't create layers for opacity if it's not needed
More could be done towards this, but after literally seeing `opacity: 1;` in
.slint files, this seems worth doing.
2022-03-23 17:37:27 +01:00
Olivier Goffart
e017d5118b Wasm GL backend: use a <input> element so it show the keyboard on mobile
cc #215

Handle Input event from the input directly instead of going through winit
for the TextInput.

Note that this doesn't handle the composition event well, so the text is
only considered written when it is accepted
2022-03-22 13:33:31 +01:00
Simon Hausmann
bef31d3169 Rename the layer boolean property to cache-rendering-hit 2022-03-21 20:22:43 +01:00
Simon Hausmann
849282a5a8 Don't render with layers if the layer property is false 2022-03-21 20:22:43 +01:00
Simon Hausmann
158cbfc68e Implement the layer hint for the GL backend 2022-03-21 20:22:43 +01:00
Simon Hausmann
d97710f3f9 Implement correct opacity for the GL backend
This also separates the blend-to-screen part of render_layer into a
helper function, as that will be useful in the future with public layer
elements.

Relates to #725
2022-03-18 16:35:26 +01:00
Simon Hausmann
91b3765e97 Improve method naming in ItemRenderer
Use `visit_` for the pattern where the trait offers a default implementation that calls other
methods to do the actual work.
2022-03-18 15:42:49 +01:00
Simon Hausmann
f04f0a3e48 GL backend: use direct layers for non-rectangular clips
Delegate the decision how to implement the Clip element entirely into the backend,
where the GL backend can now explicitly render
children into a layer, instead of the hack with a layer in the renderer's
state and the extra save/restore pair.
2022-03-18 15:42:49 +01:00
Simon Hausmann
6a6a26569d Add support for rendering complex clip paths into cached layers
If the renderer supports it, clip elements with a complex clip render
the sub-tree into a cached layer.
2022-03-18 15:42:49 +01:00
Simon Hausmann
1a48cecf4f Clean path bounding box handling
Centralize the femtovg path bbox workaround in a helper function.
2022-03-18 15:42:49 +01:00
Olivier Goffart
a85482e5a4 Fix selection and clicking on password fields 2022-03-02 21:55:49 +01:00
Olivier Goffart
70bc75c267 Use a better character for the password replacement char
Also don't use the byte len, but the char length.
It's not entierly correct, but it's good enough
2022-03-02 21:55:49 +01:00
Jared Moulton
b884a4ca19 Fix CI issues, remove references to replace-char, add a test, fix creation of string 2022-03-02 15:47:32 +01:00
Jared Moulton
fdbc8056b3 Add an option to draw *'s instead of characters for password fields 2022-03-02 15:47:32 +01:00
n-raine
beda5aca07 Add dark style detection support for GL backend
With the help of dark-light crate this is now exposed as dark-style
boolean property in NativeStyleMetrics.

Co-authored-by: Olivier Goffart <olivier@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-03-01 16:41:20 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Olivier Goffart
1425ef63de Change the Url from sixtyfps.io to slint-ui.com
Also, change the URL of the logo in the docs
2022-02-08 08:52:46 +01:00
Tobias Hunger
de4e195280
Rename internal crates and add a README.md to them
The README.md contains the warning that used to be in lib.rs.

Add README.md files to all internal crates

... pointing to the official public crate to use instead.

Rename internal crates

fixup: README files

fixup rename
2022-02-07 13:12:48 +01:00
Tobias Hunger
2b55c488ca
Rename sixtyfps to slint in internal 2022-02-02 16:16:55 +01:00
Simon Hausmann
ad0c020aa4 Rename the sixtyfps-corelib crate 2022-02-01 18:04:30 +01:00
Tobias Hunger
a3b86690ff [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
Renamed from sixtyfps_runtime/rendering_backends/gl/lib.rs (Browse further)