summaryrefslogtreecommitdiffstats
path: root/wgpu/src/image
diff options
context:
space:
mode:
authorLibravatar Malte Veerman <malte.veerman@gmail.com>2020-01-17 20:15:20 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-25 13:26:50 +0100
commitc0996923c6aab39bb61ca6d3310149c66a73fac8 (patch)
treec34f01b1b1aee5d2531810175a85313d0e30177e /wgpu/src/image
parent3f388351054c0961923b5f78e7dcf42289565a48 (diff)
downloadiced-c0996923c6aab39bb61ca6d3310149c66a73fac8.tar.gz
iced-c0996923c6aab39bb61ca6d3310149c66a73fac8.tar.bz2
iced-c0996923c6aab39bb61ca6d3310149c66a73fac8.zip
Batch image draw calls into one with multiple instances
Diffstat (limited to 'wgpu/src/image')
-rw-r--r--wgpu/src/image/raster.rs12
-rw-r--r--wgpu/src/image/vector.rs15
2 files changed, 6 insertions, 21 deletions
diff --git a/wgpu/src/image/raster.rs b/wgpu/src/image/raster.rs
index 387bd23a..bca2ebda 100644
--- a/wgpu/src/image/raster.rs
+++ b/wgpu/src/image/raster.rs
@@ -3,7 +3,6 @@ use iced_native::image;
use std::{
collections::{HashMap, HashSet},
};
-use guillotiere::Size;
use debug_stub_derive::*;
#[derive(DebugStub)]
@@ -72,17 +71,10 @@ impl Cache {
encoder: &mut wgpu::CommandEncoder,
atlas_array: &mut TextureArray,
) -> &Memory {
- let _ = self.load(handle);
-
- let memory = self.map.get_mut(&handle.id()).unwrap();
+ let memory = self.load(handle);
if let Memory::Host(image) = memory {
- let (width, height) = image.dimensions();
- let size = Size::new(width as i32, height as i32);
-
- let allocation = atlas_array.allocate(size);
-
- atlas_array.upload(image, &allocation, device, encoder);
+ let allocation = atlas_array.upload(image, device, encoder);
*memory = Memory::Device(allocation);
}
diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs
index a83d1a0a..9bddcc2b 100644
--- a/wgpu/src/image/vector.rs
+++ b/wgpu/src/image/vector.rs
@@ -3,7 +3,6 @@ use iced_native::svg;
use std::{
collections::{HashMap, HashSet},
};
-use guillotiere::Size;
use debug_stub_derive::*;
#[derive(DebugStub)]
@@ -83,25 +82,19 @@ impl Cache {
// We currently rerasterize the SVG when its size changes. This is slow
// as heck. A GPU rasterizer like `pathfinder` may perform better.
// It would be cool to be able to smooth resize the `svg` example.
- if self.rasterized.get(&(id, width, height)).is_some() {
+ if self.rasterized.contains_key(&(id, width, height)) {
let _ = self.svg_hits.insert(id);
let _ = self.rasterized_hits.insert((id, width, height));
return self.rasterized.get(&(id, width, height));
}
- let _ = self.load(handle);
-
- match self.svgs.get(&handle.id()).unwrap() {
+ match self.load(handle) {
Svg::Loaded(tree) => {
if width == 0 || height == 0 {
return None;
}
- let size = Size::new(width as i32, height as i32);
-
- let array_allocation = texture_array.allocate(size);
-
// TODO: Optimize!
// We currently rerasterize the SVG when its size changes. This is slow
// as heck. A GPU rasterizer like `pathfinder` may perform better.
@@ -121,13 +114,13 @@ impl Cache {
&mut canvas,
);
- texture_array.upload(&canvas, &array_allocation, device, encoder);
+ let allocation = texture_array.upload(&canvas, device, encoder);
let _ = self.svg_hits.insert(id);
let _ = self.rasterized_hits.insert((id, width, height));
let _ = self
.rasterized
- .insert((id, width, height), array_allocation);
+ .insert((id, width, height), allocation);
self.rasterized.get(&(id, width, height))
}