Remove all worker calls in Wasm
This commit is contained in:
parent
22488c537c
commit
71a8bc17d0
1 changed files with 15 additions and 5 deletions
|
|
@ -81,6 +81,8 @@ impl Cache {
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = self.raster.pending.insert(handle.id(), vec![callback]);
|
let _ = self.raster.pending.insert(handle.id(), vec![callback]);
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
self.worker.load(handle);
|
self.worker.load(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,6 +93,7 @@ impl Cache {
|
||||||
if let Some(memory) = load_image(
|
if let Some(memory) = load_image(
|
||||||
&mut self.raster.cache,
|
&mut self.raster.cache,
|
||||||
&mut self.raster.pending,
|
&mut self.raster.pending,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
&self.worker,
|
&self.worker,
|
||||||
handle,
|
handle,
|
||||||
None,
|
None,
|
||||||
|
|
@ -122,6 +125,7 @@ impl Cache {
|
||||||
let memory = load_image(
|
let memory = load_image(
|
||||||
&mut self.raster.cache,
|
&mut self.raster.cache,
|
||||||
&mut self.raster.pending,
|
&mut self.raster.pending,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
&self.worker,
|
&self.worker,
|
||||||
handle,
|
handle,
|
||||||
None,
|
None,
|
||||||
|
|
@ -165,6 +169,8 @@ impl Cache {
|
||||||
|
|
||||||
if !self.raster.pending.contains_key(&handle.id()) {
|
if !self.raster.pending.contains_key(&handle.id()) {
|
||||||
let _ = self.raster.pending.insert(handle.id(), Vec::new());
|
let _ = self.raster.pending.insert(handle.id(), Vec::new());
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
self.worker.upload(handle, image);
|
self.worker.upload(handle, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,8 +205,9 @@ impl Cache {
|
||||||
|
|
||||||
pub fn trim(&mut self) {
|
pub fn trim(&mut self) {
|
||||||
#[cfg(feature = "image")]
|
#[cfg(feature = "image")]
|
||||||
self.raster.cache.trim(&mut self.atlas, |bind_group| {
|
self.raster.cache.trim(&mut self.atlas, |_bind_group| {
|
||||||
self.worker.drop(bind_group);
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
self.worker.drop(_bind_group);
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "svg")]
|
#[cfg(feature = "svg")]
|
||||||
|
|
@ -209,9 +216,10 @@ impl Cache {
|
||||||
|
|
||||||
#[cfg(feature = "image")]
|
#[cfg(feature = "image")]
|
||||||
fn receive(&mut self) {
|
fn receive(&mut self) {
|
||||||
use crate::image::raster::Memory;
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
|
||||||
while let Ok(work) = self.worker.try_recv() {
|
while let Ok(work) = self.worker.try_recv() {
|
||||||
|
use crate::image::raster::Memory;
|
||||||
|
|
||||||
match work {
|
match work {
|
||||||
worker::Work::Upload {
|
worker::Work::Upload {
|
||||||
handle,
|
handle,
|
||||||
|
|
@ -273,7 +281,7 @@ type Callback = Box<dyn FnOnce(core::image::Allocation) + Send>;
|
||||||
fn load_image<'a>(
|
fn load_image<'a>(
|
||||||
cache: &'a mut crate::image::raster::Cache,
|
cache: &'a mut crate::image::raster::Cache,
|
||||||
pending: &mut HashMap<core::image::Id, Vec<Callback>>,
|
pending: &mut HashMap<core::image::Id, Vec<Callback>>,
|
||||||
worker: &Worker,
|
#[cfg(not(target_arch = "wasm32"))] worker: &Worker,
|
||||||
handle: &core::image::Handle,
|
handle: &core::image::Handle,
|
||||||
callback: Option<Callback>,
|
callback: Option<Callback>,
|
||||||
) -> Option<&'a mut crate::image::raster::Memory> {
|
) -> Option<&'a mut crate::image::raster::Memory> {
|
||||||
|
|
@ -288,6 +296,8 @@ fn load_image<'a>(
|
||||||
cache.insert(handle, Memory::load(handle));
|
cache.insert(handle, Memory::load(handle));
|
||||||
} else if !pending.contains_key(&handle.id()) {
|
} else if !pending.contains_key(&handle.id()) {
|
||||||
let _ = pending.insert(handle.id(), Vec::from_iter(callback));
|
let _ = pending.insert(handle.id(), Vec::from_iter(callback));
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
worker.load(handle);
|
worker.load(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue