Skip to content

COLRv1 group rendering, zero-callback layered glyph cache, WebGPU blend parity and CPU-exact brush colors - #412

Merged
JimBobSquarePants merged 1 commit into
mainfrom
js/colrv1-composite-groups
Aug 8, 2026
Merged

COLRv1 group rendering, zero-callback layered glyph cache, WebGPU blend parity and CPU-exact brush colors#412
JimBobSquarePants merged 1 commit into
mainfrom
js/colrv1-composite-groups

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Consumes the reworked Fonts renderer API and completes two WebGPU parity efforts.

COLRv1 groups

BaseGlyphBuilder and RichTextGlyphRenderer implement BeginGroup/EndGroup; the canvas
lowers each group to one isolated layer whose modes apply when it ends. Caller opacity
applies once to the outermost group, never per leaf. The per-glyph clip bounds become a
single rectangle intersect on each operation's rasterizer interest; no polygon clipping is
involved anywhere.

Layered glyph cache

A layered COLR cache hit now replays its stored operation sequence with zero renderer
callbacks: no outline decode and no path construction per draw. Replay tests assert
operation-for-operation equality and pixel-identical output.

WebGPU blend parity

blend.wgsl ports ImageSharp's AssociatedAlphaPorterDuffFunctions and the straight-RGB
blend curves for every PixelColorBlendingMode. Stores quantize in-shader
(round-to-nearest-even binary16, exact unorm packing) so both backends store identical
pixels.

CPU-exact brush colors

Solid colors and gradient ramp texels snap through ToPixel<TPixel> at flush, mirroring the
CPU's render-time brush creation: the retained scene streams specialize once per pixel
format and ride the ordinary uploads. Opaque fills are bit-exact against the CPU;
translucent fills sit within the wire format's binary16 rounding, documented at the patch
sites. Also fixes stale recolor payloads surviving a pixel-format switch.

Port the remaining CPU blend and Porter-Duff composition behavior to the WebGPU fine shader, including precise target-format round-tripping, half-float quantization, lossless clip backdrop storage, and support for additional blend/composition modes such as ColorDodge, ColorBurn, SoftLight, Hue, Saturation, Color, Luminosity, and Plus.

The scene encoder now defers and specializes solid colors and gradient ramps for the bound target pixel type so GPU brush inputs match CPU snapping. Text rendering also gains proper isolated COLR group lowering, glyph clip propagation, and layered glyph cache replay fixes. Tests and reference outputs were expanded to cover the new blending parity and COLR behavior.
@JimBobSquarePants JimBobSquarePants added the bug Something isn't working label Aug 8, 2026
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.10526% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 79%. Comparing base (1f6ad7e) to head (c3d5012).

Files with missing lines Patch % Lines
...eSharp.Drawing/Processing/RichTextGlyphRenderer.cs 85% 17 Missing and 5 partials ⚠️
...rc/ImageSharp.Drawing.WebGPU/WebGPUSceneEncoder.cs 95% 4 Missing and 2 partials ⚠️
src/ImageSharp.Drawing/Text/BaseGlyphBuilder.cs 86% 3 Missing ⚠️
...eSharp.Drawing/Processing/DrawingCanvas{TPixel}.cs 96% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main    #412    +/-   ##
======================================
  Coverage     79%     79%            
======================================
  Files        232     232            
  Lines      27005   27340   +335     
  Branches    3086    3112    +26     
======================================
+ Hits       21541   21858   +317     
- Misses      4574    4589    +15     
- Partials     890     893     +3     
Flag Coverage Δ
unittests 79% <92%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JimBobSquarePants
JimBobSquarePants merged commit b86b71f into main Aug 8, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant