Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve 3.x compatibility with 2.x (or vice versa) #2790

Open
mattleibow opened this issue Mar 7, 2024 · 1 comment
Open

Improve 3.x compatibility with 2.x (or vice versa) #2790

mattleibow opened this issue Mar 7, 2024 · 1 comment
Labels
tenet/compatibility Compatibility with previous versions of SkiaSharp

Comments

@mattleibow
Copy link
Contributor

mattleibow commented Mar 7, 2024

Description

Not sure we can do everything we want and have a perfect world, but we can make things a bit better.

There is a summary and diff here that you can read to learn more about the changes that we have: https://github.com/mono/SkiaSharp/blob/main/changelogs/SkiaSharp/3.0.0/SkiaSharp.humanreadable.md

Using this list and some community libraries, we have found ways to improve compatibility without much additional effort for you or the maintenance in general.

Implementation

This work is 2 parts:

Changes

Here is a list of PRs that may or may not make it in but cover this area:

Tools

I have also been working to make a tool that can be used to detect any cases where a breaking will occur, without having to update and hope everything is fine. In some cases, different overloads will resolve, hiding a potential break.

Tool: https://www.nuget.org/packages/api-tools
Docs: https://github.com/mattleibow/Mono.ApiTools.NuGetDiff/blob/main/docs/api-tools.md#compat-command

dotnet api-tools compat Svg.Skia/Svg.Skia.dll SkiaSharp/v3/SkiaSharp.dll
<?xml version="1.0" encoding="utf-8"?>
<assemblies>
  <assembly>
    <types>
      <type fullname="SkiaSharp.SKImageFilter/CropRect" />
      <type fullname="SkiaSharp.SKCropRectFlags" />
    </types>
    <members>
      <member fullname="System.Void SkiaSharp.SKImageFilter/CropRect::.ctor(SkiaSharp.SKRect,SkiaSharp.SKCropRectFlags)" />
      <member fullname="SkiaSharp.SKImageFilter SkiaSharp.SKImageFilter::CreateMerge(SkiaSharp.SKImageFilter[],SkiaSharp.SKImageFilter/CropRect)" />
      <member fullname="SkiaSharp.SKImageFilter SkiaSharp.SKImageFilter::CreatePaint(SkiaSharp.SKPaint,SkiaSharp.SKImageFilter/CropRect)" />
      <!-- several other items -->
      <member fullname="System.Void SkiaSharp.SKPath::Transform(SkiaSharp.SKMatrix)" />
      <member fullname="System.Void SkiaSharp.SKCanvas::SetMatrix(SkiaSharp.SKMatrix)" />
    </members>
  </assembly>
</assemblies>

For this result, we have done some things:

  • We added overloads to the SKImageFilter type that allow for creating of filters without SKImageFilter.CropRect and instead use SKRect.
  • We added a hidden API SKCanvas.SetMatrix that matches 2.x, but we cannot add it to the public API as it is ambiguous to VB and not what we want to use going forward.
@mattleibow mattleibow changed the title Investigate compatibility with 2.x Improve 3.x compatibility with 2.x (or vice versa) Mar 28, 2024
@mattleibow mattleibow added the tenet/compatibility Compatibility with previous versions of SkiaSharp label Apr 5, 2024
@follesoe
Copy link

Fantastic effort on easing migration and adoption of v3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tenet/compatibility Compatibility with previous versions of SkiaSharp
Projects
None yet
Development

No branches or pull requests

2 participants