Skip to content

styled_text: add compact style spans and Parley lowering#631

Open
waywardmonkeys wants to merge 1 commit into
linebender:mainfrom
waywardmonkeys:styled-text-first-slice
Open

styled_text: add compact style spans and Parley lowering#631
waywardmonkeys wants to merge 1 commit into
linebender:mainfrom
waywardmonkeys:styled-text-first-slice

Conversation

@waywardmonkeys
Copy link
Copy Markdown
Contributor

Add styled_text and styled_text_parley as first-slice crates for compact styled text storage.

The core crate stores resolved complete styles as compact StyleId spans over attributed_text, with layout and paint payloads interned separately so paint-only changes can share layout identity. It includes a builder that resolves overlapping patch ranges and reusable segment workspaces for downstream layout or paint passes.

Add styled_text_parley to lower resolved styled-text runs into Parley's low-level style-run builder with a reusable style-index workspace. The adapter includes default Parley-shaped payloads, coalesces adjacent equal style runs during lowering, and includes a Vello CPU example that renders overlapping layout and paint changes.

This intentionally leaves cascading, editing policy, and application-specific style vocabularies outside the core styled_text crate.

Add styled_text and styled_text_parley as first-slice crates for compact styled text storage.

The core crate stores resolved complete styles as compact StyleId spans over attributed_text, with layout and paint payloads interned separately so paint-only changes can share layout identity. It includes a builder that resolves overlapping patch ranges and reusable segment workspaces for downstream layout or paint passes.

Add styled_text_parley to lower resolved styled-text runs into Parley's low-level style-run builder with a reusable style-index workspace. The adapter includes default Parley-shaped payloads, coalesces adjacent equal style runs during lowering, and includes a Vello CPU example that renders overlapping layout and paint changes.

This intentionally leaves cascading, editing policy, and application-specific style vocabularies outside the core styled_text crate.
@waywardmonkeys
Copy link
Copy Markdown
Contributor Author

This was done with the assistance of Codex (GPT 5.3, 5.4, 5.5, medium, high, xhigh).

@waywardmonkeys
Copy link
Copy Markdown
Contributor Author

Some things I have in mind for follow up PRs:

  1. Public builder polish
  • Make the builder API feel like the obvious way to construct styled text.
  • Reduce “find a range, apply patch” ergonomics where possible.
  • Maybe add a push-oriented builder shape for appending text with current style state.
  1. Base style / patch convenience
  • Provide a small default patch type or helper for common style updates.
  • Keep the trait-based StylePatch escape hatch, but avoid making every user define boilerplate for basic cases.
  1. Better Parley adapter ergonomics
  • Make styled_text_parley easier to call from real code.
  • Keep the reusable workspace story front and center.
  • Avoid multiplying APIs; one good path is better than a pile of helpers.
  1. Benchmarks / memory measurements
  • Add focused measurements for style interning, paint-only changes, lowering into Parley, and workspace reuse.
  • Maybe add malloc_size_of or equivalent only if we decide the dependency is acceptable.

Copy link
Copy Markdown
Contributor

@PoignardAzur PoignardAzur left a comment

Choose a reason for hiding this comment

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

Quick note: I think this code would be much easier to review if you split it into roughly one file per type. Right now it's kind of hard to find where types are defined without doing a lot of Ctrl+F.

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.

2 participants