summaryrefslogtreecommitdiffstats
path: root/wgpu/src/image
diff options
context:
space:
mode:
authorLibravatar Aaron Housh <Dispersia@users.noreply.github.com>2021-05-19 07:14:26 -0700
committerLibravatar Aaron Housh <Dispersia@users.noreply.github.com>2021-05-19 07:14:26 -0700
commitae484429d30a3360893d030a17e52caa4164a052 (patch)
tree4bfe30d3b46c7e30170e0b495d9a4dd1a2a1825f /wgpu/src/image
parentcf6af4c2560f5996bc533402ac3e4289c0c94702 (diff)
parent3918257883dba3cf260bd9764cb7b34101c435e6 (diff)
downloadiced-ae484429d30a3360893d030a17e52caa4164a052.tar.gz
iced-ae484429d30a3360893d030a17e52caa4164a052.tar.bz2
iced-ae484429d30a3360893d030a17e52caa4164a052.zip
Merge branch 'hecrj:master' into upgrade-wgpu
Diffstat (limited to 'wgpu/src/image')
-rw-r--r--wgpu/src/image/vector.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs
index ab0f67d0..8c7de617 100644
--- a/wgpu/src/image/vector.rs
+++ b/wgpu/src/image/vector.rs
@@ -1,7 +1,8 @@
-use crate::image::atlas::{self, Atlas};
use iced_native::svg;
use std::collections::{HashMap, HashSet};
+use crate::image::atlas::{self, Atlas};
+
pub enum Svg {
Loaded(usvg::Tree),
NotFound,
@@ -111,26 +112,13 @@ impl Cache {
let width = img.width();
let height = img.height();
- let mut rgba = img.take().into_iter();
-
- // TODO: Perform conversion in the GPU
- let bgra: Vec<u8> = std::iter::from_fn(move || {
- use std::iter::once;
-
- let r = rgba.next()?;
- let g = rgba.next()?;
- let b = rgba.next()?;
- let a = rgba.next()?;
-
- Some(once(b).chain(once(g)).chain(once(r)).chain(once(a)))
- })
- .flatten()
- .collect();
+ let mut rgba = img.take();
+ rgba.chunks_exact_mut(4).for_each(|rgba| rgba.swap(0, 2));
let allocation = texture_atlas.upload(
width,
height,
- bytemuck::cast_slice(bgra.as_slice()),
+ bytemuck::cast_slice(rgba.as_slice()),
device,
encoder,
)?;