Skip to content

Commit

Permalink
chore: update deps and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Oct 16, 2024
1 parent 2db10ad commit 78a781a
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 104 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion violet-core/src/editor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt::Display, ops::RangeInclusive};
use std::fmt::Display;

use itertools::Itertools;
use unicode_segmentation::UnicodeSegmentation;
Expand Down
2 changes: 1 addition & 1 deletion violet-core/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion violet-core/src/layout/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions violet-core/src/systems.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
3 changes: 1 addition & 2 deletions violet-wgpu/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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,
};
Expand Down
115 changes: 32 additions & 83 deletions violet-wgpu/src/renderer/debug_renderer.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -29,7 +29,6 @@ pub struct DebugRenderer {
mesh: Arc<MeshHandle>,

border_shader: stored::Handle<Shader>,
solid_shader: stored::Handle<Shader>,

layout_changes_rx: flume::Receiver<(Entity, LayoutUpdateEvent)>,
layout_changes: BTreeMap<(Entity, LayoutUpdateEvent), usize>,
Expand Down Expand Up @@ -108,7 +107,6 @@ impl DebugRenderer {
layout_changes_rx,
layout_changes: BTreeMap::new(),
objects: Vec::new(),
solid_shader: todo!(),
}
}

Expand All @@ -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)| {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion violet-wgpu/src/renderer/rect_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 3 additions & 3 deletions violet-wgpu/src/renderer/text_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
));

Expand All @@ -172,22 +172,22 @@ 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,
empty_buffer: sentinel,
}
}

#[allow(clippy::too_many_arguments)]
fn update_mesh(
&mut self,
gpu: &Gpu,
mesh_buffer: &mut MeshBuffer,
assets: &AssetCache,
text_system: &mut TextSystem,
buffer: &mut Buffer,
// text: &str,
mesh: &mut Arc<MeshHandle>,
store: &mut RendererStore,
scale_factor: f64,
Expand Down
6 changes: 2 additions & 4 deletions violet-wgpu/src/systems.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
use std::sync::Arc;

use cosmic_text::{Metrics, Wrap};
use cosmic_text::Wrap;
use flax::{
components::child_of,
entity_ids,
fetch::{Modified, TransformFetch},
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;
Expand Down

0 comments on commit 78a781a

Please sign in to comment.