Skip to content

Commit

Permalink
feat(SaveLayerRec): implement SkCanvas::SaveLayerRec
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed605 committed Jul 30, 2024
1 parent 8cf8bcb commit c5045e5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
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)
{
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
{
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

0 comments on commit c5045e5

Please sign in to comment.