Uh oh!
There was an error while loading. Please reload this page.
Integrate SixLabors.PolygonClipper - #364
Merged
JimBobSquarePants merged 38 commits intoFeb 19, 2026
Merged
Conversation
stefannikoleiforce-pushed
the
sn/integrate-polygonclipper
branch
from
September 30, 2025 18:17
0081dff to
2e76417CompareUh oh!
There was an error while loading. Please reload this page.
First draft of implementing PolygonOffsetter Also added back the IntersectionRule to GenerateClippedShapes. It is not implemented yet
* Initialized clip and subject with empty polygon add a contour per path
…annikolei/ImageSharp.Drawing into sn/integrate-polygonclipper
Uh oh!
There was an error while loading. Please reload this page.
JimBobSquarePants
commented
Oct 31, 2025
Member
@stefannikolei I made some huge progress tonight. The new stroker ported from AGG is now integrated with path outline generation. I still need to replace the existing Pen end-cap and line-join options to use the new ones as we're adding inner-join and wire them up. Output looks good. I had to tweak our pattern generating outline code to get things working but it resulted in more accurate stroke length (new is left) ![]() |
stefannikolei
commented
Oct 31, 2025
ContributorAuthor
What is AGG? |
Removed Visual Studio Version 17 entry from solution file.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced May 12, 2026
This was referenced Jun 16, 2026
This was referenced Jun 29, 2026
This was referenced Aug 8, 2026
This was referenced Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Prerequisites
Description
This PR integrates
SixLabors.PolygonClipperinto ImageSharp.Drawing, replaces the legacy rasterization pipeline with a new scanner-based implementation, and introduces backend/rasterizer abstractions to support future alternate rendering paths (including non-CPU backends).Main Changes
1. Polygon clipping/stroking integration
SixLabors.PolygonClipper.PolygonClipperFactoryClippedShapeGeneratorStrokedShapeGeneratorClip()now routes through PolygonClipper boolean operations.PolygonStroker.2. New stroke semantics and options
StrokeOptions.NormalizeOutput(defaultfalse) to control post-stroke normalization.LineJoin,LineCap, andInnerJoin.3. Rasterization architecture overhaul
PolygonScanner-based path.IRasterizerDefaultRasterizerScanlineRasterizer(explicit sequential/reference path)RasterizerOptions/RasterizationModeActiveEdgeList,ScanEdge,ScanEdgeCollection, old extension wrappers).4. Drawing backend abstraction
IDrawingBackendCpuDrawingBackendFillPathProcessor<TPixel>now submits operation-level data to backend instead of owning rasterizer details.5. Fill rule and shape behavior updates
ShapeOptions.IntersectionRuledefault changed toNonZero.BooleanOperation.NonZero.6. Build/test/docs updates
PolygonScanning.MDfor the new scanner behavior.Breaking / API Surface Changes
ClippingOperation(replaced byBooleanOperation)EndCapStyle(replaced byLineCap)JointStyle(replaced byLineJoin)ShapeOptionsnow usesBooleanOperation+IntersectionRule = NonZeroby default.Why this PR
PolygonClipper).processor -> backend -> rasterizer) for future GPU/custom backend work.Benchmarks
The combination of the new stroker and tiled rasterizer makes ImageSharp highly competitive.
This benchmark measures rendering a large, complex polygon with a 10px stroke.
For ImageSharp, results are shown for both rasterizer implementations:
ImageSharp...Tiled: the default tiled/parallel rasterizer (optimized for throughput).ImageSharp...ScanlineRasterizer: the single-pass non-tiled scanline rasterizer (useful as a baseline and for comparing scheduling overhead).ImageSharpStrokeAndClipandFillPolygonare included intentionally:ImageSharpStrokeAndClipisolates stroke geometry generation + clipping cost, independent of full draw compositing.FillPolygonisolates pure polygon fill/rasterization cost without stroke expansion.Together, these rows help separate where time is spent: geometry generation, clipping/normalization, and final rasterization/compositing.