From 5feff85cdaa59a94aceb79c0e7327447f1e63bf0 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 5 Jul 2024 16:16:58 +0800 Subject: [PATCH] Use the SKPaint.FilterQuality for the SamplingOptions in obsolete methods (#2924) --- binding/SkiaSharp/SKCanvas.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/binding/SkiaSharp/SKCanvas.cs b/binding/SkiaSharp/SKCanvas.cs index e5a0dbfc68..b18c3cffd4 100644 --- a/binding/SkiaSharp/SKCanvas.cs +++ b/binding/SkiaSharp/SKCanvas.cs @@ -450,7 +450,7 @@ public void DrawPoint (float x, float y, SKColor color) public void DrawImage (SKImage image, SKPoint p, SKPaint paint = null) { - DrawImage (image, p.X, p.Y, SKSamplingOptions.Default, paint); + DrawImage (image, p.X, p.Y, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, SKPoint p, SKSamplingOptions sampling, SKPaint paint = null) @@ -460,7 +460,7 @@ public void DrawImage (SKImage image, SKPoint p, SKSamplingOptions sampling, SKP public void DrawImage (SKImage image, float x, float y, SKPaint paint = null) { - DrawImage (image, x, y, SKSamplingOptions.Default, paint); + DrawImage (image, x, y, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, float x, float y, SKSamplingOptions sampling, SKPaint paint = null) @@ -472,7 +472,7 @@ public void DrawImage (SKImage image, float x, float y, SKSamplingOptions sampli public void DrawImage (SKImage image, SKRect dest, SKPaint paint = null) { - DrawImage (image, null, &dest, SKSamplingOptions.Default, paint); + DrawImage (image, null, &dest, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, SKRect dest, SKSamplingOptions sampling, SKPaint paint = null) @@ -482,7 +482,7 @@ public void DrawImage (SKImage image, SKRect dest, SKSamplingOptions sampling, S public void DrawImage (SKImage image, SKRect source, SKRect dest, SKPaint paint = null) { - DrawImage (image, &source, &dest, SKSamplingOptions.Default, paint); + DrawImage (image, &source, &dest, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, SKRect source, SKRect dest, SKSamplingOptions sampling, SKPaint paint = null) @@ -941,25 +941,25 @@ public void DrawRoundRectDifference (SKRoundRect outer, SKRoundRect inner, SKPai // DrawAtlas - public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKPaint paint) => - DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, SKSamplingOptions.Default, null, paint); + public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKPaint paint = null) => + DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, null, paint); - public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKSamplingOptions sampling, SKPaint paint) => + public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKSamplingOptions sampling, SKPaint paint = null) => DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, sampling, null, paint); - public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKPaint paint) => - DrawAtlas (atlas, sprites, transforms, colors, mode, SKSamplingOptions.Default, null, paint); + public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKPaint paint = null) => + DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, null, paint); - public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKPaint paint) => + public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKPaint paint = null) => DrawAtlas (atlas, sprites, transforms, colors, mode, sampling, null, paint); - public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKRect cullRect, SKPaint paint) => - DrawAtlas (atlas, sprites, transforms, colors, mode, SKSamplingOptions.Default, &cullRect, paint); + public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKRect cullRect, SKPaint paint = null) => + DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, &cullRect, paint); - public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect cullRect, SKPaint paint) => + public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect cullRect, SKPaint paint = null) => DrawAtlas (atlas, sprites, transforms, colors, mode, sampling, &cullRect, paint); - private void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect* cullRect, SKPaint paint) + private void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect* cullRect, SKPaint paint = null) { if (atlas == null) throw new ArgumentNullException (nameof (atlas)); @@ -976,7 +976,7 @@ private void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] fixed (SKRect* s = sprites) fixed (SKRotationScaleMatrix* t = transforms) fixed (SKColor* c = colors) { - SkiaApi.sk_canvas_draw_atlas (Handle, atlas.Handle, t, s, (uint*)c, transforms.Length, mode, &sampling, cullRect, paint.Handle); + SkiaApi.sk_canvas_draw_atlas (Handle, atlas.Handle, t, s, (uint*)c, transforms.Length, mode, &sampling, cullRect, paint?.Handle ?? IntPtr.Zero); } }