Open
Conversation
There was a problem hiding this comment.
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.wgslfor push-constant viewport handling and text sampling - Extends the JS reconciler and Deno ops with
create_text_nodeandTextInstance - Updates
Gui,Gpu, andAppin 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); |
There was a problem hiding this comment.
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.