Fix standalone svg feature
This commit is contained in:
parent
5216253998
commit
1b51364154
2 changed files with 10 additions and 6 deletions
|
|
@ -2,9 +2,11 @@ use crate::core::{self, Size};
|
||||||
use crate::graphics::Shell;
|
use crate::graphics::Shell;
|
||||||
use crate::image::atlas::{self, Atlas};
|
use crate::image::atlas::{self, Atlas};
|
||||||
|
|
||||||
|
#[cfg(feature = "image")]
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
|
#[cfg(feature = "image")]
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::thread;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Cache {
|
pub struct Cache {
|
||||||
|
|
@ -18,26 +20,26 @@ pub struct Cache {
|
||||||
#[cfg(feature = "image")]
|
#[cfg(feature = "image")]
|
||||||
work: mpsc::Receiver<Work>,
|
work: mpsc::Receiver<Work>,
|
||||||
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
|
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
|
||||||
worker_: Option<thread::JoinHandle<()>>,
|
worker_: Option<std::thread::JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cache {
|
impl Cache {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
queue: &wgpu::Queue,
|
_queue: &wgpu::Queue,
|
||||||
backend: wgpu::Backend,
|
backend: wgpu::Backend,
|
||||||
layout: wgpu::BindGroupLayout,
|
layout: wgpu::BindGroupLayout,
|
||||||
shell: &Shell,
|
_shell: &Shell,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
|
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
|
||||||
let (worker, jobs, work) =
|
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"))]
|
#[cfg(all(feature = "image", target_arch = "wasm32"))]
|
||||||
let (jobs, work) = (mpsc::sync_channel(0).0, mpsc::sync_channel(0).1);
|
let (jobs, work) = (mpsc::sync_channel(0).0, mpsc::sync_channel(0).1);
|
||||||
|
|
||||||
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
|
#[cfg(all(feature = "image", not(target_arch = "wasm32")))]
|
||||||
let handle = thread::spawn(move || worker.run());
|
let handle = std::thread::spawn(move || worker.run());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
atlas: Atlas::new(device, backend, layout),
|
atlas: Atlas::new(device, backend, layout),
|
||||||
|
|
@ -181,6 +183,7 @@ impl Cache {
|
||||||
self.vector.trim(&mut self.atlas); // TODO: Concurrency
|
self.vector.trim(&mut self.atlas); // TODO: Concurrency
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "image")]
|
||||||
fn receive(&mut self) {
|
fn receive(&mut self) {
|
||||||
use crate::image::raster::Memory;
|
use crate::image::raster::Memory;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ impl Cache {
|
||||||
let _ = self.svg_hits.insert(id);
|
let _ = self.svg_hits.insert(id);
|
||||||
let _ = self.rasterized_hits.insert(key);
|
let _ = self.rasterized_hits.insert(key);
|
||||||
let _ = self.rasterized.insert(key, allocation);
|
let _ = self.rasterized.insert(key, allocation);
|
||||||
|
self.should_trim = true;
|
||||||
|
|
||||||
self.rasterized.get(&key)
|
self.rasterized.get(&key)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue