Skip to content

WIP. Expand DrawingBackend API and Canvas.#377

Draft
JimBobSquarePants wants to merge 87 commits intomainfrom
js/canvas-api
Draft

WIP. Expand DrawingBackend API and Canvas.#377
JimBobSquarePants wants to merge 87 commits intomainfrom
js/canvas-api

Conversation

@JimBobSquarePants
Copy link
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

WIP - Still lots of normalization and testing to do!

This PR expand on the backend drawing API and drawing canvas to normalize usage throughout the library and to better allow custom backends both CPU and GPU.

There's an experimental WebGPU backend in the repo but it's nowhere near production ready so serves simply as a dogfooding tool for the API design. Our new CPU backend is more than fast enough for most usage.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 89.51856% with 209 lines in your changes missing coverage. Please review.
✅ Project coverage is 85%. Comparing base (e7aa1b6) to head (6fbc481).

Files with missing lines Patch % Lines
...p.Drawing/Processing/Backends/DefaultRasterizer.cs 91% 52 Missing and 31 partials ⚠️
...eSharp.Drawing/Processing/DrawingCanvas{TPixel}.cs 85% 58 Missing and 22 partials ⚠️
...awing/Processing/Backends/DefaultDrawingBackend.cs 81% 12 Missing and 6 partials ⚠️
...Sharp.Drawing/Processing/Backends/NativeSurface.cs 25% 9 Missing ⚠️
...awing/Processing/Backends/DrawingCoverageHandle.cs 37% 5 Missing ⚠️
...g/Processing/Backends/CanvasRegionFrame{TPixel}.cs 77% 3 Missing and 1 partial ⚠️
src/ImageSharp.Drawing/Helpers/ArrayExtensions.cs 75% 1 Missing and 1 partial ⚠️
...Sharp.Drawing/Helpers/ThreadLocalBlenderBuffers.cs 89% 1 Missing and 1 partial ⚠️
...rp.Drawing/Processing/Backends/CompositionBatch.cs 88% 2 Missing ⚠️
src/ImageSharp.Drawing/Processing/ImageBrush.cs 87% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@         Coverage Diff          @@
##           main   #377    +/-   ##
====================================
  Coverage    84%    85%            
====================================
  Files       101     83    -18     
  Lines      4529   4950   +421     
  Branches    654    677    +23     
====================================
+ Hits       3849   4210   +361     
- Misses      540    574    +34     
- Partials    140    166    +26     
Flag Coverage Δ
unittests 85% <89%> (+<1%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@antonfirsov
Copy link
Member

antonfirsov commented Mar 4, 2026

Target 2, then 1.

This means that it would be of key importance to validate the API with a simple GUI app that truly challenges the rendering engine! I just made this thing with Claude*. We need an equivalent C# app. It can of course do something else (as long as it does mass text rendering!), but we need to make sure we have an HTML5 reference app, and that its' functionality is kept in sync with our C# app's, so we can compare them.

the WebGPU IDrawingBackend implementation is purely experimental

We don't need it to be production ready, but if we find performance bottlenecks, we should identify where is the root cause: suboptimal backend implementation VS the API shape VS our library code.

I can chime in into this work later, but not right now.

*disclaimer: didn't spend time on deslopification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants