Skip to content

Add sk_colorfilter_new_overdraw C API#262

Merged
mattleibow merged 1 commit into
skiasharpfrom
dev/issue-3941-colorfilter-overdraw
Jun 25, 2026
Merged

Add sk_colorfilter_new_overdraw C API#262
mattleibow merged 1 commit into
skiasharpfrom
dev/issue-3941-colorfilter-overdraw

Conversation

@mattleibow

Copy link
Copy Markdown
Collaborator

C API for SKColorFilter.CreateOverdraw() - wraps SkOverdrawColorFilter::MakeWithSkColors.

Maps overdraw counts (0-5+) to a 6-color palette for rendering performance debugging.

Part of mono/SkiaSharp#3941 and mono/SkiaSharp#4227

Wraps SkOverdrawColorFilter::MakeWithSkColors to expose overdraw
visualization filter that maps overdraw counts (0-5+) to a 6-color palette.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattleibow mattleibow force-pushed the dev/issue-3941-colorfilter-overdraw branch from 529de3c to a10e105 Compare June 25, 2026 17:30
@mattleibow mattleibow merged commit b16789e into skiasharp Jun 25, 2026
1 check passed
@mattleibow mattleibow deleted the dev/issue-3941-colorfilter-overdraw branch June 25, 2026 18:55
pull Bot pushed a commit to zilo555/SkiaSharp that referenced this pull request Jun 25, 2026
)

Add SKColorFilter.CreateOverdraw() for overdraw visualization (mono#4227)

Context: mono#3941
Changes: mono/skia#262

Implements overdraw visualization support by wrapping Skia's
SkOverdrawColorFilter, which maps overdraw counts (0–5+) to a
6-color heat-map palette for rendering performance debugging.

~~ Problem ~~

SkiaSharp wrapped SKOverdrawCanvas (which tracks draw counts by writing
to the alpha channel) but did not expose SkOverdrawColorFilter (which
converts those alpha values into visible colors). Users could generate
overdraw data but not visualize it without dropping into native code.

Issue mono#3941 requested the missing API to complete the overdraw debugging
workflow.

~~ Solution ~~

Added SKColorFilter.CreateOverdraw() with the standard Span-triple pattern:
  - CreateOverdraw(ReadOnlySpan<SKColor>) — primary overload
  - CreateOverdraw(SKColor[]) — convenience overload

Input validation ensures exactly 6 colors are provided (throws
ArgumentException otherwise, ArgumentNullException for null arrays).

~~ C API ~~

Requires mono/skia#262, which adds sk_colorfilter_new_overdraw() wrapping
SkOverdrawColorFilter::MakeWithSkColors(). The C API accepts a 6-element
color array and returns an sk_colorfilter_t*.

~~ Gallery Sample and Tests ~~

Added OverdrawVisualizationSample showing side-by-side comparison of normal
rendering vs overdraw visualization. The sample demonstrates the full workflow:
  1. Create offscreen A8 surface
  2. Wrap in SKOverdrawCanvas (writes counts to alpha)
  3. Draw overlapping shapes
  4. Snapshot to image
  5. Apply CreateOverdraw filter when drawing the image

Tests cover creation, validation (wrong length, null), Span equivalence,
and rendering with SKOverdrawCanvas to verify the filter correctly maps
alpha values to colors.

~~ Submodule Update ~~

Updates externals/skia to a10e10524a (dev/issue-3941-colorfilter-overdraw
rebased on 214e2d2f38) to include the required C API. The cgmanifest.json
is updated accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant