Skip to content

Conversation

LukasBombach
Copy link
Owner

No description provided.

@LukasBombach LukasBombach requested a review from Copilot June 1, 2025 06:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds end-to-end text rendering support by integrating a new WGSL shader, extending the JS reconciler, GUI layout, and GPU pipeline, and wiring it into the application loop.

  • Introduces text_shader.wgsl for push-constant viewport handling and text sampling
  • Extends the JS reconciler and Deno ops with create_text_node and TextInstance
  • Updates Gui, Gpu, and App in Rust to support text node creation, layout, rendering, and DPI scaling

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/text_shader.wgsl New WGSL vertex/fragment shader for textured text quads
src/javascript_runtime/reconciler.ts Added create_text_node op, TextInstance type, and reconciler handling
src/javascript_runtime/mod.rs Implemented op_create_text_node and registered the op
src/gui.rs Added NodeKind::Text, text node creation, layout and collection
src/gpu.rs Integrated TextRenderer, DPI scaling, and text draw/update methods
src/app.rs Hooked text collection and rendering into event handlers
src/main.tsx Display placeholder text instead of empty div
src/main.rs Registered new text module
Cargo.toml Added cosmic-text dependency for text rendering
Comments suppressed due to low confidence (3)

src/gui.rs:140

  • New text rendering logic isn't covered by unit or integration tests; consider adding tests for create_text_node and collect_text_instances to ensure text nodes behave as expected.
pub fn create_text_node(

src/javascript_runtime/reconciler.ts:26

  • [nitpick] Using RectId for text nodes may be misleading since this ID now represents text instances. Consider renaming RectId to a more generic identifier like InstanceId or NodeId to accurately reflect its usage.
type TextInstance = { type: "text"; id: RectId };

src/gui.rs:160

  • [nitpick] Using println! for debugging in production code can be noisy and isn't configurable by log level. Consider using a logging framework (e.g., the log crate) with appropriate log levels.
println!("create_text_node {:?} {:?} {:?}",

Comment on lines 64 to 74
let text_items = gui.collect_text_instances();
println!("GuiUpdate: collected {} text items", text_items.len());
let mut all_text_instances = Vec::new();

for (text, x, y, font_size, color, max_width) in text_items {
let text_instances = gpu.render_text(&text, x, y, font_size, color, Some(max_width));
all_text_instances.extend(text_instances);
}

println!("GuiUpdate: updating GPU with {} text instances", all_text_instances.len());
gpu.update_text_instances(&all_text_instances);
Copy link

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic to collect and update text instances is duplicated across GuiUpdate, Resized, and ScaleFactorChanged handlers. Consider extracting this into a helper method to reduce code duplication.

Suggested change
let text_items = gui.collect_text_instances();
println!("GuiUpdate: collected {} text items", text_items.len());
let mut all_text_instances = Vec::new();
for (text, x, y, font_size, color, max_width) in text_items {
let text_instances = gpu.render_text(&text, x, y, font_size, color, Some(max_width));
all_text_instances.extend(text_instances);
}
println!("GuiUpdate: updating GPU with {} text instances", all_text_instances.len());
gpu.update_text_instances(&all_text_instances);
self.collect_and_render_text_instances(window, gpu, &mut gui);

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant