Don't require passing a dyn WindowAdapter. This was only used for
calling request_redraw(), which a proper window adapter should do anyway
if has_active_animations() is true.
For .slint files that are included, we canonicalize the path before
adding it into the import stack, to avoid duplicates. We didn't do that
for images in the global_embedded_resources.
Ensure this by canonicalizing as early as possible.
Fixes#2608
Add explicit enum values for repr(C) enums that have attributes like
cfg, so that even if there's a cfg gap in an enum (say cfg(feature =
"svg")) it won't break the ABI.
See also 004dce6c0b
Return the path events for rendering as an Option, so that if the path is empty,
we simply return.
This avoids a double property dependency in the (likely) event the path is not empty.
- On the web, to return the image size, we need to use the natural size
of the image, and not its dom size, as the later get modified since
commit b727aba4a0
- The target size did not take in account the image fit, that's because
former version of resvg could only render by respecting the aspect
ratio. But since the web don't have this limitation, we now need to
take it into account. And new version of resvg can also scale with
any aspect ratio
SVGs are rendered using HTML image elements, that are converted to textures.
The size of the texture defaults to the SVGs viewbox, which may be small - despite
it being possible to render the SVG at a higher resolution with great quality.
Similar to the native code path, this patch also uses the target image size
and propagates it to the DOM HTML image element to instruct the browser to
render the SVG at a higher resolution.
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
This avoids accidental use of logical pixels, esp. for SVG, elimiates
one call to `to_untyped()` as well as an untyped scale factor in the
femtovg renderer.
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.
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.
Because re-generating the Skia image is slow and there is no point
storing both the image buffer and the SkiaImage in the cache as it
is basically the same information.
Instead of a new() function and a start() and no stop() function, create the collector
when we want to measure and drop it when we're done.
This will also make it possible to move the collector into the renderer
in the future.
For embedded images the path is empty but we unconditionally used it to create a TextureCacheKey,
which clashes.
Instead, preserve and store the ImageCacheKey in the ImageInner variants.