Bite the bullet and introduce the public API and testing backend as
dev-dependencies, so that we can properly at least compile-test the
doctests, some of which were previously in the public API crate and
require the compiler macro.
For the MCU port, we need to proccess the image to save them in the binary
in a convenient format.
This patch start this work by trying to anaylyze what format should an image
be using, and saving it as a texture in the binary.
The current graphical backend and the C++ frontend are not yet supported
Avoid creating an intermediate array of items to free the graphics resources.
Instead call run-time function with the item tree as a parameter, which is traversed.
It's practically the same data structure that was previously created, except
that it is shared/global and has little holes for the dynamic tree items, but those are easy to skip.
Use the new fontdb API:
* When registering embedded fonts, we don't need to make a copy of the
embedded font data anymore.
* We don't have to mmap the font files ourselves anymore, fontdb can
do this now for us.
The font resolution function querying fontdb is fast now, so we can
always call it when rendering text. That way we don't need all the
indirection in the text_size(), etc. functions, we don't need an entry
in the item graphics cache for the font and we can avoid a lot of
property dependencies.
Unfortunately the text property was not included in the property dependency chain
for the cached Font.
This is fixed by delaying that with a getter function, but in the mid term
we should be able to remove this again once
femtovg learns lazy font resolution.
since there is only one function in it, just put that function in the Window
then there is no need to heap alocate a dyn FontMetrics just to call this function.
In preparation of having mutiple-lines TextInput, we will need to give more
data to this function so it no longer belong in FontMetrics
Also remove the unused FontMetric::line_height()
This adds an ImageBuffer and PixelBuffer type for SharedVector
backed images. The documentation explains how to use this
with low-level rendering functions and the popular image crate.
Fixes#387
* Remove the `new` function from the main impl and use the slightly
less visible From conversion trait
* Make the inner Rc<Window> pub(crate) instead of pub
* Instead, provide a public as_any() accessor that the Qt backend can use
If we were to add `sixtyfps:🪟:Window` to the re_exports, then
this clashes. We might rename the former, but this is a cleaner naming
in any case.
Relates to #333
This requires the image size query to be window independent and go
through the backend instead.
This implies minor changes for the Qt backend and bigger ones for the GL
backend:
* There exists now a thread-local IMAGE_CACHE, which is used by the
backend's image_size() function as well as by the renderer for
loading CPU side images.
* The image remain as decoded images in there (including SVG tree)
and the window now has a texture_cache, which holds CachedImage
with ImageData::Texture.
* Rendering an image item therefore fetches the CPU side image,
calls upload_to_gpu() on it, which creates a new Rc<CachedImage>
and that's stored in the texture_cache.
* The texture cache continues to be pruned when hiding the window.
When a Text element has wrapping enabled, it should not have zero
minimum size. Otherwise the layout will give it a height of zero in the
layout in the test case and that'll make the text disappear. There are
different options but this patch goes for minimum height as if no
wrapping was enabled (so at least one line plus forced line breaks).
Fixes#246
We don't need a property reference anymore, a plain image reference is fine AFAICS.
Dirtyness of the source is tracked on the caller side of layouting_info()
or in the draw_image_impl anyway.