From 78a781a49851efe88a4f8021dbacc854bdecadfa Mon Sep 17 00:00:00 2001 From: Freja Roberts Date: Thu, 17 Oct 2024 00:13:28 +0200 Subject: [PATCH] chore: update deps and fix warnings --- Cargo.lock | 8 +- Cargo.toml | 4 +- violet-core/src/editor.rs | 2 +- violet-core/src/layout/mod.rs | 2 +- violet-core/src/layout/stack.rs | 2 +- violet-core/src/systems.rs | 4 +- violet-wgpu/src/app.rs | 3 +- violet-wgpu/src/renderer/debug_renderer.rs | 115 ++++++--------------- violet-wgpu/src/renderer/rect_renderer.rs | 2 +- violet-wgpu/src/renderer/text_renderer.rs | 6 +- violet-wgpu/src/systems.rs | 6 +- 11 files changed, 50 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb51238..031a78f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -990,7 +990,7 @@ dependencies = [ [[package]] name = "flax" version = "0.7.1" -source = "git+https://github.com/ten3roberts/flax#02f9f375c119b487ede481cce0a2bd27f6fb3fda" +source = "git+https://github.com/ten3roberts/flax#29c82199f8793c9942d57134c8d34a28c1ec9887" dependencies = [ "anyhow", "atomic_refcell", @@ -1008,7 +1008,7 @@ dependencies = [ [[package]] name = "flax-derive" version = "0.7.1" -source = "git+https://github.com/ten3roberts/flax#02f9f375c119b487ede481cce0a2bd27f6fb3fda" +source = "git+https://github.com/ten3roberts/flax#29c82199f8793c9942d57134c8d34a28c1ec9887" dependencies = [ "itertools 0.11.0", "proc-macro-crate 2.0.2", @@ -1657,7 +1657,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -1946,7 +1946,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 2.0.2", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.74", diff --git a/Cargo.toml b/Cargo.toml index 11b54f5..12cf17f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ winit = "0.30" wgpu = { version = "22.1", default-features = false, features = ["fragile-send-sync-non-atomic-wasm", "webgl", "wgsl"] } palette = { version = "0.7", features = ["serializing"] } dashmap = "6.0" -image = { version = "0.25", default_features = false, features = ["png", "jpeg"] } +image = { version = "0.25", default-features = false, features = ["png", "jpeg"] } color-hex = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -100,7 +100,7 @@ color-hex.workspace = true tracing.workspace = true futures.workspace = true -tokio = { version = "1.39", default_features= false, features = ["macros"] } +tokio = { version = "1.39", default-features= false, features = ["macros"] } serde_json = "1.0" tracing-tree.workspace = true diff --git a/violet-core/src/editor.rs b/violet-core/src/editor.rs index 7597bef..ad9086b 100644 --- a/violet-core/src/editor.rs +++ b/violet-core/src/editor.rs @@ -1,4 +1,4 @@ -use std::{fmt::Display, ops::RangeInclusive}; +use std::fmt::Display; use itertools::Itertools; use unicode_segmentation::UnicodeSegmentation; diff --git a/violet-core/src/layout/mod.rs b/violet-core/src/layout/mod.rs index 30ce816..126111c 100644 --- a/violet-core/src/layout/mod.rs +++ b/violet-core/src/layout/mod.rs @@ -13,7 +13,7 @@ use crate::{ self, anchor, aspect_ratio, children, layout, max_size, maximize, min_size, offset, padding, size, size_resolver, }, - layout::cache::{validate_cached_layout, validate_cached_query, CachedValue, LAYOUT_TOLERANCE}, + layout::cache::{validate_cached_layout, validate_cached_query, CachedValue}, Edges, Rect, }; diff --git a/violet-core/src/layout/stack.rs b/violet-core/src/layout/stack.rs index 7855031..6cd4610 100644 --- a/violet-core/src/layout/stack.rs +++ b/violet-core/src/layout/stack.rs @@ -24,7 +24,7 @@ use super::{ /// - Overlaying widgets /// - Horizontal or vertical alignment /// - Padding and margin with background colors (widgets don't inherently have a concept of "inner" -/// content, as they are their own content) +/// content, as they are their own content) /// - Centering widgets (this isn't HTML :P) /// - Limiting and expanding size of widgets #[derive(Default, Debug, Clone)] diff --git a/violet-core/src/systems.rs b/violet-core/src/systems.rs index f9212d2..cb238d7 100644 --- a/violet-core/src/systems.rs +++ b/violet-core/src/systems.rs @@ -1,12 +1,12 @@ use std::{ - collections::{BTreeMap, HashSet}, + collections::HashSet, sync::{Arc, Weak}, }; use atomic_refcell::AtomicRefCell; use flax::{ archetype::Storage, - component::{ComponentDesc, ComponentKey, ComponentValue}, + component::ComponentValue, components::child_of, entity_ids, events::{EventData, EventSubscriber}, diff --git a/violet-wgpu/src/app.rs b/violet-wgpu/src/app.rs index 15cacdd..f4bf1ab 100644 --- a/violet-wgpu/src/app.rs +++ b/violet-wgpu/src/app.rs @@ -15,7 +15,7 @@ use winit::{ use violet_core::{ animation::update_animations, assets::AssetCache, - components::{self, max_size, size}, + components::{self}, executor::Executor, input::InputState, io::{self, Clipboard}, @@ -25,7 +25,6 @@ use violet_core::{ hydrate_text, invalidate_cached_layout_system, layout_system, templating_system, transform_system, }, - unit::Unit, widget::{col, WidgetExt}, Frame, FutureEffect, Rect, Scope, Widget, }; diff --git a/violet-wgpu/src/renderer/debug_renderer.rs b/violet-wgpu/src/renderer/debug_renderer.rs index 73bbe71..c2b4543 100644 --- a/violet-wgpu/src/renderer/debug_renderer.rs +++ b/violet-wgpu/src/renderer/debug_renderer.rs @@ -1,13 +1,13 @@ use std::{collections::BTreeMap, sync::Arc}; -use flax::{fetch::entity_refs, Entity, Query}; +use flax::Entity; use glam::{vec2, vec3, vec4, Mat4, Quat, Vec4}; use itertools::Itertools; use violet_core::{ - components::{layout_args, rect, screen_clip_mask, screen_transform}, - layout::cache::{layout_cache, LayoutUpdateEvent}, + components::{rect, screen_clip_mask, screen_transform}, + layout::cache::LayoutUpdateEvent, stored::{self, Handle}, - Frame, Rect, + Frame, }; use wgpu::{BindGroup, BindGroupLayout, SamplerDescriptor, ShaderStages, TextureFormat}; @@ -29,7 +29,6 @@ pub struct DebugRenderer { mesh: Arc, border_shader: stored::Handle, - solid_shader: stored::Handle, layout_changes_rx: flume::Receiver<(Entity, LayoutUpdateEvent)>, layout_changes: BTreeMap<(Entity, LayoutUpdateEvent), usize>, @@ -108,7 +107,6 @@ impl DebugRenderer { layout_changes_rx, layout_changes: BTreeMap::new(), objects: Vec::new(), - solid_shader: todo!(), } } @@ -122,53 +120,6 @@ impl DebugRenderer { self.objects.clear(); - let mut overflow = Vec::new(); - - let mut query = Query::new((entity_refs(), layout_args(), rect())); - let mut query = query.borrow(&frame.world); - - query - .iter() - .filter_map(|(entity, &args, &rect)| { - let transform = entity.get_copy(screen_transform()).ok()?; - let clip_mask = entity.get_copy(screen_clip_mask()).ok()?; - - // let model_matrix = Mat4::from_scale_rotation_translation( - // screen_rect.size().extend(1.0), - // Quat::IDENTITY, - // screen_rect.pos().extend(0.2), - // ); - - let mut draw = |rect: Rect| { - let model_matrix = transform - * Mat4::from_scale_rotation_translation( - rect.size().extend(1.0), - Quat::IDENTITY, - rect.pos().extend(0.2), - ); - - let object_data = ObjectData { - model_matrix, - color: vec4(1.0, 0.0, 0.0, 0.5), - }; - - overflow.push(( - DrawCommand { - shader: self.solid_shader.clone(), - bind_group: self.bind_group.clone(), - mesh: self.mesh.clone(), - index_count: 6, - clip_mask, - }, - object_data, - )); - }; - - Some(()) - }) - .for_each(|_| {}); - - let mut query = Query::new((entity_refs(), layout_cache())); let groups = self.layout_changes.iter().chunk_by(|v| v.0 .0); let objects = groups.into_iter().filter_map(|(id, group)| { @@ -183,36 +134,34 @@ impl DebugRenderer { Some((entity, &self.border_shader, color)) }); - let objects = objects - .filter_map(|(entity, shader, color)| { - let rect = entity.get_copy(rect()).ok()?.align_to_grid(); - let transform = entity.get_copy(screen_transform()).ok()?; - let clip_mask = entity.get_copy(screen_clip_mask()).ok()?; - - let model_matrix = transform - * Mat4::from_scale_rotation_translation( - rect.size().extend(1.0), - Quat::IDENTITY, - rect.pos().extend(0.2), - ); - - let object_data = ObjectData { - model_matrix, - color, - }; - - Some(( - DrawCommand { - shader: shader.clone(), - bind_group: self.bind_group.clone(), - mesh: self.mesh.clone(), - index_count: 6, - clip_mask, - }, - object_data, - )) - }) - .chain(overflow); + let objects = objects.filter_map(|(entity, shader, color)| { + let rect = entity.get_copy(rect()).ok()?.align_to_grid(); + let transform = entity.get_copy(screen_transform()).ok()?; + let clip_mask = entity.get_copy(screen_clip_mask()).ok()?; + + let model_matrix = transform + * Mat4::from_scale_rotation_translation( + rect.size().extend(1.0), + Quat::IDENTITY, + rect.pos().extend(0.2), + ); + + let object_data = ObjectData { + model_matrix, + color, + }; + + Some(( + DrawCommand { + shader: shader.clone(), + bind_group: self.bind_group.clone(), + mesh: self.mesh.clone(), + index_count: 6, + clip_mask, + }, + object_data, + )) + }); self.objects.clear(); self.objects.extend(objects); diff --git a/violet-wgpu/src/renderer/rect_renderer.rs b/violet-wgpu/src/renderer/rect_renderer.rs index d9efb77..4d39684 100644 --- a/violet-wgpu/src/renderer/rect_renderer.rs +++ b/violet-wgpu/src/renderer/rect_renderer.rs @@ -3,7 +3,7 @@ use std::{convert::Infallible, sync::Arc}; use flax::{ entity_ids, filter::{All, With}, - CommandBuffer, Component, EntityIds, EntityRef, Fetch, FetchExt, Mutable, Opt, OptOr, Query, + CommandBuffer, Component, EntityIds, Fetch, FetchExt, Mutable, Opt, OptOr, Query, }; use glam::{vec2, vec3, Mat4, Quat, Vec2, Vec4}; use image::{DynamicImage, ImageBuffer}; diff --git a/violet-wgpu/src/renderer/text_renderer.rs b/violet-wgpu/src/renderer/text_renderer.rs index b08c74d..cb18b6f 100644 --- a/violet-wgpu/src/renderer/text_renderer.rs +++ b/violet-wgpu/src/renderer/text_renderer.rs @@ -159,7 +159,7 @@ impl MeshGenerator { source: include_str!("../../../assets/shaders/text.wgsl"), format: color_format, vertex_layouts: &[Vertex::layout()], - layouts: &[&globals_layout, object_layout, &text_layout], + layouts: &[globals_layout, object_layout, &text_layout], }, )); @@ -172,7 +172,7 @@ impl MeshGenerator { ..Default::default() })); - let sentinel = Arc::new(mesh_buffer.allocate(&gpu, 0, 0)); + let sentinel = Arc::new(mesh_buffer.allocate(gpu, 0, 0)); Self { rasterizer: FontRasterizer::new(gpu, sampler, text_layout, store), shader, @@ -180,6 +180,7 @@ impl MeshGenerator { } } + #[allow(clippy::too_many_arguments)] fn update_mesh( &mut self, gpu: &Gpu, @@ -187,7 +188,6 @@ impl MeshGenerator { assets: &AssetCache, text_system: &mut TextSystem, buffer: &mut Buffer, - // text: &str, mesh: &mut Arc, store: &mut RendererStore, scale_factor: f64, diff --git a/violet-wgpu/src/systems.rs b/violet-wgpu/src/systems.rs index fdf2671..fd8c7c3 100644 --- a/violet-wgpu/src/systems.rs +++ b/violet-wgpu/src/systems.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use cosmic_text::{Metrics, Wrap}; +use cosmic_text::Wrap; use flax::{ components::child_of, entity_ids, @@ -8,15 +8,13 @@ use flax::{ BoxedSystem, CommandBuffer, Component, EntityIds, Fetch, FetchExt, Mutable, OptOr, Query, QueryBorrow, RelationExt, System, World, }; -use glam::Vec2; use parking_lot::Mutex; use puffin::profile_scope; use violet_core::{ - components::{font_size, layout_bounds, layout_glyphs, rect, size_resolver, text, text_wrap}, + components::{font_size, layout_glyphs, size_resolver, text, text_wrap}, style::stylesheet, text::{LayoutGlyphs, TextSegment}, - Rect, }; use crate::text::TextSystem;