Add gradient interpolation color space support (CSS Color Level 4)#3775
Draft
mattleibow wants to merge 3 commits into
Draft
Add gradient interpolation color space support (CSS Color Level 4)#3775mattleibow wants to merge 3 commits into
mattleibow wants to merge 3 commits into
Conversation
Add CSS Color Level 4 gradient interpolation to SkiaSharp's gradient shader APIs, wrapping Skia's SkGradientShader::Interpolation (available since m114). C API: - sk_gradient_interpolation_colorspace_t enum (11 color spaces) - sk_gradient_interpolation_huemethod_t enum (4 hue methods) - sk_gradient_interpolation_t struct - 4 new gradient functions with interpolation parameter C# API: - SKGradientInterpolationColorSpace enum (Destination, SrgbLinear, Lab, OKLab, OKLabGamutMap, LCH, OKLCH, OKLCHGamutMap, Srgb, HSL, HWB) - SKGradientInterpolationHueMethod enum (Shorter, Longer, Increasing, Decreasing) - SKGradientInterpolation struct - New overloads on CreateLinearGradient, CreateRadialGradient, CreateSweepGradient, CreateTwoPointConicalGradient Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nt-interpolation-colorspace # Conflicts: # externals/skia
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
📦 Try the packages from this PRWarning 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 -- 3775PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 3775"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-3775/packages --name skiasharp-pr-3775More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-3775 |
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.
Fixes #3773
Summary
Adds CSS Color Level 4 gradient interpolation support to SkiaSharp's gradient shader APIs, wrapping Skia's
SkGradient::Interpolation.New API surface
SKGradientInterpolationColorSpaceSKGradientInterpolationHueMethodSKGradientInterpolationSKShader.CreateLinearGradientSKShader.CreateRadialGradientSKShader.CreateSweepGradientSKShader.CreateTwoPointConicalGradientWhy
OKLab/OKLCH interpolation eliminates the muddy gray midpoints that plague sRGB gradient blending. Web platforms now default to OKLab (CSS Color Level 4). Display P3 and Rec2020 wide-gamut displays need proper color space interpolation.
Notes
Tests
39 tests covering all 4 gradient types, all 11 color spaces, all 4 hue methods, struct equality/defaults, premul, error cases, and a perceptual quality comparison (OKLab vs sRGB midpoint saturation).
Gallery sample
Updated
GradientSample.cswith an "Interpolation Color Space" picker (9 non-experimental options).