Commit graph

49 commits

Author SHA1 Message Date
Simon Hausmann
da5e7d5b22 WGPU: Add support for using WGPU textures in Slint
This adds a `unstable-wgpu-24` feature that exposes WGPU types in the
GraphicsAPI enum, adds `require_wgpu_24()` to the backend selector,
and adds a conversion from `wgpu::Texture` to `slint::Image`.

The `require_wgpu_24()` function in the selector will be extended in the
future (before the next release) to permit specifying additional aspects
of the WGPU configuration.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-29 17:46:57 +02:00
Olivier Goffart
c98d234b9e Janitor: Always use `#![no_std] for runtime lib
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
2025-01-27 19:22:00 +01:00
Simon Hausmann
386710cd6d Fix repeated loading of an image by path if the file was changed since last time
Fixes #6030
2024-09-04 17:19:42 +02:00
Tobias Hunger
f78ea5e7cf janitor: Fix clippy "field assignment outside of initializer
... for an instance created with Default::default()"
2024-06-24 14:59:47 +02:00
Tobias Hunger
09e9cdebb1 janitor: Fix clippy "duplicated attribute" 2024-06-24 14:59:47 +02:00
Tobias Hunger
571ee7a0bb janitor: Fix clippy "parameter is only used in recursion" 2024-06-24 14:59:47 +02:00
Olivier Goffart
c89ea56abb Update a bunch of dependencies
Bigger change is cause by resvg/usvg which now takes the font database
in a Arc, so we must store it in a Arc ourself to cheaply lend it to usvg
2024-06-23 16:47:13 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Olivier Goffart
2ab71db4f7 Update deps, including resvg 2024-02-21 12:30:33 +01:00
Olivier Goffart
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Olivier Goffart
01336be871 Fix svg loading on android after update of resvg
It would incoditionally try to load the FONTDB that can't load any font
from the system using libloading

Instead, hardcode the path to the font to a known android font
2024-01-23 23:04:59 +01:00
Olivier Goffart
c7aae4b77e Update resvg and related dependencies 2024-01-22 16:16:35 +01:00
Olivier Goffart
1864257f29 Silence error when rendering SVG in an 0x0 size
Make the size argument to svg::render optional to mean that it is the
default size of the image.
Otherwise, passing None as the size to ImageInner::render_to_buffer
would not render the image which is possible in some backend (eg: the
button image icon with the qt backend)

And if the image is really rendered on an empty because of layouting or
so, we don't need to show a warning anyway.

Fix #3790
2023-11-02 11:09:20 +01:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Simon Hausmann
a84aa70cd0 Fix rendering of scale SVGs
Commit c8f1f4354b accidentally inverted
the target size computation logic when porting away from FitTo, scaling
to the tree width instead of scaling the tree width to the image element
width but preserving aspect ratio.

Fixes rendering of AboutSlint in gallery.
2023-06-19 22:39:39 +02:00
Simon Hausmann
653b63a35e Port to resvg 0.34 2023-06-18 08:58:09 +02:00
Simon Hausmann
c8f1f4354b Port to resvg 0.33 2023-06-18 08:58:09 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Simon Hausmann
eadfec64a3 Add support for importing OpenGL textures into Slint
This is the initial API for Slint to borrow OpenGL textures from the
application for rendering.
2023-06-01 15:56:55 +02:00
Simon Hausmann
328cfc76b6 Move sharedfontdb from core to common
This way it is also accessible to the compiler.
2023-05-23 08:26:03 +02:00
Simon Hausmann
afd85a9a0b Remove outdated comment
This is handled in fixup_text now.
2023-05-19 10:40:51 +02:00
Simon Hausmann
4970742f88 Fix support for text in SVGs
This feature was lost in the move of the image decoding to core.

Fixes #2646
2023-05-19 10:40:51 +02:00
Simon Hausmann
6c8fa5f215
Fix duplicated loading/embedding of images (#2612)
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
2023-04-21 13:15:22 +02:00
Olivier Goffart
977b1cc23a Update resvg dependency
Don't import all the dependent crate, use the re-export

And use a workspace dependency
2023-03-28 15:55:27 +02:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Olivier Goffart
69df22e2fb Update resvg dependencies 2022-12-18 08:49:19 -08:00
Simon Hausmann
65e4e7bf15 Bump resvg/usvg/tiny-skia dependencies 2022-11-01 10:44:33 +01:00
Olivier Goffart
2e08b7dd1e Fix the rendering size of svg
- 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
2022-10-24 10:05:38 +02:00
Simon Hausmann
b727aba4a0
Fix quality of SVG rendering in the online editor (#1740)
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>
2022-10-18 14:43:33 +02:00
Simon Hausmann
0577d8a20d Use physical lengths for the image cache rendering
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.
2022-10-13 17:02:18 +02:00
Olivier Goffart
b3605cb4ec Fix errors and warnings in the wasm build 2022-09-07 10:13:58 +02:00
Olivier Goffart
7417422e3c Make the PlatformAbstraction not Send using a EventLoopProxy trait
This changes the way the platform abstraction is initialized
2022-08-24 11:32:21 +02:00
Olivier Goffart
2e5ab86bea Rename backend module to platform
and the Backend trait into PlatfromAbstraction trait
2022-08-23 19:39:49 +02:00
Olivier Goffart
a1724602e6 Skia: Cache the Skia image in the core image cache
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.
2022-08-16 11:22:11 +02:00
Simon Hausmann
650fd2c6ba Simplify internal svg rendering API a little bit
Since there is only one call site now, we can also return the correct
type without inconveniencing any other code.
2022-07-20 12:57:37 +02:00
Simon Hausmann
b4b7b27db8 Add bounds to the decoded image cache
This defaults to 5 MB right now and SVGs aren't counted properly.
2022-07-20 12:57:37 +02:00
Simon Hausmann
5619abb878 Move ImageCacheKey into the image module
That way it'll be eaiser to deal with the code with image-decoders disabled
2022-07-20 12:57:37 +02:00
Simon Hausmann
34dc0a80e7 Fix duplicated images when building with embedded images
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.
2022-07-20 12:57:37 +02:00
Simon Hausmann
71d6717b68 Simplify image cache API
Make the image cache return Image, instead of ImageInner
2022-07-20 12:57:37 +02:00
Olivier Goffart
b8e3d2af89 HTML image in core 2022-07-20 12:57:37 +02:00
Simon Hausmann
4bb3fee04e Fix doc warnings 2022-07-20 12:57:37 +02:00
Simon Hausmann
3ef35c5ef9 WIP: compile the GL backend without image cache and its own image decoding 2022-07-20 12:57:37 +02:00
Olivier Goffart
65346c699c Attempt to get the "image-in-corelib" feature compile with C++ 2022-07-20 12:57:37 +02:00
Simon Hausmann
67a2f0ce3f WIP: Make image decoding a feature of the core library
This includes the cache of decoded images, the HTMLImage element support
and the SVG rendering adapter.

The objective is that Image holds an ImageInner, which is not a path
anymore that the backend has to process, but instead always either
decoded image data, a pointer to a static texture or an SVG tree that
can be rendered to the desired size.
2022-07-20 12:57:37 +02:00