Skip to content

Add a modern shared pixel-comparison API for tests - #5293

Merged
mattleibow merged 44 commits into
mainfrom
mattleibow-pixel-comparison-research
Nov 19, 2026
Merged

mattleibow merged 44 commits into
mainfrom
mattleibow-pixel-comparison-research

Conversation

@mattleibow

@mattleibow mattleibow commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add experimental SkiaSharp.Testing, a separately packaged image-comparison library, and replace the copied/Extended pixel comparer in existing rendering-test consumers. It supports channel tolerances, mismatch budgets, raw/thresholded error metrics, MAE/RMS acceptance limits, tolerance/ignore masks, and five diagnostic styles.

The package uses normal SkiaSharp family versioning and SKIA4001 experimental opt-in. Existing native APIs, reviewed baselines and consumer acceptance policies are unchanged. Exact-package integration uses the matching Testing package rather than a locally built substitute.

Guides → Testing includes generated examples. Inputs, masks and diagnostic outputs are saved at 800×600; separate *-preview.png copies preserve the checkerboard gallery presentation. The scene covers a subtle RGB change, an alpha-only change, an added square and a gradient-to-solid fill change.

Related issues

None.

Required skia PR

None.

Areas affected

  • Managed API (binding/)
  • Native / C API (externals/skia/src/c, include/c)
  • Generated P/Invoke bindings
  • Native dependency or Skia update (libpng, HarfBuzz, FreeType, zlib, milestone bump, …)
  • Views & integrations (MAUI, Uno, WPF, WinUI, Blazor, …)
  • Rendering output / visual behavior
  • Performance
  • Tests
  • Build, packaging, or CI
  • Documentation or samples

Changes

Public API

All types below are in SkiaSharp.Testing. This is a new, unpublished experimental API; existing SkiaSharp and Extended public types are not renamed or removed.

Complete public declarations
[assembly: System.Diagnostics.CodeAnalysis.Experimental("SKIA4001", UrlFormat = "https://mono.github.io/SkiaSharp/docs/guides/testing/image-comparison.html#getting-started")]

namespace SkiaSharp.Testing;

public static class SKImageComparison
{
    public static SKComparisonResult Compare(SKImage first, SKImage second, SKComparisonOptions? options = null);
    public static SKComparisonResult Compare(SKBitmap first, SKBitmap second, SKComparisonOptions? options = null);
    public static SKComparisonResult Compare(SKPixmap first, SKPixmap second, SKComparisonOptions? options = null);
    public static SKImage GenerateDifferenceImage(SKImage first, SKImage second, SKDifferenceStyle style = SKDifferenceStyle.ThresholdOverlay, SKComparisonOptions? options = null);
    public static SKImage GenerateDifferenceImage(SKBitmap first, SKBitmap second, SKDifferenceStyle style = SKDifferenceStyle.ThresholdOverlay, SKComparisonOptions? options = null);
    public static SKImage GenerateDifferenceImage(SKPixmap first, SKPixmap second, SKDifferenceStyle style = SKDifferenceStyle.ThresholdOverlay, SKComparisonOptions? options = null);
}

public readonly struct SKPixelTolerance : IEquatable<SKPixelTolerance>
{
    public SKPixelTolerance();
    public static SKPixelTolerance Exact { get; }
    public static SKPixelTolerance Absolute(int value);
    public static SKPixelTolerance Percent(double value);
    public double Value { get; }
    public bool Allows(double absoluteDifference);
    public bool Equals(SKPixelTolerance other);
    public override bool Equals(object? obj);
    public override int GetHashCode();
    public static bool operator ==(SKPixelTolerance left, SKPixelTolerance right);
    public static bool operator !=(SKPixelTolerance left, SKPixelTolerance right);
}

public readonly struct SKPixelMismatchBudget : IEquatable<SKPixelMismatchBudget>
{
    public SKPixelMismatchBudget();
    public static SKPixelMismatchBudget Exact { get; }
    public static SKPixelMismatchBudget Pixels(long maximum);
    public static SKPixelMismatchBudget Percent(double maximum);
    public static SKPixelMismatchBudget Both(long pixels, double percent);
    public long? MaxPixels { get; }
    public double? MaxPercent { get; }
    public bool Allows(long mismatchedPixels, long comparedPixels);
    public bool Equals(SKPixelMismatchBudget other);
    public override bool Equals(object? obj);
    public override int GetHashCode();
    public static bool operator ==(SKPixelMismatchBudget left, SKPixelMismatchBudget right);
    public static bool operator !=(SKPixelMismatchBudget left, SKPixelMismatchBudget right);
}

public sealed class SKComparisonOptions
{
    public SKComparisonOptions();
    public SKPixelTolerance? RedTolerance { get; set; }
    public SKPixelTolerance? GreenTolerance { get; set; }
    public SKPixelTolerance? BlueTolerance { get; set; }
    public SKPixelTolerance? AlphaTolerance { get; set; }
    public SKAlphaType AlphaType { get; set; }
    public SKImage? ToleranceMask { get; set; }
    public SKImage? IgnoreMask { get; set; }
    public SKPixelMismatchBudget? MismatchBudget { get; set; }
    public double? MaxNormalizedRootMeanSquaredError { get; set; }
    public double? MaxNormalizedMeanAbsoluteError { get; set; }
}

public sealed class SKComparisonResult
{
    public bool IsMatch { get; }
    public int TotalPixels { get; }
    public int ComparedPixelCount { get; }
    public int IgnoredPixelCount { get; }
    public int ChannelCount { get; }
    public int MismatchedPixelCount { get; }
    public double MismatchedPixelFraction { get; }
    public int MaxChannelDifference { get; }
    public SKRectI? MismatchBounds { get; }
    public SKComparisonMetrics RawMetrics { get; }
    public SKComparisonMetrics ThresholdedMetrics { get; }
}

public sealed class SKComparisonMetrics
{
    public long SampleCount { get; }
    public long SumAbsoluteError { get; }
    public long SumSquaredError { get; }
    public double MeanAbsoluteError { get; }
    public double NormalizedMeanAbsoluteError { get; }
    public double MeanSquaredError { get; }
    public double RootMeanSquaredError { get; }
    public double NormalizedRootMeanSquaredError { get; }
    public double PeakSignalToNoiseRatio { get; }
}

public enum SKDifferenceStyle
{
    BinaryMask = 0,
    ChannelDifference = 1,
    ThresholdMap = 2,
    ThresholdOverlay = 3,
    Heatmap = 4,
}

Implicit constructors are listed above for completeness; results and metrics are library-constructed. The compatibility experimental attribute is internal.

Behavior

Default comparison is exact RGBA after normalization to unpremultiplied BGRA8888. Null channel tolerances exclude channels. Tolerance percentages use the channel range; mismatch percentages use nonignored compared pixels, with inclusive whole-pixel limits floored from the round-trip decimal percentage. Configured mismatch/MAE/RMS gates combine with AND; magnitude-only gates impose no implicit zero-mismatch requirement.

Tolerance masks widen enabled-channel allowances without reducing raw measurements. Ignore masks exclude pixels from errors, bounds and sample denominators; ignoring every pixel throws. Inputs and masks are borrowed for each synchronous call. Results retain no native inputs; returned diagnostics are independently owned by the caller.

Diagnostics are opaque: BinaryMask shows mismatch status, ChannelDifference shows raw RGB differences (including disabled RGB channels, without alpha), ThresholdMap shows solid red/amber/gray classifications, default ThresholdOverlay blends classifications at 50% over actual pixels flattened onto white, and Heatmap maps the largest raw enabled-channel error to a fixed blue-to-red scale, with black exact matches and gray ignored coverage. Heatmap includes tolerated and enabled alpha differences.

No native/C API or generated-binding changes, automatic baseline acceptance, or relaxed consumer thresholds. Comparison avoids repeated native width lookups and skips zero-error arithmetic for identical normalized pixels; timing and managed-allocation benchmarks are included in source tracking.

Testing

Latest local review-fix validation on macOS ARM64:

  • dotnet test tests/SkiaSharp.Tests.Console.slnx -p:TargetFramework=net10.0 -p:TargetFrameworks=net10.0 — comparison host 69 passed, 0 failed, 0 skipped; full solution still fails only the previously observed ganesh-gl/DiagonalLines golden comparison. Main host: 6,407 total, 6,383 passed, 23 policy skips, 1 failure. Other hosts passed. No baselines or skip policies changed.
  • dotnet build tests/SkiaSharp.Testing.Tests/SkiaSharp.Testing.Tests.csproj -p:TargetFramework=net48 -p:TargetFrameworks=net48 -p:AllTargetFrameworks=net48 -p:BasicTargetFrameworks=net48 -p:AutomaticallyUseReferenceAssemblyPackages=true -v:q — passed, 0 warnings/errors. Windows .NET Framework execution remains CI validation; no Windows runtime execution was performed locally.
  • dotnet run --file documentation/docfx/guides/testing/generate-images.cs -p:TargetFrameworks=net10.0 — passed; regenerated raw outputs and separately named previews. Raw files are 800×600; previews are 850×650 and byte-identical to the previous gallery presentation.

The test host is now registered in both Cake CI runner lists (.NET and Windows .NET Framework x86/x64). The previously green AzDO build 1639386 predates these runner-registration fixes. Matching native assets from that build were used locally; no compatibility checks were bypassed. No package published.

Checklist

  • Tests added or updated (if omitted, explain why above)
  • Changes above lists all public API and behavioral changes (or "None.")
  • New/changed public API? Added or updated accurate source /// documentation and regenerated bindings when applicable
  • Native change? Companion mono/skia PR linked above and bindings regenerated

Native regeneration is not applicable.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

Add the automation/staging label to build and publish a documentation preview for this PR.

Removing the label removes the preview. While the label is present, each new commit updates it.


This comment is automatically updated by the documentation staging workflow.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

📦 Try the packages from this PR

Warning

Do not run these scripts without first reviewing the code in this PR.

Step 1 — Download the packages

bash / macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 5293

PowerShell / Windows:

iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 5293"

Step 2 — Add the local NuGet source

dotnet nuget add source ~/.skiasharp/hives/pr-5293/packages --name skiasharp-pr-5293
More options
Option Description
--successful-only / -SuccessfulOnly Only use successful builds
--force / -Force Overwrite previously downloaded packages
--list / -List List available artifacts without downloading
--build-id ID / -BuildId ID Download from a specific build

Or download manually from Azure Pipelines — look for the nuget artifact on the build for this PR.

Remove the source when you're done:

dotnet nuget remove source skiasharp-pr-5293

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

📊 SkiaSharp benchmarks — PR #5293

⭐ this PR (full source build) vs 🌙 nightly · Linux · Windows · macOS

Informational only — this never blocks the PR. 🟢 faster / less allocation · 🔴 slower / more allocation; moves under 5% are hidden as noise.

⏱️ Times are raw BenchmarkDotNet means, and the ⭐ PR and baseline legs run on separate CI runners, so microbenchmarks can swing run-to-run — treat small time deltas as noise. Allocations are deterministic and the reliable signal. The interactive perf-dashboard (linked below) applies smoothing for the trend view.

Highlights

⏱️ Time — 🔴 20 slower · 🟢 70 faster

  • 🔴 MatrixMapPointsBenchmark.MapPoints(Points: 256) · macOS · 177.4 ns → 323.2 ns (+82%)
  • 🔴 MatrixMapPointsBenchmark.MapPoints(Points: 4096) · macOS · 2.09 µs → 3.28 µs (+57%)
  • 🟢 MatrixMapPointsBenchmark.MapPoints(Points: 4096) · Windows · 2.73 µs → 1.70 µs (-38%)
  • 🔴 RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) · macOS · 75.99 µs → 98.13 µs (+29%)
  • 🟢 MatrixMapPointsBenchmark.MapPoints(Points: 256) · Windows · 188.4 ns → 138.8 ns (-26%)
  • …and 85 more (see details below)
Full per-OS benchmark deltas

Linux

⏱️ Time (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 272.72 µs 204.00 µs 🟢 -25%
ColorMathBenchmark.ToColor(Colors: 4096) 15.34 µs 12.02 µs 🟢 -22%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 234.36 µs 191.53 µs 🟢 -18%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 18.18 ms 14.88 ms 🟢 -18%
ColorParseBenchmark.Parse(Iterations: 1000) 73.56 µs 60.51 µs 🟢 -18%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 3.94 ms 3.24 ms 🟢 -18%
PathBoundsBenchmark.TightBounds(Points: 64) 973.0 ns 806.9 ns 🟢 -17%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 911.83 µs 757.45 µs 🟢 -17%
CanvasDrawBenchmark.Draw(Shapes: 512) 33.06 ms 27.52 ms 🟢 -17%
CanvasDrawBenchmark.Draw(Shapes: 64) 4.15 ms 3.46 ms 🟢 -17%
RuntimeEffectShaderBenchmark.DrawFrame 2.83 ms 2.37 ms 🟢 -17%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 2.52 µs 2.12 µs 🟢 -16%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 245.83 µs 207.14 µs 🟢 -16%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 1.95 ms 1.65 ms 🟢 -16%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 345.91 µs 292.76 µs 🟢 -15%
PathBoundsBenchmark.TightBounds(Points: 1024) 10.45 µs 8.84 µs 🟢 -15%
ColorMathBenchmark.ToColorF(Colors: 4096) 13.12 µs 11.13 µs 🟢 -15%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 93.07 µs 79.32 µs 🟢 -15%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 74.11 µs 63.30 µs 🟢 -15%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 7.49 ms 6.42 ms 🟢 -14%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 677.83 µs 581.38 µs 🟢 -14%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 176.95 µs 153.75 µs 🟢 -13%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 13.91 µs 12.13 µs 🟢 -13%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.60 ms 2.27 ms 🟢 -13%
MatrixMapPointsBenchmark.MapVector(Points: 256) 11.16 µs 9.77 µs 🟢 -12%
…and 9 more

Windows

⏱️ Time (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 2.73 µs 1.70 µs 🟢 -38%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 188.4 ns 138.8 ns 🟢 -26%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 2.29 ms 1.79 ms 🟢 -22%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 2.54 µs 2.03 µs 🟢 -20%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 10.55 ms 8.42 ms 🟢 -20%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 39.71 µs 32.00 µs 🟢 -19%
ColorMathBenchmark.ToColorF(Colors: 4096) 13.31 µs 10.88 µs 🟢 -18%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 925.05 µs 780.88 µs 🟢 -16%
CanvasDrawBenchmark.Draw(Shapes: 512) 21.38 ms 18.09 ms 🟢 -15%
CanvasDrawBenchmark.Draw(Shapes: 64) 2.68 ms 2.27 ms 🟢 -15%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.92 ms 2.48 ms 🟢 -15%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 738.10 µs 628.90 µs 🟢 -15%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.24 ms 1.06 ms 🟢 -14%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 9.99 ms 8.60 ms 🟢 -14%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 2.53 ms 2.18 ms 🟢 -14%
RuntimeEffectShaderBenchmark.DrawFrame 1.13 ms 973.35 µs 🟢 -14%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 245.04 µs 211.73 µs 🟢 -14%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 327.30 µs 283.59 µs 🟢 -13%
ColorMathBenchmark.ToColor(Colors: 4096) 14.37 µs 12.51 µs 🟢 -13%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 11.29 µs 9.84 µs 🟢 -13%
ColorMathBenchmark.PreMultiply(Colors: 4096) 12.96 µs 11.38 µs 🟢 -12%
ColorParseBenchmark.Parse(Iterations: 1000) 75.15 µs 66.57 µs 🟢 -11%
MatrixOpsBenchmark.Concat(Count: 4096) 237.05 µs 213.30 µs 🟢 -10%
MatrixMapPointsBenchmark.MapRect(Points: 256) 10.41 µs 9.58 µs 🟢 -8%
MatrixMapPointsBenchmark.MapRect(Points: 4096) 166.53 µs 153.36 µs 🟢 -8%
…and 4 more

macOS

⏱️ Time (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
MatrixMapPointsBenchmark.MapPoints(Points: 256) 177.4 ns 323.2 ns 🔴 +82%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 2.09 µs 3.28 µs 🔴 +57%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 75.99 µs 98.13 µs 🔴 +29%
MatrixOpsBenchmark.Invert(Count: 4096) 79.67 µs 59.82 µs 🟢 -25%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 272.52 µs 215.26 µs 🟢 -21%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 8.31 µs 9.74 µs 🔴 +17%
ColorMathBenchmark.ToColor(Colors: 4096) 21.62 µs 19.05 µs 🟢 -12%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 969.56 µs 857.87 µs 🟢 -12%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 42.91 µs 47.73 µs 🔴 +11%
PathBoundsBenchmark.TightBounds(Points: 64) 979.9 ns 1.09 µs 🔴 +11%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 6.19 ms 6.86 ms 🔴 +11%
CanvasDrawBenchmark.Draw(Shapes: 512) 14.34 ms 12.84 ms 🟢 -10%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 109.50 µs 120.85 µs 🔴 +10%
RuntimeEffectShaderBenchmark.DrawFrame 594.46 µs 654.40 µs 🔴 +10%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.96 ms 2.67 ms 🟢 -10%
PathBoundsBenchmark.TightBounds(Points: 1024) 9.29 µs 10.14 µs 🔴 +9%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 1.32 ms 1.44 ms 🔴 +9%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 729.66 µs 665.23 µs 🟢 -9%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 1.31 µs 1.41 µs 🔴 +8%
ColorMathBenchmark.PreMultiply(Colors: 4096) 9.24 µs 9.86 µs 🔴 +7%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 21.44 µs 22.85 µs 🔴 +7%
ColorParseBenchmark.Parse(Iterations: 1000) 72.54 µs 77.11 µs 🔴 +6%
MatrixMapPointsBenchmark.MapVector(Points: 256) 2.67 µs 2.82 µs 🔴 +6%
ColorMathBenchmark.ToColorF(Colors: 4096) 5.63 µs 5.95 µs 🔴 +6%
MatrixOpsBenchmark.Concat(Count: 4096) 135.02 µs 142.55 µs 🔴 +6%
…and 2 more

📈 Full interactive perf-dashboard & run details →

@mattleibow mattleibow changed the title Share the pixel comparer across SkiaSharp test hosts Add a modern shared pixel-comparison API for tests Oct 6, 2026
@mattleibow
mattleibow force-pushed the mattleibow-pixel-comparison-research branch 2 times, most recently from de4ce13 to 9824725 Compare October 14, 2026 17:41
@mattleibow
mattleibow requested a balanced review from Copilot October 15, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

CI runner registration and reusable generated-mask dimensions need correction before approval.

2 open findings
What changed in this PR

Introduces experimental SkiaSharp.Testing as the shared image-comparison package for rendering tests, replacing copied and Extended comparers.

Changes:

  • Adds channel tolerances, mismatch budgets, error metrics, masks, and diagnostic images.
  • Migrates test consumers and integrates package versioning, signing, and solutions.
  • Adds focused regression tests and illustrated testing guides.
File Description
tests/​Tests/​Utils/​SKPixelComparer.cs Removes the copied comparer.
tests/​Tests/​SkiaSharp/​Visual/​Tests/​VisualMatrixTestsBase.cs Migrates golden-image comparisons.
tests/​Tests/​SkiaSharp/​SKTest.cs Migrates bitmap assertions.
tests/​SkiaSharp.Tests/​SkiaSharp.Tests.csproj References the testing library.
tests/​SkiaSharp.Tests.Samples/​Utils/​SampleImage.cs Migrates sample comparisons and diagnostics.
tests/​SkiaSharp.Tests.Samples/​SkiaSharp.Tests.Samples.csproj Replaces linked comparer source.
tests/​SkiaSharp.Tests.Samples/​SampleInfrastructureTests.cs Tests error-gate boundaries.
tests/​SkiaSharp.Tests.Integration/​Tests/​PlatformTestBase.cs Migrates integration comparisons.
tests/​SkiaSharp.Tests.Integration/​SkiaSharp.Tests.Integration.csproj Uses the matching testing package.
tests/​SkiaSharp.Tests.Console/​SkiaSharp.Tests.Console.csproj References the testing library.
tests/​SkiaSharp.Tests.Console.slnx Includes library and regression tests.
tests/​SkiaSharp.Testing.Tests/​SKPixelValidationTest.cs Tests validation and experimental metadata.
tests/​SkiaSharp.Testing.Tests/​SKPixelToleranceTest.cs Tests channel and mask tolerances.
tests/​SkiaSharp.Testing.Tests/​SKPixelNormalizationTest.cs Tests normalization across input types.
tests/​SkiaSharp.Testing.Tests/​SKPixelIgnoreCoverageTest.cs Tests ignored coverage semantics.
tests/​SkiaSharp.Testing.Tests/​SKPixelDifferenceImageTest.cs Tests diagnostic pixels and ownership.
tests/​SkiaSharp.Testing.Tests/​SKPixelComparisonMetricsTest.cs Tests statistics and overflow boundaries.
tests/​SkiaSharp.Testing.Tests/​SKPixelComparisonAcceptanceTest.cs Tests budgets and combined gates.
tests/​SkiaSharp.Testing.Tests/​SKPixelComparerTestBase.cs Adds shared test helpers.
tests/​SkiaSharp.Testing.Tests/​SkiaSharp.Testing.Tests.csproj Defines the regression test host.
source/​SkiaSharpSource.Windows.slnf Includes the library on Windows.
source/​SkiaSharpSource.slnx Registers the library project.
source/​SkiaSharpSource.Mac.slnf Includes the library on macOS.
source/​SkiaSharpSource.Linux.slnf Includes the library on Linux.
source/​SkiaSharp.Testing/​SKPixelTolerance.cs Defines channel allowances.
source/​SkiaSharp.Testing/​SKPixelMismatchBudget.cs Defines count and percentage budgets.
source/​SkiaSharp.Testing/​SKPixelDifferenceStyle.cs Defines diagnostic styles.
source/​SkiaSharp.Testing/​SKPixelComparisonResult.cs Exposes immutable comparison outcomes.
source/​SkiaSharp.Testing/​SKPixelComparisonMetrics.cs Computes error statistics.
source/​SkiaSharp.Testing/​SKPixelComparerOptions.cs Defines comparison configuration.
source/​SkiaSharp.Testing/​SKPixelComparer.cs Implements comparisons and diagnostics.
source/​SkiaSharp.Testing/​SkiaSharp.Testing.csproj Defines the shipping package.
source/​SkiaSharp.Testing/​Properties/​AssemblyInfo.cs Marks the API experimental.
source/​SkiaSharp.Testing/​Compatibility/​ExperimentalAttribute.cs Supports older target frameworks.
scripts/​VERSIONS.txt Registers package versioning.
scripts/​infra/​shared/​shared.cake Registers package support.
eng/​Signing.props Registers assembly signing.
documentation/​docfx/​guides/​TOC.yml Adds testing navigation.
documentation/​docfx/​guides/​testing/​index.md Introduces rendering-test guidance.
documentation/​docfx/​guides/​testing/​image-comparison.md Explains comparison features and examples.
documentation/​docfx/​guides/​testing/​generate-images.cs Generates illustrated comparison assets.
documentation/​dev/​README.md Links experimental API guidance.
documentation/​dev/​golden-image-tests.md Documents the migrated comparer.
documentation/​dev/​experimental-apis.md Defines experimental policy and registry.
documentation/​dev/​api-design.md Links experimental API policy.

🧠 Review effort: Balanced

Comment thread tests/SkiaSharp.Tests.Console.slnx Resolved
@mattleibow

Copy link
Copy Markdown
Contributor Author

@dalexsoto review

dalexsoto
dalexsoto previously approved these changes Oct 23, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The experimental comparison API preserves existing consumer acceptance policies, and the earlier raw-image and test-runner integration findings are fixed.

Reviewed source/static integration only. The Windows source-benchmark check still reports missing matching Spectre libraries; the existing job-level non-blocking policy is unchanged, and no pre-existing/transient or safe-to-retry classification is claimed.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all 77 changed files, the committed diagnostic images, existing consumers and the static build/package/test integration, including a separate final blocker search.

One blocking project-evaluation issue remains: tests/SkiaSharp.Tests.Samples/SkiaSharp.Tests.Samples.csproj:51 unconditionally imports tests/TestUtilities/PixelComparison/PixelComparison.projitems, but both that exact file and its directory are absent at this head. MSBuild therefore fails with MSB4019 before restore/build/test of the sample host. The current sample helper already uses SkiaSharp.Tests.Shared; remove the stale import rather than restoring the removed comparer.

This is a deterministic static import-resolution finding, not an executed build or runtime reproduction. The experimental API and previously accepted comparison policies are not being re-blocked.

@github-project-automation github-project-automation Bot moved this from Approved to Changes Requested in SkiaSharp Backlog Oct 27, 2026
@mattleibow

Copy link
Copy Markdown
Contributor Author

One blocking project-evaluation issue remains: SkiaSharp.Tests.Samples.csproj imports the deleted PixelComparison.projitems.

Fixed in 75883d85fcc: removed the stale import. The sample project now evaluates successfully, references SkiaSharp.Tests.Shared, and has no remaining PixelComparison import/reference. The previous Linux x86 CI failure was unrelated: Ubuntu archive InRelease GPG verification returned a BAD signature while constructing the native rootfs, before project build.

dalexsoto
dalexsoto previously approved these changes Oct 28, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prior missing-import blocker is fixed: the complete current Samples project no longer imports the deleted PixelComparison.projitems, and its Shared-to-Testing reference chain remains intact. This is a static source verification, not an executed MSBuild evaluation.

Reviewed all 76 changed paths, the committed diagnostic images, existing consumers and static API/build/package/test/documentation integration, including a separate final blocker search. The experimental pixel-comparison API, diagnostics and build/package/test consumers preserve the accepted comparison and ownership policies. The experimental API and previously accepted comparison and ownership policies are not being re-blocked. No independent high-confidence blocker remains in this bounded static review; no executed runtime or whole-pipeline certification is claimed.

@github-project-automation github-project-automation Bot moved this from Changes Requested to Approved in SkiaSharp Backlog Oct 28, 2026
@mattleibow
mattleibow force-pushed the mattleibow-pixel-comparison-research branch from 75883d8 to e9f7883 Compare October 28, 2026 18:09
dalexsoto
dalexsoto previously approved these changes Oct 28, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all 76 changed paths, the committed diagnostic images, existing consumers and static API/build/package/test/documentation integration, including a separate final blocker search. The experimental pixel-comparison API, diagnostics and build/package/test consumers preserve the accepted comparison and ownership policies. The experimental API and previously accepted comparison and ownership policies are not being re-blocked. No independent high-confidence blocker remains in this bounded static review; no executed runtime or whole-pipeline certification is claimed.

@dalexsoto

Copy link
Copy Markdown
Member

In response to @mattleibow's request: I am deferring a formal review of rebased head b85536a8364d5e8cdf6f7e73fcee40166694a793. The two changed text bodies and matching Testing/SkiaSharp 4.157.0 version registration have been inspected; no new high-confidence blocker was established. Necessary coverage still missing is the retained full-source coverage reconciliation for the 74 reused paths and the affected native rendering/font and platform-build integration through native revision ce0fc683a40c6ba84d55072f31aa48d55c8f2131. The earlier import, image-dimension and test-host findings remain fixed, and the accepted experimental API and acceptance/ownership policies are not being reopened. This is a source-coverage deferment, not a request to change code or run CI, and neither the old-head approval nor its dismissal certifies this head.

@mattleibow
mattleibow force-pushed the mattleibow-pixel-comparison-research branch from b85536a to b1f35c7 Compare November 6, 2026 03:25
Port the current Extended comparison logic into an unpublished shared-source test utility so core, golden-image, and exact-package integration tests no longer maintain different comparers or depend on Extended.

Preserve existing premultiplied comparison gates and transparent-pixel normalization, add wide error metrics and explicit diagnostic styles, and document small future API improvements. Keep native sources, goldens, tolerances, and skip policy unchanged.

Co-authored-by: Copilot App <[email protected]>
v and others added 25 commits November 12, 2026 22:47
Replace the 808-line developer report with a short public DocFX guide and one compact experimental registry. Remove competitor/roadmap/migration analysis and duplicate policy/API listings. Restore existing package and publishing test scripts rather than adding configuration-validation harnesses.

Keep real comparison and consumer regressions plus required normal production wiring. Remove historical-name and documentation-URL proxy assertions, simplify the golden-test note, and use repository-standard source license headers without repeated Extended provenance.

Co-authored-by: Copilot App <[email protected]>
Separate Testing from the drawing tutorials with its own overview and navigation. Move image comparison there, add input/diagnostic/ignore-coverage illustrations, and update documentation and diagnostic links. Keep screenshots, baselines and assertions scoped to their owning test layer; do not add speculative feature pages or migrate unrelated Extended APIs.

Co-authored-by: Copilot App <[email protected]>
Keep Testing as a dedicated subsection with its overview, comparison guide and illustrations while removing the top-level navigation tab. Update feature and diagnostic documentation links.

Co-authored-by: Copilot App <[email protected]>
Remove decode/encode exception boilerplate from the conceptual sample.

Co-authored-by: Copilot App <[email protected]>
Label exact source RGB values, show equivalent regional tolerance and ignore masks with their different metric coverage, and illustrate alpha-only changes that raw RGB diagnostics cannot show. Keep visuals explicitly illustrative and avoid adding generation or validation scripts.

Co-authored-by: Copilot App <[email protected]>
Order the conceptual guide as introduction, installation/opt-in, then the illustrated comparison. Update the diagnostic help anchor.

Co-authored-by: Copilot App <[email protected]>
Save diagnostics without exception boilerplate and pair each comparison step with its output illustration. Pass the comparison options to tolerant difference generation so the visual matches the classification.

Co-authored-by: Copilot App <[email protected]>
Preserve opaque classification as ThresholdMap and make ThresholdOverlay blend highlights at50percent over white-flattened actual pixels. Keep comparison metrics/gates unchanged and cover both styles with exact-pixel tests. Correct hidden-RGB mask fixtures to distinguish transparent white from transparent black.

Add a file-based documentation generator using one800x600scene with color, alpha and added-content differences. Save only raw PNG inputs, masks and real comparer outputs; keep all labels/layout in Markdown. Split budget guidance and show the same scene in every example.

Validation: dedicated comparison48passed; generator and DocFX build passed. Full unfiltered desktop suite still hits varying stream/document GC failures and the known macOSGL DiagonalLines1832-pixel divergence; no tests, tolerances or GPU policies relaxed.

Co-authored-by: Copilot App <[email protected]>
Use identical RGB tolerance2 and exact alpha for all four style examples. Display a separate tolerant overlay next to the opaque amber/red map, retain the alpha-only circle and RGB-only raw diagnostic, and explain mixed overlay colors.

Co-authored-by: Copilot App <[email protected]>
Render a rounded blue panel, emerald alpha-only circle and added rounded rose square over a subtle gradient. Keep shared mask geometry and all comparison features intact, regenerate the raw800x600PNGs and rebuild DocFX.

Co-authored-by: Copilot App <[email protected]>
Keep source artwork distinct from red mismatch and amber tolerance indicators, and regenerate the documentation images.

Co-authored-by: Copilot App <[email protected]>
Save separate display copies over a checkerboard while retaining the original RGBA inputs for actual comparisons. Keep source artwork, measurements, masks and opaque diagnostic outputs unchanged.

Co-authored-by: Copilot App <[email protected]>
Center every800x600 display image in a900x700 checkerboard preview with50-pixel padding. Apply the same presentation to masks and all diagnostics without changing in-memory comparison data or original RGBA inputs.

Co-authored-by: Copilot App <[email protected]>
Remove border/dimension/display-production commentary and the maintainer regeneration section. Keep the regeneration command beside the generator and let visuals illustrate the comparison features without palette-specific narration.

Co-authored-by: Copilot App <[email protected]>
Cover decoded image, bitmap and pixmap inputs, tolerance/ignore masks, all diagnostic styles, and percentage-budget arithmetic with reusable BenchmarkDotNet fixtures. Include the cases in PR source tracking without requiring the unpublished Testing package for historical release baselines.

Co-authored-by: Copilot App <[email protected]>
Cache the normalized image width instead of invoking native lookups for each mismatched pixel. Count identical pixels as compared, but skip their zero-error channel evaluation. Cover sparse, dense, identical and narrow image cases, and track identical-image performance.

Make pixel benchmarks unconditional in source tracking and reduce the benchmark README addition to a two-line note.

Co-authored-by: Copilot App <[email protected]>
BuildingInsideVisualStudio causes MSBuild to strip parent configuration from project references by default. Disable that behavior for the Testing build so it consumes the Release SkiaSharp assembly already built by the workflow, instead of a nonexistent Debug reference on clean CI runners.

Co-authored-by: Copilot App <[email protected]>
Color the largest raw enabled-channel difference from blue through cyan and yellow to red, keeping exact matches black and ignored coverage gray. Reuse the existing pixel evaluation and a lazily initialized color table without changing comparison acceptance or existing diagnostic styles.

Cover palette boundaries, tolerances, masks, alpha, input families and ownership; include the diagnostic in benchmark tracking and the illustrated guide.

Co-authored-by: Copilot App <[email protected]>
Group the heatmap with the other styles, remove duplicated example images, and keep the guide focused on using the library rather than explaining individual implementation decisions.

Co-authored-by: Copilot App <[email protected]>
Add an ellipse shared by both inputs, changing its teal-to-cream gradient to a solid fill. Regenerate the diagnostic gallery so raw differences and the heatmap show progressively larger errors across the shape.

Co-authored-by: Copilot App <[email protected]>
Rename the experimental entry point to SKImageComparison and supporting types to SKComparisonOptions, SKComparisonResult, SKComparisonMetrics, and SKDifferenceStyle. Keep SKPixelTolerance, SKPixelMismatchBudget, and the SkiaSharp.Testing namespace and package unchanged.

Update source filenames, consumers, tests, benchmarks, and guide examples without altering comparison behavior or benchmark tracking identifiers.

Co-authored-by: Copilot App <[email protected]>
Register the Testing host with .NET and .NET Framework Cake runners, using Framework-compatible enum enumeration. Save reusable masks and diagnostic outputs at the input dimensions and retain decorated gallery images under explicit preview filenames.

Co-authored-by: Copilot App <[email protected]>
Preserve the unified golden lookup, retry, attachment, and reference workflow added on main while replacing its copied pixel comparer with the experimental shared package. Keep existing visual, sample, and core assertion policies unchanged.

Co-authored-by: Copilot App <[email protected]>
The sample host now uses the shared golden harness, so the deleted PixelComparison project import prevented project evaluation after the main-branch conflict resolution.

Co-authored-by: Copilot App <[email protected]>
@mattleibow
mattleibow force-pushed the mattleibow-pixel-comparison-research branch from b1f35c7 to 504c141 Compare November 12, 2026 20:50

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 504c1416 (static, read-only review).

The stale PixelComparison.projitems import from my earlier review was removed in 75883d85, and the rebased head keeps that fix. I re-read the full current boundary:

  • Testing library: the SkiaSharp.Testing sources (the comparison, options, tolerance, mismatch budget, result and metrics types, plus the ExperimentalAttribute polyfill for targets below .NET 8) are consistent with the six test files and the docs (image-comparison.md, experimental-apis.md, api-design.md, the testing index and TOC).
  • SKIA4001 suppression: every project that compiles code calling the experimental API suppresses the diagnostic: SkiaSharp.Tests, Tests.Console, Tests.Shared, Tests.Integration, Testing.Tests, Benchmarks and Benchmarks.Tracking.Source. The Devices/Wasm, Direct3D/Vulkan, Gallery, SingletonInit, Gtk4, Fuzzing, MSBuild, Samples.Analyzers and Native projects either don't reference SkiaSharp.Testing or only reference it through a ProjectReference. No global TreatWarningsAsErrors is set.
  • Packaging, signing and test runs: VERSIONS.txt, SUPPORTED_NUGETS in shared.cake, Signing.props, the three .slnf filters and SkiaSharpSource.slnx, the netcore/netfx cake test lists and track-benchmarks.yml all wire in the new package and test project consistently.
  • Leftover references: a code search found no remaining references to the removed comparer outside files this PR changes, and none in those files at this head.
  • Target: current main (46d73186) only touches release-notes docs and an issue template since the merge base, so there's no overlap.

This is static review only; I didn't run builds or tests.

LGTM.

@mattleibow
mattleibow merged commit f69cc3a into main Nov 19, 2026
126 checks passed
@mattleibow
mattleibow deleted the mattleibow-pixel-comparison-research branch November 19, 2026 00:32
@github-project-automation github-project-automation Bot moved this from Approved to Done in SkiaSharp Backlog Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants