Commit graph

1507 commits

Author SHA1 Message Date
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
5fb41f92d1
Update MCU readme a little 2022-03-23 11:15:44 +01:00
Olivier Goffart
b259656f4c Wasm: fix dead keys on firefox desktop
We don't want to intercept the press of the non dead key when it is composed
with a dead key. Let the input event handle it
2022-03-22 15:35:02 +01:00
Simon Hausmann
e9350403bc Fix animations not running in secondary windows with wasm
When a second canvas is visible, only animations in the first canvas
resulted in updates and visible animation.  An animation in the second
canvas wouldn't result in repaints.

When we start an animation, we request a redraw on all windows and
return with `ControlFlow::Poll` to winit.

Winit then schedules an animation frame request, and in the callback the
redraw request events are delivered. For the first window we call
`update_animations()`, a new tick is detected (different than the
previous one) and animated properties are dirty and yield new windows.

Then right away we get called again with a redraw request for the second
window. update_animations() determines that the instant::now() is the
same, and has_animations() returns false. So at the end of the event
handler we return fail to return `Poll` and therefore no animation frame
request is created, which means the animations just stop.

Fix this by calling update_animations() only once, when all input events
have been processed and the redraw events are up for delivery next.

This is visible in the preview canvases in the documentation, if a
canvas other than the first has animations.
2022-03-22 14:22: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
3a5181d31f Implement the Layer element for the Qt renderer 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
fb20113f17 Fix manual application of the window constraints with the HTML canvas
The size returned by inner_size is a physical size, so we must convert it to
a logical one before comparing it with the logical constraint sizes.
2022-03-21 16:53:30 +01:00
Olivier Goffart
eb9092ba15 MCU: run the timers 2022-03-18 18:51:29 +01:00
Simon Hausmann
a72aa9f799 Implement correct opacity for the Qt backend
Relates to #725
2022-03-18 16:35:26 +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
Simon Hausmann
75949e702c Prepare item rendering for children self-handling
The render function now takes a self_rc and returns a enum that permits
the implementation to handle rendering of children on its own and
thus make the caller skip that traversal step.
2022-03-18 15:42:49 +01:00
Olivier Goffart
ed60dcb6b5 MCU pico: increase heap size
So it doesn't do out of memory with the printerdemo_mcu in normal
usage
2022-03-18 09:33:23 +01:00
Olivier Goffart
8f4df47b1c MCU pico: adjust the touch driver thresholds
The Press and Release threshold where inverted.

Also increase the Flickable threshold because the precision of the
touch screen is too low, and if the threshold is too small, we
can't click on things inside a Flickable
2022-03-18 09:33:16 +01:00
Olivier Goffart
66fa1fcfee
MCU readme: remove the scale factor
The new demo don't need it
2022-03-17 16:04:38 +01:00
Lukas Jung
5495a8a701 add close request handling the qt backend 2022-03-17 08:51:00 +01:00
Lukas Jung
8617e92d65 add close request handling the gl backend 2022-03-17 08:51:00 +01:00
Olivier Goffart
42947b3fe2 MCU renderer: Fix border radius bigger than the item 2022-03-17 07:34:23 +01:00
Olivier Goffart
3e7e575f41 Implement the length traits with generics 2022-03-17 07:34:23 +01:00
Olivier Goffart
8f67b1170c MCU renderer: fix artifact when drawing clipped border rectangle
(It would sometimes miss a couple pixel for small clips otherwise)
2022-03-17 07:34:23 +01:00
Olivier Goffart
8afee6b3ff MCU renderer: implement image-fit 2022-03-17 07:34:23 +01:00
Olivier Goffart
14a8a6faa2 MCU: improve touch driver
- use both z1 and z2 to compute the pressure because these number
   depends on the temperature so we need to use both
 - check the pressure at the end of the reading in case it was
   released when reading
 - have different pressure threshold when the button is already
   pressed so we avoid emitting a release too early
2022-03-16 13:04:42 +01:00
Olivier Goffart
8cae8b9602 MCU: Make the debug show more lines 2022-03-16 13:04:42 +01:00
Olivier Goffart
ed3419ac0e MCU renderer: Fix another rounding error
We need to use round_in() instead of cast() as cast() discard
too much data if both the x position and the width position are 0.5
then we loose one pixel of width
2022-03-16 10:36:17 +01:00
Olivier Goffart
b510c2f7a2 MCU: fix drawing clipped images
The computation of the coordinate was not correct. The coordinate was
turncated in the case of Image. And for Text, the image was drawn smaller
instead of being clipped
2022-03-15 15:15:45 +01:00
Olivier Goffart
b54b9bae61 MCU partial renderer: Actually do not draw items that are not in the dirty region
We computed the clip, but still generated span and even rendered the full
line for items that were meant to be clipped
2022-03-15 09:42:17 +01:00
Olivier Goffart
608211b0d6 MCU: Allow to use RGB565 for the draw buffer 2022-03-14 15:52:09 +01:00
Olivier Goffart
d7c998b649 Remove unused commented code 2022-03-14 11:50:05 +01:00
Olivier Goffart
2260681075 Janitor: bump rp-pico dependency 2022-03-14 11:50:05 +01:00
Olivier Goffart
bcb06e94c9 MCU renderer: fix clipping of rounded rectangle
We need to do the conversion from float to int after doing the
substraction or we might clip too much if the position is not
a round number
2022-03-11 20:39:54 +01:00
Olivier Goffart
b75e9a8cf3 Revert "MCU renderer: Do not call geometry() to avoid creating bindings on x and y"
This reverts commit dea0990fb1.

Otherwise the dirty tracker don't register dependency on x and y
2022-03-11 15:27:47 +01:00
Olivier Goffart
dca597b9f1 MCU renderer: skip empty text early 2022-03-11 14:53:19 +01:00
Olivier Goffart
8038f6e6ea MCU: don't draw clipped text 2022-03-11 14:53:19 +01:00
Olivier Goffart
dea0990fb1 MCU renderer: Do not call geometry() to avoid creating bindings on x and y 2022-03-11 14:53:19 +01:00
Olivier Goffart
ee3d375c12 MCU renderer: add performence counter for the dirty items 2022-03-11 14:53:19 +01:00
Olivier Goffart
cbed63f60d MCU renderer: optimize the line processing step
Do all the things in-place so we do not need to allocate
2022-03-11 12:39:09 +01:00
Simon Hausmann
2e7f6f55a2 Adapt to simplier line layout callback signature 2022-03-10 10:51:32 +01:00
Simon Hausmann
7faabdbbbc Adapt to changed text line layout API 2022-03-10 10:51:32 +01:00
Simon Hausmann
525d24fc49 Prospective build fix
Remove unused trait
2022-03-10 10:51:32 +01:00
Simon Hausmann
f57e9ef50c Adapt to the TextShaper API changes in the mcu font backend 2022-03-10 10:51:32 +01:00
Simon Hausmann
f6b484ca91 Implement glyph_for_char in mcu font to support elision 2022-03-10 10:51:32 +01:00
Simon Hausmann
9b9d6efdc8 Adapt the mcu text code to use glyph based layout callback 2022-03-10 10:51:32 +01:00
Simon Hausmann
089dc47b66 Adapt the mcu font handling to the glyph trait based textshaper 2022-03-10 10:51:32 +01:00