From 1b5136415483293207f44862ee0778128fec63bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 24 Oct 2025 18:21:03 +0200 Subject: [PATCH] Fix standalone `svg` feature --- wgpu/src/image/cache.rs | 15 +++++++++------ wgpu/src/image/vector.rs | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wgpu/src/image/cache.rs b/wgpu/src/image/cache.rs index 858c6b4c..61777318 100644 --- a/wgpu/src/image/cache.rs +++ b/wgpu/src/image/cache.rs @@ -2,9 +2,11 @@ use crate::core::{self, Size}; use crate::graphics::Shell; use crate::image::atlas::{self, Atlas}; +#[cfg(feature = "image")] use std::collections::BTreeSet; + +#[cfg(feature = "image")] use std::sync::mpsc; -use std::thread; #[derive(Debug)] pub struct Cache { @@ -18,26 +20,26 @@ pub struct Cache { #[cfg(feature = "image")] work: mpsc::Receiver, #[cfg(all(feature = "image", not(target_arch = "wasm32")))] - worker_: Option>, + worker_: Option>, } impl Cache { pub fn new( device: &wgpu::Device, - queue: &wgpu::Queue, + _queue: &wgpu::Queue, backend: wgpu::Backend, layout: wgpu::BindGroupLayout, - shell: &Shell, + _shell: &Shell, ) -> Self { #[cfg(all(feature = "image", not(target_arch = "wasm32")))] let (worker, jobs, work) = - Worker::new(device, queue, backend, layout.clone(), shell); + Worker::new(device, _queue, backend, layout.clone(), _shell); #[cfg(all(feature = "image", target_arch = "wasm32"))] let (jobs, work) = (mpsc::sync_channel(0).0, mpsc::sync_channel(0).1); #[cfg(all(feature = "image", not(target_arch = "wasm32")))] - let handle = thread::spawn(move || worker.run()); + let handle = std::thread::spawn(move || worker.run()); Self { atlas: Atlas::new(device, backend, layout), @@ -181,6 +183,7 @@ impl Cache { self.vector.trim(&mut self.atlas); // TODO: Concurrency } + #[cfg(feature = "image")] fn receive(&mut self) { use crate::image::raster::Memory; diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index 9949cf39..2fa6ba39 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -176,6 +176,7 @@ impl Cache { let _ = self.svg_hits.insert(id); let _ = self.rasterized_hits.insert(key); let _ = self.rasterized.insert(key, allocation); + self.should_trim = true; self.rasterized.get(&key) }