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

Implement SkCanvas::SaveLayerRec #2962

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions binding/SkiaSharp/SKCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public int SaveLayer (SKPaint paint)
return SkiaApi.sk_canvas_save_layer (Handle, null, paint == null ? IntPtr.Zero : paint.Handle);
}

public int SaveLayer (SKRect bounds, SKPaint paint, SKImageFilter backdrop, SKSaveLayerFlags saveLayerFlags = SKSaveLayerFlags.None)
mattleibow marked this conversation as resolved.
Show resolved Hide resolved
{
return SkiaApi.sk_canvas_save_layer_rec (Handle, &bounds, paint == null ? IntPtr.Zero : paint.Handle, backdrop == null ? IntPtr.Zero : backdrop.Handle, (uint)saveLayerFlags);
}

public int SaveLayer (SKRect bounds, SKPaint paint, SKSaveLayerFlags saveLayerFlags)
{
return SaveLayer (bounds, paint, null, saveLayerFlags);
}

public int SaveLayer () =>
SaveLayer (null);

Expand Down Expand Up @@ -1066,4 +1076,13 @@ public void Restore ()
}
}
}

[Flags]
public enum SKSaveLayerFlags
mattleibow marked this conversation as resolved.
Show resolved Hide resolved
{
None = 0,
PreserveLCDText = 1 << 1,
InitWithPrevious = 1 << 2,
UseF16ColorType = 1 << 4,
}
}
16 changes: 15 additions & 1 deletion binding/SkiaSharp/SkiaApi.generated.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;

#region Namespaces
Expand Down Expand Up @@ -2301,6 +2301,20 @@ internal static Int32 sk_canvas_save_layer (sk_canvas_t ccanvas, SKRect* crect,
(sk_canvas_save_layer_delegate ??= GetSymbol<Delegates.sk_canvas_save_layer> ("sk_canvas_save_layer")).Invoke (ccanvas, crect, cpaint);
#endif

// int sk_canvas_save_layer_rec(sk_canvas_t* ccanvas, const sk_rect_t* cbounds, const sk_paint_t* cpaint, const sk_imagefilter_t* cfilter, uint32_t flags)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern Int32 sk_canvas_save_layer_rec (sk_canvas_t ccanvas, SKRect* cbounds, sk_paint_t cpaint, sk_imagefilter_t cfilter, uint flags);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate Int32 sk_canvas_save_layer_rec (sk_canvas_t ccanvas, SKRect* cbounds, sk_paint_t cpaint, sk_imagefilter_t cfilter, uint flags);
}
private static Delegates.sk_canvas_save_layer_rec sk_canvas_save_layer_rec_delegate;
internal static Int32 sk_canvas_save_layer_rec (sk_canvas_t ccanvas, SKRect* cbounds, sk_paint_t cpaint, sk_imagefilter_t cfilter, uint flags) =>
(sk_canvas_save_layer_rec_delegate ??= GetSymbol<Delegates.sk_canvas_save_layer_rec> ("sk_canvas_save_layer_rec")).Invoke (ccanvas, cbounds, cpaint, cfilter, flags);
#endif

// void sk_canvas_scale(sk_canvas_t* ccanvas, float sx, float sy)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
Expand Down