Added bindings for SKPath.ComputeTightBounds()

This commit is contained in:
Matthew Leibowitz 2017-05-12 23:56:55 +02:00
Родитель 97e0bd1368
Коммит 59139457ae
3 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -375,6 +375,13 @@ namespace SkiaSharp
return SkiaApi.sk_path_get_bounds (Handle, out rect);
}
public SKRect ComputeTightBounds ()
{
SKRect rect;
SkiaApi.sk_path_compute_tight_bounds (Handle, out rect);
return rect;
}
public void Transform (SKMatrix matrix)
{
SkiaApi.sk_path_transform (Handle, ref matrix);

Просмотреть файл

@ -597,6 +597,8 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_path_get_bounds(sk_path_t t, out SKRect rect);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_path_compute_tight_bounds(sk_path_t t, out SKRect rect);
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKPathFillType sk_path_get_filltype (sk_path_t t);
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]

Просмотреть файл

@ -258,19 +258,24 @@ namespace SkiaSharp.Tests
}
}
// based on https://groups.google.com/forum/#!topic/skia-discuss/bhQCWsmARzo
[Ignore ("Known to fail, see: https://groups.google.com/forum/#!topic/skia-discuss/bhQCWsmARzo")]
[Test]
public void TightBoundsForEnclosedPathIsNotZero ()
{
var path = new SKPath();
path.MoveTo(10, 20);
path.CubicTo(10, 20, 30, 40, 30, 40);
path.CubicTo(50, 60, 30, 40, 30, 40);
var delta = 0.001f;
var bounds = path.TightBounds;
var rect = SKRect.Create (10, 20, 28.889f, 28.889f);
Assert.AreEqual(SKRect.Create(10, 20, 20, 20), bounds);
var path = new SKPath ();
path.MoveTo (10, 20);
path.CubicTo (10, 20, 30, 40, 30, 40);
path.CubicTo (50, 60, 30, 40, 30, 40);
var bounds = path.ComputeTightBounds ();
Assert.AreEqual (rect.Left, bounds.Left, "Left");
Assert.AreEqual (rect.Top, bounds.Top, "Top");
Assert.AreEqual (rect.Right, bounds.Right, delta, "Right");
Assert.AreEqual (rect.Bottom, bounds.Bottom, delta, "Bottom");
}
}
}