Skip to content

Add SKSamplingOptions support to SKSurface.Draw and SKCanvas.DrawSurface#3491

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-drawsurface-sampling-options
Open

Add SKSamplingOptions support to SKSurface.Draw and SKCanvas.DrawSurface#3491
Copilot wants to merge 3 commits intomainfrom
copilot/fix-drawsurface-sampling-options

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Summary

Fixes #3344

This PR adds SKSamplingOptions parameter support to SKSurface.Draw and SKCanvas.DrawSurface methods, allowing users to specify sampling options when drawing surfaces.

Changes

C API (externals/skia)

  • Added sk_surface_draw_with_sampling() function

C# API

  • Added SKSurface.Draw(SKCanvas, float, float, SKSamplingOptions, SKPaint) overload
  • Added SKSurface.Draw(SKCanvas, SKPoint, SKSamplingOptions, SKPaint) overload
  • Added SKCanvas.DrawSurface(SKSurface, float, float, SKSamplingOptions, SKPaint) overload
  • Added SKCanvas.DrawSurface(SKSurface, SKPoint, SKSamplingOptions, SKPaint) overload

Tests

  • Added CanDrawSurfaceWithSamplingOptions test
  • Added CanDrawSurfaceOnCanvasWithSamplingOptions test

Usage Example

var sampling = new SKSamplingOptions(SKFilterMode.Linear, SKMipmapMode.Linear);

// Using SKSurface.Draw
surface.Draw(canvas, x, y, sampling, paint);
surface.Draw(canvas, new SKPoint(x, y), sampling, paint);

// Using SKCanvas.DrawSurface
canvas.DrawSurface(surface, x, y, sampling, paint);
canvas.DrawSurface(surface, new SKPoint(x, y), sampling, paint);

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_sampling to support drawing surfaces with sampling options
  • Added C# wrapper methods with SKSamplingOptions parameter to SKSurface and SKCanvas classes
  • 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

@mattleibow mattleibow changed the title [WIP] Fix missing SKSamplingOptions in DrawSurface arguments Add SKSamplingOptions support to SKSurface.Draw and SKCanvas.DrawSurface Feb 2, 2026
@mattleibow mattleibow requested a review from Copilot February 2, 2026 23:50
@mattleibow mattleibow marked this pull request as ready for review February 2, 2026 23:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI and others added 2 commits February 3, 2026 12:36
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
@mattleibow mattleibow force-pushed the copilot/fix-drawsurface-sampling-options branch 2 times, most recently from 477ec1f to 94a61db Compare February 3, 2026 10:45
- Add missing SKSurface.Draw(SKCanvas, SKPoint, SKSamplingOptions, SKPaint) overload
- Remove unused sourcePaint variable from test
- Improve test comments to explain coordinate calculations
@mattleibow mattleibow force-pushed the copilot/fix-drawsurface-sampling-options branch 2 times, most recently from b3d5697 to 35d2016 Compare February 3, 2026 10:56
@mattleibow mattleibow closed this Feb 3, 2026
@mattleibow mattleibow reopened this Feb 3, 2026
@github-project-automation github-project-automation bot moved this from Done to In Progress in SkiaSharp Backlog Feb 3, 2026
mattleibow added a commit that referenced this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot Created by GitHub Copilot

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[BUG] SkSurface.Draw and Canvas.DrawSurface are missing SKSamplingOptions in arguments

3 participants