From 48cba424a3521a5fbcf57a6061a6556d9b4dbbe4 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 25 Oct 2016 02:26:53 +0200 Subject: [PATCH] A few changes: - Make the decision about the region clip in managed code so we can re-use the method. - Make GetBounds method a Bounds property - Added exceptions --- binding/Binding/SKRegion.cs | 26 ++++++++++++++++++++------ binding/Binding/SkiaApi.cs | 2 +- externals/skia | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/binding/Binding/SKRegion.cs b/binding/Binding/SKRegion.cs index 8f26a2e9..7f21f55e 100755 --- a/binding/Binding/SKRegion.cs +++ b/binding/Binding/SKRegion.cs @@ -35,8 +35,12 @@ namespace SkiaSharp { } + public SKRectI Bounds => SkiaApi.sk_region_get_bounds(Handle); + public bool Contains(SKRegion src) { + if (src == null) + throw new ArgumentNullException (nameof (src)); return SkiaApi.sk_region_contains(Handle, src.Handle); } @@ -47,6 +51,8 @@ namespace SkiaSharp public bool Intersects(SKRegion region) { + if (region == null) + throw new ArgumentNullException (nameof (region)); return SkiaApi.sk_region_intersects(Handle, region.Handle); } @@ -57,6 +63,8 @@ namespace SkiaSharp public bool Set(SKRegion region) { + if (region == null) + throw new ArgumentNullException (nameof (region)); return SkiaApi.sk_region_set(Handle, region.Handle); } @@ -65,9 +73,20 @@ namespace SkiaSharp return SkiaApi.sk_region_set_rect(Handle, ref rect); } + public bool SetPath(SKPath path, SKRegion clip) + { + if (path == null) + throw new ArgumentNullException (nameof (path)); + if (clip == null) + throw new ArgumentNullException (nameof (clip)); + return SkiaApi.sk_region_set_path(Handle, path.Handle, clip.Handle); + } + public bool SetPath(SKPath path) { - return SkiaApi.sk_region_set_path(Handle, path.Handle); + if (path == null) + throw new ArgumentNullException (nameof (path)); + return SkiaApi.sk_region_set_path(Handle, path.Handle, Handle); } public bool Op(int left, int top, int right, int bottom, SKRegionOperation op) @@ -79,10 +98,5 @@ namespace SkiaSharp { return SkiaApi.sk_region_op2(Handle, region.Handle, op); } - - public SKRectI GetBounds() - { - return SkiaApi.sk_region_get_bounds(Handle); - } } } diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index 57cd6a03..29657df2 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -1229,7 +1229,7 @@ namespace SkiaSharp public extern static bool sk_region_set_rect(sk_region_t r, ref SKRectI rect); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - public extern static bool sk_region_set_path(sk_region_t r, sk_path_t t); + public extern static bool sk_region_set_path(sk_region_t r, sk_path_t t, sk_region_t clip); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] public extern static bool sk_region_op(sk_region_t r, int left, int top, int right, int bottom, SKRegionOperation op); diff --git a/externals/skia b/externals/skia index f63aeb07..2e88a239 160000 --- a/externals/skia +++ b/externals/skia @@ -1 +1 @@ -Subproject commit f63aeb071105c8babbf28b79f693c7d593f9abf6 +Subproject commit 2e88a2396f0d54fca7883b0a925b3bc37b11fe7e