Skip to content

Rework aliased rasterization and path lowering to allow full hinting - #411

Merged
JimBobSquarePants merged 2 commits into
mainfrom
js/aliased-scan-conversion
Aug 6, 2026
Merged

Rework aliased rasterization and path lowering to allow full hinting#411
JimBobSquarePants merged 2 commits into
mainfrom
js/aliased-scan-conversion

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

Fix #134

Replace threshold-based aliased coverage with exact center-sampled rasterization in both the CPU and WebGPU backends, including profile-driven thin-feature recovery for fills and updated hard-clip behavior. Rename the WebGPU flatten stage to path lowering, add the new profile/tile scene data plumbing, and update related scheduling, docs, and shader bindings. The change also removes antialias-threshold plumbing, adds shared linear-geometry profile storage, refreshes text and aliasing tests/reference images, and bumps SixLabors.Fonts.

Pipeline terminology and documentation updates:

  • Renamed the "flatten" stage and related identifiers to "path lowering" throughout the C# and WGSL shader code, including class and file names, comments, and error messages. This provides clearer terminology and aligns with upstream projects. (src/ImageSharp.Drawing.WebGPU/Shaders/FlattenComputeShader.csPathLoweringComputeShader.cs, [1] [2] [3] [4]; [5] [6] [7]; [8]; [9] [10] [11]; [12] [13]; [14]; [15]
  • Updated documentation comments in several shaders to clarify the use of "final lines" instead of "flattened lines" and to better describe the data flow between stages. [1] [2] [3] [4] [5]

Shader and pipeline binding expansions:

  • Added new bind group layout entries for profile data and path bounding boxes to support advanced rendering features, updating both the C# and WGSL code to match. (FineAreaComputeShader.cs, [1] [2]; PathRowAllocComputeShader.cs, [3]

Shader structure and field updates:

  • Updated the PathBbox WGSL struct and related documentation to use coverage_data instead of coverage_threshold, reflecting a more general approach to coverage adjustment. [1] [2]

Configuration and shared resources:

  • Extended the Config WGSL struct to include offsets for segment-profile tag and record tables, supporting new features in the rendering pipeline.

Project and solution file maintenance:

  • Removed an unused shared project import from ImageSharp.Drawing.WebGPU.csproj and cleaned up the solution file. [1] [2]

Replace threshold-based aliased coverage with exact center-sampled rasterization in both the CPU and WebGPU backends, including profile-driven thin-feature recovery for fills and updated hard-clip behavior. Rename the WebGPU flatten stage to path lowering, add the new profile/tile scene data plumbing, and update related scheduling, docs, and shader bindings. The change also removes antialias-threshold plumbing, adds shared linear-geometry profile storage, refreshes text and aliasing tests/reference images, and bumps SixLabors.Fonts.
@JimBobSquarePants JimBobSquarePants added the enhancement New feature or request label Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.57588% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 79%. Comparing base (d8c0e28) to head (f1fa7c7).

Files with missing lines Patch % Lines
...eSharp.Drawing/Processing/DrawingClipDescriptor.cs 55% 8 Missing ⚠️
...p.Drawing/Processing/Backends/DefaultRasterizer.cs 97% 2 Missing and 5 partials ⚠️
.../ImageSharp.Drawing.WebGPU/WebGPUSceneResources.cs 86% 6 Missing ⚠️
...c/ImageSharp.Drawing.WebGPU/WebGPUSceneDispatch.cs 82% 2 Missing and 3 partials ⚠️
...ageSharp.Drawing/Processing/Backends/FlushScene.cs 95% 4 Missing and 1 partial ⚠️
src/ImageSharp.Drawing/LinearGeometryProfiles.cs 97% 2 Missing and 2 partials ⚠️
...rocessing/Backends/DefaultRasterizer.Linearizer.cs 96% 2 Missing and 1 partial ⚠️
...rc/ImageSharp.Drawing.WebGPU/WebGPUSceneEncoder.cs 99% 0 Missing and 2 partials ⚠️
...ocessing/Backends/DefaultDrawingBackend.Helpers.cs 85% 1 Missing and 1 partial ⚠️
...rawing.WebGPU/Shaders/PathLoweringComputeShader.cs 50% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@          Coverage Diff           @@
##            main    #411    +/-   ##
======================================
  Coverage     79%     79%            
======================================
  Files        231     232     +1     
  Lines      26195   27005   +810     
  Branches    2953    3086   +133     
======================================
+ Hits       20746   21542   +796     
- Misses      4567    4574     +7     
- Partials     882     889     +7     
Flag Coverage Δ
unittests 79% <96%> (+<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 1f6ad7e into main Aug 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DrawText over a BMP 128x64 displays deformed text

1 participant