mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-15 02:07:22 +00:00
Make it possible to build without the FemtoVG renderer
This commit is contained in:
parent
fa956aca2d
commit
1d04b8665f
2 changed files with 45 additions and 17 deletions
|
|
@ -19,7 +19,7 @@ path = "lib.rs"
|
||||||
[features]
|
[features]
|
||||||
wayland = ["winit/wayland", "glutin/wayland", "copypasta/wayland"]
|
wayland = ["winit/wayland", "glutin/wayland", "copypasta/wayland"]
|
||||||
x11 = ["winit/x11", "glutin/x11", "copypasta/x11"]
|
x11 = ["winit/x11", "glutin/x11", "copypasta/x11"]
|
||||||
renderer-femtovg = []
|
renderer-femtovg = ["femtovg", "fontdb", "libc", "servo-fontconfig", "winapi", "dwrote", "imgref", "unicode-script", "ttf-parser"]
|
||||||
renderer-skia = ["skia-safe", "glow"]
|
renderer-skia = ["skia-safe", "glow"]
|
||||||
rtti = ["i-slint-core/rtti"]
|
rtti = ["i-slint-core/rtti"]
|
||||||
default = []
|
default = []
|
||||||
|
|
@ -35,19 +35,21 @@ vtable = { version = "0.1.6", path = "../../../helper_crates/vtable" }
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
copypasta = { version = "0.8.1", default-features = false }
|
copypasta = { version = "0.8.1", default-features = false }
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
femtovg = { version = "0.3.5" }
|
|
||||||
fontdb = { version = "0.9.0", default-features = false }
|
|
||||||
imgref = "1.6.1"
|
|
||||||
lyon_path = "1.0"
|
lyon_path = "1.0"
|
||||||
once_cell = "1.5"
|
once_cell = "1.5"
|
||||||
pin-weak = "1"
|
pin-weak = "1"
|
||||||
rgb = "0.8.27"
|
rgb = "0.8.27"
|
||||||
scoped-tls-hkt = "0.1"
|
scoped-tls-hkt = "0.1"
|
||||||
ttf-parser = "0.15.0" # Use the same version was femtovg's rustybuzz, to avoid duplicate crates
|
|
||||||
unicode-script = "0.5.4" # Use the same version was femtovg's rustybuzz, to avoid duplicate crates
|
|
||||||
winit = { version = "0.26", default-features = false }
|
winit = { version = "0.26", default-features = false }
|
||||||
dark-light = "0.2.2"
|
dark-light = "0.2.2"
|
||||||
|
|
||||||
|
# For the FemtoVG renderer
|
||||||
|
femtovg = { version = "0.3.5", optional = true }
|
||||||
|
fontdb = { version = "0.9.0", optional = true, default-features = false }
|
||||||
|
ttf-parser = { version = "0.15.0", optional = true } # Use the same version was femtovg's rustybuzz, to avoid duplicate crates
|
||||||
|
unicode-script = { version = "0.5.4", optional = true } # Use the same version was femtovg's rustybuzz, to avoid duplicate crates
|
||||||
|
imgref = { version = "1.6.1", optional = true }
|
||||||
|
|
||||||
# For the Skia renderer
|
# For the Skia renderer
|
||||||
skia-safe = { version = "0.53.0", optional = true, features = ["gl", "textlayout"] }
|
skia-safe = { version = "0.53.0", optional = true, features = ["gl", "textlayout"] }
|
||||||
glow = { version = "0.11", optional = true }
|
glow = { version = "0.11", optional = true }
|
||||||
|
|
@ -57,19 +59,21 @@ web-sys = { version = "0.3", features=["console", "WebGlContextAttributes", "Can
|
||||||
wasm-bindgen = { version = "0.2" }
|
wasm-bindgen = { version = "0.2" }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
fontdb = { version = "0.9.0", features = ["memmap", "fontconfig"] }
|
fontdb = { version = "0.9.0", optional = true, features = ["memmap", "fontconfig"] }
|
||||||
glutin = { version = "0.28", default-features = false }
|
glutin = { version = "0.28", default-features = false }
|
||||||
|
|
||||||
|
# For the FemtoVG renderer
|
||||||
[target.'cfg(target_family = "windows")'.dependencies]
|
[target.'cfg(target_family = "windows")'.dependencies]
|
||||||
dwrote = "0.11.0"
|
dwrote = { version = "0.11.0", optional = true }
|
||||||
winapi = { version = "0.3", features = ["dwrite"] }
|
winapi = { version = "0.3", optional = true, features = ["dwrite"] }
|
||||||
|
|
||||||
[target.'cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios", target_arch = "wasm32")))'.dependencies]
|
[target.'cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios", target_arch = "wasm32")))'.dependencies]
|
||||||
libc = { version = "0.2" }
|
libc = { version = "0.2", optional = true }
|
||||||
# Require font-config from the system on Linux. Issue #88 indicates that the copy provided by servo-fontconfig may be incompatible
|
# Require font-config from the system on Linux. Issue #88 indicates that the copy provided by servo-fontconfig may be incompatible
|
||||||
# with distros at times.
|
# with distros at times.
|
||||||
servo-fontconfig = { version = "0.5", features = [ "force_system_lib" ] }
|
servo-fontconfig = { version = "0.5", optional = true, features = [ "force_system_lib" ] }
|
||||||
|
|
||||||
|
# For the GL
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
cocoa = { version = "0.24.0" }
|
cocoa = { version = "0.24.0" }
|
||||||
core-foundation = { version = "0.9.1" }
|
core-foundation = { version = "0.9.1" }
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ mod renderer {
|
||||||
fn component_destroyed(&self, component: i_slint_core::component::ComponentRef);
|
fn component_destroyed(&self, component: i_slint_core::component::ComponentRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "renderer-femtovg")]
|
||||||
pub(crate) mod femtovg;
|
pub(crate) mod femtovg;
|
||||||
#[cfg(feature = "renderer-skia")]
|
#[cfg(feature = "renderer-skia")]
|
||||||
pub(crate) mod skia;
|
pub(crate) mod skia;
|
||||||
|
|
@ -92,7 +93,8 @@ pub struct Backend {
|
||||||
|
|
||||||
impl Backend {
|
impl Backend {
|
||||||
pub fn new(renderer_name: Option<&str>) -> Self {
|
pub fn new(renderer_name: Option<&str>) -> Self {
|
||||||
let femtovg_factory = || {
|
#[cfg(feature = "renderer-femtovg")]
|
||||||
|
let (default_renderer, default_renderer_factory) = ("FemtoVG", || {
|
||||||
i_slint_core::window::WindowInner::new(|window| {
|
i_slint_core::window::WindowInner::new(|window| {
|
||||||
GLWindow::<renderer::femtovg::FemtoVGRenderer>::new(
|
GLWindow::<renderer::femtovg::FemtoVGRenderer>::new(
|
||||||
window,
|
window,
|
||||||
|
|
@ -101,10 +103,31 @@ impl Backend {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
};
|
});
|
||||||
|
#[cfg(all(not(feature = "renderer-femtovg"), feature = "renderer-skia"))]
|
||||||
|
let (default_renderer, default_renderer_factory) = ("Skia", || {
|
||||||
|
i_slint_core::window::WindowInner::new(|window| {
|
||||||
|
GLWindow::<renderer::skia::SkiaRenderer>::new(
|
||||||
|
window,
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
"canvas".into(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.into()
|
||||||
|
});
|
||||||
|
|
||||||
let factory_fn = match renderer_name {
|
let factory_fn = match renderer_name {
|
||||||
Some("gl") | Some("femtovg") | None => femtovg_factory,
|
#[cfg(feature = "renderer-femtovg")]
|
||||||
|
Some("gl") | Some("femtovg") => || {
|
||||||
|
i_slint_core::window::WindowInner::new(|window| {
|
||||||
|
GLWindow::<renderer::femtovg::FemtoVGRenderer>::new(
|
||||||
|
window,
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
"canvas".into(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.into()
|
||||||
|
},
|
||||||
#[cfg(feature = "renderer-skia")]
|
#[cfg(feature = "renderer-skia")]
|
||||||
Some("skia") => || {
|
Some("skia") => || {
|
||||||
i_slint_core::window::WindowInner::new(|window| {
|
i_slint_core::window::WindowInner::new(|window| {
|
||||||
|
|
@ -116,12 +139,13 @@ impl Backend {
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
},
|
},
|
||||||
|
None => default_renderer_factory,
|
||||||
Some(renderer_name) => {
|
Some(renderer_name) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"slint winit: unrecognized renderer {}, falling back to FemtoVG",
|
"slint winit: unrecognized renderer {}, falling back to {}",
|
||||||
renderer_name
|
renderer_name, default_renderer
|
||||||
);
|
);
|
||||||
femtovg_factory
|
default_renderer_factory
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Self { window_factory_fn: Mutex::new(Box::new(factory_fn)) }
|
Self { window_factory_fn: Mutex::new(Box::new(factory_fn)) }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue