Skip to content

Cleanup render pipeline#1131

Merged
jaytaph merged 14 commits into
gosub-io:mainfrom
jaytaph:cleanup-render-pipeline
Jul 17, 2026
Merged

Cleanup render pipeline#1131
jaytaph merged 14 commits into
gosub-io:mainfrom
jaytaph:cleanup-render-pipeline

Conversation

@jaytaph

@jaytaph jaytaph commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved text alignment for inline content, including inherited alignment behavior.
    • Corrected border rendering when styles are set to none or hidden.
    • Improved rounded-corner rendering for rectangles and images.
    • Fixed SVG cache reuse across different pixel formats and sizes.
    • Improved tile repaint and rasterization readiness for smoother updates.
    • Ensured rendering backends consistently honor their configured capabilities.
  • Documentation

    • Clarified rendering, media decoding, text layout, and feature configuration documentation.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR removes Parley feature branches and compositor APIs, updates computed CSS and inline layout handling, renames tile readiness states, adds pixel-format-aware SVG caching, adjusts renderer backend contracts, and refreshes render-pipeline documentation.

Changes

Render pipeline alignment

Layer / File(s) Summary
Feature and public contract cleanup
Cargo.toml, crates/gosub_engine/..., crates/gosub_render_pipeline/..., crates/gosub_renderer_*/...
Parley feature wiring and compositor exports are removed; document, texture, font, compositor, and surface APIs are reduced or updated.
Computed CSS and inline layout
crates/gosub_render_pipeline/src/common/document/..., crates/gosub_render_pipeline/src/layouter/...
Computed border widths and text alignment now flow through layout; inline line boxes receive justification and text measurement is implemented directly.
Tile states and media cache correctness
crates/gosub_render_pipeline/src/tiler.rs, crates/gosub_render_pipeline/src/rasterizer.rs, crates/gosub_render_pipeline/src/common/media/svg.rs, crates/gosub_renderer_*/src/rasterizer/svg.rs
TileState::Clean becomes Ready, hover and rasterization paths use the new state, and SVG cache entries include pixel format.
Renderer behavior and backend delegation
crates/gosub_renderer_dynamic/src/lib.rs, crates/gosub_renderer_skia/..., crates/gosub_renderer_vello/...
Dynamic backend methods explicitly delegate to the active backend, Skia uses per-corner rounded rectangles, and unused renderer paths are removed.
Documentation and validation updates
docs/render-pipeline/*, crates/gosub_render_pipeline/src/tests.rs, renderer modules
Rendering contracts, feature flags, media behavior, paint commands, and supporting test documentation are revised.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DOMStyles
  participant PipelineDocument
  participant TaffyLayouter
  participant FontSystem
  participant Rasterizer
  DOMStyles->>PipelineDocument: resolve computed CSS
  PipelineDocument->>TaffyLayouter: provide border and text-align values
  TaffyLayouter->>FontSystem: measure and shape text
  TaffyLayouter->>Rasterizer: emit layout and paint commands
  Rasterizer->>Rasterizer: reuse format-compatible SVG or rasterize
Loading

Possibly related PRs

Suggested reviewers: sharktheone

Poem

I’m a rabbit with tiles, hopping ready and bright,
Parley paths vanished into the night.
CSS lines now stretch, borders know their cue,
SVG caches remember the format they knew.
Backends relay every rendering call—
A tidy burrow welcomes them all.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main theme: broad cleanup across the render pipeline.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/gosub_render_pipeline/src/layering/layer.rs (1)

230-247: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove redundant get_layer_mut to avoid double lookups and fix unreachable code.

The current implementation of get_layer_mut filters out missing layers using contains_key. Consequently, the else block containing the log::warn! inside add_to_layer is unreachable when a layer is missing.

You can simplify the logic, remove the double HashMap lookup, and restore the intended warning by directly accessing the entry.

♻️ Proposed refactor
-    fn add_to_layer(&self, layer_id: LayerId, element_id: LayoutElementId) {
-        if let Some(mut layers) = self.get_layer_mut(layer_id) {
-            if let Some(layer) = layers.get_mut(&layer_id) {
-                layer.add_element(element_id);
-            } else {
-                log::warn!("Layer {} not found in HashMap", layer_id);
-            }
-        }
-    }
-
-    fn get_layer_mut(&self, layer_id: LayerId) -> Option<parking_lot::RwLockWriteGuard<'_, HashMap<LayerId, Layer>>> {
-        let layers = self.layers.write();
-        if layers.contains_key(&layer_id) {
-            Some(layers)
-        } else {
-            None
-        }
-    }
+    fn add_to_layer(&self, layer_id: LayerId, element_id: LayoutElementId) {
+        if let Some(layer) = self.layers.write().get_mut(&layer_id) {
+            layer.add_element(element_id);
+        } else {
+            log::warn!("Layer {} not found in HashMap", layer_id);
+        }
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/gosub_render_pipeline/src/layering/layer.rs` around lines 230 - 247,
Remove the redundant get_layer_mut method and update add_to_layer to acquire the
layers write guard directly, then use a single get_mut(&layer_id) lookup to add
the element or emit the existing warning when the layer is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/gosub_render_pipeline/src/layering/layer.rs`:
- Around line 230-247: Remove the redundant get_layer_mut method and update
add_to_layer to acquire the layers write guard directly, then use a single
get_mut(&layer_id) lookup to add the element or emit the existing warning when
the layer is absent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d25d3b8e-b388-4c56-9a45-99bb02fd7dda

📥 Commits

Reviewing files that changed from the base of the PR and between e1f6a82 and cf17342.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (79)
  • Cargo.toml
  • crates/gosub_engine/Cargo.toml
  • crates/gosub_engine/src/engine/context.rs
  • crates/gosub_render_pipeline/Cargo.toml
  • crates/gosub_render_pipeline/src/common/browser_state.rs
  • crates/gosub_render_pipeline/src/common/document/inline_style.rs
  • crates/gosub_render_pipeline/src/common/document/node.rs
  • crates/gosub_render_pipeline/src/common/document/pipeline_doc.rs
  • crates/gosub_render_pipeline/src/common/document/style.rs
  • crates/gosub_render_pipeline/src/common/font.rs
  • crates/gosub_render_pipeline/src/common/font/parley.rs
  • crates/gosub_render_pipeline/src/common/geo.rs
  • crates/gosub_render_pipeline/src/common/media/decoder.rs
  • crates/gosub_render_pipeline/src/common/media/decoder/raster.rs
  • crates/gosub_render_pipeline/src/common/media/decoder/svg.rs
  • crates/gosub_render_pipeline/src/common/media/image.rs
  • crates/gosub_render_pipeline/src/common/media/media.rs
  • crates/gosub_render_pipeline/src/common/media/media_store.rs
  • crates/gosub_render_pipeline/src/common/media/svg.rs
  • crates/gosub_render_pipeline/src/common/texture.rs
  • crates/gosub_render_pipeline/src/common/texture_store.rs
  • crates/gosub_render_pipeline/src/compositor.rs
  • crates/gosub_render_pipeline/src/layering/layer.rs
  • crates/gosub_render_pipeline/src/layouter.rs
  • crates/gosub_render_pipeline/src/layouter/box_model.rs
  • crates/gosub_render_pipeline/src/layouter/css_taffy_converter.rs
  • crates/gosub_render_pipeline/src/layouter/inline_run.rs
  • crates/gosub_render_pipeline/src/layouter/taffy.rs
  • crates/gosub_render_pipeline/src/layouter/text.rs
  • crates/gosub_render_pipeline/src/layouter/text/parley.rs
  • crates/gosub_render_pipeline/src/lib.rs
  • crates/gosub_render_pipeline/src/painter.rs
  • crates/gosub_render_pipeline/src/painter/commands.rs
  • crates/gosub_render_pipeline/src/painter/commands/border.rs
  • crates/gosub_render_pipeline/src/painter/commands/brush.rs
  • crates/gosub_render_pipeline/src/painter/commands/color.rs
  • crates/gosub_render_pipeline/src/painter/commands/gradient.rs
  • crates/gosub_render_pipeline/src/painter/commands/rectangle.rs
  • crates/gosub_render_pipeline/src/painter/commands/text.rs
  • crates/gosub_render_pipeline/src/rasterizer.rs
  • crates/gosub_render_pipeline/src/render.rs
  • crates/gosub_render_pipeline/src/render/backend.rs
  • crates/gosub_render_pipeline/src/render/backends.rs
  • crates/gosub_render_pipeline/src/render/compositor.rs
  • crates/gosub_render_pipeline/src/render/compositor_router.rs
  • crates/gosub_render_pipeline/src/render/tile_composite.rs
  • crates/gosub_render_pipeline/src/rendertree_builder/tree.rs
  • crates/gosub_render_pipeline/src/tests.rs
  • crates/gosub_render_pipeline/src/tiler.rs
  • crates/gosub_renderer_cairo/src/backend.rs
  • crates/gosub_renderer_cairo/src/compositor.rs
  • crates/gosub_renderer_cairo/src/compositor/inner.rs
  • crates/gosub_renderer_cairo/src/lib.rs
  • crates/gosub_renderer_cairo/src/rasterizer.rs
  • crates/gosub_renderer_cairo/src/rasterizer/brush.rs
  • crates/gosub_renderer_cairo/src/rasterizer/svg.rs
  • crates/gosub_renderer_cairo/src/rasterizer/text/glyphs.rs
  • crates/gosub_renderer_dynamic/src/lib.rs
  • crates/gosub_renderer_skia/src/backend.rs
  • crates/gosub_renderer_skia/src/rasterizer.rs
  • crates/gosub_renderer_skia/src/rasterizer/paint.rs
  • crates/gosub_renderer_skia/src/rasterizer/rectangle.rs
  • crates/gosub_renderer_skia/src/rasterizer/svg.rs
  • crates/gosub_renderer_skia/src/rasterizer/text/glyphs.rs
  • crates/gosub_renderer_vello/Cargo.toml
  • crates/gosub_renderer_vello/src/backend.rs
  • crates/gosub_renderer_vello/src/backend/font_cache.rs
  • crates/gosub_renderer_vello/src/backend/font_manager.rs
  • crates/gosub_renderer_vello/src/backend/text_renderer.rs
  • crates/gosub_renderer_vello/src/compositor.rs
  • crates/gosub_renderer_vello/src/compositor/inner.rs
  • crates/gosub_renderer_vello/src/gpu_tiles.rs
  • crates/gosub_renderer_vello/src/lib.rs
  • crates/gosub_renderer_vello/src/rasterizer.rs
  • crates/gosub_renderer_vello/src/rasterizer/brush.rs
  • crates/gosub_renderer_vello/src/rasterizer/svg.rs
  • crates/gosub_renderer_vello/src/rasterizer/text/glyphs.rs
  • docs/render-pipeline/README.md
  • docs/render-pipeline/stages.md
💤 Files with no reviewable changes (21)
  • crates/gosub_render_pipeline/src/common/font/parley.rs
  • crates/gosub_renderer_vello/Cargo.toml
  • crates/gosub_render_pipeline/src/layouter/box_model.rs
  • crates/gosub_renderer_skia/src/rasterizer/paint.rs
  • crates/gosub_render_pipeline/src/render.rs
  • crates/gosub_render_pipeline/src/lib.rs
  • crates/gosub_renderer_cairo/src/compositor/inner.rs
  • crates/gosub_renderer_vello/src/compositor/inner.rs
  • crates/gosub_render_pipeline/src/compositor.rs
  • crates/gosub_render_pipeline/src/layouter/text/parley.rs
  • crates/gosub_render_pipeline/src/common/media/media.rs
  • crates/gosub_renderer_vello/src/compositor.rs
  • crates/gosub_renderer_vello/src/lib.rs
  • crates/gosub_renderer_cairo/src/lib.rs
  • crates/gosub_renderer_cairo/src/compositor.rs
  • crates/gosub_render_pipeline/src/render/compositor_router.rs
  • crates/gosub_render_pipeline/Cargo.toml
  • crates/gosub_renderer_vello/src/backend/font_manager.rs
  • crates/gosub_render_pipeline/src/common/font.rs
  • crates/gosub_renderer_vello/src/backend/font_cache.rs
  • crates/gosub_render_pipeline/src/common/geo.rs

@jaytaph
jaytaph merged commit bb47dfa into gosub-io:main Jul 17, 2026
10 checks passed
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