Add SKSamplingOptions support to SKSurface.Draw and SKCanvas.DrawSurface#3491
Open
Add SKSamplingOptions support to SKSurface.Draw and SKCanvas.DrawSurface#3491
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a missing feature in SkiaSharp 3.x where SKSamplingOptions cannot be specified when drawing surfaces, forcing users to rely on legacy SKPaint fields that no longer work. The changes add new overloads to SKSurface.Draw and SKCanvas.DrawSurface that accept SKSamplingOptions as a parameter.
Changes:
- Added new C API function
sk_surface_draw_with_samplingto support drawing surfaces with sampling options - Added C# wrapper methods with
SKSamplingOptionsparameter toSKSurfaceandSKCanvasclasses - Added comprehensive test coverage for both new API methods
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| externals/skia | Updated skia submodule to include new C API function for surface drawing with sampling |
| binding/SkiaSharp/SkiaApi.generated.cs | Generated P/Invoke declarations for the new sk_surface_draw_with_sampling C API function |
| binding/SkiaSharp/SKSurface.cs | Added new Draw overload accepting SKSamplingOptions parameter |
| binding/SkiaSharp/SKCanvas.cs | Added new DrawSurface overloads accepting SKSamplingOptions parameter |
| tests/Tests/SkiaSharp/SKSurfaceTest.cs | Added tests verifying the new sampling options functionality works correctly |
Fixes #3344 - Add sk_surface_draw_with_sampling to C API - Add SKSurface.Draw overload with SKSamplingOptions parameter - Add SKCanvas.DrawSurface overloads with SKSamplingOptions parameter - Add tests for new functionality
477ec1f to
94a61db
Compare
- Add missing SKSurface.Draw(SKCanvas, SKPoint, SKSamplingOptions, SKPaint) overload - Remove unused sourcePaint variable from test - Improve test comments to explain coordinate calculations
b3d5697 to
35d2016
Compare
mattleibow
added a commit
that referenced
this pull request
Feb 13, 2026
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.
Summary
Fixes #3344
This PR adds
SKSamplingOptionsparameter support toSKSurface.DrawandSKCanvas.DrawSurfacemethods, allowing users to specify sampling options when drawing surfaces.Changes
C API (externals/skia)
sk_surface_draw_with_sampling()functionC# API
SKSurface.Draw(SKCanvas, float, float, SKSamplingOptions, SKPaint)overloadSKSurface.Draw(SKCanvas, SKPoint, SKSamplingOptions, SKPaint)overloadSKCanvas.DrawSurface(SKSurface, float, float, SKSamplingOptions, SKPaint)overloadSKCanvas.DrawSurface(SKSurface, SKPoint, SKSamplingOptions, SKPaint)overloadTests
CanDrawSurfaceWithSamplingOptionstestCanDrawSurfaceOnCanvasWithSamplingOptionstestUsage Example