diff --git a/examples/integration/Cargo.toml b/examples/integration/Cargo.toml index afc2c791..4515502f 100644 --- a/examples/integration/Cargo.toml +++ b/examples/integration/Cargo.toml @@ -8,4 +8,4 @@ publish = false [dependencies] iced_winit = { path = "../../winit" } iced_wgpu = { path = "../../wgpu" } -env_logger = "0.7" +env_logger = "0.8" diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index b236cc0d..c8926c33 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -12,7 +12,7 @@ serde_json = "1.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] async-std = "1.0" -directories = "2.0" +directories-next = "2.0" [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys = { version = "0.3", features = ["Window", "Storage"] } diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 7a546815..f88e9869 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -499,7 +499,7 @@ enum SaveError { impl SavedState { fn path() -> std::path::PathBuf { let mut path = if let Some(project_dirs) = - directories::ProjectDirs::from("rs", "Iced", "Todos") + directories_next::ProjectDirs::from("rs", "Iced", "Todos") { project_dirs.data_dir().into() } else { diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml index 96749e90..bc7fac11 100644 --- a/examples/tour/Cargo.toml +++ b/examples/tour/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] iced = { path = "../..", features = ["image", "debug"] } -env_logger = "0.7" +env_logger = "0.8" diff --git a/glow/Cargo.toml b/glow/Cargo.toml index 11ca80e2..8c15be04 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -15,11 +15,11 @@ image = [] svg = [] [dependencies] -glow = "0.5" -glow_glyph = "0.3" +glow = "0.6" +glow_glyph = "0.4" glyph_brush = "0.7" -euclid = "0.20" -bytemuck = "1.2" +euclid = "0.22" +bytemuck = "1.4" log = "0.4" [dependencies.iced_native] diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index dec24c59..1511f8b0 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -12,11 +12,14 @@ font-icons = [] opengl = [] [dependencies] -bytemuck = "1.2" -glam = "0.9" +glam = "0.10" raw-window-handle = "0.3" thiserror = "1.0" +[dependencies.bytemuck] +version = "1.4" +features = ["derive"] + [dependencies.iced_native] version = "0.2" path = "../native" @@ -26,11 +29,11 @@ version = "0.1" path = "../style" [dependencies.lyon] -version = "0.15" +version = "0.16" optional = true [dependencies.font-kit] -version = "0.6" +version = "0.8" optional = true [package.metadata.docs.rs] diff --git a/graphics/src/triangle.rs b/graphics/src/triangle.rs index ce879ffc..eb1494b1 100644 --- a/graphics/src/triangle.rs +++ b/graphics/src/triangle.rs @@ -1,4 +1,5 @@ //! Draw geometry using meshes of triangles. +use bytemuck::{Pod, Zeroable}; /// A set of [`Vertex2D`] and indices representing a list of triangles. /// @@ -16,7 +17,7 @@ pub struct Mesh2D { } /// A two-dimensional vertex with some color in __linear__ RGBA. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Zeroable, Pod)] #[repr(C)] pub struct Vertex2D { /// The vertex position @@ -24,9 +25,3 @@ pub struct Vertex2D { /// The vertex color in __linear__ RGBA. pub color: [f32; 4], } - -#[allow(unsafe_code)] -unsafe impl bytemuck::Zeroable for Vertex2D {} - -#[allow(unsafe_code)] -unsafe impl bytemuck::Pod for Vertex2D {} diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index c07081fd..01fd720b 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -16,13 +16,15 @@ default_system_font = ["iced_graphics/font-source"] wgpu = "0.6" wgpu_glyph = "0.10" glyph_brush = "0.7" -zerocopy = "0.3" -bytemuck = "1.2" raw-window-handle = "0.3" log = "0.4" guillotiere = "0.6" futures = "0.3" +[dependencies.bytemuck] +version = "1.4" +features = ["derive"] + [dependencies.iced_native] version = "0.2" path = "../native" diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 891dba1e..c256ca7e 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -13,7 +13,8 @@ use iced_graphics::layer; use iced_native::Rectangle; use std::cell::RefCell; use std::mem; -use zerocopy::AsBytes; + +use bytemuck::{Pod, Zeroable}; #[cfg(feature = "image")] use iced_native::image; @@ -219,14 +220,14 @@ impl Pipeline { let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::image vertex buffer"), - contents: QUAD_VERTS.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_VERTS), usage: wgpu::BufferUsage::VERTEX, }); let indices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::image index buffer"), - contents: QUAD_INDICES.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_INDICES), usage: wgpu::BufferUsage::INDEX, }); @@ -385,12 +386,9 @@ impl Pipeline { device, ); - uniforms_buffer.copy_from_slice( - Uniforms { - transform: transformation.into(), - } - .as_bytes(), - ); + uniforms_buffer.copy_from_slice(bytemuck::bytes_of(&Uniforms { + transform: transformation.into(), + })); } let mut i = 0; @@ -411,8 +409,9 @@ impl Pipeline { device, ); - instances_buffer - .copy_from_slice(instances[i..i + amount].as_bytes()); + instances_buffer.copy_from_slice(bytemuck::cast_slice( + &instances[i..i + amount], + )); let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { @@ -463,7 +462,7 @@ impl Pipeline { } #[repr(C)] -#[derive(Clone, Copy, AsBytes)] +#[derive(Clone, Copy, Zeroable, Pod)] pub struct Vertex { _position: [f32; 2], } @@ -486,7 +485,7 @@ const QUAD_VERTS: [Vertex; 4] = [ ]; #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Instance { _position: [f32; 2], _size: [f32; 2], @@ -500,7 +499,7 @@ impl Instance { } #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Uniforms { transform: [f32; 16], } diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index 7648aa7e..95df2e99 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -2,8 +2,6 @@ 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, @@ -119,7 +117,7 @@ impl Cache { let allocation = texture_atlas.upload( width, height, - canvas.get_data().as_bytes(), + bytemuck::cast_slice(canvas.get_data()), device, encoder, )?; diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index d54f2577..24d20cfa 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -2,9 +2,9 @@ use crate::Transformation; use iced_graphics::layer; use iced_native::Rectangle; +use bytemuck::{Pod, Zeroable}; use std::mem; use wgpu::util::DeviceExt; -use zerocopy::AsBytes; #[derive(Debug)] pub struct Pipeline { @@ -156,14 +156,14 @@ impl Pipeline { let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::quad vertex buffer"), - contents: QUAD_VERTS.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_VERTS), usage: wgpu::BufferUsage::VERTEX, }); let indices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::quad index buffer"), - contents: QUAD_INDICES.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_INDICES), usage: wgpu::BufferUsage::INDEX, }); @@ -207,7 +207,7 @@ impl Pipeline { device, ); - constants_buffer.copy_from_slice(uniforms.as_bytes()); + constants_buffer.copy_from_slice(bytemuck::bytes_of(&uniforms)); } let mut i = 0; @@ -271,7 +271,7 @@ impl Pipeline { } #[repr(C)] -#[derive(Clone, Copy, AsBytes)] +#[derive(Clone, Copy, Zeroable, Pod)] pub struct Vertex { _position: [f32; 2], } @@ -296,7 +296,7 @@ const QUAD_VERTS: [Vertex; 4] = [ const MAX_INSTANCES: usize = 100_000; #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Uniforms { transform: [f32; 16], scale: f32, diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index 53ce454b..61a771d8 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -1,8 +1,9 @@ //! Draw meshes of triangles. use crate::{settings, Transformation}; use iced_graphics::layer; + +use bytemuck::{Pod, Zeroable}; use std::mem; -use zerocopy::AsBytes; pub use iced_graphics::triangle::{Mesh2D, Vertex2D}; @@ -322,7 +323,7 @@ impl Pipeline { } } - let uniforms = uniforms.as_bytes(); + let uniforms = bytemuck::cast_slice(&uniforms); if let Some(uniforms_size) = wgpu::BufferSize::new(uniforms.len() as u64) @@ -409,7 +410,7 @@ impl Pipeline { } #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Uniforms { transform: [f32; 16], // We need to align this to 256 bytes to please `wgpu`...