Fixed the matrix interop
This commit is contained in:
Родитель
0aefff0b65
Коммит
121ab0496c
|
@ -346,7 +346,7 @@ typeMask = Mask.Scale | Mask.RectStaysRect
|
|||
|
||||
public bool TryInvert (out SKMatrix inverse)
|
||||
{
|
||||
return SkiaApi.sk_matrix_try_invert (ref this, out inverse) != 0;
|
||||
return SkiaApi.sk_matrix_try_invert (ref this, out inverse);
|
||||
}
|
||||
|
||||
public static void Concat (ref SKMatrix target, SKMatrix first, SKMatrix second)
|
||||
|
|
|
@ -1510,7 +1510,8 @@ namespace SkiaSharp
|
|||
|
||||
// matrix
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static int sk_matrix_try_invert (ref SKMatrix matrix, out SKMatrix result);
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
public extern static bool sk_matrix_try_invert (ref SKMatrix matrix, out SKMatrix result);
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void sk_matrix_concat (ref SKMatrix target, ref SKMatrix first, ref SKMatrix second);
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ae5b160550244321c26510b6520270de275bbdcf
|
||||
Subproject commit 1cd54720ac6d215cd9086b18ef7582a4a85dd42f
|
|
@ -156,6 +156,20 @@ namespace SkiaSharp.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void TotalMatrixIsCorrect()
|
||||
{
|
||||
using (var bitmap = new SKBitmap(new SKImageInfo(100, 100)))
|
||||
using (var canvas = new SKCanvas(bitmap))
|
||||
{
|
||||
canvas.Translate(10, 20);
|
||||
Assert.Equal(SKMatrix.MakeTranslation(10, 20).Values, canvas.TotalMatrix.Values);
|
||||
|
||||
canvas.Translate(10, 20);
|
||||
Assert.Equal(SKMatrix.MakeTranslation(20, 40).Values, canvas.TotalMatrix.Values);
|
||||
}
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void SvgCanvasSavesFile()
|
||||
{
|
||||
|
|
|
@ -145,6 +145,48 @@ namespace SkiaSharp.Tests
|
|||
Assert.Equal(results, actualResults);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void MatrixCanInvert()
|
||||
{
|
||||
var m = SKMatrix.MakeTranslation(10, 20);
|
||||
Assert.True(m.TryInvert(out var inverse));
|
||||
Assert.Equal(SKMatrix.MakeTranslation(-10, -20).Values, inverse.Values);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void MatrixCanConcat()
|
||||
{
|
||||
var a = SKMatrix.MakeTranslation(10, 20);
|
||||
var b = SKMatrix.MakeTranslation(5, 7);
|
||||
var c = new SKMatrix();
|
||||
|
||||
SKMatrix.Concat(ref c, ref a, ref b);
|
||||
|
||||
Assert.Equal(SKMatrix.MakeTranslation(15, 27).Values, c.Values);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void MatrixCanPreConcat()
|
||||
{
|
||||
var a = SKMatrix.MakeTranslation(10, 20);
|
||||
var b = SKMatrix.MakeTranslation(5, 7);
|
||||
|
||||
SKMatrix.PreConcat(ref a, ref b);
|
||||
|
||||
Assert.Equal(SKMatrix.MakeTranslation(15, 27).Values, a.Values);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void MatrixCanPostConcat()
|
||||
{
|
||||
var a = SKMatrix.MakeTranslation(10, 20);
|
||||
var b = SKMatrix.MakeTranslation(5, 7);
|
||||
|
||||
SKMatrix.PostConcat(ref a, ref b);
|
||||
|
||||
Assert.Equal(SKMatrix.MakeTranslation(15, 27).Values, a.Values);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void MatrixMapsPoints()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче