-
-
Notifications
You must be signed in to change notification settings - Fork 45
DrawingCanvas API: Replace imperative extension methods with stateful canvas-based drawing model #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JimBobSquarePants
wants to merge
300
commits into
main
Choose a base branch
from
js/canvas-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
DrawingCanvas API: Replace imperative extension methods with stateful canvas-based drawing model #377
Changes from 138 commits
Commits
Show all changes
300 commits
Select commit
Hold shift + click to select a range
faa3623
Move elliptic gradient tests to ProcessWithCanvas
JimBobSquarePants 130f106
Migrate FillImageBrush tests to ProcessWithCanvas
JimBobSquarePants b8c714d
Move linear gradient tests to ProcessWithCanvas
JimBobSquarePants 52fb65f
Migrate FillsOutOfBounds tests
JimBobSquarePants bb12d60
PathGradientBrush sampling & intersect fix; tests move
JimBobSquarePants b63da78
Move FillPath tests to ProcessWithCanvas
JimBobSquarePants 7fa4871
Migrate text drawing tests to ProcessWithCanvas
JimBobSquarePants f01190b
Move FillPatternBrush tests to canvas tests
JimBobSquarePants 625ab85
Migrate FillPolygon tests to ProcessWithDrawingCanvas
JimBobSquarePants 34468f3
Migrate RadialGradient tests
JimBobSquarePants c15ba00
Migrate SolidBrush tests
JimBobSquarePants 405b253
Migrate SweetGradientBrush tests
JimBobSquarePants e8922e4
Migrate RecolorBrush tests
JimBobSquarePants 79f0909
Migrate SolidBezier tests
JimBobSquarePants 64bcbb0
Migrate Blending tests
JimBobSquarePants 0753ee0
Migrate Clip tests
JimBobSquarePants 7f5f3d6
Migrate robustness tests
JimBobSquarePants 1dd49af
Migrate Issues tests
JimBobSquarePants a0d0bb8
Migrate SVGPath tests
JimBobSquarePants fd0babf
Cleanup references
JimBobSquarePants 697319e
Optimize refs
JimBobSquarePants 368f99d
Remove legacy APIs
JimBobSquarePants 691bc17
Fix build
JimBobSquarePants 3fc0488
Update ImageSharp.Drawing.sln
JimBobSquarePants f4a3b87
Include binaries use streaming for composition
JimBobSquarePants 73e4347
Update ImageSharp.Drawing.Tests.csproj
JimBobSquarePants d8e0910
Use tolerance comparer
JimBobSquarePants c2db283
Update DrawingCanvasTests.RegionAndState.cs
JimBobSquarePants 18a51df
Skip WebGPU drawing tests on Linux
JimBobSquarePants 2ec6284
Skip WebGPU tests for all CI
JimBobSquarePants f427d04
Remove rasterizer config
JimBobSquarePants d427d29
Replace PolygonScanner with DefaultRasterizer and optimize
JimBobSquarePants 35c4445
Feng shui all the things.
JimBobSquarePants d06676f
Remove unused type
JimBobSquarePants d8a57f8
Reuse WorkerScratch across rasterizer calls + optimizations
JimBobSquarePants 7d50cf9
Fix tile mapping and dispatch dimensions
JimBobSquarePants 6fbc481
Use output texture for readback to avoid copy
JimBobSquarePants 0d6f935
Add CSR shaders; restructure WebGPU shaders & tests
JimBobSquarePants ccf8a4a
Switch to CSR-based composite shaders
JimBobSquarePants 49ebbe6
Add start_cover fast path; skip outside edges
JimBobSquarePants 36425d1
Compute CSR on CPU; refactor coverage rasterizer
JimBobSquarePants 5a3b89a
Update DrawingCanvasTests.Process.cs
JimBobSquarePants bb7311e
Switch edge buffers to IMemoryOwner
JimBobSquarePants 8da2642
Pre-split edges into band-sorted buffers (remove CSR)
JimBobSquarePants 34f110f
Add small-geometry fast path to rasterizer
JimBobSquarePants 1229e73
Update reference images
JimBobSquarePants 67d8078
Update Draw_NormalizeOutputFalse_MatchesReference_Rgba32.png
JimBobSquarePants c7ae446
Bump tolerance
JimBobSquarePants b5c1f8a
Fix #344
JimBobSquarePants da77460
Fix #367
JimBobSquarePants a95d910
Fix #244
JimBobSquarePants cde991c
Add AntialiasThreshold and aliased mode
JimBobSquarePants a96c74c
Remove FillPath API from drawing backends
JimBobSquarePants 23c5c37
Add WebGPUWindowDemo and backend feature checks
JimBobSquarePants aee48a5
Make API public
JimBobSquarePants b04a0ec
Remove NormalizeOutput
JimBobSquarePants 2f0a7f6
Move stroking to the GPU
JimBobSquarePants fa6b1db
Add GPU stroke expand shader & refactor strokes
JimBobSquarePants bc0fb83
Add per-band stroke rasterization and StrokeEdgeFlags
JimBobSquarePants 5ac7af4
Update docs
JimBobSquarePants fc1c65c
Update reference images
JimBobSquarePants 6f7e0c6
GPU: add gradient, pattern & recolor brushes
JimBobSquarePants ea688af
Replace DashPathSplitter with GenerateDashes extension
JimBobSquarePants 63dbd46
Add ReleaseFrameResources and WebGPU CPU cache key
JimBobSquarePants 233b04e
Add new text measuring tests
JimBobSquarePants 837df16
Migrate drawing transforms to Matrix4x4
JimBobSquarePants 2115d36
Attempt to run WebGPU tests in CI
JimBobSquarePants 4f37759
Use explicit theory with runtime support check
JimBobSquarePants d88e6de
Update build-and-test.yml
JimBobSquarePants e1c2605
Cache WebGPU support and gate drawing backend
JimBobSquarePants e058bf3
Use PNG for comparison
JimBobSquarePants 76a17bc
Update WebGPUDrawingBackendTests.cs
JimBobSquarePants cd3565e
Remove duplicate assertion
JimBobSquarePants a22d843
Verify WebGPU compute pipeline in ProbeSupport
JimBobSquarePants 08f2985
Add RemoteExecutor and WebGPU probe
JimBobSquarePants 6c934ce
Add missing tests.
JimBobSquarePants dc97cf2
Merge branch 'main' into js/canvas-api
JimBobSquarePants 488bed4
Add GPU layer compositing and shared WGSL snippets
JimBobSquarePants 3c351a9
Remove reference codecs and simplify tests
JimBobSquarePants 355b56c
Add pre-flattened paths and FlattenAndTransform helper
JimBobSquarePants 819bc18
Optimize Bezier subdivision and list allocation
JimBobSquarePants 9eb8dee
Use IMemoryOwner for edge and band offset buffers
JimBobSquarePants 8344111
Cleanup
JimBobSquarePants dc538ad
Use auto-properties; drop isRoot flag
JimBobSquarePants fca77ba
Add no AA rectangle tests
JimBobSquarePants ba57846
Remove some copying.
JimBobSquarePants 7a08695
Update dependencies
JimBobSquarePants e146a2b
Refactor path flattening and remove tessellation
JimBobSquarePants 04b6c65
Handle different separators in SVG parsing
JimBobSquarePants 4117466
Cache flattening properly.
JimBobSquarePants 5a1c4ed
Refactor CPU to actually follow architecture
JimBobSquarePants 586fe94
Refactor composition preparation and batching
JimBobSquarePants 3441b89
Fix orientation, update ref output
JimBobSquarePants 6a1c8be
Update refs
JimBobSquarePants aca600d
semi-reasonable performance
JimBobSquarePants 5add5a3
Update FlushScene.cs
JimBobSquarePants b796ece
Remove GeometryPreparationCache and cache bands
JimBobSquarePants 2fbb74a
Remove obsolete enforceFillOrientation flag
JimBobSquarePants 359bc73
Remove enforceFillOrientation; simplify Reverse
JimBobSquarePants 403b4fb
Reimplement all GPU brushes
JimBobSquarePants 108bf55
Support per-draw blend mode and alpha in WebGPU
JimBobSquarePants fdb5ef8
Extract DeviceSharedState to WebGPURuntime
JimBobSquarePants d9e128e
Add inline layer support to compositing pipeline
JimBobSquarePants 3e512d5
Refactor brush renderers and FlushScene parallel loop
JimBobSquarePants f0fe9d9
Refactor WebGPU encoder and linearize path model
JimBobSquarePants 1159f09
Cleanup and document
JimBobSquarePants 7be0001
Treat TargetFramework as local in csproj
JimBobSquarePants 44fa989
Pass layer bounds and refactor rasterizer spans
JimBobSquarePants 6f97c13
Buffer contiguous spans to batch row callbacks
JimBobSquarePants b29a440
Apply DestinationOffset for path point translation
JimBobSquarePants bd8d170
Add aliased fine-pass threshold shader and plumbing
JimBobSquarePants ea883f8
Move WGSL sources to Shaders/WgslSource
JimBobSquarePants a60f921
Add 3rd part notices
JimBobSquarePants 0937ae3
Add WebGPU scene support & optimize encoding
JimBobSquarePants ce482dc
Add docs and helpers for WebGPU shaders & backend
JimBobSquarePants 98f4309
Add sample; add WebGPU chunking.
JimBobSquarePants dccffdc
Use CI solution in scripts; tweak sample csproj
JimBobSquarePants 2fd7a8d
Update refs
JimBobSquarePants d1d1007
Update WgslSourceGenerator.cs
JimBobSquarePants 001c9b1
Add tolerance
JimBobSquarePants 39472dd
Update ci-test.ps1
JimBobSquarePants e327130
Update docs.
JimBobSquarePants a801d03
add Skia "benchmark backend" options to DrawingBackendBenchmark
antonfirsov b75449f
tmp - progress capture only
JimBobSquarePants 76af5f8
Improve GPU perf
JimBobSquarePants 3e90cfc
Fix chunking
JimBobSquarePants 7e338eb
cleanup
JimBobSquarePants e80c72e
Cache and reuse scheduling arena across flushes
JimBobSquarePants 9541b2c
Add reusable WebGPU scene resource arena
JimBobSquarePants 108cac3
Refactor scheduling & resource arena helpers
JimBobSquarePants b47a539
Remove debug logging
JimBobSquarePants 371aa37
Add slowpath transform
JimBobSquarePants 16a02bd
Apply transforms
JimBobSquarePants d5d1d76
Fix gradient brushes
JimBobSquarePants c6fc3ab
Fix GPU stroking and ImageBrush
JimBobSquarePants 557111d
Fix GPU brush transforms
JimBobSquarePants 4ebf33d
Test pass.
JimBobSquarePants eab9402
Implement retained stroke rasterization and stroke commands
JimBobSquarePants eba4bd0
Clean up public API
JimBobSquarePants 9b31222
Centralize WebGPU probes into WebGPURuntime
JimBobSquarePants 073e2b7
Patch test, update docs
JimBobSquarePants 44d0e74
Honor MaxDegreeOfParallelism in flush
JimBobSquarePants 5553d94
Add Fill symmetry, new Pie polygon, and migrate to extensions
JimBobSquarePants 5eac1ee
Simplify tests and update docs
JimBobSquarePants aba2197
detangle build version numbers
JimBobSquarePants 5077d42
Add PathBuilder shape helpers; normalize angles to degrees
JimBobSquarePants d07e429
Fix tests
JimBobSquarePants 7fc45bb
Add ParallelExecutionHelper for partitioning
JimBobSquarePants 2b217b6
Update refs
JimBobSquarePants 99c2bd4
Update ImageSharp ref
JimBobSquarePants ef29546
Cleanup API and fix demo FPS display
JimBobSquarePants 2e46ac7
Inline explicit layers; remove compose pass, fix issues
JimBobSquarePants 0110ef5
Include square line cap in bounds; update WebGPU tests
JimBobSquarePants cc01945
Improve coverage a little
JimBobSquarePants a4d0378
Add emoji grid text rendering test and bump Fonts
JimBobSquarePants 24af798
Fix parallel bounds, use configuration
JimBobSquarePants 36f2203
Replace Lease-based runtime with shared API
JimBobSquarePants 1290892
Remove HybridCanvasFrame and hybrid APIs
JimBobSquarePants 920b798
Replace TryReadback API with Readback methods, remove Shutdown
JimBobSquarePants a6de45e
benchmark parallel efficiency and overhead
antonfirsov 7ed6fbf
Introduce safe WebGPU handle wrappers
JimBobSquarePants 636bc6d
Merge branch 'js/canvas-api' of https://github.com/SixLabors/ImageSha…
JimBobSquarePants 53ee7c9
Use WebGPUEnvironmentError for probe results
JimBobSquarePants 951ef8c
Use error codes in test attributes.
JimBobSquarePants 8e80543
Make ToLinearGeometry() cache threadsafe.
JimBobSquarePants f1a0cdb
Merge -> Concat
JimBobSquarePants 6b2632f
Use inline array, fix GPU retry counter logic
JimBobSquarePants 5c821fc
Update src/ImageSharp.Drawing/Processing/Backends/DefaultDrawingBacke…
JimBobSquarePants f5cf5c0
Update src/ImageSharp.Drawing/Processing/Backends/ParallelExecutionHe…
JimBobSquarePants ada96d1
Merge branch 'js/canvas-api' of https://github.com/SixLabors/ImageSha…
JimBobSquarePants 390d2a4
Update ParallelExecutionHelper.cs
JimBobSquarePants 8935070
ProcessWithCanvas -> Paint
JimBobSquarePants 1af0996
Process -> Apply
JimBobSquarePants 64edabf
Add useful scripts.
JimBobSquarePants f61551d
restructure solutions and fix DrawShapesWithImageSharp sample
antonfirsov 8ebefc2
make the lines benchmark resizable
antonfirsov e48c02c
Refactor WebGPU handles and render targets
JimBobSquarePants 9637899
Use safe handle refs for WebGPU native calls via using
JimBobSquarePants 84e2c32
Use DrawingOptions in composition and stroke commands
JimBobSquarePants 185f7d6
Fix tests
JimBobSquarePants acca457
Update WebGPU docs.
JimBobSquarePants 529615b
Align chunk tile heights to 16-row bins
JimBobSquarePants 0f450fc
Add more efficient path-row shaders and sparse tile handling
JimBobSquarePants ecc069f
Fix benchmark resize handling
JimBobSquarePants d3c3979
Add hosted window API and samples + fix bugs/perf
JimBobSquarePants 3fc9b18
Remove overly defensive guards
JimBobSquarePants d444734
Make CloneForClearOperation internal
JimBobSquarePants b89a0af
Use IEnumerable for DrawGlyphs
JimBobSquarePants f1ec587
Unify text measurement API to TextMetrics
JimBobSquarePants de08b34
Remove InnerJoin config, ensure WebGPU configuration coverage
JimBobSquarePants 872b315
Remove WebGPUTextureTransfer and use Readback APIs
JimBobSquarePants dd37975
Remove partial modifier from DrawingCanvas
JimBobSquarePants a50e945
Rename DrawingCanvasExtensions class
JimBobSquarePants d8706d4
Full cleanup pass
JimBobSquarePants 1defc56
Use WebGPUHostedSurface and normalize API
JimBobSquarePants 76ff622
Treat DeviceLost a non-fatal until it is.
JimBobSquarePants 681b5a4
Refactor WebGPU resource allocation to throw
JimBobSquarePants e79e82a
Replace TryReadRegion with ReadRegion (throws)
JimBobSquarePants b5c6458
Add Apply readback scene and UI wiring
JimBobSquarePants 07c74ad
Make NativeSurface abstract, simplify, and add WebGPU surface
JimBobSquarePants 210df0d
Make types internal
JimBobSquarePants 356bbd8
Add WebGPU path-gradient support and remove fallback behavior
JimBobSquarePants 1310439
Move canvas convenience APIs to extensions
JimBobSquarePants c343942
Normalize stroke docs.
JimBobSquarePants dfd3237
Update TextBuilderTests.cs
JimBobSquarePants 24386f0
Update PathTests.cs
JimBobSquarePants 970a42e
More Path extensions tests
JimBobSquarePants d15c48b
Add FillPath_UncontainedGeometry WebGPU test
JimBobSquarePants 1771beb
Handle point strokes in WebGPU encoder
JimBobSquarePants 93d4c77
Use Allocator/IMemoryOwner instead of ArrayPool
JimBobSquarePants 654b96b
Use WebGPUNativeTarget and refactor native surface
JimBobSquarePants 66b9e71
Rename HostedSurface to ExternalSurface
JimBobSquarePants dedd939
Remove FramebufferSize from WebGPUSurfaceFrame
JimBobSquarePants c2e93f8
Remove Present method; auto-present on Dispose
JimBobSquarePants 6dc2adc
Make presentMode readonly; remove properties
JimBobSquarePants 5c7fae3
Introduce DrawingCanvas base type and APIs
JimBobSquarePants 1045220
Introduce FlattenedPointBuilder and rendering optimizations
JimBobSquarePants 2dee25d
Add rich drawing samples and assets. Fix SaveLayer clipping
JimBobSquarePants c4f08fa
Clean up images that shouldn't be there.
JimBobSquarePants a31ec09
Tweak sample
JimBobSquarePants f043269
Add files to LFS
JimBobSquarePants 9a12335
Dispose Canvas then ensure surface handle release
JimBobSquarePants b6bc3f8
Make DrawingCanvas factory internal and update tests
JimBobSquarePants 6fa5d73
ImageSharp.Drawing.All
antonfirsov 8dfce85
simplify CompositePixelRegistration storage and related lookup methods
antonfirsov 69d2cba
fix xmldoc leftover
antonfirsov 2ed1c0a
delete unused code
antonfirsov 86c1fbe
Add retained drawing scenes and refactor WebGPU
JimBobSquarePants f53fd52
Merge branch 'js/canvas-api' of https://github.com/SixLabors/ImageSha…
JimBobSquarePants c71f248
Remove TPixel generics from WebGPU API
JimBobSquarePants f80477d
Refactor drawing backend API and WebGPU helpers
JimBobSquarePants 0169887
Add partitioned parallel encoding for WebGPU scenes
JimBobSquarePants 78d680d
Add WebGPU uncaptured-error handling and safety
JimBobSquarePants 24c7c6e
Add retain regression tests
JimBobSquarePants 8b314aa
Remove TryGetOrCreateSharedBuffer
JimBobSquarePants fd5a72d
Refactor WebGPU buffer creation helpers to remove Try
JimBobSquarePants 03bd40a
Merge branch 'js/canvas-api' of https://github.com/SixLabors/ImageSha…
antonfirsov 1dfca18
delete unused code
antonfirsov be9ab86
delete more dead code
antonfirsov 66327e4
Rename Graphics to DeviceContext and make field
JimBobSquarePants 7c66fb2
Remove WebGPUNativeSurfaceFactory
JimBobSquarePants 884c0f7
Add ReadbackImage API and Buffer2DRegion usage
JimBobSquarePants 5db4e95
Migrate Create to WebGPUNativeSurface
JimBobSquarePants 1eec802
Use native frames for WebGPU staging and flush
JimBobSquarePants 005ffa4
Fix binning regression.
JimBobSquarePants a683e7b
Align GPU ImageBrush with CPU
JimBobSquarePants 506b059
Convert shape extensions to DrawingCanvas methods
JimBobSquarePants 0386d47
Use explicit native mappings instead of casts
JimBobSquarePants d5a87e2
Refactor WebGPU native surface and chunking
JimBobSquarePants 6e0b36c
Add WebGPU environment options and preference
JimBobSquarePants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Draw Shapes With ImageSharp | ||
|
|
||
| A sample application that demonstrates the core vector drawing capabilities of ImageSharp.Drawing. Each example renders shapes to an `Image<Rgba32>` using the `DrawingCanvas` API and saves the result as a PNG file in the `Output/` directory. | ||
|
|
||
| ## What it demonstrates | ||
|
|
||
| - **Stars** — Filled and outlined star polygons with varying point counts, inner/outer radii, line join styles (miter, round, bevel), and dashed outlines with different line caps. | ||
| - **Clipping** — Rectangle-on-rectangle clipping using `IPath.Clip()`. | ||
| - **Path building** — Constructing complex shapes with `PathBuilder`, including multi-figure paths (a V overlaid with a rectangle) and an hourglass shape. | ||
| - **Curves** — Ellipses via `EllipsePolygon` and cubic Bezier arcs via `CubicBezierLineSegment`. | ||
| - **Text as paths** — Converting text to vector outlines using `TextBuilder.GeneratePaths()` with system fonts, including text laid out along a curved path. | ||
| - **Serialized glyph data** — Rendering OpenSans letter shapes ('a' and 'o') from serialized coordinate data as `ComplexPolygon` instances. | ||
| - **Canvas API** — `Fill` for solid backgrounds and shape rendering via `ProcessWithCanvas`. | ||
|
|
||
| ## Running | ||
|
|
||
| ```bash | ||
| dotnet run --project samples/DrawShapesWithImageSharp -c Debug | ||
| ``` | ||
|
|
||
| Output images are written to the `Output/` directory, organized into subdirectories by category: `Stars/`, `Clipping/`, `Curves/`, `Text/`, `Drawing/`, `Letter/`, and `Issues/`. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.