Fix standalone svg feature

This commit is contained in:
Héctor Ramón Jiménez 2025-10-24 18:21:03 +02:00
parent 5216253998
commit 1b51364154
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 10 additions and 6 deletions

View file

@ -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<Work>,
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
worker_: Option<thread::JoinHandle<()>>,
worker_: Option<std::thread::JoinHandle<()>>,
}
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;

View file

@ -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)
}