COLRv1 group rendering, zero-callback layered glyph cache, WebGPU blend parity and CPU-exact brush colors by JimBobSquarePants · Pull Request #412 · SixLabors/ImageSharp.Drawing · GitHub
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

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

@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