Add sk_colorfilter_new_overdraw C API#262
Merged
Merged
Conversation
f52aea6 to
529de3c
Compare
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>
529de3c to
a10e105
Compare
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>
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 free
to 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.
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