Skip to content

Commit 34a8b9b

Browse files
Desktop: Render overlays with vello (#2965)
* Render overlays with vello * Fix nix flake comments * Rendering refactor with better names and code location * Remove unnecessary overlay renders * Post rebase fix
1 parent 037bcb6 commit 34a8b9b

File tree

14 files changed

+728
-401
lines changed

14 files changed

+728
-401
lines changed

.nix/flake.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#
55
# Development Environment:
66
# - Provides all necessary tools for Rust/Wasm development
7+
# - Includes dependencies for desktop app development
78
# - Sets up profiling and debugging tools
89
# - Configures mold as the default linker for faster builds
910
#
1011
# Usage:
11-
# - Development shell: `nix develop`
12+
# - Development shell: `nix develop .nix` from the project root
1213
# - Run in dev shell with direnv: add `use flake` to .envrc
1314
{
1415
description = "Development environment and build configuration";

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

desktop/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ graphite-editor = { path = "../editor", features = [
1919
"ron",
2020
"vello",
2121
] }
22+
graphene-std = { workspace = true }
2223
graph-craft = { workspace = true }
2324
wgpu-executor = { workspace = true }
2425

@@ -34,3 +35,5 @@ dirs = { workspace = true }
3435
ron = { workspace = true}
3536
bytemuck = { workspace = true }
3637
glam = { workspace = true }
38+
vello = { workspace = true }
39+
derivative = { workspace = true }

desktop/src/app.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ impl WinitApp {
4848
self.send_messages_to_editor(responses);
4949
}
5050

51-
fn send_messages_to_editor(&mut self, responses: Vec<FrontendMessage>) {
51+
fn send_messages_to_editor(&mut self, mut responses: Vec<FrontendMessage>) {
52+
for message in responses.extract_if(.., |m| matches!(m, FrontendMessage::RenderOverlays(_))) {
53+
let FrontendMessage::RenderOverlays(overlay_context) = message else { unreachable!() };
54+
if let Some(graphics_state) = &mut self.graphics_state {
55+
let scene = overlay_context.take_scene();
56+
graphics_state.set_overlays_scene(scene);
57+
}
58+
}
59+
5260
if responses.is_empty() {
5361
return;
5462
}
@@ -110,8 +118,8 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
110118
match event {
111119
CustomEvent::UiUpdate(texture) => {
112120
if let Some(graphics_state) = self.graphics_state.as_mut() {
113-
graphics_state.bind_ui_texture(&texture);
114121
graphics_state.resize(texture.width(), texture.height());
122+
graphics_state.bind_ui_texture(texture);
115123
}
116124
if let Some(window) = &self.window {
117125
window.request_redraw();
@@ -125,7 +133,7 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
125133
}
126134
}
127135
CustomEvent::MessageReceived { message } => {
128-
if let Message::InputPreprocessor(ipp_message) = &message {
136+
if let Message::InputPreprocessor(_) = &message {
129137
if let Some(window) = &self.window {
130138
window.request_redraw();
131139
}
@@ -144,13 +152,14 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
144152
panic!("graphics state not intialized, viewport offset might be lost");
145153
}
146154
}
155+
147156
self.dispatch_message(message);
148157
}
149158
CustomEvent::NodeGraphRan { texture } => {
150159
if let Some(texture) = texture
151160
&& let Some(graphics_state) = &mut self.graphics_state
152161
{
153-
graphics_state.bind_viewport_texture(&texture);
162+
graphics_state.bind_viewport_texture(texture);
154163
}
155164
let mut responses = VecDeque::new();
156165
let err = self.editor.poll_node_graph_evaluation(&mut responses);

0 commit comments

Comments
 (0)