Skip to content

Commit

Permalink
Update to Image 0.25
Browse files Browse the repository at this point in the history
Added image-default-formats with all the format supported by image by
default, and enable that feature by default.
Also put that feature in compat-1-2 for compatibility with user that
have used image 0.24 with enabled features.
Make a new compat-1-10 feature that does not enable default format by
default

ChangeLog: upgraded image crate to 0.25, added a new cargo feature
to enable all image formats. (that feature is enabled by default with
compat-1-2, added compat-1-10 to disable it

Fixes #7251
  • Loading branch information
ogoffart committed Jan 14, 2025
1 parent dacfea7 commit 37a68d2
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ euclid = { version = "0.22.1", default-features = false }
fontdb = { version = "0.22.0", default-features = false }
fontdue = { version = "0.9.0" }
glutin = { version = "0.32.0", default-features = false }
image = { version = "0.24", default-features = false, features = [ "png", "jpeg" ] }
image = { version = "0.25", default-features = false, features = [ "png", "jpeg" ] }
itertools = { version = "0.14" }
log = { version = "0.4.17" }
resvg = { version= "0.44.0", default-features = false, features = ["text"] }
Expand Down
6 changes: 2 additions & 4 deletions api/cpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ gettext = ["i-slint-core/gettext-rs"]
accessibility = ["i-slint-backend-selector/accessibility"]
system-testing = ["i-slint-backend-selector/system-testing"]

std = ["image", "i-slint-core/default", "i-slint-backend-selector"]
std = ["i-slint-core/default", "i-slint-core/image-default-formats", "i-slint-backend-selector"]
freestanding = ["i-slint-core/libm", "i-slint-core/unsafe-single-threaded"]
experimental = []

Expand All @@ -55,10 +55,8 @@ i-slint-backend-selector = { workspace = true, optional = true }
i-slint-backend-testing = { workspace = true, optional = true, features = ["ffi"] }
i-slint-renderer-skia = { workspace = true, features = ["default", "x11", "wayland"], optional = true }
i-slint-core = { workspace = true, features = ["ffi"] }
slint-interpreter = { workspace = true, features = ["ffi", "compat-1-2"], optional = true }
slint-interpreter = { workspace = true, features = ["ffi", "compat-1-10"], optional = true }
raw-window-handle = { version = "0.6", optional = true }
# Enable image-rs' default features to make all image formats to C++ users
image = { workspace = true, optional = true, features = ["default"] }

esp-backtrace = { version = "0.14.0", features = ["panic-handler", "println"], optional = true }
esp-println = { version = "0.12.0", default-features = false, features = ["uart"], optional = true }
Expand Down
12 changes: 9 additions & 3 deletions api/rs/slint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ default = [
"backend-default",
"renderer-femtovg",
"renderer-software",
"image-default-formats",
"accessibility",
"compat-1-2",
"compat-1-10",
]

## Mandatory feature:
## This feature is required to keep the compatibility with Slint 1.2
## This feature is required to keep the compatibility with Slint 1.10
## Newer patch version may put current functionality behind a new feature
## that would be enabled by default only if this feature was added.
## [More info in this blog post](https://slint.dev/blog/rust-adding-default-cargo-feature.html)
"compat-1-2" = []
"compat-1-10" = []
"compat-1-2" = ["compat-1-10", "image-default-formats"]
"compat-1-0" = ["compat-1-2", "renderer-software"]

## Enable use of the Rust standard library.
Expand Down Expand Up @@ -84,6 +86,10 @@ accessibility = ["i-slint-backend-selector/accessibility"]
## [HasDisplayHandle](raw_window_handle_06::HasDisplayHandle) implementation.
raw-window-handle-06 = ["dep:raw-window-handle-06", "i-slint-backend-selector/raw-window-handle-06"]

## Enable all formats from the `image` crate. To increase what is supported from [`Image::load_from_path`]
## or in `@image-url`. Without this feature, only PNG and JPEG are supported.
image-default-formats = ["i-slint-core/image-default-formats"]

#! ### Backends

#! Slint needs a backend that will act as liaison between Slint and the OS.
Expand Down
4 changes: 2 additions & 2 deletions api/rs/slint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ each instance will have their own instance of associated globals singletons.

extern crate alloc;

#[cfg(not(feature = "compat-1-2"))]
#[cfg(not(feature = "compat-1-10"))]
compile_error!(
"The feature `compat-1-2` must be enabled to ensure \
"The feature `compat-1-10` must be enabled to ensure \
forward compatibility with future version of this crate"
);

Expand Down
12 changes: 6 additions & 6 deletions api/rs/slint/mcu.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Start by adding a dependency to the `slint` and the `slint-build` crates to your
Start with the `slint` crate like this:

```sh
cargo add slint@1.9.0 --no-default-features --features "compat-1-2 unsafe-single-threaded libm renderer-software"
cargo add slint@1.10.0 --no-default-features --features "compat-1-10 unsafe-single-threaded libm renderer-software"
```

The default features of the `slint` crate are tailored towards hosted environments and includes the "std" feature. In bare metal environments,
you need to disable the default features.

In the snippet above, three features are selected:

* `compat-1-2`: We select this feature when disabling the default features. For a detailed explanation see our blog post ["Adding default cargo features without breaking Semantic Versioning"](https://slint.dev/blog/rust-adding-default-cargo-feature.html).
* `compat-1-10`: We select this feature when disabling the default features. For a detailed explanation see our blog post ["Adding default cargo features without breaking Semantic Versioning"](https://slint.dev/blog/rust-adding-default-cargo-feature.html).
* `unsafe-single-threaded`: Slint internally uses Rust's [`thread_local!`](https://doc.rust-lang.org/std/macro.thread_local.html) macro to store global data.
This macro is only available in the Rust Standard Library (std), but not in bare metal environments. As a fallback, the `unsafe-single-threaded`
feature changes Slint to use unsafe static for storage. This way, you guarantee to use Slint API only from a single thread, and not from interrupt handlers.
Expand All @@ -52,7 +52,7 @@ This is the default when using the Rust 2021 Edition, but not if you use a works
Then add the `slint-build` crate as a build dependency:

```sh
cargo add --build slint-build@1.9.0
cargo add --build slint-build@1.10.0
```

For reference: These are the relevant parts of your `Cargo.toml` file,
Expand All @@ -68,11 +68,11 @@ edition = "2021"
## ... your other dependencies

[dependencies.slint]
version = "1.8.0"
version = "1.10.0"
default-features = false
features = ["compat-1-2", "unsafe-single-threaded", "libm", "renderer-software"]
features = ["compat-1-10", "unsafe-single-threaded", "libm", "renderer-software"]
[build-dependencies]
slint-build = "1.9.0"
slint-build = "1.10.0"
```

## Changes to `build.rs`
Expand Down
2 changes: 1 addition & 1 deletion api/wasm-interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
slint-interpreter = { workspace = true, features = ["std", "backend-winit", "renderer-femtovg", "compat-1-2", "internal"] }
slint-interpreter = { workspace = true, features = ["std", "backend-winit", "renderer-femtovg", "compat-1-10", "internal"] }
send_wrapper = { workspace = true }

vtable = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion demos/energy-monitor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ license = "MIT"
crate-type = ["cdylib", "lib"]

[dependencies]
slint = { path = "../../api/rs/slint", default-features = false, features = ["compat-1-2"] }
slint = { path = "../../api/rs/slint", default-features = false, features = ["compat-1-10"] }
mcu-board-support = { path = "../../examples/mcu-board-support", optional = true }
chrono = { version = "0.4.34", optional = true, default-features = false, features = ["clock", "std", "wasmbind"] }
weer_api = { version = "0.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion demos/printerdemo_mcu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ simulator = ["slint/renderer-software", "slint/backend-winit", "slint/std"]
default = ["simulator"]

[dependencies]
slint = { path = "../../api/rs/slint", default-features = false, features = ["compat-1-2"] }
slint = { path = "../../api/rs/slint", default-features = false, features = ["compat-1-10"] }
mcu-board-support = { path = "../../examples/mcu-board-support" }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/bazel_build/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ crate = use_extension(
"crate",
)

crate.spec(package = "slint", git = "https://github.com/slint-ui/slint", branch = "master", default_features = False, features = ["std","backend-winit", "renderer-skia-opengl", "compat-1-2"])
crate.spec(package = "slint", git = "https://github.com/slint-ui/slint", branch = "master", default_features = False, features = ["std","backend-winit", "renderer-skia-opengl", "compat-1-10"])
crate.spec(package = "slint-build", git = "https://github.com/slint-ui/slint", branch = "master")

crate.annotation(
Expand Down
2 changes: 1 addition & 1 deletion examples/carousel/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ path = "main.rs"
name = "carousel"

[dependencies]
slint = { path = "../../../api/rs/slint", default-features = false, features = ["compat-1-2"] }
slint = { path = "../../../api/rs/slint", default-features = false, features = ["compat-1-10"] }
mcu-board-support = { path = "../../mcu-board-support", optional = true }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/mcu-board-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ esp32-s2-kaluga-1 = ["slint/unsafe-single-threaded", "esp-hal/esp32s2", "embedde
esp32-s3-box = ["slint/unsafe-single-threaded", "esp-hal/esp32s3", "embedded-hal", "embedded-hal-bus", "esp-alloc", "esp-println/esp32s3", "esp-backtrace/esp32s3", "dep:mipidsi", "embedded-graphics-core", "slint/libm", "tt21100"]

[dependencies]
slint = { version = "=1.10.0", path = "../../api/rs/slint", default-features = false, features = ["compat-1-2", "renderer-software"] }
slint = { version = "=1.10.0", path = "../../api/rs/slint", default-features = false, features = ["compat-1-10", "renderer-software"] }
i-slint-core-macros = { version = "=1.10.0", path = "../../internal/core-macros" }

derive_more = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion examples/uefi-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ uefi = { version = "0.33", features = ["panic_handler", "global_allocator"] }
minipng = "=0.1.1"

slint = { path = "../../api/rs/slint", default-features = false, features = [
"compat-1-2",
"compat-1-10",
"renderer-software",
"libm",
"log",
Expand Down
2 changes: 1 addition & 1 deletion internal/backends/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ image = { workspace = true, optional = true, features = ["png"] }
pb-rs = { version = "0.10.0", optional = true, default-features = false }

[dev-dependencies]
slint = { path = "../../../api/rs/slint", default-features = false, features = ["std", "compat-1-2"] }
slint = { path = "../../../api/rs/slint", default-features = false, features = ["std", "compat-1-10"] }
i-slint-core-macros = { path = "../../core-macros" }
i-slint-common = { path = "../../common" }
2 changes: 1 addition & 1 deletion internal/backends/winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ objc2-app-kit = { version = "0.2.2" }
cfg_aliases = { workspace = true }

[dev-dependencies]
slint = { path = "../../../api/rs/slint", default-features = false, features = ["std", "compat-1-2", "backend-winit", "renderer-software", "raw-window-handle-06"] }
slint = { path = "../../../api/rs/slint", default-features = false, features = ["std", "compat-1-10", "backend-winit", "renderer-software", "raw-window-handle-06"] }

[package.metadata.docs.rs]
features = ["wayland", "renderer-software", "raw-window-handle-06"]
3 changes: 1 addition & 2 deletions internal/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ display-diagnostics = ["codemap", "codemap-diagnostic"]

# Enabled the support to render images and font in the binary
software-renderer = ["image", "dep:resvg", "fontdue", "i-slint-common/shared-fontdb", "dep:rayon"]
embed-glyphs-as-sdf = ["dep:fdsm", "dep:ttf-parser-fdsm", "dep:nalgebra", "dep:image-fdsm", "dep:rayon"]
embed-glyphs-as-sdf = ["dep:fdsm", "dep:ttf-parser-fdsm", "dep:nalgebra", "dep:rayon"]

# Translation bundler
bundle-translations = ["dep:polib"]
Expand Down Expand Up @@ -62,7 +62,6 @@ resvg = { workspace = true, optional = true }
fontdue = { workspace = true, optional = true, features = ["parallel"] }
fdsm = { version = "0.6.0", optional = true, features = ["ttf-parser"]}
ttf-parser-fdsm = { package = "ttf-parser", version = "0.24.1", optional = true }
image-fdsm = { package = "image", version = "0.25", optional = true, default-features = false }
nalgebra = { version = "0.33.0", optional = true }
rayon = { workspace = true, optional = true }
# translations
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/passes/embed_glyphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ fn generate_sdf_for_glyph(

// Set up the resulting image and generate the distance field:

let mut sdf = image_fdsm::GrayImage::new(width, height);
let mut sdf = image::GrayImage::new(width, height);
fdsm::generate::generate_sdf(&prepared_shape, range, &mut sdf);
fdsm::render::correct_sign_sdf(
&mut sdf,
Expand Down
3 changes: 2 additions & 1 deletion internal/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ software-renderer-systemfonts = ["shared-fontdb", "rustybuzz", "fontdue", "softw
software-renderer = ["bytemuck"]

image-decoders = ["dep:image", "dep:clru"]
image-default-formats = ["image?/default-formats"]
svg = ["dep:resvg", "shared-fontdb"]

box-shadow-cache = []
Expand Down Expand Up @@ -107,7 +108,7 @@ web-sys = { workspace = true, features = [ "HtmlImageElement" ] }
fontdb = { workspace = true, optional = true, default-features = true }

[dev-dependencies]
slint = { path = "../../api/rs/slint", default-features = false, features = ["std", "compat-1-2"] }
slint = { path = "../../api/rs/slint", default-features = false, features = ["std", "compat-1-10"] }
i-slint-backend-testing = { path="../backends/testing" }
rustybuzz = { workspace = true }
ttf-parser = { workspace = true }
Expand Down
12 changes: 9 additions & 3 deletions internal/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ path = "lib.rs"

[features]

default = ["backend-default", "renderer-femtovg", "renderer-software", "accessibility", "compat-1-2"]
default = ["backend-default", "renderer-femtovg", "renderer-software", "accessibility", "image-default-formats", "compat-1-10"]

## Mandatory feature:
## This feature is required to keep the compatibility with Slint 1.2
## This feature is required to keep the compatibility with Slint 1.10
## Newer patch version may put current functionality behind a new feature
## that would be enabled by default only if this feature was added
"compat-1-2" = []
"compat-1-10" = []
"compat-1-2" = ["compat-1-10", "image-default-formats"]
"compat-1-0" = ["compat-1-2"]

## enable the [`print_diagnostics`] function to show diagnostic in the console output
display-diagnostics = ["i-slint-compiler/display-diagnostics"]

## Enable all formats from the `image` crate. To increase what is supported from [`Image::load_from_path`]
## or in `@image-url`. Without this feature, only PNG and JPEG are supported.
image-default-formats = ["i-slint-core/image-default-formats"]


# (internal) export C++ FFI functions
ffi = ["spin_on", "i-slint-core/ffi"]

Expand Down
4 changes: 2 additions & 2 deletions internal/interpreter/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ instance.run().unwrap();
#![warn(missing_docs)]
#![doc(html_logo_url = "https://slint.dev/logo/slint-logo-square-light.svg")]

#[cfg(not(feature = "compat-1-2"))]
#[cfg(not(feature = "compat-1-10"))]
compile_error!(
"The feature `compat-1-2` must be enabled to ensure \
"The feature `compat-1-10` must be enabled to ensure \
forward compatibility with future version of this crate"
);

Expand Down
2 changes: 1 addition & 1 deletion tests/driver/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ path = "main.rs"
name = "test-driver-interpreter"

[dev-dependencies]
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-2"] }
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-10"] }
i-slint-backend-testing = { workspace = true }

itertools = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion tests/driver/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build-time = ["i-slint-compiler", "spin_on"]
[dependencies]
slint = { workspace = true, features = ["std", "compat-1-2"] }
i-slint-backend-testing = { workspace = true, features = ["internal"] }
slint-interpreter = { workspace = true, features = ["std", "compat-1-2", "internal"] }
slint-interpreter = { workspace = true, features = ["std", "compat-1-10", "internal"] }
spin_on = { workspace = true }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tests/screenshots/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ path = "main.rs"
name = "test-driver-screenshot"

[dependencies]
slint = { workspace = true, features = ["std", "compat-1-2"] }
slint = { workspace = true, features = ["std", "compat-1-10"] }
i-slint-core = { workspace = true, features = ["default", "software-renderer"] }
i-slint-backend-testing = { workspace = true }
image = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion tools/docsnapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ keywords = ["viewer", "gui", "ui", "toolkit"]
[dependencies]
i-slint-compiler = { workspace = true }
i-slint-core = { workspace = true }
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-2", "internal", "accessibility"] }
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-10", "internal", "accessibility"] }
i-slint-renderer-skia = { workspace = true, features = ["default", "wayland"] }

clap = { workspace = true }
Expand Down
9 changes: 3 additions & 6 deletions tools/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ preview-lense = []
## to provide an implementation of the external preview API when building for WASM)
preview-api = ["preview-external"]
## Build in the actual code to act as a preview for slint files.
preview-engine = ["dep:slint", "dep:slint-interpreter", "dep:i-slint-core", "dep:i-slint-backend-selector", "dep:image", "dep:slint-build", "dep:i-slint-backend-winit", "dep:muda", "dep:objc2-foundation"]
preview-engine = ["dep:slint", "dep:slint-interpreter", "dep:i-slint-core", "dep:i-slint-backend-selector", "dep:slint-build", "dep:i-slint-backend-winit", "dep:muda", "dep:objc2-foundation"]
## Build in the actual code to act as a preview for slint files. Does nothing in WASM!
preview-builtin = ["preview-engine"]
## Support the external preview optionally used by e.g. the VSCode plugin
Expand All @@ -92,17 +92,14 @@ smol_str = { workspace = true }
# for the preview-engine feature
i-slint-backend-selector = { workspace = true, optional = true }
i-slint-core = { workspace = true, features = ["std"], optional = true }
slint = { workspace = true, features = ["compat-1-2"], optional = true }
slint-interpreter = { workspace = true, features = ["compat-1-2", "highlight", "internal"], optional = true }
slint = { workspace = true, features = ["compat-1-10"], optional = true }
slint-interpreter = { workspace = true, features = ["compat-1-10", "highlight", "internal", "image-default-formats"], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clap = { workspace = true }
crossbeam-channel = "0.5" # must match the version used by lsp-server
lsp-server = "0.7"

# Enable image-rs' default features to make all image formats available for the preview
image = { workspace = true, optional = true, features = ["default"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.5"
js-sys = { version = "0.3.57" }
Expand Down
5 changes: 1 addition & 4 deletions tools/viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ default = ["backend-default", "renderer-femtovg", "renderer-software"]
[dependencies]
i-slint-compiler = { workspace = true }
i-slint-core = { workspace = true }
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-2", "internal", "accessibility"] }
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-10", "internal", "accessibility", "image-default-formats"] }
i-slint-backend-selector = { workspace = true }

clap = { workspace = true }
Expand All @@ -67,9 +67,6 @@ env_logger = "0.11.0"
itertools = { workspace = true }
smol_str = { workspace = true }

# Enable image-rs' default features to make all image formats available for preview
image = { workspace = true, features = ["default"] }

[[bin]]
name = "slint-viewer"
path = "main.rs"

0 comments on commit 37a68d2

Please sign in to comment.