diff options
author | 2020-04-07 05:48:21 +0200 | |
---|---|---|
committer | 2020-04-07 05:48:21 +0200 | |
commit | d807ef367e0257ba54f8cf38708a7a61e28a4acb (patch) | |
tree | 1ee065aa7f47cc9a3e3e642c9b58576dd54d3327 /wgpu/src/image | |
parent | 703beae05ec2988b9a6b15e84291ec818b37bf5b (diff) | |
download | iced-d807ef367e0257ba54f8cf38708a7a61e28a4acb.tar.gz iced-d807ef367e0257ba54f8cf38708a7a61e28a4acb.tar.bz2 iced-d807ef367e0257ba54f8cf38708a7a61e28a4acb.zip |
Update `wgpu` to `0.5` in `iced_wgpu` :tada:
Diffstat (limited to 'wgpu/src/image')
-rw-r--r-- | wgpu/src/image/atlas.rs | 38 | ||||
-rw-r--r-- | wgpu/src/image/vector.rs | 4 |
2 files changed, 15 insertions, 27 deletions
diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index 86a5ff49..3ce3ce8b 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -28,6 +28,7 @@ impl Atlas { }; let texture = device.create_texture(&wgpu::TextureDescriptor { + label: None, size: extent, array_layer_count: 2, mip_level_count: 1, @@ -56,17 +57,14 @@ impl Atlas { self.layers.len() } - pub fn upload<C>( + pub fn upload( &mut self, width: u32, height: u32, - data: &[C], + data: &[u8], device: &wgpu::Device, encoder: &mut wgpu::CommandEncoder, - ) -> Option<Entry> - where - C: Copy + 'static, - { + ) -> Option<Entry> { let entry = { let current_size = self.layers.len(); let entry = self.allocate(width, height)?; @@ -80,9 +78,8 @@ impl Atlas { log::info!("Allocated atlas entry: {:?}", entry); - let buffer = device - .create_buffer_mapped(data.len(), wgpu::BufferUsage::COPY_SRC) - .fill_from_slice(data); + let buffer = + device.create_buffer_with_data(data, wgpu::BufferUsage::COPY_SRC); match &entry { Entry::Contiguous(allocation) => { @@ -274,18 +271,14 @@ impl Atlas { wgpu::BufferCopyView { buffer, offset: offset as u64, - row_pitch: 4 * image_width, - image_height, + bytes_per_row: 4 * image_width, + rows_per_image: image_height, }, wgpu::TextureCopyView { texture: &self.texture, array_layer: layer as u32, mip_level: 0, - origin: wgpu::Origin3d { - x: x as f32, - y: y as f32, - z: 0.0, - }, + origin: wgpu::Origin3d { x, y, z: 0 }, }, extent, ); @@ -302,6 +295,7 @@ impl Atlas { } let new_texture = device.create_texture(&wgpu::TextureDescriptor { + label: None, size: wgpu::Extent3d { width: SIZE, height: SIZE, @@ -331,21 +325,13 @@ impl Atlas { texture: &self.texture, array_layer: i as u32, mip_level: 0, - origin: wgpu::Origin3d { - x: 0.0, - y: 0.0, - z: 0.0, - }, + origin: wgpu::Origin3d { x: 0, y: 0, z: 0 }, }, wgpu::TextureCopyView { texture: &new_texture, array_layer: i as u32, mip_level: 0, - origin: wgpu::Origin3d { - x: 0.0, - y: 0.0, - z: 0.0, - }, + origin: wgpu::Origin3d { x: 0, y: 0, z: 0 }, }, wgpu::Extent3d { width: SIZE, diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index b6776827..7648aa7e 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -2,6 +2,8 @@ use crate::image::atlas::{self, Atlas}; use iced_native::svg; use std::collections::{HashMap, HashSet}; +use zerocopy::AsBytes; + pub enum Svg { Loaded(resvg::usvg::Tree), NotFound, @@ -117,7 +119,7 @@ impl Cache { let allocation = texture_atlas.upload( width, height, - canvas.get_data(), + canvas.get_data().as_bytes(), device, encoder, )?; |