Commit graph

46 commits

Author SHA1 Message Date
Simon Hausmann
c16253d29f Use Property<LogicalLength> instead of Property<Coord>
This removes the special code for the generated property getters and
ensures type safety in the run-time library for property value setting.

In the Rust generated code we continue to do arithmetic on the scalar
values, that means we immediately extract the scalar, do arithmetic and
rely on the compiler to only allow compatible units.

Danger zone alert: In the interpreter Value::Number can now be converted
to LogicalLength as-is.
2022-10-24 12:49:37 +02:00
Simon Hausmann
c11b4305c1 Change Item::geometry() to return a LogicalRect 2022-10-13 17:02:18 +02:00
Simon Hausmann
299325370d Change generated accessor functions for Property<Coord> getters to return LogicalLength 2022-10-13 17:02:18 +02:00
Simon Hausmann
2da2511f13
Use a vector for ItemRenderer::translate (#1700)
This simplifes call sites and implementations.
2022-10-02 10:06:20 +02:00
Simon Hausmann
8adc4404d7 Remove two uses untyped logical rect creation 2022-09-30 13:00:37 +02:00
Simon Hausmann
9d421de47d Remove remaining uses of LogicalRect::from_untyped 2022-09-30 13:00:37 +02:00
Simon Hausmann
57fe1b9c47 Replace manual calls to LogicalLength::new() for item fields with logical_XXX getters 2022-09-30 13:00:37 +02:00
Simon Hausmann
59368363c9 Change the ItemRenderer trait to use logical lengths 2022-09-30 13:00:37 +02:00
Olivier Goffart
6b88fc634d Fix partial renderer not rendering some dirty area that were clipped
During the rendering, if an area is clipped, it will not be rendered and
therefore will not be rendered as a dependency.

Consider this example:

```
    HorizontalBox {
        Rectangle {
           TouchArea{
              Rectangle { background: parent.pressed ? red : blue; }
           }
        }

        Rectangle {
           clip: true;
           TouchArea{
              Rectangle { background: parent.pressed ? red: blue; }
           }
        }
    }
}

```

Clicking on the first rectangle will make that area dirty and it will be
redrawn, but since the second one is clipped away, the renderer will not
visit the child items. And clicking on the second rectangle will not
make it re-drawn.

This patch makes sure we rejuster ad dependency of the window tracker
the non-dirty areas

This fix the printerdemo_mcu stopping to render in some cases
2022-09-08 16:22:13 +02:00
Olivier Goffart
1237285fef Fixup some documentaion links
And add a test in the CI that checks for warnings in the internal
crates

(Also changed --exlcude in the test to be matching the one from build,
since c++ test are tested separately)
2022-09-01 12:16:24 +02:00
Tobias Hunger
1e6ffeaa0f API cleanup: Rename PlatformWindow to WindowAdapter 2022-08-29 16:53:47 +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
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
Simon Hausmann
9799571396 Make it possible to implement the ItemRenderer trait with a lifetime
The as_any() method returning a `&mut dyn Any` meant that the type has to be
'static. The class solution of returning &()
doesn't work because it has to be a mutable ref. Therefore just return an Option.
2022-07-12 20:37:14 +02:00
Simon Hausmann
211aaf1dd8 Simplify with_entry
Use `.and_then()` instead of `.map().flatten()`

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-07-11 23:19:05 +02:00
Simon Hausmann
0b20f58ada GL backend: speed up updates to layer content
Now that we store the layer textures as Rc<Texture>, before rendering a
layer we can take a clone of a possibly existing layer texture and if if
the layer's tracker is dirty, we can re-use the existing layer texture
if it's the same size.

This avoids unnecessary texture allocations.
2022-07-11 23:19:05 +02:00
Olivier Goffart
4ecc2cd1c0 swrenderer: add a renderer that operate dirrectly on the frame buffer 2022-07-06 17:06:40 +02:00
Tobias Hunger
581533f302 Rename free_*_graphics_resources to unregister_component
I want a more generic name as I want to do to track component structure
changes in addition to resource freeing and I do not want to add another
call into the generated code.
2022-06-30 11:51:49 +02:00
Simon Hausmann
f5210b5586 Fix per-item pixmap/texture caching in the Qt and GL renderer
The borrow logic in ItemCache<T>::get_or_update_cache_entry requires us
to take the per-item cache dirty tracker out of the cache entry, so that
we can drop the ref and allow the update_fn to access the cache for
other items during evaluation.

However in order for the cache to work by not re-evaluating the
update_fn next time if nothing rendering related change, we must put the
tracker back after the check/evaluation, otherwise take() will always
return none.

This is a regression from commit
6cbf2c0609 that changed the call from
get_or_update() - which puts the tracker back - to
get_or_update_cache_entry(), which doesn't. Since the former is now
unused, this commit also removes it.
2022-06-29 21:00:41 +02:00
Olivier Goffart
dfc87e7c33 Janitor: cleanup a function
no need to have two separate function for clipping items
2022-06-18 22:31:38 +02:00
Simon Hausmann
a5f29d401b Fix panic when clicking on an open printer queue in the printer demo with the partial renderer
When computing the dirty regions, the call to geometry() might end up
querying a value that's computed by the layout. For the layout
computation we might end up calling ensure_updated() on a repeater,
which then might destroy components. The destruction involves freeing
cached dirty rectangles (via free_graphics_resources), and that also
requires a write access to the cache. So after retrieving the property
tracker for the dirty geometry, drop access to the cache before calling
geometry().
2022-06-14 11:33:00 +02:00
Simon Hausmann
2d2eb70b51 Fix panic about multiple mutable borrows with the software renderer
When using repeaters - like in the slide puzzle - and during renderer a component
gets deleted, we call free_graphics_resources and try to free
the dirty rectangle list in the partial renderer cache. At that point the cache is
already mutably borrowed, which causes a panic.

As remedy, apply the mutable borrow more fine grained and not right when calling
render().
2022-06-10 08:38:34 +02:00
Olivier Goffart
6cbf2c0609 Put the new cache in corelib and use it in the GL backend 2022-05-31 10:48:24 +02:00
Olivier Goffart
d2186593c0 Pass the ItemRc to each draw_function
So that it can be used as a key to the cache
2022-05-31 10:48:24 +02:00
Tobias Hunger
96b6ca8830 janitor: Remove unnecessary references 2022-05-22 11:59:00 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +02:00
Simon Hausmann
afb59cba29 mcu: fix popups not visibly closing
When closing a popup, notify the platform window, so that the mcu
backend can remember that region and start the dirty region with it.

Also, free all the rendering cache items of deleted items, to avoid accidental re-use
when re-opening a popup.
2022-04-08 19:32:33 +02:00
Simon Hausmann
67af5a79f6 Revert "Avoid rendering if the clip is empty"
This reverts commit faf07ea237 as it
breaks dependency tracking with the partial renderer. The effect is that
the mcu printer demo (in release?) doesn't react to input events
anymore. They are delivered by the redraw tracker doesn't get notified.
2022-04-07 17:38:54 +02:00
Olivier Goffart
0429e11cf7 Refactor: Move ItemRc and ItemWeak to item_tree.rs
Keep items.rs for the implementation of items, and move the logic
that helprs navigating the tree to the item_tree.rs module
2022-04-07 16:59:38 +02:00
Simon Hausmann
faf07ea237 Avoid rendering if the clip is empty
Take an early shortcut
2022-04-07 09:39:30 +02: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
535e134223 Add a Layer element that's created when using a layer boolean property
For now no backend implements this optimization hint.
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
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
Simon Hausmann
a3830e785a janitor: remove unused return value from render_item_children 2022-03-16 09:28:33 +01:00
Simon Hausmann
c94c223c3b Simplify item rendering loop
Instead of using the generic visitor, call `visit_children_item` directly on the Component.

This way we avoid the RefCell for the renderer and this will make it
easier to introduce items that decide to render the children themselves, with
their own property tracker.
2022-03-16 09:18:09 +01:00
Olivier Goffart
24237377cf Don't register dependencies when computing the dirty geometry 2022-03-07 19:06:23 +01:00
Olivier Goffart
3703c862a0 Fix BorrowMutError panic
Introduced in commit b2caa75

Fixes #1010
2022-03-04 09:16:57 +01:00
Olivier Goffart
b2caa757e7 Partial renderer: Initial work 2022-03-03 14:58:48 +01:00
Olivier Goffart
b6ef333444 Rendering: put the clipping an a function in the ItemRenderer trait
This will allow partial updates
2022-03-03 14:58:48 +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
Tobias Hunger
e6b24bceec [reorg]: Set up and populate the internal directory
Move "internal" crates into the `internal` directory. This first batch
includes most of sixtyfps_runtime but leaves the rendering backends
alone for now.

pre-commit applied some cleanups to the moved files:
 - Consistent newline at end of file policy
 - trimming trailing whitespace
 - Formatting Cargo.toml files.
2022-01-31 16:00:50 +01:00
Renamed from sixtyfps_runtime/corelib/item_rendering.rs (Browse further)