Skip to content

Commit df47f0b

Browse files
committed
femtovg: Upgrade to wgpu 27
Also: - The newer version of femtovg permits disabling text layouting, so this means less dependencies - Skia is the only renderer left to support wgpu 26, so unstable-wgpu-26 now implies a dependency to renderer-skia Closes #9605
1 parent 4f21981 commit df47f0b

File tree

9 files changed

+40
-44
lines changed

9 files changed

+40
-44
lines changed

examples/bevy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ name = "bevy_example"
1919
path = "main.rs"
2020

2121
[dependencies]
22-
slint = { path = "../../api/rs/slint", features = ["unstable-wgpu-26", "renderer-skia"] }
22+
slint = { path = "../../api/rs/slint", features = ["unstable-wgpu-26"] }
2323
spin_on = { version = "0.1" }
2424
bevy = { version = "0.17.0", default-features = false, features = ["bevy_core_pipeline", "bevy_pbr", "bevy_window", "bevy_scene", "bevy_gltf", "bevy_log", "jpeg", "png", "tonemapping_luts", "multi_threaded", "reflect_auto_register", "debug"] }
2525
bevy_image = { version = "0.17.0", features = ["zstd_rust"] }

internal/backends/winit/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ x11 = [
4141
"softbuffer?/x11-dlopen",
4242
]
4343
renderer-femtovg = ["i-slint-renderer-femtovg/opengl", "dep:glutin", "dep:glutin-winit"]
44-
renderer-femtovg-wgpu = ["i-slint-renderer-femtovg/wgpu", "dep:i-slint-renderer-femtovg", "unstable-wgpu-26"]
44+
renderer-femtovg-wgpu = ["i-slint-renderer-femtovg/wgpu", "dep:i-slint-renderer-femtovg", "unstable-wgpu-27"]
4545
renderer-skia = ["i-slint-renderer-skia"]
4646
renderer-skia-opengl = ["renderer-skia", "i-slint-renderer-skia/opengl"]
4747
renderer-skia-vulkan = ["renderer-skia", "i-slint-renderer-skia/vulkan"]
@@ -56,15 +56,15 @@ accessibility = ["dep:accesskit", "dep:accesskit_winit"]
5656
raw-window-handle-06 = ["i-slint-core/raw-window-handle-06"]
5757
unstable-wgpu-26 = [
5858
"i-slint-core/unstable-wgpu-26",
59-
"renderer-femtovg-wgpu",
60-
"i-slint-renderer-femtovg/unstable-wgpu-26",
61-
"i-slint-renderer-skia?/unstable-wgpu-26",
59+
"i-slint-renderer-femtovg?/unstable-wgpu-26",
60+
"renderer-skia",
61+
"i-slint-renderer-skia/unstable-wgpu-26",
6262
]
6363
unstable-wgpu-27 = [
6464
"i-slint-core/unstable-wgpu-27",
65-
"renderer-skia",
66-
"i-slint-renderer-femtovg?/unstable-wgpu-27",
67-
"i-slint-renderer-skia/unstable-wgpu-27",
65+
"renderer-femtovg-wgpu",
66+
"i-slint-renderer-femtovg/unstable-wgpu-27",
67+
"i-slint-renderer-skia?/unstable-wgpu-27",
6868
]
6969
default = []
7070

internal/backends/winit/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,14 @@ impl BackendBuilder {
385385
#[cfg(feature = "renderer-femtovg-wgpu")]
386386
(Some("femtovg-wgpu"), maybe_graphics_api) => {
387387
if !maybe_graphics_api.is_some_and(|_api| {
388-
#[cfg(feature = "unstable-wgpu-26")]
389-
if matches!(_api, RequestedGraphicsAPI::WGPU26(..)) {
388+
#[cfg(feature = "unstable-wgpu-27")]
389+
if matches!(_api, RequestedGraphicsAPI::WGPU27(..)) {
390390
return true;
391391
}
392392
false
393393
}) {
394394
return Err(
395-
"The FemtoVG WGPU renderer only supports the WGPU26 graphics API selection"
395+
"The FemtoVG WGPU renderer only supports the WGPU27 graphics API selection"
396396
.into(),
397397
);
398398
}
@@ -480,18 +480,18 @@ impl BackendBuilder {
480480
}
481481
#[cfg(feature = "unstable-wgpu-26")]
482482
(None, Some(RequestedGraphicsAPI::WGPU26(..))) => {
483+
renderer::skia::WinitSkiaRenderer::new_wgpu_26_suspended
484+
}
485+
#[cfg(feature = "unstable-wgpu-27")]
486+
(None, Some(RequestedGraphicsAPI::WGPU27(..))) => {
483487
cfg_if::cfg_if! {
484488
if #[cfg(enable_skia_renderer)] {
485-
renderer::skia::WinitSkiaRenderer::new_wgpu_26_suspended
489+
renderer::skia::WinitSkiaRenderer::new_wgpu_27_suspended
486490
} else {
487491
renderer::femtovg::WGPUFemtoVGRenderer::new_suspended
488492
}
489493
}
490494
}
491-
#[cfg(feature = "unstable-wgpu-27")]
492-
(None, Some(RequestedGraphicsAPI::WGPU27(..))) => {
493-
renderer::skia::WinitSkiaRenderer::new_wgpu_27_suspended
494-
}
495495
(None, Some(_requested_graphics_api)) => {
496496
cfg_if::cfg_if! {
497497
if #[cfg(enable_skia_renderer)] {

internal/backends/winit/renderer/femtovg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl WGPUFemtoVGRenderer {
9797
pub fn new_suspended(
9898
shared_backend_data: &Rc<crate::SharedBackendData>,
9999
) -> Result<Box<dyn WinitCompatibleRenderer>, PlatformError> {
100-
if !i_slint_core::graphics::wgpu_26::any_wgpu26_adapters_with_gpu(
100+
if !i_slint_core::graphics::wgpu_27::any_wgpu27_adapters_with_gpu(
101101
shared_backend_data._requested_graphics_api.clone(),
102102
) {
103103
return Err(PlatformError::from("WGPU: No GPU adapters found"));

internal/renderers/femtovg/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ path = "lib.rs"
1818
[features]
1919
default = []
2020
opengl = []
21-
wgpu = ["wgpu-26"]
22-
wgpu-26 = ["dep:wgpu-26", "femtovg/wgpu", "i-slint-core/unstable-wgpu-26"]
23-
unstable-wgpu-26 = ["wgpu-26"]
24-
unstable-wgpu-27 = []
21+
wgpu = ["wgpu-27"]
22+
wgpu-27 = ["dep:wgpu-27", "femtovg/wgpu", "i-slint-core/unstable-wgpu-27"]
23+
unstable-wgpu-26 = []
24+
unstable-wgpu-27 = ["wgpu-27"]
2525

2626
[dependencies]
2727
i-slint-core = { workspace = true, features = ["default", "box-shadow-cache", "shared-fontique", "shared-parley"] }
@@ -34,14 +34,14 @@ cfg-if = "1"
3434
derive_more = { workspace = true }
3535
lyon_path = "1.0"
3636
pin-weak = "1"
37-
femtovg = { version = "0.18.1" }
37+
femtovg = { version = "0.19.0", default-features = false, features = ["image-loading"] }
3838
ttf-parser = { workspace = true }
3939
imgref = { version = "1.6.1" }
4040
rgb = { version = "0.8.27" }
4141

4242
glow = { workspace = true }
4343

44-
wgpu-26 = { workspace = true, optional = true, default-features = true }
44+
wgpu-27 = { workspace = true, optional = true, default-features = true }
4545

4646
[target.'cfg(target_arch = "wasm32")'.dependencies]
4747
web-sys = { workspace = true, features = ["console", "WebGlContextAttributes", "CanvasRenderingContext2d", "HtmlInputElement", "HtmlCanvasElement", "Window", "Document"] }

internal/renderers/femtovg/font_cache.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
// cspell:ignore Noto fontconfig
55

6-
use core::num::NonZeroUsize;
76
use femtovg::TextContext;
87
use i_slint_core::textlayout::sharedparley::parley;
98
use std::cell::RefCell;
@@ -17,9 +16,6 @@ pub struct FontCache {
1716
impl Default for FontCache {
1817
fn default() -> Self {
1918
let text_context = TextContext::default();
20-
text_context.resize_shaped_words_cache(NonZeroUsize::new(10_000_000).unwrap());
21-
text_context.resize_shaping_run_cache(NonZeroUsize::new(1_000_000).unwrap());
22-
2319
Self { text_context, fonts: Default::default() }
2420
}
2521
}

internal/renderers/femtovg/images.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ where
2121
#[cfg(not(target_family = "wasm"))]
2222
fn convert_opengl_texture(opengl_texture: std::num::NonZero<u32>) -> Self::NativeTexture;
2323

24-
#[cfg(feature = "unstable-wgpu-26")]
25-
fn convert_wgpu_26_texture(wgpu_texture: wgpu_26::Texture) -> Self::NativeTexture;
24+
#[cfg(feature = "unstable-wgpu-27")]
25+
fn convert_wgpu_27_texture(wgpu_texture: wgpu_27::Texture) -> Self::NativeTexture;
2626
}
2727

2828
impl TextureImporter for femtovg::renderer::OpenGl {
@@ -31,8 +31,8 @@ impl TextureImporter for femtovg::renderer::OpenGl {
3131
glow::NativeTexture(opengl_texture)
3232
}
3333

34-
#[cfg(feature = "unstable-wgpu-26")]
35-
fn convert_wgpu_26_texture(_wgpu_texture: wgpu_26::Texture) -> Self::NativeTexture {
34+
#[cfg(feature = "unstable-wgpu-27")]
35+
fn convert_wgpu_27_texture(_wgpu_texture: wgpu_27::Texture) -> Self::NativeTexture {
3636
unimplemented!()
3737
}
3838
}
@@ -43,8 +43,8 @@ impl TextureImporter for femtovg::renderer::WGPURenderer {
4343
todo!()
4444
}
4545

46-
#[cfg(feature = "unstable-wgpu-26")]
47-
fn convert_wgpu_26_texture(wgpu_texture: wgpu_26::Texture) -> Self::NativeTexture {
46+
#[cfg(feature = "unstable-wgpu-27")]
47+
fn convert_wgpu_27_texture(wgpu_texture: wgpu_27::Texture) -> Self::NativeTexture {
4848
wgpu_texture
4949
}
5050
}
@@ -183,8 +183,8 @@ impl<R: femtovg::Renderer + TextureImporter> Texture<R> {
183183
)
184184
.unwrap()
185185
}
186-
#[cfg(all(not(target_arch = "wasm32"), feature = "unstable-wgpu-26"))]
187-
ImageInner::WGPUTexture(i_slint_core::graphics::WGPUTexture::WGPU26Texture(
186+
#[cfg(all(not(target_arch = "wasm32"), feature = "unstable-wgpu-27"))]
187+
ImageInner::WGPUTexture(i_slint_core::graphics::WGPUTexture::WGPU27Texture(
188188
texture,
189189
)) => {
190190
let texture = texture.clone();
@@ -193,7 +193,7 @@ impl<R: femtovg::Renderer + TextureImporter> Texture<R> {
193193
canvas
194194
.borrow_mut()
195195
.create_image_from_native_texture(
196-
<R as TextureImporter>::convert_wgpu_26_texture(texture),
196+
<R as TextureImporter>::convert_wgpu_27_texture(texture),
197197
femtovg::ImageInfo::new(
198198
image_flags,
199199
size.width as _,
@@ -203,8 +203,8 @@ impl<R: femtovg::Renderer + TextureImporter> Texture<R> {
203203
)
204204
.unwrap()
205205
}
206-
#[cfg(all(not(target_arch = "wasm32"), feature = "unstable-wgpu-27"))]
207-
ImageInner::WGPUTexture(i_slint_core::graphics::WGPUTexture::WGPU27Texture(..)) => {
206+
#[cfg(all(not(target_arch = "wasm32"), feature = "unstable-wgpu-26"))]
207+
ImageInner::WGPUTexture(i_slint_core::graphics::WGPUTexture::WGPU26Texture(..)) => {
208208
return None;
209209
}
210210
_ => {

internal/renderers/femtovg/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mod images;
3939
mod itemrenderer;
4040
#[cfg(feature = "opengl")]
4141
pub mod opengl;
42-
#[cfg(feature = "wgpu-26")]
42+
#[cfg(feature = "wgpu-27")]
4343
pub mod wgpu;
4444

4545
pub trait WindowSurface<R: femtovg::Renderer> {

internal/renderers/femtovg/wgpu.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use i_slint_core::{api::PhysicalSize as PhysicalWindowSize, graphics::RequestedG
77

88
use crate::{FemtoVGRenderer, GraphicsBackend, WindowSurface};
99

10-
use wgpu_26 as wgpu;
10+
use wgpu_27 as wgpu;
1111

1212
pub struct WGPUBackend {
1313
instance: RefCell<Option<wgpu::Instance>>,
@@ -73,7 +73,7 @@ impl GraphicsBackend for WGPUBackend {
7373
Ok(())
7474
}
7575

76-
#[cfg(feature = "unstable-wgpu-26")]
76+
#[cfg(feature = "unstable-wgpu-27")]
7777
fn with_graphics_api<R>(
7878
&self,
7979
callback: impl FnOnce(Option<i_slint_core::api::GraphicsAPI<'_>>) -> R,
@@ -82,15 +82,15 @@ impl GraphicsBackend for WGPUBackend {
8282
let device = self.device.borrow().clone();
8383
let queue = self.queue.borrow().clone();
8484
if let (Some(instance), Some(device), Some(queue)) = (instance, device, queue) {
85-
Ok(callback(Some(i_slint_core::graphics::create_graphics_api_wgpu_26(
85+
Ok(callback(Some(i_slint_core::graphics::create_graphics_api_wgpu_27(
8686
instance, device, queue,
8787
))))
8888
} else {
8989
Ok(callback(None))
9090
}
9191
}
9292

93-
#[cfg(not(feature = "unstable-wgpu-26"))]
93+
#[cfg(not(feature = "unstable-wgpu-27"))]
9494
fn with_graphics_api<R>(
9595
&self,
9696
callback: impl FnOnce(Option<i_slint_core::api::GraphicsAPI<'_>>) -> R,
@@ -130,7 +130,7 @@ impl FemtoVGRenderer<WGPUBackend> {
130130
requested_graphics_api: Option<RequestedGraphicsAPI>,
131131
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
132132
let (instance, adapter, device, queue, surface) =
133-
i_slint_core::graphics::wgpu_26::init_instance_adapter_device_queue_surface(
133+
i_slint_core::graphics::wgpu_27::init_instance_adapter_device_queue_surface(
134134
window_handle,
135135
requested_graphics_api,
136136
/* rendering artifacts :( */

0 commit comments

Comments
 (0)