Skip to content

Commit

Permalink
Adjust some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Nov 14, 2023
1 parent c6cf62d commit 98cf75c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 0 additions & 10 deletions binding/SkiaSharp/SKCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ public SKCodecResult GetPixels (SKImageInfo info, out byte[] pixels)
return GetPixels (info, pixels);
}

public SKCodecResult GetPixels (SKImageInfo info, byte[] pixels)
{
if (pixels == null)
throw new ArgumentNullException (nameof (pixels));

fixed (byte* p = pixels) {
return GetPixels (info, (IntPtr)p, info.RowBytes, SKCodecOptions.Default);
}
}

public SKCodecResult GetPixels (SKImageInfo info, Span<byte> pixels)
{
if (pixels == null)
Expand Down
18 changes: 11 additions & 7 deletions binding/SkiaSharp/SKPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ public SKRoundRect GetRoundRect ()
public SKPoint[] GetLine ()
{
Span<SKPoint> temp = stackalloc SKPoint[2];
if (TryGetLine (temp)) {
return temp.ToArray ();
} else {
return null;
fixed (SKPoint* t = temp) {
var result = SkiaApi.sk_path_is_line (Handle, t);
if (result) {
return temp.ToArray ();
} else {
return null;
}
}
}

Expand All @@ -135,12 +138,13 @@ public bool TryGetLine (Span<SKPoint> points)
if (points.Length != 2)
throw new ArgumentException ("Points must have a length of 2.");

fixed (SKPoint* p = points) {
var result = SkiaApi.sk_path_is_line (Handle, p);
Span<SKPoint> temp = stackalloc SKPoint[2];
fixed (SKPoint* t = temp) {
var result = SkiaApi.sk_path_is_line (Handle, t);
if (result) {
temp.CopyTo (points);
return true;
} else {
points.Clear ();
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion binding/SkiaSharp/SKTypeface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public int[] GetKerningPairAdjustments (ReadOnlySpan<ushort> glyphs)
return adjustments;
}

public void GetKerningPairAdjustments (ReadOnlySpan<ushort> glyphs, Span<int> adjustments)
public void GetKerningPairAdjustments (Span<int> adjustments, ReadOnlySpan<ushort> glyphs)
{
if (glyphs.Length != adjustments.Length)
throw new ArgumentException ("Length of adjustments must be the same as the length of glyphs.", nameof(adjustments));
Expand Down

0 comments on commit 98cf75c

Please sign in to comment.