diff --git a/binding/Binding/SKImageFilter.cs b/binding/Binding/SKImageFilter.cs index 00e01e7b221..e7accba9a42 100644 --- a/binding/Binding/SKImageFilter.cs +++ b/binding/Binding/SKImageFilter.cs @@ -74,6 +74,12 @@ protected override void Dispose (bool disposing) => // CreateMatrix + public static SKImageFilter CreateMatrix(in SKMatrix matrix) + { + fixed (SKMatrix* m = &matrix) + return GetObject(SkiaApi.sk_imagefilter_new_matrix(m, default, IntPtr.Zero)); + } + public static SKImageFilter CreateMatrix(SKMatrix matrix, SKFilterQuality quality, SKImageFilter input = null) { return GetObject(SkiaApi.sk_imagefilter_new_matrix(&matrix, quality, input == null ? IntPtr.Zero : input.Handle)); @@ -81,6 +87,9 @@ public static SKImageFilter CreateMatrix(SKMatrix matrix, SKFilterQuality qualit // CreateAlphaThreshold + public static SKImageFilter CreateAlphaThreshold (SKRectI region, float innerThreshold, float outerThreshold) => + CreateAlphaThreshold (region, innerThreshold, outerThreshold, null); + public static SKImageFilter CreateAlphaThreshold(SKRectI region, float innerThreshold, float outerThreshold, SKImageFilter input = null) { var reg = new SKRegion (); @@ -98,6 +107,12 @@ public static SKImageFilter CreateAlphaThreshold(SKRegion region, float innerThr // CreateBlur + public static SKImageFilter CreateBlur (float sigmaX, float sigmaY) => + CreateBlur (sigmaX, sigmaY, SKShaderTileMode.Decal, null); + + public static SKImageFilter CreateBlur (float sigmaX, float sigmaY, SKShaderTileMode tileMode) => + CreateBlur (sigmaX, sigmaY, tileMode, null); + public static SKImageFilter CreateBlur (float sigmaX, float sigmaY, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) => CreateBlur (sigmaX, sigmaY, SKShaderTileMode.Decal, input, cropRect); @@ -106,6 +121,9 @@ public static SKImageFilter CreateBlur (float sigmaX, float sigmaY, SKShaderTile // CreateColorFilter + public static SKImageFilter CreateColorFilter (SKColorFilter cf) => + CreateColorFilter (cf, null); + public static SKImageFilter CreateColorFilter(SKColorFilter cf, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { if (cf == null) @@ -131,6 +149,9 @@ public static SKImageFilter CreateCompose(SKImageFilter outer, SKImageFilter inn public static SKImageFilter CreateDisplacementMapEffect (SKDisplacementMapEffectChannelSelectorType xChannelSelector, SKDisplacementMapEffectChannelSelectorType yChannelSelector, float scale, SKImageFilter displacement, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) => CreateDisplacementMapEffect (xChannelSelector.ToColorChannel (), yChannelSelector.ToColorChannel (), scale, displacement, input, cropRect); + public static SKImageFilter CreateDisplacementMapEffect (SKColorChannel xChannelSelector, SKColorChannel yChannelSelector, float scale, SKImageFilter displacement) => + CreateDisplacementMapEffect (xChannelSelector, yChannelSelector, scale, displacement, null); + public static SKImageFilter CreateDisplacementMapEffect (SKColorChannel xChannelSelector, SKColorChannel yChannelSelector, float scale, SKImageFilter displacement, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { if (displacement == null) @@ -147,6 +168,9 @@ public static SKImageFilter CreateDropShadow (float dx, float dy, float sigmaX, ? CreateDropShadowOnly (dx, dy, sigmaX, sigmaY, color, input, cropRect) : CreateDropShadow (dx, dy, sigmaX, sigmaY, color, input, cropRect); + public static SKImageFilter CreateDropShadow (float dx, float dy, float sigmaX, float sigmaY, SKColor color) => + CreateDropShadow (dx, dy, sigmaX, sigmaY, color, null); + public static SKImageFilter CreateDropShadow (float dx, float dy, float sigmaX, float sigmaY, SKColor color, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) => GetObject (SkiaApi.sk_imagefilter_new_drop_shadow (dx, dy, sigmaX, sigmaY, (uint)color, input == null ? IntPtr.Zero : input.Handle, cropRect == null ? IntPtr.Zero : cropRect.Handle)); @@ -155,6 +179,9 @@ public static SKImageFilter CreateDropShadowOnly (float dx, float dy, float sigm // Create*LitDiffuse + public static SKImageFilter CreateDistantLitDiffuse (SKPoint3 direction, SKColor lightColor, float surfaceScale, float kd) => + CreateDistantLitDiffuse (direction, lightColor, surfaceScale, kd, null); + public static SKImageFilter CreateDistantLitDiffuse(SKPoint3 direction, SKColor lightColor, float surfaceScale, float kd, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { return GetObject(SkiaApi.sk_imagefilter_new_distant_lit_diffuse(&direction, (uint)lightColor, surfaceScale, kd, input == null ? IntPtr.Zero : input.Handle, cropRect == null ? IntPtr.Zero : cropRect.Handle)); @@ -172,6 +199,9 @@ public static SKImageFilter CreateSpotLitDiffuse(SKPoint3 location, SKPoint3 tar // Create*LitSpecular + public static SKImageFilter CreateDistantLitSpecular (SKPoint3 direction, SKColor lightColor, float surfaceScale, float ks, float shininess) => + CreateDistantLitSpecular (direction, lightColor, surfaceScale, ks, shininess, null); + public static SKImageFilter CreateDistantLitSpecular(SKPoint3 direction, SKColor lightColor, float surfaceScale, float ks, float shininess, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { return GetObject(SkiaApi.sk_imagefilter_new_distant_lit_specular(&direction, (uint)lightColor, surfaceScale, ks, shininess, input == null ? IntPtr.Zero : input.Handle, cropRect == null ? IntPtr.Zero : cropRect.Handle)); @@ -189,6 +219,9 @@ public static SKImageFilter CreateSpotLitSpecular(SKPoint3 location, SKPoint3 ta // CreateMagnifier + public static SKImageFilter CreateMagnifier (SKRect src, float inset) => + CreateMagnifier (src, inset, null); + public static SKImageFilter CreateMagnifier(SKRect src, float inset, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { return GetObject(SkiaApi.sk_imagefilter_new_magnifier(&src, inset, input == null ? IntPtr.Zero : input.Handle, cropRect == null ? IntPtr.Zero : cropRect.Handle)); @@ -201,6 +234,9 @@ public static SKImageFilter CreateMagnifier(SKRect src, float inset, SKImageFilt public static SKImageFilter CreateMatrixConvolution (SKSizeI kernelSize, float[] kernel, float gain, float bias, SKPointI kernelOffset, SKMatrixConvolutionTileMode tileMode, bool convolveAlpha, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) => CreateMatrixConvolution (kernelSize, kernel, gain, bias, kernelOffset, tileMode.ToShaderTileMode (), convolveAlpha, input, cropRect); + public static SKImageFilter CreateMatrixConvolution (SKSizeI kernelSize, System.ReadOnlySpan kernel, float gain, float bias, SKPointI kernelOffset, SKShaderTileMode tileMode, bool convolveAlpha) => + CreateMatrixConvolution (kernelSize, kernel.ToArray (), gain, bias, kernelOffset, tileMode, convolveAlpha); + public static SKImageFilter CreateMatrixConvolution (SKSizeI kernelSize, float[] kernel, float gain, float bias, SKPointI kernelOffset, SKShaderTileMode tileMode, bool convolveAlpha, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { if (kernel == null) @@ -214,6 +250,12 @@ public static SKImageFilter CreateMatrixConvolution (SKSizeI kernelSize, float[] // CreateMerge + public static SKImageFilter CreateMerge (SKImageFilter first, SKImageFilter second) => + CreateMerge (new[] { first, second }); + + public static SKImageFilter CreateMerge (System.ReadOnlySpan filters) => + CreateMerge (filters.ToArray ()); + [EditorBrowsable (EditorBrowsableState.Never)] [Obsolete("Use CreateMerge(SKImageFilter, SKImageFilter, SKImageFilter.CropRect) instead.")] public static SKImageFilter CreateMerge(SKImageFilter first, SKImageFilter second, SKBlendMode mode, SKImageFilter.CropRect cropRect = null) @@ -249,6 +291,9 @@ public static SKImageFilter CreateMerge(SKImageFilter[] filters, SKImageFilter.C // CreateDilate + public static SKImageFilter CreateDilate (int radiusX, int radiusY) => + CreateDilate (radiusX, radiusY, null); + public static SKImageFilter CreateDilate(int radiusX, int radiusY, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) => CreateDilate ((float)radiusX, (float)radiusY, input, cropRect); @@ -259,6 +304,9 @@ public static SKImageFilter CreateDilate(float radiusX, float radiusY, SKImageFi // CreateErode + public static SKImageFilter CreateErode (int radiusX, int radiusY) => + CreateErode (radiusX, radiusY, null); + public static SKImageFilter CreateErode(int radiusX, int radiusY, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) => CreateErode ((float)radiusX, (float)radiusY, input, cropRect); @@ -269,6 +317,9 @@ public static SKImageFilter CreateErode(float radiusX, float radiusY, SKImageFil // CreateOffset + public static SKImageFilter CreateOffset (float dx, float dy) => + CreateOffset (dx, dy, null); + public static SKImageFilter CreateOffset(float dx, float dy, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null) { return GetObject(SkiaApi.sk_imagefilter_new_offset(dx, dy, input == null ? IntPtr.Zero : input.Handle, cropRect == null ? IntPtr.Zero : cropRect.Handle)); @@ -301,6 +352,9 @@ public static SKImageFilter CreateTile(SKRect src, SKRect dst, SKImageFilter inp // CreateBlendMode + public static SKImageFilter CreateBlendMode (SKBlendMode mode, SKImageFilter background, SKImageFilter foreground = null) => + CreateBlendMode (mode, background, foreground, null); + public static SKImageFilter CreateBlendMode(SKBlendMode mode, SKImageFilter background, SKImageFilter foreground = null, SKImageFilter.CropRect cropRect = null) { if (background == null) @@ -310,6 +364,9 @@ public static SKImageFilter CreateBlendMode(SKBlendMode mode, SKImageFilter back // CreateArithmetic + public static SKImageFilter CreateArithmetic (float k1, float k2, float k3, float k4, bool enforcePMColor, SKImageFilter background) => + CreateArithmetic (k1, k2, k3, k4, enforcePMColor, background, null); + public static SKImageFilter CreateArithmetic(float k1, float k2, float k3, float k4, bool enforcePMColor, SKImageFilter background, SKImageFilter foreground = null, SKImageFilter.CropRect cropRect = null) { if (background == null)